*-user: probe_guest_base improvments
v3 cover *-user: probe_guest_base improvments
Changes for v3:
- Actually include the read_self_maps rewrite from Warner. For v2 I failed to push the updated patch from the freebsd vm. :-( I've also expanded a TODO comment wrt the balance of MapInfo.
r~
Richard Henderson (13):
linux-user: Introduce PGBRange
linux-user: Use PGBRange in load_elf_image
linux-user: Drop hiaddr out-of-range check in probe_guest_base
linux-user: Pass image_range to probe_guest_base
linux-user: Use PGBRange for commpage
common-user: Move mmap_min_addr from linux-user
common-user: Initialize mmap_min_addr for FreeBSD include/user/guest-host: Include missing cpu.h
common-user: Move selfmap from util
common-user: Implement read_self_maps for FreeBSD
common-user: Move probe_guest_base from linux-user
bsd-user: Use probe_guest_base
common-user: Move guest_base, have_guest_base to probe-guest-base.c
include/user/guest-host.h | 1 +
include/user/mmap-min-addr.h | 12 +
include/user/probe-guest-base.h | 37 +++
include/{qemu => user}/selfmap.h | 0
linux-user/arm/target_elf.h | 2 +-
linux-user/hppa/target_elf.h | 2 +-
linux-user/user-internals.h | 17 +-
bsd-user/elfload.c | 37 +--
bsd-user/main.c | 42 +---
common-user/mmap-min-addr.c | 50 ++++
common-user/probe-guest-base.c | 347 +++++++++++++++++++++++++++
{util => common-user}/selfmap.c | 45 +++-
linux-user/arm/elfload.c | 2 +-
linux-user/elfload.c | 400 ++-----------------------------
linux-user/flatload.c | 3 +-
linux-user/hppa/elfload.c | 4 +-
linux-user/main.c | 35 +--
linux-user/mmap.c | 1 +
linux-user/syscall.c | 2 +-
common-user/meson.build | 8 +
util/meson.build | 4 -
21 files changed, 565 insertions(+), 486 deletions(-)
create mode 100644 include/user/mmap-min-addr.h
create mode 100644 include/user/probe-guest-base.h
rename include/{qemu => user}/selfmap.h (100%)
create mode 100644 common-user/mmap-min-addr.c
create mode 100644 common-user/probe-guest-base.c
rename {util => common-user}/selfmap.c (69%)Signature · 1 line
2.43.0
PATCH v3 1/13 linux-user: Introduce PGBRange
Create a structure to hold a beginning/end range for guest virtual addresses, for use by probe_guest_base. Use vaddr for clarity.
--- linux-user/user-internals.h | 5 +++++ linux-user/elfload.c | 36 ++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 18 deletions(-)
linux-user/user-internals.h +5 -0
@@ -75,6 +75,11 @@ void clone_fork_end(bool child);void fork_start (void );void fork_end (pid_t pid); +typedef struct PGBRange { +vaddr lo; +vaddr hi; +}PGBRange ; +/** * probe_guest_base: * @image_name: the executable being loaded
linux-user/elfload.c +18 -18
@@ -828,15 +828,15 @@ static int pgb_try_mmap_skip_brk(uintptr_t addr, uintptr_t addr_last,*/ typedef struct PGBAddrs { -uintptr_t bounds[3 ][2 ];/* start/last pairs */ +PGBRange bounds[3 ];int nbounds; }PGBAddrs ;static bool pgb_try_mmap_set (const PGBAddrs *ga,uintptr_t base,uintptr_t brk) {for (int i = ga->nbounds -1 ; i >=0 ; --i) { -if (pgb_try_mmap_skip_brk (ga->bounds[i][0 ] + base, - ga->bounds[i][1 ] + base, +if (pgb_try_mmap_skip_brk (ga->bounds[i].lo + base, + ga->bounds[i].hi + base, brk, i ==0 && reserved_va) <=0 ) {return false; }
@@ -875,26 +875,26 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr, n =0 ;if (reserved_va) { - ga->bounds[n][0 ] = try_identity ? mmap_min_addr :0 ; - ga->bounds[n][1 ] = reserved_va; + ga->bounds[n].lo = try_identity ? mmap_min_addr :0 ; + ga->bounds[n].hi = reserved_va; n++;/* LO_COMMPAGE and NULL handled by reserving from 0. */ }else {/* Add any LO_COMMPAGE or NULL page. */ if (LO_COMMPAGE !=-1 ) { - ga->bounds[n][0 ] =0 ; - ga->bounds[n][1 ] =LO_COMMPAGE +TARGET_PAGE_SIZE -1 ; + ga->bounds[n].lo =0 ; + ga->bounds[n].hi =LO_COMMPAGE +TARGET_PAGE_SIZE -1 ; n++; }else if (!try_identity) { - ga->bounds[n][0 ] =0 ; - ga->bounds[n][1 ] =TARGET_PAGE_SIZE -1 ; + ga->bounds[n].lo =0 ; + ga->bounds[n].hi =TARGET_PAGE_SIZE -1 ; n++; }/* Add the guest image for ET_EXEC. */ if (guest_loaddr) { - ga->bounds[n][0 ] = guest_loaddr; - ga->bounds[n][1 ] = guest_hiaddr; + ga->bounds[n].lo = guest_loaddr; + ga->bounds[n].hi = guest_hiaddr; n++; } }
@@ -909,8 +909,8 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr,/* Add any HI_COMMPAGE not covered by reserved_va. */ if (reserved_va <HI_COMMPAGE ) { - ga->bounds[n][0 ] =HI_COMMPAGE &qemu_real_host_page_mask (); - ga->bounds[n][1 ] =HI_COMMPAGE +TARGET_PAGE_SIZE -1 ; + ga->bounds[n].lo =HI_COMMPAGE &qemu_real_host_page_mask (); + ga->bounds[n].hi =HI_COMMPAGE +TARGET_PAGE_SIZE -1 ; n++; }
@@ -976,8 +976,8 @@ static uintptr_t pgb_try_itree(const PGBAddrs *ga, uintptr_t base, IntervalTreeRoot *root) {for (int i = ga->nbounds -1 ; i >=0 ; --i) { -uintptr_t s = base + ga->bounds[i][0 ]; -uintptr_t l = base + ga->bounds[i][1 ]; +uintptr_t s = base + ga->bounds[i].lo; +uintptr_t l = base + ga->bounds[i].hi;IntervalTreeNode *n;if (l < s) {
@@ -1076,9 +1076,9 @@ static void pgb_dynamic(const char *image_name, uintptr_t guest_loaddr, "guest address mapping requirements", image_name);for (int i =0 ; i < ga.nbounds; ++i) { -error_printf (" %0*" PRIx64"-%0*" PRIx64"\n" , - w, (uint64_t )ga.bounds[i][0 ], - w, (uint64_t )ga.bounds[i][1 ]); +error_printf (" %0*" VADDR_PRIx"-%0*" VADDR_PRIx"\n" , + w, ga.bounds[i].lo, + w, ga.bounds[i].hi); }exit (EXIT_FAILURE ); }
Signature · 1 line
2.43.0
PATCH v3 2/13 linux-user: Use PGBRange in load_elf_image
In reply to Richard HendersonCollect into range instead of loaddr+hiaddr.
--- linux-user/elfload.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
linux-user/elfload.c +12 -12
@@ -1278,7 +1278,8 @@ static void load_elf_image(const char *image_name, const ImageSource *src, char **pinterp_name) { g_autofree struct elf_phdr *phdr = NULL; -abi_ulong load_addr, load_bias, loaddr, hiaddr, error, align; +PGBRange range = {-1 ,0 }; +abi_ulong load_addr, load_bias, error, align;size_t reserve_size, align_size;int i, prot_exec;Error *err =NULL ;
@@ -1318,19 +1319,18 @@ static void load_elf_image(const char *image_name, const ImageSource *src,* Find the maximum size of the image and allocate an appropriate * amount of memory to handle that. Locate the interpreter, if any. */ - loaddr =-1 , hiaddr =0 ; align =0 ; info->exec_stack =EXSTACK_DEFAULT ;for (i =0 ; i < ehdr->e_phnum; ++i) {struct elf_phdr *eppnt = phdr + i;if (eppnt->p_type ==PT_LOAD ) {abi_ulong a = eppnt->p_vaddr &TARGET_PAGE_MASK ; -if (a < loaddr) { - loaddr = a; +if (a < range.lo) { + range.lo = a; } a = eppnt->p_vaddr + eppnt->p_memsz -1 ; -if (a > hiaddr) { - hiaddr = a; +if (a > range.hi) { + range.hi = a; } ++info->nsegs; align |= eppnt->p_align;
@@ -1361,7 +1361,7 @@ static void load_elf_image(const char *image_name, const ImageSource *src, } } - load_addr = loaddr; + load_addr = range.lo; align =pow2ceil (align);
@@ -1371,13 +1371,13 @@ static void load_elf_image(const char *image_name, const ImageSource *src,* Make sure that the low address does not conflict with * MMAP_MIN_ADDR or the QEMU application itself. */ -probe_guest_base (image_name, loaddr, hiaddr); +probe_guest_base (image_name, range.lo, range.hi); }else {/* * The binary is dynamic, but we still need to * select guest_base. In this case we pass a size. */ -probe_guest_base (image_name,0 , hiaddr - loaddr); +probe_guest_base (image_name,0 , range.hi - range.lo);/* * Avoid collision with the loader by providing a different
@@ -1414,7 +1414,7 @@ static void load_elf_image(const char *image_name, const ImageSource *src,* In both cases, we will overwrite pages in this range with mappings * from the executable. */ - reserve_size = (size_t )hiaddr - loaddr +1 ; + reserve_size = range.hi - range.lo +1 ; align_size = reserve_size;if (ehdr->e_type !=ET_EXEC && align >qemu_real_host_page_size ()) {
@@ -1443,7 +1443,7 @@ static void load_elf_image(const char *image_name, const ImageSource *src, load_addr = align_addr; } - load_bias = load_addr - loaddr; + load_bias = load_addr - range.lo;if (elf_is_fdpic (ehdr)) { struct elf32_fdpic_loadseg *loadsegs = info->loadsegs =
@@ -1474,7 +1474,7 @@ static void load_elf_image(const char *image_name, const ImageSource *src, info->start_data =-1 ; info->end_data =0 ;/* Usual start for brk is after all sections of the main executable. */ - info->brk =TARGET_PAGE_ALIGN (hiaddr + load_bias); + info->brk =TARGET_PAGE_ALIGN (range.hi + load_bias); info->elf_flags = ehdr->e_flags;#ifdef TARGET_MIPS info->use_k0_tls = (ehdr->e_flags &EF_MIPS_MACH ) ==EF_MIPS_MACH_OCTEON ;
Signature · 1 line
2.43.0
PATCH v3 3/13 linux-user: Drop hiaddr out-of-range check in probe_guest_base
In reply to Richard HendersonSince dropping 32-bit host support, a guest address cannot overflow a host pointer. This means guest_hiaddr is unused for relocatable images, so don't pass guest_hiaddr as size.
--- linux-user/elfload.c | 26 +++++++------------------- linux-user/flatload.c | 3 +-- 2 files changed, 8 insertions(+), 21 deletions(-)
linux-user/elfload.c +7 -19
@@ -1092,20 +1092,11 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,uintptr_t align =MAX (SHMLBA ,TARGET_PAGE_SIZE );/* Sanity check the guest binary. */ -if (reserved_va) { -if (guest_hiaddr > reserved_va) { -error_report ("%s: requires more than reserved virtual " -"address space (0x%" PRIx64" > 0x%lx)" , - image_name, (uint64_t )guest_hiaddr, reserved_va); -exit (EXIT_FAILURE ); - } - }else { -if (guest_hiaddr != (uintptr_t )guest_hiaddr) { -error_report ("%s: requires more virtual address space " -"than the host can provide (0x%" PRIx64")" , - image_name, (uint64_t )guest_hiaddr +1 ); -exit (EXIT_FAILURE ); - } +if (reserved_va && guest_hiaddr > reserved_va) { +error_report ("%s: requires more than reserved virtual " +"address space (0x%" PRIx64" > 0x%lx)" , + image_name, (uint64_t )guest_hiaddr, reserved_va); +exit (EXIT_FAILURE ); }if (have_guest_base) {
@@ -1373,11 +1364,8 @@ static void load_elf_image(const char *image_name, const ImageSource *src,*/ probe_guest_base (image_name, range.lo, range.hi); }else { -/* -* The binary is dynamic, but we still need to -* select guest_base. In this case we pass a size. -*/ -probe_guest_base (image_name,0 , range.hi - range.lo); +/* The binary is dynamic; we still need to select guest_base. */ +probe_guest_base (image_name,0 ,0 );/* * Avoid collision with the loader by providing a different
linux-user/flatload.c +1 -2
@@ -261,8 +261,7 @@ static int load_flat_file(struct linux_binprm * bprm,/* * Allocate the address space. */ -probe_guest_base (bprm->filename,0 , - text_len + data_len + extra + indx_len -1 ); +probe_guest_base (bprm->filename,0 ,0 );/* * there are a couple of cases here, the separate code/data
Signature · 1 line
2.43.0
PATCH v3 4/13 linux-user: Pass image_range to probe_guest_base
In reply to Richard HendersonPass a PGBRange structure instead of separate guest_loaddr and guest_hiaddr parameters. This allows NULL to indicate that the image is relocatable, so that image_range->lo == 0 is a valid fixed setting.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/1890
--- linux-user/user-internals.h | 13 ++++------- linux-user/elfload.c | 46 +++++++++++++++++-------------------- linux-user/flatload.c | 2 +- 3 files changed, 27 insertions(+), 34 deletions(-)
linux-user/user-internals.h +5 -8
@@ -83,24 +83,21 @@ typedef struct PGBRange {/** * probe_guest_base: * @image_name: the executable being loaded -* @loaddr: the lowest fixed address within the executable -* @hiaddr: the highest fixed address within the executable +* @image_range: the fixed addresses within the executable * * Creates the initial guest address space in the host memory space. * -* If @loaddr == 0, then no address in the executable is fixed, i.e. -* it is fully relocatable. In that case @hiaddr is the size of the -* executable minus one. +* If @image_range is NULL, then no address in the executable is fixed, +* i.e. it is fully relocatable. * * This function will not return if a valid value for guest_base * cannot be chosen. On return, the executable loader can expect * -* target_mmap(loaddr, hiaddr - loaddr + 1, ...) +* target_mmap(i->lo, i->hi - i->lo + 1, ...) * * to succeed. */ -void probe_guest_base (const char *image_name, -abi_ulong loaddr,abi_ulong hiaddr); +void probe_guest_base (const char *image_name,const PGBRange *image_range);/* syscall.c */ int host_to_target_waitstatus (int status);
linux-user/elfload.c +21 -25
123 lines not on this page · raw message
linux-user/flatload.c +1 -1
@@ -261,7 +261,7 @@ static int load_flat_file(struct linux_binprm * bprm,/* * Allocate the address space. */ -probe_guest_base (bprm->filename,0 ,0 ); +probe_guest_base (bprm->filename,NULL );/* * there are a couple of cases here, the separate code/data
Signature · 1 line
2.43.0
PATCH v3 5/13 linux-user: Use PGBRange for commpage
In reply to Richard HendersonThis simplifies check for no commpage to a NULL pointer check, rather than reserved values for LO_COMMPAGE and HI_COMMPAGE.
Unify {LO,HI}_COMMPAGE into a single COMMPAGE define.
--- linux-user/arm/target_elf.h | 2 +- linux-user/hppa/target_elf.h | 2 +- linux-user/arm/elfload.c | 2 +- linux-user/elfload.c | 64 ++++++++++++++---------------------- linux-user/hppa/elfload.c | 4 +-- 5 files changed, 30 insertions(+), 44 deletions(-)
linux-user/arm/target_elf.h +1 -1
@@ -20,7 +20,7 @@#define HAVE_ELF_CORE_DUMP 1#define HAVE_VDSO_IMAGE_INFO 1 -#define HI_COMMPAGE ((intptr_t)0xffff0f00u) +#define COMMPAGE ((intptr_t)0xffff0f00u)/* * See linux kernel: arch/arm/include/asm/elf.h, where
linux-user/hppa/target_elf.h +1 -1
@@ -34,7 +34,7 @@ typedef struct target_elf_gregset_t {abi_ulong pad[16 ];/* pad to 80 elements [64..79] */ } target_elf_gregset_t; -#define LO_COMMPAGE 0 +#define COMMPAGE 0#define STACK_GROWS_DOWN 0#define STACK_ALIGNMENT 64#define VDSO_HEADER "vdso.c.inc"
linux-user/arm/elfload.c +1 -1
@@ -219,7 +219,7 @@ bool init_guest_commpage(void)return true; } - commpage =HI_COMMPAGE & -host_page_size; + commpage =COMMPAGE & -host_page_size; want =g2h_untagged (commpage); addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE |
linux-user/elfload.c +25 -39
143 lines not on this page · raw message
linux-user/hppa/elfload.c +2 -2
@@ -35,7 +35,7 @@ bool init_guest_commpage(void)if (!reserved_va) {void *want, *addr; - want =g2h_untagged (LO_COMMPAGE ); + want =g2h_untagged (COMMPAGE ); addr =mmap (want,TARGET_PAGE_SIZE ,PROT_NONE ,MAP_ANONYMOUS |MAP_PRIVATE |MAP_FIXED_NOREPLACE ,-1 ,0 );if (addr ==MAP_FAILED ) {
@@ -54,7 +54,7 @@ bool init_guest_commpage(void)* and implement syscalls. Here, simply mark the page executable. * Special case the entry points during translation (see do_page_zero). */ -page_set_flags (LO_COMMPAGE ,LO_COMMPAGE | ~TARGET_PAGE_MASK , +page_set_flags (COMMPAGE ,COMMPAGE | ~TARGET_PAGE_MASK ,PAGE_EXEC |PAGE_VALID ,PAGE_VALID );return true; }
Signature · 1 line
2.43.0
PATCH v3 6/13 common-user: Move mmap_min_addr from linux-user
In reply to Richard HendersonIntroduce user/mmap-min-addr.h. Initialize the variable from a constructor instead of main.
--- include/user/mmap-min-addr.h | 12 ++++++++++++ linux-user/user-internals.h | 1 - common-user/mmap-min-addr.c | 37 ++++++++++++++++++++++++++++++++++++ linux-user/elfload.c | 1 + linux-user/main.c | 33 +++----------------------------- linux-user/mmap.c | 1 + common-user/meson.build | 1 + 7 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 include/user/mmap-min-addr.h create mode 100644 common-user/mmap-min-addr.c
include/user/mmap-min-addr.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef USER_MMAP_MIN_ADDR_H +#define USER_MMAP_MIN_ADDR_H + +#ifndef CONFIG_USER_ONLY +#error Cannot include this header from system emulation +#endif + +extern uintptr_t mmap_min_addr; + +#endif
linux-user/user-internals.h +0 -1
@@ -29,7 +29,6 @@ void init_task_state(TaskState *ts);void task_settid (TaskState *);void stop_all_tasks (void );extern const char *qemu_uname_release; -extern unsigned long mmap_min_addr;typedef struct IOCTLEntry IOCTLEntry ;
common-user/mmap-min-addr.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Utility function to get the minimum mmap address. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "user/mmap-min-addr.h" + +uintptr_t mmap_min_addr; + +static void __attribute__((constructor))init (void ) +{ +#ifdef __linux__ +/* +* We prefer to not make NULL pointers accessible to QEMU. +* If something goes wrong below, fall back to 1 page. +*/ +size_t min_addr =qemu_real_host_page_size (); +/* +* Read in mmap_min_addr kernel parameter. This value is used +* When loading the ELF image to determine whether guest_base +* is needed. It is also used in mmap_find_vma. +*/ +FILE *fp =fopen ("/proc/sys/vm/mmap_min_addr" ,"r" ); + +if (fp) { +unsigned long tmp; +if (fscanf (fp,"%lu" , &tmp) ==1 && tmp !=0 ) { + min_addr =MAX (min_addr, tmp); + } +fclose (fp); + } + mmap_min_addr = min_addr; +#else +# error +#endif +}
linux-user/elfload.c +1 -0
@@ -14,6 +14,7 @@#include "exec/translation-block.h" #include "exec/tswap.h" #include "user/guest-base.h" +#include "user/mmap-min-addr.h" #include "user-internals.h" #include "signal-common.h" #include "loader.h"
linux-user/main.c +3 -30
@@ -39,6 +39,7 @@#include "qemu/module.h" #include "qemu/plugin.h" #include "user/guest-base.h" +#include "user/mmap-min-addr.h" #include "user/page-protection.h" #include "exec/gdbstub.h" #include "gdbstub/user.h"
@@ -78,7 +79,6 @@ static envlist_t *envlist;static const char *cpu_model;static const char *cpu_type;static const char *seed_optarg; -unsigned long mmap_min_addr;uintptr_t guest_base;bool have_guest_base;
@@ -914,35 +914,8 @@ int main(int argc, char **argv, char **envp) target_environ =envlist_to_environ (envlist,NULL );envlist_free (envlist); -/* -* Read in mmap_min_addr kernel parameter. This value is used -* When loading the ELF image to determine whether guest_base -* is needed. It is also used in mmap_find_vma. -*/ - { -FILE *fp; - -if ((fp =fopen ("/proc/sys/vm/mmap_min_addr" ,"r" )) !=NULL ) { -unsigned long tmp; -if (fscanf (fp,"%lu" , &tmp) ==1 && tmp !=0 ) { - mmap_min_addr =MAX (tmp, host_page_size); -qemu_log_mask (CPU_LOG_PAGE ,"host mmap_min_addr=0x%lx\n" , - mmap_min_addr); - } -fclose (fp); - } - } - -/* -* We prefer to not make NULL pointers accessible to QEMU. -* If we're in a chroot with no /proc, fall back to 1 page. -*/ -if (mmap_min_addr ==0 ) { - mmap_min_addr = host_page_size; -qemu_log_mask (CPU_LOG_PAGE , -"host mmap_min_addr=0x%lx (fallback)\n" , - mmap_min_addr); - } +qemu_log_mask (CPU_LOG_PAGE ,"host mmap_min_addr=0x%" PRIxPTR"\n" , + mmap_min_addr);/* * Prepare copy of argv vector for target.
linux-user/mmap.c +1 -0
@@ -24,6 +24,7 @@#include "exec/mmap-lock.h" #include "qemu.h" #include "user/page-protection.h" +#include "user/mmap-min-addr.h" #include "user-internals.h" #include "user-mmap.h" #include "target_mman.h"
common-user/meson.build +1 -0
@@ -5,6 +5,7 @@ endif common_user_inc += include_directories('host/' / host_arch) user_ss.add(files( + 'mmap-min-addr.c', 'safe-syscall.S', 'safe-syscall-error.c', ))
Signature · 1 line
2.43.0
PATCH v3 7/13 common-user: Initialize mmap_min_addr for FreeBSD
In reply to Richard HendersonUse sysctl to fetch the vm layout of the current process.
--- common-user/mmap-min-addr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
common-user/mmap-min-addr.c +13 -0
@@ -5,6 +5,10 @@#include "qemu/osdep.h" #include "user/mmap-min-addr.h" +#ifdef __FreeBSD__ +#include <sys/sysctl.h> +#include <sys/user.h> +#endif uintptr_t mmap_min_addr;
@@ -31,6 +35,15 @@ static void __attribute__((constructor)) init(void) fclose(fp); } mmap_min_addr = min_addr; +#elif defined(__FreeBSD__) +int mib[] = {CTL_KERN ,KERN_PROC ,KERN_PROC_VM_LAYOUT ,getpid () }; +struct kinfo_vm_layout info; +size_t info_len =sizeof (info); + + mmap_min_addr = + (sysctl (mib,ARRAY_SIZE (mib), &info, &info_len,NULL ,0 ) <0 + ?qemu_real_host_page_size () + : info.kvm_min_user_addr);#else # error #endif
Signature · 1 line
2.43.0
PATCH v3 8/13 include/user/guest-host: Include missing cpu.h
In reply to Richard HendersonThis file dereferences CPUState without including the required header.
--- include/user/guest-host.h | 1 + 1 file changed, 1 insertion(+)
include/user/guest-host.h +1 -0
@@ -10,6 +10,7 @@#include "exec/vaddr.h" #include "user/guest-base.h" +#include "hw/core/cpu.h" #include "accel/tcg/cpu-ops.h" /*
Signature · 1 line
2.43.0
PATCH v3 9/13 common-user: Move selfmap from util
In reply to Richard HendersonThis interface is only used for user-only. It's more usefully placed within common-user than util. Temporarily add stub implementation for bsd-user.
---
include/{qemu => user}/selfmap.h | 0
{util => common-user}/selfmap.c | 6 +++++-
linux-user/elfload.c | 2 +-
linux-user/syscall.c | 2 +-
common-user/meson.build | 1 +
util/meson.build | 4 ----
6 files changed, 8 insertions(+), 7 deletions(-)
rename include/{qemu => user}/selfmap.h (100%)
rename {util => common-user}/selfmap.c (97%)include/user/selfmap.h renamed from include/qemu/selfmap.h +0 -0
common-user/selfmap.c renamed from util/selfmap.c +5 -1
@@ -8,10 +8,11 @@#include "qemu/osdep.h" #include "qemu/cutils.h" -#include "qemu/selfmap.h" +#include "user/selfmap.h" IntervalTreeRoot *read_self_maps (void ) { +#ifdef __linux__IntervalTreeRoot *root;gchar *maps, **lines;guint i, nlines;
@@ -80,6 +81,9 @@ IntervalTreeRoot *read_self_maps(void)g_free (maps);return root; +#else +return NULL ; +#endif }/**
linux-user/elfload.c +1 -1
@@ -25,7 +25,7 @@#include "qemu/queue.h" #include "qemu/guest-random.h" #include "qemu/units.h" -#include "qemu/selfmap.h" +#include "user/selfmap.h" #include "qemu/lockable.h" #include "qapi/error.h" #include "qemu/error-report.h"
linux-user/syscall.c +1 -1
@@ -141,7 +141,7 @@#include "user/safe-syscall.h" #include "user/signal.h" #include "qemu/guest-random.h" -#include "qemu/selfmap.h" +#include "user/selfmap.h" #include "special-errno.h" #include "qapi/error.h" #include "fd-trans.h"
common-user/meson.build +1 -0
@@ -8,4 +8,5 @@ user_ss.add(files( 'mmap-min-addr.c', 'safe-syscall.S', 'safe-syscall-error.c', + 'selfmap.c', ))
util/meson.build +0 -4
@@ -67,10 +67,6 @@ util_ss.add(files('memalign.c')) util_ss.add(files('interval-tree.c')) util_ss.add(files('lockcnt.c')) -if have_user - util_ss.add(files('selfmap.c')) -endif - if have_system util_ss.add(files('crc-ccitt.c')) util_ss.add(when: gio, if_true: files('dbus.c'))
Signature · 1 line
2.43.0
PATCH v3 10/13 common-user: Implement read_self_maps for FreeBSD
In reply to Richard Henderson--- common-user/selfmap.c | 41 ++++++++++++++++++++++++++++++++++++++++- common-user/meson.build | 5 +++++ 2 files changed, 45 insertions(+), 1 deletion(-)
common-user/selfmap.c +40 -1
@@ -9,6 +9,10 @@#include "qemu/osdep.h" #include "qemu/cutils.h" #include "user/selfmap.h" +#ifdef __FreeBSD__ +#include <libutil.h> +#include <sys/user.h> +#endif IntervalTreeRoot *read_self_maps (void ) {
@@ -80,9 +84,44 @@ IntervalTreeRoot *read_self_maps(void)g_strfreev (lines);g_free (maps); +return root; +#elif defined(__FreeBSD__) +int n =0 ; +struct kinfo_vmentry *entries =kinfo_getvmmap (getpid (), &n); +IntervalTreeRoot *root; + +if (!entries) { +return NULL ; + } + root =g_new0 (IntervalTreeRoot,1 ); + +for (int i =0 ; i < n; ++i) { +struct kinfo_vmentry *k = &entries[i]; +size_t path_len =strnlen (k->kve_path,sizeof (k->kve_path)) +1 ; +MapInfo *e =g_malloc0 (sizeof (*e) + path_len); + + e->itree.start = k->kve_start; + e->itree.last = k->kve_end -1 ; + +/* ??? The rest of these fields are only used in linux-user. */ + e->dev = k->kve_vn_fsid_freebsd11; + e->inode = k->kve_vn_fileid; + e->offset = k->kve_offset; + e->is_read = k->kve_protection &KVME_PROT_READ ; + e->is_write = k->kve_protection &KVME_PROT_WRITE ; + e->is_exec = k->kve_protection &KVME_PROT_EXEC ; + e->is_priv = k->kve_flags &KVME_FLAG_COW ; +if (path_len) { + e->path =memcpy (e +1 , k->kve_path, path_len); + } + +interval_tree_insert (&e->itree, root); + } + +free (entries);return root;#else -return NULL ; +# error #endif }
common-user/meson.build +5 -0
@@ -10,3 +10,8 @@ user_ss.add(files( 'safe-syscall-error.c', 'selfmap.c', )) + +if host_os == 'freebsd' + libutil = cc.find_library('util', required: true) + user_ss.add(libutil) +endif
Signature · 1 line
2.43.0
Re: [PATCH v3 10/13] common-user: Implement read_self_maps for FreeBSD
Quoted 13 lines · Richard Henderson
Reviewed-by Helge Deller <[email protected]>Reviewed-by Warner Losh <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- common-user/selfmap.c | 41 ++++++++++++++++++++++++++++++++++++++++- common-user/meson.build | 5 +++++ 2 files changed, 45 insertions(+), 1 deletion(-)common-user/selfmap.c +0
-0
common-user/selfmap.c line 13
Quoted 5 lines
common-user/selfmap.c +2
-0@@ -9,6 +9,10 @@#include "qemu/osdep.h" #include "qemu/cutils.h" #include "user/selfmap.h" +#ifdef __FreeBSD__ +#include <libutil.h>
Out of curiosity, what is libutil for?
Quoted 64 lines
common-user/selfmap.c +38
-1+#include <sys/user.h> +#endif IntervalTreeRoot *read_self_maps (void ) {@@ -80,9 +84,44 @@ IntervalTreeRoot *read_self_maps(void)g_strfreev (lines);g_free (maps); +return root; +#elif defined(__FreeBSD__) +int n =0 ; +struct kinfo_vmentry *entries =kinfo_getvmmap (getpid (), &n); +IntervalTreeRoot *root; + +if (!entries) { +return NULL ; + } + root =g_new0 (IntervalTreeRoot,1 ); + +for (int i =0 ; i < n; ++i) { +struct kinfo_vmentry *k = &entries[i]; +size_t path_len =strnlen (k->kve_path,sizeof (k->kve_path)) +1 ; +MapInfo *e =g_malloc0 (sizeof (*e) + path_len); + + e->itree.start = k->kve_start; + e->itree.last = k->kve_end -1 ; + +/* ??? The rest of these fields are only used in linux-user. */ + e->dev = k->kve_vn_fsid_freebsd11; + e->inode = k->kve_vn_fileid; + e->offset = k->kve_offset; + e->is_read = k->kve_protection &KVME_PROT_READ ; + e->is_write = k->kve_protection &KVME_PROT_WRITE ; + e->is_exec = k->kve_protection &KVME_PROT_EXEC ; + e->is_priv = k->kve_flags &KVME_FLAG_COW ; +if (path_len) { + e->path =memcpy (e +1 , k->kve_path, path_len); + } + +interval_tree_insert (&e->itree, root); + } + +free (entries);return root;#else -return NULL ; +# error #endif }common-user/meson.build +5
-0@@ -10,3 +10,8 @@ user_ss.add(files( 'safe-syscall-error.c', 'selfmap.c', )) + +if host_os == 'freebsd' + libutil = cc.find_library('util', required: true) + user_ss.add(libutil) +endif
Re: [PATCH v3 10/13] common-user: Implement read_self_maps for FreeBSD
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Richard Henderson
Reviewed-by Helge Deller <[email protected]>Reviewed-by Warner Losh <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- common-user/selfmap.c | 41 ++++++++++++++++++++++++++++++++++++++++- common-user/meson.build | 5 +++++ 2 files changed, 45 insertions(+), 1 deletion(-)
Quoted 13 lines
common-user/selfmap.c line 13
Quoted 10 lines
common-user/selfmap.c +2
-0@@ -9,6 +9,10 @@#include "qemu/osdep.h" #include "qemu/cutils.h" #include "user/selfmap.h" +#ifdef __FreeBSD__ +#include <libutil.h> Out of curiosity, what is libutil for?
kinfo_getvmmap
My rewrite grabbed the data from the sysctl directly and didn't need this wrapper.
Warner
Quoted 66 lines
Quoted 64 lines
common-user/selfmap.c +38
-1+#include <sys/user.h> +#endif IntervalTreeRoot *read_self_maps (void ) {@@ -80,9 +84,44 @@ IntervalTreeRoot *read_self_maps(void)g_strfreev (lines);g_free (maps); +return root; +#elif defined(__FreeBSD__) +int n =0 ; +struct kinfo_vmentry *entries =kinfo_getvmmap (getpid (), &n); +IntervalTreeRoot *root; + +if (!entries) { +return NULL ; + } + root =g_new0 (IntervalTreeRoot,1 ); + +for (int i =0 ; i < n; ++i) { +struct kinfo_vmentry *k = &entries[i]; +size_t path_len =strnlen (k->kve_path,sizeof (k->kve_path)) +1 ; +MapInfo *e =g_malloc0 (sizeof (*e) + path_len); + + e->itree.start = k->kve_start; + e->itree.last = k->kve_end -1 ; + +/* ??? The rest of these fields are only used in linux-user. */ + e->dev = k->kve_vn_fsid_freebsd11; + e->inode = k->kve_vn_fileid; + e->offset = k->kve_offset; + e->is_read = k->kve_protection &KVME_PROT_READ ; + e->is_write = k->kve_protection &KVME_PROT_WRITE ; + e->is_exec = k->kve_protection &KVME_PROT_EXEC ; + e->is_priv = k->kve_flags &KVME_FLAG_COW ; +if (path_len) { + e->path =memcpy (e +1 , k->kve_path, path_len); + } + +interval_tree_insert (&e->itree, root); + } + +free (entries);return root;#else -return NULL ; +# error #endif }common-user/meson.build +5
-0@@ -10,3 +10,8 @@ user_ss.add(files( 'safe-syscall-error.c', 'selfmap.c', )) + +if host_os == 'freebsd' + libutil = cc.find_library('util', required: true) + user_ss.add(libutil) +endif
Re: [PATCH v3 10/13] common-user: Implement read_self_maps for FreeBSD
Quoted 26 lines · Warner Losh
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Richard Henderson
Reviewed-by Helge Deller <[email protected]>Reviewed-by Warner Losh <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- common-user/selfmap.c | 41 ++++++++++++++++++++++++++++++++++++++++- common-user/meson.build | 5 +++++ 2 files changed, 45 insertions(+), 1 deletion(-)Quoted 13 lines
common-user/selfmap.c line 13
Quoted 10 lines
common-user/selfmap.c +2
-0@@ -9,6 +9,10 @@#include "qemu/osdep.h" #include "qemu/cutils.h" #include "user/selfmap.h" +#ifdef __FreeBSD__ +#include <libutil.h> Out of curiosity, what is libutil for?
Quoted 1 line
kinfo_getvmmap
Indeed. I was looking at an outdated manpage.
Quoted 3 lines
My rewrite grabbed the data from the sysctl directly and didn't need this wrapper.
Yep, saw in v4 :)
PATCH v3 11/13 common-user: Move probe_guest_base from linux-user
In reply to Richard HendersonPrepare to share probe_guest_base with bsd-user.
Create a linux_probe_guest_base wrapper with the portions of probe_guest_base that are linux specific: managing the commpage for various targets.
--- include/user/probe-guest-base.h | 37 ++++ linux-user/user-internals.h | 10 +- common-user/probe-guest-base.c | 343 ++++++++++++++++++++++++++++++++ linux-user/elfload.c | 337 +------------------------------ linux-user/flatload.c | 2 +- common-user/meson.build | 1 + 6 files changed, 392 insertions(+), 338 deletions(-) create mode 100644 include/user/probe-guest-base.h create mode 100644 common-user/probe-guest-base.c
include/user/probe-guest-base.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef USER_PROBE_GUEST_BASE_H +#define USER_PROBE_GUEST_BASE_H + +#ifndef CONFIG_USER_ONLY +#error Cannot include this header from system emulation +#endif + +#include "exec/vaddr.h" + +typedef struct PGBRange { +vaddr lo; +vaddr hi; +}PGBRange ; + +/** +* probe_guest_base: +* @image_name: the executable being loaded +* @image_range: the fixed addresses within the executable +* +* Creates the initial guest address space in the host memory space. +* +* If @image_range is NULL, then no address in the executable is fixed, +* i.e. it is fully relocatable. +* +* This function will not return if a valid value for guest_base +* cannot be chosen. On return, the executable loader can expect +* +* target_mmap(i->lo, i->hi - i->lo + 1, ...) +* +* to succeed. +*/ +void probe_guest_base (const char *image_name,const PGBRange *image_range, +const PGBRange *commpage_range); + +#endif
linux-user/user-internals.h +3 -7
@@ -22,6 +22,7 @@#include "qemu/log.h" #include "exec/tb-flush.h" #include "exec/translation-block.h" +#include "user/probe-guest-base.h" extern char *exec_path;extern char real_exec_path[PATH_MAX ];
@@ -74,13 +75,8 @@ void clone_fork_end(bool child);void fork_start (void );void fork_end (pid_t pid); -typedef struct PGBRange { -vaddr lo; -vaddr hi; -}PGBRange ; -/** -* probe_guest_base: +* linux_probe_guest_base: * @image_name: the executable being loaded * @image_range: the fixed addresses within the executable *
@@ -96,7 +92,7 @@ typedef struct PGBRange {* * to succeed. */ -void probe_guest_base (const char *image_name,const PGBRange *image_range); +void linux_probe_guest_base (const char *image_name,const PGBRange *image_range);/* syscall.c */ int host_to_target_waitstatus (int status);
common-user/probe-guest-base.c new file +343 -0
343 lines not on this page · raw message
linux-user/elfload.c +7 -330
381 lines not on this page · raw message
linux-user/flatload.c +1 -1
@@ -261,7 +261,7 @@ static int load_flat_file(struct linux_binprm * bprm,/* * Allocate the address space. */ -probe_guest_base (bprm->filename,NULL ); +linux_probe_guest_base (bprm->filename,NULL );/* * there are a couple of cases here, the separate code/data
common-user/meson.build +1 -0
@@ -6,6 +6,7 @@ common_user_inc += include_directories('host/' / host_arch) user_ss.add(files( 'mmap-min-addr.c', + 'probe-guest-base.c', 'safe-syscall.S', 'safe-syscall-error.c', 'selfmap.c',
Signature · 1 line
2.43.0
PATCH v3 12/13 bsd-user: Use probe_guest_base
In reply to Richard HendersonMerge the PT_LOAD loop with the PT_INTERP loop, as the XXX comment suggests. Pass the probed range to probe_guest_base.
--- bsd-user/elfload.c | 37 +++++++++++++++++++------------------ bsd-user/main.c | 39 ++++----------------------------------- 2 files changed, 23 insertions(+), 53 deletions(-)
bsd-user/elfload.c +19 -18
@@ -22,6 +22,7 @@#include "qemu.h" #include "disas/disas.h" #include "qemu/path.h" +#include "user/probe-guest-base.h" static abi_ulong target_auxents;/* Where the AUX entries are in target */ static size_t target_auxents_sz;/* Size of AUX entries including AT_NULL */
@@ -610,8 +611,9 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,abi_ulong elf_brk;int error, retval;char *elf_interpreter; -abi_ulong baddr, elf_entry, et_dyn_addr, interp_load_addr =0 ; +abi_ulong elf_entry, et_dyn_addr, interp_load_addr =0 ;abi_ulong reloc_func_desc =0 ; +PGBRange range = {-1 ,0 }; load_addr =0 ; elf_ex = *((struct elfhdr *) bprm->buf);/* exec-header */
@@ -654,10 +656,10 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs, elf_brk =0 ; - elf_interpreter =NULL ; -for (i =0 ; i < elf_ex.e_phnum; i++) { -if (elf_ppnt->p_type ==PT_INTERP ) { +for (i =0 ; i < elf_ex.e_phnum; i++, elf_ppnt++) { +switch (elf_ppnt->p_type) { +case PT_INTERP :if (elf_interpreter !=NULL ) {free (elf_phdata);free (elf_interpreter);
@@ -709,8 +711,14 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,close (bprm->fd);return retval; } +break ; + +case PT_LOAD : + range.lo =MIN (range.lo, elf_ppnt->p_vaddr); + range.hi =MAX (range.hi, + elf_ppnt->p_vaddr + elf_ppnt->p_memsz -1 ); +break ; } - elf_ppnt++; }/* Some simple consistency checks for the interpreter */
@@ -740,19 +748,12 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs, info->end_code =0 ; elf_entry = (abi_ulong ) elf_ex.e_entry; -/* XXX Join this with PT_INTERP search? */ - baddr =0 ; -for (i =0 , elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) { -if (elf_ppnt->p_type !=PT_LOAD ) { -continue ; - } - baddr = elf_ppnt->p_vaddr; -break ; - } - et_dyn_addr =0 ; -if (elf_ex.e_type ==ET_DYN && baddr ==0 ) { - et_dyn_addr =ELF_ET_DYN_LOAD_ADDR ; +if (elf_ex.e_type ==ET_DYN ) { +probe_guest_base (bprm->filename,NULL ,NULL ); + et_dyn_addr =ELF_ET_DYN_LOAD_ADDR - range.lo; + }else { +probe_guest_base (bprm->filename, &range,NULL ); }/*
@@ -766,7 +767,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs, info->elf_flags = elf_ex.e_flags; error =load_elf_sections (&elf_ex, elf_phdata, bprm->fd, et_dyn_addr, - &load_addr); + &load_addr);for (i =0 , elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) {if (elf_ppnt->p_type !=PT_LOAD ) {continue ;
bsd-user/main.c +4 -35
@@ -540,41 +540,10 @@ int main(int argc, char **argv) } } -/* -* If reserving host virtual address space, do so now. -* Combined with '-B', ensure that the chosen range is free. -*/ -if (reserved_va) { -void *p; - -if (have_guest_base) { - p =mmap ((void *)guest_base, reserved_va +1 ,PROT_NONE , -MAP_ANON |MAP_PRIVATE |MAP_FIXED |MAP_EXCL ,-1 ,0 ); - }else { - p =mmap (NULL , reserved_va +1 ,PROT_NONE , -MAP_ANON |MAP_PRIVATE ,-1 ,0 ); - } -if (p ==MAP_FAILED ) { -const char *err =strerror (errno); -char *sz =size_to_str (reserved_va +1 ); - -if (have_guest_base) { -error_report ("Cannot allocate %s bytes at -B %p for guest " -"address space: %s" , sz, (void *)guest_base, err); - }else { -error_report ("Cannot allocate %s bytes for guest " -"address space: %s" , sz, err); - } -exit (1 ); - } - guest_base = (uintptr_t )p; - have_guest_base = true; - -/* Ensure that mmap_next_start is within range. */ -if (reserved_va <= mmap_next_start) { - mmap_next_start = (reserved_va /4 *3 ) - &TARGET_PAGE_MASK & qemu_host_page_mask; - } +/* Ensure that mmap_next_start is within range. */ +if (reserved_va && reserved_va <= mmap_next_start) { + mmap_next_start = ((reserved_va /4 *3 ) + &TARGET_PAGE_MASK & qemu_host_page_mask); } if (loader_exec(filename, argv + optind, target_environ, regs, info,
Signature · 1 line
2.43.0
Re: [PATCH v3 12/13] bsd-user: Use probe_guest_base
bsd-user/main.c int main(int argc, char **argv) · line 545
Quoted 13 lines · Richard Henderson
Merge the
PT_LOADloop with thePT_INTERPloop, as the XXX comment suggests. Pass the probed range toprobe_guest_base.Signed-off-by Richard Henderson <[email protected]>--- bsd-user/elfload.c | 37 +++++++++++++++++++------------------ bsd-user/main.c | 39 ++++----------------------------------- 2 files changed, 23 insertions(+), 53 deletions(-)bsd-user/main.c +3
-0+/* Ensure that mmap_next_start is within range. */ +if (reserved_va && reserved_va <= mmap_next_start) { + mmap_next_start = ((reserved_va / 4 * 3)
Is that ROUND_DOWN(reserved_va, 4)?
Quoted 2 lines
+ & TARGET_PAGE_MASK & qemu_host_page_mask);
}Rest LGTM AFAICT :)
Warner Losh
Reviewed-byRe: [PATCH v3 12/13] bsd-user: Use probe_guest_base
Quoted 15 lines · Philippe Mathieu-Daudé
bsd-user/main.c int main(int argc, char **argv) · line 545
Quoted 13 lines · Richard Henderson
Merge the
PT_LOADloop with thePT_INTERPloop, as the XXX comment suggests. Pass the probed range toprobe_guest_base.Signed-off-by Richard Henderson <[email protected]>--- bsd-user/elfload.c | 37 +++++++++++++++++++------------------ bsd-user/main.c | 39 ++++----------------------------------- 2 files changed, 23 insertions(+), 53 deletions(-)bsd-user/main.c +3
-0+/* Ensure that mmap_next_start is within range. */ +if (reserved_va && reserved_va <= mmap_next_start) { + mmap_next_start = ((reserved_va / 4 * 3)
Quoted 9 lines
Is that
ROUND_DOWN(reserved_va, 4)?Quoted 2 lines
+ & TARGET_PAGE_MASK & qemu_host_page_mask); }Rest LGTM AFAICT :)
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Same comment
Re: [PATCH v3 12/13] bsd-user: Use probe_guest_base
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Richard Henderson
Merge the
PT_LOADloop with thePT_INTERPloop, as the XXX comment suggests. Pass the probed range toprobe_guest_base.Signed-off-by Richard Henderson <[email protected]>---
bsd-user/elfload.c| 37 +++++++++++++++++++------------------ bsd-user/main.c | 39 ++++-----------------------------------2 files changed, 23 insertions(+), 53 deletions(-)
Quoted 5 lines
Quoted 3 lines
+ /* Ensure that
mmap_next_startis within range. */ + if (reserved_va&&reserved_va<=mmap_next_start) { +mmap_next_start= ((reserved_va/ 4 * 3)Is that
ROUND_DOWN(reserved_va, 4)?
No, this is reserved_va * 0.75.
r~
PATCH v3 13/13 common-user: Move guest_base, have_guest_base to probe-guest-base.c
In reply to Richard HendersonUnify the definitions of guest_base and have_guest_base.
--- bsd-user/main.c | 3 +-- common-user/probe-guest-base.c | 4 ++++ linux-user/main.c | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-)
bsd-user/main.c +1 -2
@@ -62,8 +62,7 @@ intptr_t qemu_host_page_mask;static bool opt_one_insn_per_tb;static unsigned long opt_tb_size; -uintptr_t guest_base; -bool have_guest_base; +/* * When running 32-on-64 we should make sure we can fit all of the possible * guest address space into a contiguous chunk of virtual host memory.
common-user/probe-guest-base.c +4 -0
@@ -7,6 +7,7 @@#include "qemu/log.h" #include "user/guest-base.h" #include "user/mmap-min-addr.h" +#include "user/guest-base.h" #include "user/guest-host.h" #include "user/probe-guest-base.h" #include "user/selfmap.h"
@@ -18,6 +19,9 @@#define MAP_FIXED_NOREPLACE (MAP_FIXED | MAP_EXCL)#endif +uintptr_t guest_base; +bool have_guest_base; +/** * pgb_try_mmap: * @addr: host start address
linux-user/main.c +0 -2
@@ -79,8 +79,6 @@ static envlist_t *envlist;static const char *cpu_model;static const char *cpu_type;static const char *seed_optarg; -uintptr_t guest_base; -bool have_guest_base;/* * Used to implement backwards-compatibility for the `-strace`, and
Signature · 1 line
2.43.0