mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge tag 'pull-lu-20230808' of https://gitlab.com/rth7680/qemu into staging
linux-user: Adjust guest image layout vs reserved_va linux-user: Do not adjust image mapping for host page size linux-user: Adjust initial brk when interpreter is close to executable util/selfmap: Rewrite using qemu/interval-tree.h linux-user: Rewrite probe_guest_base # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmTSrp4dHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9lTQf/W/Tbd6CFnZpVE8Sb # BPrhdmo+x6Jftt1Ha66b/4xnasX7DuVaI1ECDh4CQQKIOh9A4LETx6ue9/UGi4vT # Fe4UrrJcAjt/CPaZhwXniJM9CvEnw1gkl3AgKAtZOBEConuPnkTiSWjySmCt3T4r # EGQxDe0HLpWYavNtvyywak/sEbwOD4hNAunFpJB6PLZ+KEoCDZwtcQdl55kg5bIt # WBMgUSXnWhC45t+26OcSDeHovqxHoA647H10T0y0U6bNVkW0tRW51xCTvHt+iDyR # s8UOCe1Q+w8F18fN68HIWBJ6NCzUts/AmQrWwc/MWiK1z91/ht5mlKAuNYnoZ6jH # htCSEA== # =ERAI # -----END PGP SIGNATURE----- # gpg: Signature made Tue 08 Aug 2023 02:07:42 PM PDT # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate] * tag 'pull-lu-20230808' of https://gitlab.com/rth7680/qemu: linux-user: Rewrite non-fixed probe_guest_base linux-user: Rewrite fixed probe_guest_base linux-user: Consolidate guest bounds check in probe_guest_base linux-user: Remove duplicate CPU_LOG_PAGE from probe_guest_base util/selfmap: Rewrite using qemu/interval-tree.h linux-user: Use zero_bss for PT_LOAD with no file contents too linux-user: Do not adjust zero_bss for host page size linux-user: Do not adjust image mapping for host page size linux-user: Adjust initial brk when interpreter is close to executable linux-user: Use elf_et_dyn_base for ET_DYN with interpreter linux-user: Use MAP_FIXED_NOREPLACE for initial image mmap linux-user: Define ELF_ET_DYN_BASE in $guest/target_mman.h linux-user: Define TASK_UNMAPPED_BASE in $guest/target_mman.h linux-user: Adjust task_unmapped_base for reserved_va Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
+11
-11
@@ -9,9 +9,10 @@
|
||||
#ifndef SELFMAP_H
|
||||
#define SELFMAP_H
|
||||
|
||||
#include "qemu/interval-tree.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned long start;
|
||||
unsigned long end;
|
||||
IntervalTreeNode itree;
|
||||
|
||||
/* flags */
|
||||
bool is_read;
|
||||
@@ -19,26 +20,25 @@ typedef struct {
|
||||
bool is_exec;
|
||||
bool is_priv;
|
||||
|
||||
unsigned long offset;
|
||||
gchar *dev;
|
||||
uint64_t offset;
|
||||
uint64_t inode;
|
||||
gchar *path;
|
||||
const char *path;
|
||||
char dev[];
|
||||
} MapInfo;
|
||||
|
||||
|
||||
/**
|
||||
* read_self_maps:
|
||||
*
|
||||
* Read /proc/self/maps and return a list of MapInfo structures.
|
||||
* Read /proc/self/maps and return a tree of MapInfo structures.
|
||||
*/
|
||||
GSList *read_self_maps(void);
|
||||
IntervalTreeRoot *read_self_maps(void);
|
||||
|
||||
/**
|
||||
* free_self_maps:
|
||||
* @info: a GSlist
|
||||
* @info: an interval tree
|
||||
*
|
||||
* Free a list of MapInfo structures.
|
||||
* Free a tree of MapInfo structures.
|
||||
*/
|
||||
void free_self_maps(GSList *info);
|
||||
void free_self_maps(IntervalTreeRoot *root);
|
||||
|
||||
#endif /* SELFMAP_H */
|
||||
|
||||
@@ -4,6 +4,19 @@
|
||||
#define TARGET_PROT_BTI 0x10
|
||||
#define TARGET_PROT_MTE 0x20
|
||||
|
||||
/*
|
||||
* arch/arm64/include/asm/processor.h:
|
||||
*
|
||||
* TASK_UNMAPPED_BASE DEFAULT_MAP_WINDOW / 4
|
||||
* DEFAULT_MAP_WINDOW DEFAULT_MAP_WINDOW_64
|
||||
* DEFAULT_MAP_WINDOW_64 UL(1) << VA_BITS_MIN
|
||||
* VA_BITS_MIN 48 (unless explicitly configured smaller)
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE (1ull << (48 - 2))
|
||||
|
||||
/* arch/arm64/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE TARGET_PAGE_ALIGN((1ull << 48) / 3 * 2)
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,17 @@
|
||||
#define TARGET_MS_SYNC 2
|
||||
#define TARGET_MS_INVALIDATE 4
|
||||
|
||||
/*
|
||||
* arch/alpha/include/asm/processor.h:
|
||||
*
|
||||
* TASK_UNMAPPED_BASE TASK_SIZE / 2
|
||||
* TASK_SIZE 0x40000000000UL
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE 0x20000000000ull
|
||||
|
||||
/* arch/alpha/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
/*
|
||||
* arch/arm/include/asm/memory.h
|
||||
* TASK_UNMAPPED_BASE ALIGN(TASK_SIZE / 3, SZ_16M)
|
||||
* TASK_SIZE CONFIG_PAGE_OFFSET
|
||||
* CONFIG_PAGE_OFFSET 0xC0000000 (default in Kconfig)
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE 0x40000000
|
||||
|
||||
/* arch/arm/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE 0x00400000
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
@@ -1 +1,13 @@
|
||||
/*
|
||||
* arch/cris/include/asm/processor.h:
|
||||
* TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
|
||||
*
|
||||
* arch/cris/include/arch-v32/arch/processor.h
|
||||
* TASK_SIZE 0xb0000000
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE TARGET_PAGE_ALIGN(0xb0000000 / 3)
|
||||
|
||||
/* arch/cris/include/uapi/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE * 2)
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
+394
-398
File diff suppressed because it is too large
Load Diff
@@ -1 +1,14 @@
|
||||
/*
|
||||
* arch/hexgon/include/asm/processor.h
|
||||
* TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
|
||||
*
|
||||
* arch/hexagon/include/asm/mem-layout.h
|
||||
* TASK_SIZE PAGE_OFFSET
|
||||
* PAGE_OFFSET 0xc0000000
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE 0x40000000
|
||||
|
||||
/* arch/hexagon/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE 0x08000000
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
#define TARGET_MS_ASYNC 2
|
||||
#define TARGET_MS_INVALIDATE 4
|
||||
|
||||
/* arch/parisc/include/asm/processor.h: DEFAULT_MAP_BASE32 */
|
||||
#define TASK_UNMAPPED_BASE 0x40000000
|
||||
|
||||
/* arch/parisc/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,17 @@
|
||||
/*
|
||||
* arch/x86/include/asm/processor.h:
|
||||
* TASK_UNMAPPED_BASE __TASK_UNMAPPED_BASE(TASK_SIZE_LOW)
|
||||
* __TASK_UNMAPPED_BASE(S) PAGE_ALIGN(S / 3)
|
||||
*
|
||||
* arch/x86/include/asm/page_32_types.h:
|
||||
* TASK_SIZE_LOW TASK_SIZE
|
||||
* TASK_SIZE __PAGE_OFFSET
|
||||
* __PAGE_OFFSET CONFIG_PAGE_OFFSET
|
||||
* CONFIG_PAGE_OFFSET 0xc0000000 (default in Kconfig)
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE 0x40000000
|
||||
|
||||
/* arch/x86/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE 0x00400000
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
/*
|
||||
* arch/loongarch/include/asm/processor.h:
|
||||
* TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
|
||||
* TASK_SIZE64 0x1UL << (... ? VA_BITS : ...)
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE \
|
||||
TARGET_PAGE_ALIGN((1ull << TARGET_VIRT_ADDR_SPACE_BITS) / 3)
|
||||
|
||||
/* arch/loongarch/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE * 2)
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
/* arch/m68k/include/asm/processor.h */
|
||||
#define TASK_UNMAPPED_BASE 0xC0000000
|
||||
/* arch/m68k/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE 0xD0000000
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
@@ -821,6 +821,49 @@ int main(int argc, char **argv, char **envp)
|
||||
reserved_va = max_reserved_va;
|
||||
}
|
||||
|
||||
/*
|
||||
* Temporarily disable
|
||||
* "comparison is always false due to limited range of data type"
|
||||
* due to comparison between (possible) uint64_t and uintptr_t.
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
|
||||
/*
|
||||
* Select an initial value for task_unmapped_base that is in range.
|
||||
*/
|
||||
if (reserved_va) {
|
||||
if (TASK_UNMAPPED_BASE < reserved_va) {
|
||||
task_unmapped_base = TASK_UNMAPPED_BASE;
|
||||
} else {
|
||||
/* The most common default formula is TASK_SIZE / 3. */
|
||||
task_unmapped_base = TARGET_PAGE_ALIGN(reserved_va / 3);
|
||||
}
|
||||
} else if (TASK_UNMAPPED_BASE < UINTPTR_MAX) {
|
||||
task_unmapped_base = TASK_UNMAPPED_BASE;
|
||||
} else {
|
||||
/* 32-bit host: pick something medium size. */
|
||||
task_unmapped_base = 0x10000000;
|
||||
}
|
||||
mmap_next_start = task_unmapped_base;
|
||||
|
||||
/* Similarly for elf_et_dyn_base. */
|
||||
if (reserved_va) {
|
||||
if (ELF_ET_DYN_BASE < reserved_va) {
|
||||
elf_et_dyn_base = ELF_ET_DYN_BASE;
|
||||
} else {
|
||||
/* The most common default formula is TASK_SIZE / 3 * 2. */
|
||||
elf_et_dyn_base = TARGET_PAGE_ALIGN(reserved_va / 3) * 2;
|
||||
}
|
||||
} else if (ELF_ET_DYN_BASE < UINTPTR_MAX) {
|
||||
elf_et_dyn_base = ELF_ET_DYN_BASE;
|
||||
} else {
|
||||
/* 32-bit host: pick something medium size. */
|
||||
elf_et_dyn_base = 0x18000000;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
{
|
||||
Error *err = NULL;
|
||||
if (seed_optarg != NULL) {
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
/*
|
||||
* arch/microblaze/include/asm/processor.h:
|
||||
* TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
|
||||
* TASK_SIZE CONFIG_KERNEL_START
|
||||
* CONFIG_KERNEL_START 0xc0000000 (default in Kconfig)
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE 0x48000000
|
||||
|
||||
/* arch/microblaze/include/uapi/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE 0x08000000
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
@@ -14,6 +14,16 @@
|
||||
#define TARGET_MAP_STACK 0x40000
|
||||
#define TARGET_MAP_HUGETLB 0x80000
|
||||
|
||||
/*
|
||||
* arch/mips/include/asm/processor.h:
|
||||
* TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE \
|
||||
TARGET_PAGE_ALIGN((1ull << TARGET_VIRT_ADDR_SPACE_BITS) / 3)
|
||||
|
||||
/* arch/mips/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE * 2)
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
#endif
|
||||
|
||||
+4
-15
@@ -299,20 +299,9 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last,
|
||||
return true;
|
||||
}
|
||||
|
||||
#if HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
|
||||
#ifdef TARGET_AARCH64
|
||||
# define TASK_UNMAPPED_BASE 0x5500000000
|
||||
#else
|
||||
# define TASK_UNMAPPED_BASE (1ul << 38)
|
||||
#endif
|
||||
#else
|
||||
#ifdef TARGET_HPPA
|
||||
# define TASK_UNMAPPED_BASE 0xfa000000
|
||||
#else
|
||||
# define TASK_UNMAPPED_BASE 0x40000000
|
||||
#endif
|
||||
#endif
|
||||
abi_ulong mmap_next_start = TASK_UNMAPPED_BASE;
|
||||
abi_ulong task_unmapped_base;
|
||||
abi_ulong elf_et_dyn_base;
|
||||
abi_ulong mmap_next_start;
|
||||
|
||||
/*
|
||||
* Subroutine of mmap_find_vma, used when we have pre-allocated
|
||||
@@ -391,7 +380,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align)
|
||||
|
||||
if ((addr & (align - 1)) == 0) {
|
||||
/* Success. */
|
||||
if (start == mmap_next_start && addr >= TASK_UNMAPPED_BASE) {
|
||||
if (start == mmap_next_start && addr >= task_unmapped_base) {
|
||||
mmap_next_start = addr + size;
|
||||
}
|
||||
return addr;
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
/*
|
||||
* arch/nios2/include/asm/processor.h:
|
||||
* TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
|
||||
* TASK_SIZE 0x7FFF0000UL
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE TARGET_PAGE_ALIGN(0x7FFF0000 / 3)
|
||||
|
||||
/* arch/nios2/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE 0xD0000000
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
/*
|
||||
* arch/openrisc/include/asm/processor.h:
|
||||
* TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
|
||||
* TASK_SIZE (0x80000000UL)
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE 0x30000000
|
||||
|
||||
/* arch/openrisc/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE 0x08000000
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
@@ -4,6 +4,26 @@
|
||||
#define TARGET_MAP_NORESERVE 0x40
|
||||
#define TARGET_MAP_LOCKED 0x80
|
||||
|
||||
/*
|
||||
* arch/powerpc/include/asm/task_size_64.h
|
||||
* TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
|
||||
* TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(DEFAULT_MAP_WINDOW_USER64 / 4))
|
||||
* TASK_SIZE_USER32 (0x0000000100000000UL - (1 * PAGE_SIZE))
|
||||
* DEFAULT_MAP_WINDOW_USER64 TASK_SIZE_64TB (with 4k pages)
|
||||
*/
|
||||
#ifdef TARGET_PPC64
|
||||
#define TASK_UNMAPPED_BASE 0x0000100000000000ull
|
||||
#else
|
||||
#define TASK_UNMAPPED_BASE 0x40000000
|
||||
#endif
|
||||
|
||||
/* arch/powerpc/include/asm/elf.h */
|
||||
#ifdef TARGET_PPC64
|
||||
#define ELF_ET_DYN_BASE 0x100000000ull
|
||||
#else
|
||||
#define ELF_ET_DYN_BASE 0x000400000
|
||||
#endif
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,6 @@ struct image_info {
|
||||
abi_ulong start_data;
|
||||
abi_ulong end_data;
|
||||
abi_ulong brk;
|
||||
abi_ulong reserve_brk;
|
||||
abi_ulong start_mmap;
|
||||
abi_ulong start_stack;
|
||||
abi_ulong stack_limit;
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
/*
|
||||
* arch/loongarch/include/asm/processor.h:
|
||||
* TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
|
||||
*/
|
||||
#define TASK_UNMAPPED_BASE \
|
||||
TARGET_PAGE_ALIGN((1ull << (TARGET_VIRT_ADDR_SPACE_BITS - 1)) / 3)
|
||||
|
||||
/* arch/riscv/include/asm/elf.h */
|
||||
#define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE * 2)
|
||||
|
||||
#include "../generic/target_mman.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user