linux-user patch queue
cover linux-user patch queue
Combine a bunch of smaller linux-user patches:
Supercedes: [email protected]
("[PATCH v2 0/3] linux-user: /proc/cpuinfo fix and content emulation for arm")
Supercedes: [email protected]
("[PATCH v2] linux-user: Emulate the Anonymous: keyword in /proc/self/smaps")
Supercedes: [email protected] ("[PATCH 0/6] linux-user: Rewrite open_self_maps")
Supercedes: [email protected] ("[PATCH 0/4] linux-user: shmat/shmdt improvements")
with some additions. Patches needing review:
01-linux-user-Split-out-cpu-target_proc.h.patch 11-linux-user-Use-WITH_MMAP_LOCK_GUARD-in-target_-shmat.patch 12-linux-user-Fix-shmdt.patch 13-linux-user-Track-shm-regions-with-an-interval-tree.patch
r~
Helge Deller (2):
linux-user: Emulate /proc/cpuinfo on aarch64 and arm
linux-user: Emulate /proc/cpuinfo for Alpha
Ilya Leoshkevich (1):
linux-user: Emulate the Anonymous: keyword in /proc/self/smaps
Richard Henderson (10):
linux-user: Split out cpu/target_proc.h util/selfmap: Use dev_t and ino_t in MapInfo
linux-user: Use walk_memory_regions for open_self_maps
linux-user: Adjust brk for load_bias
linux-user: Show heap address in /proc/pid/maps
linux-user: Remove ELF_START_MMAP and image_info.start_mmap
linux-user: Move shmat and shmdt implementations to mmap.c
linux-user: Use WITH_MMAP_LOCK_GUARD in target_{shmat,shmdt}
linux-user: Fix shmdt
linux-user: Track shm regions with an interval tree
include/qemu/selfmap.h | 4 +- linux-user/aarch64/target_proc.h | 1 + linux-user/alpha/target_proc.h | 67 ++++ linux-user/arm/target_proc.h | 101 ++++++ linux-user/cris/target_proc.h | 1 + linux-user/hexagon/target_proc.h | 1 + linux-user/hppa/target_proc.h | 26 ++ linux-user/i386/target_proc.h | 1 + linux-user/loader.h | 6 +- linux-user/loongarch64/target_proc.h | 1 + linux-user/m68k/target_proc.h | 16 + linux-user/microblaze/target_proc.h | 1 + linux-user/mips/target_proc.h | 1 + linux-user/mips64/target_proc.h | 1 + linux-user/nios2/target_proc.h | 1 + linux-user/openrisc/target_proc.h | 1 + linux-user/ppc/target_proc.h | 1 + linux-user/qemu.h | 1 - linux-user/riscv/target_proc.h | 37 ++ linux-user/s390x/target_proc.h | 109 ++++++ linux-user/sh4/target_proc.h | 1 + linux-user/sparc/target_proc.h | 16 + linux-user/user-mmap.h | 4 + linux-user/x86_64/target_proc.h | 1 + linux-user/xtensa/target_proc.h | 1 + linux-user/elfload.c | 170 ++++++--- linux-user/mmap.c | 168 +++++++++ linux-user/syscall.c | 514 +++++++-------------------- util/selfmap.c | 12 +- 29 files changed, 828 insertions(+), 437 deletions(-) create mode 100644 linux-user/aarch64/target_proc.h create mode 100644 linux-user/alpha/target_proc.h create mode 100644 linux-user/arm/target_proc.h create mode 100644 linux-user/cris/target_proc.h create mode 100644 linux-user/hexagon/target_proc.h create mode 100644 linux-user/hppa/target_proc.h create mode 100644 linux-user/i386/target_proc.h create mode 100644 linux-user/loongarch64/target_proc.h create mode 100644 linux-user/m68k/target_proc.h create mode 100644 linux-user/microblaze/target_proc.h create mode 100644 linux-user/mips/target_proc.h create mode 100644 linux-user/mips64/target_proc.h create mode 100644 linux-user/nios2/target_proc.h create mode 100644 linux-user/openrisc/target_proc.h create mode 100644 linux-user/ppc/target_proc.h create mode 100644 linux-user/riscv/target_proc.h create mode 100644 linux-user/s390x/target_proc.h create mode 100644 linux-user/sh4/target_proc.h create mode 100644 linux-user/sparc/target_proc.h create mode 100644 linux-user/x86_64/target_proc.h create mode 100644 linux-user/xtensa/target_proc.h
Signature · 1 line
2.34.1
PATCH 1/13 linux-user: Split out cpu/target_proc.h
Move the various open_cpuinfo functions into new files. Move the m68k open_hardware function as well.
All other guest architectures get a boilerplate empty file.
--- linux-user/aarch64/target_proc.h | 1 + linux-user/alpha/target_proc.h | 1 + linux-user/arm/target_proc.h | 1 + linux-user/cris/target_proc.h | 1 + linux-user/hexagon/target_proc.h | 1 + linux-user/hppa/target_proc.h | 26 ++++ linux-user/i386/target_proc.h | 1 + linux-user/loongarch64/target_proc.h | 1 + linux-user/m68k/target_proc.h | 16 +++ linux-user/microblaze/target_proc.h | 1 + linux-user/mips/target_proc.h | 1 + linux-user/mips64/target_proc.h | 1 + linux-user/nios2/target_proc.h | 1 + linux-user/openrisc/target_proc.h | 1 + linux-user/ppc/target_proc.h | 1 + linux-user/riscv/target_proc.h | 37 ++++++ linux-user/s390x/target_proc.h | 109 +++++++++++++++++ linux-user/sh4/target_proc.h | 1 + linux-user/sparc/target_proc.h | 16 +++ linux-user/x86_64/target_proc.h | 1 + linux-user/xtensa/target_proc.h | 1 + linux-user/syscall.c | 176 +-------------------------- 22 files changed, 226 insertions(+), 170 deletions(-) create mode 100644 linux-user/aarch64/target_proc.h create mode 100644 linux-user/alpha/target_proc.h create mode 100644 linux-user/arm/target_proc.h create mode 100644 linux-user/cris/target_proc.h create mode 100644 linux-user/hexagon/target_proc.h create mode 100644 linux-user/hppa/target_proc.h create mode 100644 linux-user/i386/target_proc.h create mode 100644 linux-user/loongarch64/target_proc.h create mode 100644 linux-user/m68k/target_proc.h create mode 100644 linux-user/microblaze/target_proc.h create mode 100644 linux-user/mips/target_proc.h create mode 100644 linux-user/mips64/target_proc.h create mode 100644 linux-user/nios2/target_proc.h create mode 100644 linux-user/openrisc/target_proc.h create mode 100644 linux-user/ppc/target_proc.h create mode 100644 linux-user/riscv/target_proc.h create mode 100644 linux-user/s390x/target_proc.h create mode 100644 linux-user/sh4/target_proc.h create mode 100644 linux-user/sparc/target_proc.h create mode 100644 linux-user/x86_64/target_proc.h create mode 100644 linux-user/xtensa/target_proc.h
linux-user/aarch64/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/alpha/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/arm/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/cris/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/hexagon/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/hppa/target_proc.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* HPPA specific proc functions for linux-user +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef HPPA_TARGET_PROC_H +#define HPPA_TARGET_PROC_H + +static int open_cpuinfo (CPUArchState *cpu_env,int fd) +{ +int i, num_cpus; + + num_cpus =sysconf (_SC_NPROCESSORS_ONLN); +for (i =0 ; i < num_cpus; i++) { +dprintf (fd,"processor\t: %d\n" , i); +dprintf (fd,"cpu family\t: PA-RISC 1.1e\n" ); +dprintf (fd,"cpu\t\t: PA7300LC (PCX-L2)\n" ); +dprintf (fd,"capabilities\t: os32\n" ); +dprintf (fd,"model\t\t: 9000/778/B160L - " +"Merlin L2 160 QEMU (9000/778/B160L)\n\n" ); + } +return 0 ; +} +#define HAVE_ARCH_PROC_CPUINFO + +#endif /* HPPA_TARGET_PROC_H */
linux-user/i386/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/loongarch64/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/m68k/target_proc.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* M68K specific proc functions for linux-user +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef M68K_TARGET_PROC_H +#define M68K_TARGET_PROC_H + +static int open_hardware (CPUArchState *cpu_env,int fd) +{ +dprintf (fd,"Model:\t\tqemu-m68k\n" ); +return 0 ; +} +#define HAVE_ARCH_PROC_HARDWARE + +#endif /* M68K_TARGET_PROC_H */
linux-user/microblaze/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/mips/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/mips64/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/nios2/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/openrisc/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/ppc/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/riscv/target_proc.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* RISC-V specific proc functions for linux-user +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef RISCV_TARGET_PROC_H +#define RISCV_TARGET_PROC_H + +static int open_cpuinfo (CPUArchState *cpu_env,int fd) +{ +int i; +int num_cpus =sysconf (_SC_NPROCESSORS_ONLN); +RISCVCPU *cpu =env_archcpu (cpu_env); +const RISCVCPUConfig *cfg =riscv_cpu_cfg ((CPURISCVState *) cpu_env); +char *isa_string =riscv_isa_string (cpu); +const char *mmu; + +if (cfg->mmu) { + mmu = (cpu_env->xl ==MXL_RV32 ) ?"sv32" :"sv48" ; + }else { + mmu ="none" ; + } + +for (i =0 ; i < num_cpus; i++) { +dprintf (fd,"processor\t: %d\n" , i); +dprintf (fd,"hart\t\t: %d\n" , i); +dprintf (fd,"isa\t\t: %s\n" , isa_string); +dprintf (fd,"mmu\t\t: %s\n" , mmu); +dprintf (fd,"uarch\t\t: qemu\n\n" ); + } + +g_free (isa_string); +return 0 ; +} +#define HAVE_ARCH_PROC_CPUINFO + +#endif /* RISCV_TARGET_PROC_H */
linux-user/s390x/target_proc.h new file +109 -0
109 lines not on this page · raw message
linux-user/sh4/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/sparc/target_proc.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Sparc specific proc functions for linux-user +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef SPARC_TARGET_PROC_H +#define SPARC_TARGET_PROC_H + +static int open_cpuinfo (CPUArchState *cpu_env,int fd) +{ +dprintf (fd,"type\t\t: sun4u\n" ); +return 0 ; +} +#define HAVE_ARCH_PROC_CPUINFO + +#endif /* SPARC_TARGET_PROC_H */
linux-user/x86_64/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/xtensa/target_proc.h new file +1 -0
@@ -0,0 +1 @@ +/* No target-specific /proc support */
linux-user/syscall.c +6 -170
197 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 01/13] linux-user: Split out cpu/target_proc.h
Quoted 42 lines · Richard Henderson
Move the various
open_cpuinfofunctions into new files. Move the m68kopen_hardwarefunction as well.
All other guest architectures get a boilerplate empty file.Signed-off-by Richard Henderson <[email protected]>--- linux-user/aarch64/target_proc.h | 1 + linux-user/alpha/target_proc.h | 1 + linux-user/arm/target_proc.h | 1 + linux-user/cris/target_proc.h | 1 + linux-user/hexagon/target_proc.h | 1 + linux-user/hppa/target_proc.h | 26 ++++ linux-user/i386/target_proc.h | 1 + linux-user/loongarch64/target_proc.h | 1 + linux-user/m68k/target_proc.h | 16 +++ linux-user/microblaze/target_proc.h | 1 + linux-user/mips/target_proc.h | 1 + linux-user/mips64/target_proc.h | 1 + linux-user/nios2/target_proc.h | 1 + linux-user/openrisc/target_proc.h | 1 + linux-user/ppc/target_proc.h | 1 + linux-user/riscv/target_proc.h | 37 ++++++ linux-user/s390x/target_proc.h | 109 +++++++++++++++++ linux-user/sh4/target_proc.h | 1 + linux-user/sparc/target_proc.h | 16 +++ linux-user/x86_64/target_proc.h | 1 + linux-user/xtensa/target_proc.h | 1 + linux-user/syscall.c | 176 +-------------------------- 22 files changed, 226 insertions(+), 170 deletions(-)create mode 100644
linux-user/aarch64/target_proc.hcreate mode 100644linux-user/alpha/target_proc.hcreate mode 100644linux-user/arm/target_proc.hcreate mode 100644linux-user/cris/target_proc.hcreate mode 100644linux-user/hexagon/target_proc.hcreate mode 100644linux-user/hppa/target_proc.hcreate mode 100644linux-user/i386/target_proc.hcreate mode 100644linux-user/loongarch64/target_proc.hcreate mode 100644linux-user/m68k/target_proc.hcreate mode 100644linux-user/microblaze/target_proc.hcreate mode 100644linux-user/mips/target_proc.hcreate mode 100644linux-user/mips64/target_proc.hcreate mode 100644linux-user/nios2/target_proc.h
Quoted 8 lines
create mode 100644
linux-user/openrisc/target_proc.hcreate mode 100644linux-user/ppc/target_proc.hcreate mode 100644linux-user/riscv/target_proc.hcreate mode 100644linux-user/s390x/target_proc.hcreate mode 100644linux-user/sh4/target_proc.hcreate mode 100644linux-user/sparc/target_proc.hcreate mode 100644linux-user/x86_64/target_proc.hcreate mode 100644linux-user/xtensa/target_proc.h
PATCH 2/13 linux-user: Emulate /proc/cpuinfo on aarch64 and arm
In reply to Richard HendersonFrom: Helge Deller <[email protected]>
Add emulation for /proc/cpuinfo for arm architecture. The output below mimics output as seen on debian porterboxes.
aarch64 output example:
processor : 0
model name : ARMv8 Processor rev 0 (v8l)
BogoMIPS : 100.00
Features : swp half thumb fast_mult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x1
CPU part : 0xd07
CPU revision : 0
arm 32-bit output example:
processor : 0
model name : ARMv7 Processor rev 5 (armv7l)
BogoMIPS : 100.00
Features : swp half thumb fast_mult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0f
CPU part : 0xc07
CPU revision : 5
Message-Id: <[email protected]>
--- linux-user/aarch64/target_proc.h | 2 +- linux-user/arm/target_proc.h | 102 +++++++++++++++++++++++- linux-user/loader.h | 6 +- linux-user/elfload.c | 130 ++++++++++++++++++++++++++++++- 4 files changed, 233 insertions(+), 7 deletions(-)
linux-user/aarch64/target_proc.h +1 -1
@@ -1 +1 @@ -/* No target-specific /proc support */ +#include "../arm/target_proc.h"
linux-user/arm/target_proc.h +101 -1
102 lines not on this page · raw message
linux-user/loader.h +5 -1
@@ -56,9 +56,13 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src,extern unsigned long guest_stack_size; -#ifdef TARGET_S390X +#if defined(TARGET_S390X ) || defined(TARGET_AARCH64 ) || defined(TARGET_ARM )uint32_t get_elf_hwcap (void );const char *elf_hwcap_str (uint32_t bit);#endif +#if defined(TARGET_AARCH64 ) || defined(TARGET_ARM ) +uint32_t get_elf_hwcap2 (void ); +const char *elf_hwcap2_str (uint32_t bit); +#endif #endif /* LINUX_USER_LOADER_H */
linux-user/elfload.c +126 -4
166 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 3/13 linux-user: Emulate /proc/cpuinfo for Alpha
In reply to Richard HendersonFrom: Helge Deller <[email protected]>
Add emulation for /proc/cpuinfo for the alpha architecture.
alpha output example:
(alpha-chroot)root@p100:/# cat /proc/cpuinfo cpu : Alpha cpu model : ev67 cpu variation : 0 cpu revision : 0 cpu serial number : JA00000000 system type : QEMU system variation : QEMU_v8.0.92 system revision : 0 system serial number : AY00000000 cycle frequency [Hz] : 250000000 timer frequency [Hz] : 250.00 page size [bytes] : 8192 phys. address bits : 44 max. addr. space # : 255 BogoMIPS : 2500.00 platform string : AlphaServer QEMU user-mode VM cpus detected : 8 cpus active : 4 cpu active mask : 0000000000000095 L1 Icache : n/a L1 Dcache : n/a L2 cache : n/a L3 cache : n/a
Message-Id: <[email protected]>
--- linux-user/alpha/target_proc.h | 68 +++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-)
linux-user/alpha/target_proc.h +67 -1
@@ -1 +1,67 @@ -/* No target-specific /proc support */ +/* +* Alpha specific proc functions for linux-user +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef ALPHA_TARGET_PROC_H +#define ALPHA_TARGET_PROC_H + +static int open_cpuinfo (CPUArchState *cpu_env,int fd) +{ +int max_cpus =sysconf (_SC_NPROCESSORS_CONF); +int num_cpus =sysconf (_SC_NPROCESSORS_ONLN); +unsigned long cpu_mask; +char model[32 ]; +const char *p, *q; +int t; + + p =object_class_get_name (OBJECT_CLASS (CPU_GET_CLASS (env_cpu (cpu_env)))); + q =strchr (p,'-' ); + t = q - p; +assert (t <sizeof (model)); +memcpy (model, p, t); + model[t] =0 ; + + t =sched_getaffinity (getpid (),sizeof (cpu_mask), (cpu_set_t *)&cpu_mask); +if (t <0 ) { +if (num_cpus >=sizeof (cpu_mask) *8 ) { + cpu_mask =-1 ; + }else { + cpu_mask = (1UL << num_cpus) -1 ; + } + } + +dprintf (fd, +"cpu\t\t\t: Alpha\n" +"cpu model\t\t: %s\n" +"cpu variation\t\t: 0\n" +"cpu revision\t\t: 0\n" +"cpu serial number\t: JA00000000\n" +"system type\t\t: QEMU\n" +"system variation\t: QEMU_v" QEMU_VERSION "\n" +"system revision\t\t: 0\n" +"system serial number\t: AY00000000\n" +"cycle frequency [Hz]\t: 250000000\n" +"timer frequency [Hz]\t: 250.00\n" +"page size [bytes]\t: %d\n" +"phys. address bits\t: %d\n" +"max. addr. space #\t: 255\n" +"BogoMIPS\t\t: 2500.00\n" +"kernel unaligned acc\t: 0 (pc=0,va=0)\n" +"user unaligned acc\t: 0 (pc=0,va=0)\n" +"platform string\t\t: AlphaServer QEMU user-mode VM\n" +"cpus detected\t\t: %d\n" +"cpus active\t\t: %d\n" +"cpu active mask\t\t: %016lx\n" +"L1 Icache\t\t: n/a\n" +"L1 Dcache\t\t: n/a\n" +"L2 cache\t\t: n/a\n" +"L3 cache\t\t: n/a\n" , + model,TARGET_PAGE_SIZE ,TARGET_PHYS_ADDR_SPACE_BITS , + max_cpus, num_cpus, cpu_mask); + +return 0 ; +} +#define HAVE_ARCH_PROC_CPUINFO + +#endif /* ALPHA_TARGET_PROC_H */
Signature · 1 line
2.34.1
Re: [PATCH 03/13] linux-user: Emulate /proc/cpuinfo for Alpha
Hi Helge,
Quoted 54 lines · Richard Henderson
From: Helge Deller <[email protected]>
Add emulation for
/proc/cpuinfofor the alpha architecture.alpha output example:
(alpha-chroot)root@p100:/# cat /proc/cpuinfo cpu : Alpha cpu model : ev67 cpu variation : 0 cpu revision : 0 cpu serial number : JA00000000 system type : QEMU system variation : QEMU_v8.0.92 system revision : 0 system serial number : AY00000000 cycle frequency [Hz] : 250000000 timer frequency [Hz] : 250.00 page size [bytes] : 8192 phys. address bits : 44 max. addr. space # : 255 BogoMIPS : 2500.00 platform string : AlphaServer QEMU user-mode VM cpus detected : 8 cpus active : 4 cpu active mask : 0000000000000095 L1 Icache : n/a L1 Dcache : n/a L2 cache : n/a L3 cache : n/aCc Michael Cree <[email protected]>Signed-off-by Helge Deller <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-Id: <[email protected]>
Signed-off-by Richard Henderson <[email protected]>--- linux-user/alpha/target_proc.h | 68 +++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-)linux-user/alpha/target_proc.h +8
-1@@ -1 +1,67 @@ -/* No target-specific /proc support */ +/* +* Alpha specific proc functions for linux-user +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef ALPHA_TARGET_PROC_H +#define ALPHA_TARGET_PROC_H +
linux-user/alpha/target_proc.h line 18
Quoted 10 lines
linux-user/alpha/target_proc.h +10
-0+static int open_cpuinfo (CPUArchState *cpu_env,int fd) +{ +int max_cpus =sysconf (_SC_NPROCESSORS_CONF); +int num_cpus =sysconf (_SC_NPROCESSORS_ONLN); +unsigned long cpu_mask; +char model[32 ]; +const char *p, *q; +int t; + + p =object_class_get_name (OBJECT_CLASS (CPU_GET_CLASS (env_cpu (cpu_env))));
Isn't it the same of:
p = object_get_typename(OBJECT(env_cpu(cpu_env)));
?
PATCH 4/13 util/selfmap: Use dev_t and ino_t in MapInfo
In reply to Richard HendersonUse dev_t instead of a string, and ino_t instead of uint64_t. The latter is likely to be identical on modern systems but is more type-correct for usage.
--- include/qemu/selfmap.h | 4 ++-- linux-user/syscall.c | 6 ++++-- util/selfmap.c | 12 +++++++----- 3 files changed, 13 insertions(+), 9 deletions(-)
include/qemu/selfmap.h +2 -2
@@ -20,10 +20,10 @@ typedef struct {bool is_exec;bool is_priv; +dev_t dev; +ino_t inode;uint64_t offset; -uint64_t inode;const char *path; -char dev[]; } MapInfo;/**
linux-user/syscall.c +4 -2
@@ -8160,13 +8160,15 @@ static int open_self_maps_1(CPUArchState *cpu_env, int fd, bool smaps) } count =dprintf (fd, TARGET_ABI_FMT_ptr"-" TARGET_ABI_FMT_ptr -" %c%c%c%c %08" PRIx64" %s %" PRId64, +" %c%c%c%c %08" PRIx64" %02x:%02x %" PRId64,h2g (min),h2g (max -1 ) +1 , (flags &PAGE_READ ) ?'r' :'-' , (flags &PAGE_WRITE_ORG ) ?'w' :'-' , (flags &PAGE_EXEC ) ?'x' :'-' , e->is_priv ?'p' :'s' , - (uint64_t ) e->offset, e->dev, e->inode); + (uint64_t )e->offset, +major (e->dev),minor (e->dev), + (uint64_t )e->inode);if (path) {dprintf (fd,"%*s%s\n" ,73 - count,"" , path); }else {
util/selfmap.c +7 -5
@@ -30,19 +30,21 @@ IntervalTreeRoot *read_self_maps(void)if (nfields >4 ) {uint64_t start, end, offset, inode; +unsigned dev_maj, dev_min;int errors =0 ;const char *p; errors |=qemu_strtou64 (fields[0 ], &p,16 , &start); errors |=qemu_strtou64 (p +1 ,NULL ,16 , &end); errors |=qemu_strtou64 (fields[2 ],NULL ,16 , &offset); + errors |=qemu_strtoui (fields[3 ], &p,16 , &dev_maj); + errors |=qemu_strtoui (p +1 ,NULL ,16 , &dev_min); errors |=qemu_strtou64 (fields[4 ],NULL ,10 , &inode);if (!errors) { -size_t dev_len, path_len; +size_t path_len;MapInfo *e; - dev_len =strlen (fields[3 ]) +1 ;if (nfields ==6 ) { p = fields[5 ]; p +=strspn (p," " );
@@ -52,11 +54,12 @@ IntervalTreeRoot *read_self_maps(void) path_len =0 ; } - e =g_malloc0 (sizeof (*e) + dev_len + path_len); + e =g_malloc0 (sizeof (*e) + path_len); e->itree.start = start; e->itree.last = end -1 ; e->offset = offset; + e->dev =makedev (dev_maj, dev_min); e->inode = inode; e->is_read = fields[1 ][0 ] =='r' ;
@@ -64,9 +67,8 @@ IntervalTreeRoot *read_self_maps(void) e->is_exec = fields[1 ][2 ] =='x' ; e->is_priv = fields[1 ][3 ] =='p' ; -memcpy (e->dev, fields[3 ], dev_len);if (path_len) { - e->path =memcpy (e->dev + dev_len, p, path_len); + e->path =memcpy (e +1 , p, path_len); }interval_tree_insert (&e->itree, root);
Signature · 1 line
2.34.1
PATCH 5/13 linux-user: Use walk_memory_regions for open_self_maps
In reply to Richard HendersonReplace the by-hand method of region identification with the official user-exec interface. Cross-check the region provided to the callback with the interval tree from read_self_maps().
--- linux-user/syscall.c | 192 ++++++++++++++++++++++++++----------------- 1 file changed, 115 insertions(+), 77 deletions(-)
linux-user/syscall.c +115 -77
@@ -8095,12 +8095,66 @@ static int open_self_cmdline(CPUArchState *cpu_env, int fd)return 0 ; } -static void show_smaps (int fd,unsigned long size) -{ -unsigned long page_size_kb =TARGET_PAGE_SIZE >>10 ; -unsigned long size_kb = size >>10 ; +struct open_self_maps_data { +TaskState *ts; +IntervalTreeRoot *host_maps; +int fd; +bool smaps; +}; -dprintf (fd,"Size: %lu kB\n" +/* +* Subroutine to output one line of /proc/self/maps, +* or one region of /proc/self/smaps. +*/ + +#ifdef TARGET_HPPA +# define test_stack (S ,E ,L ) (E == L) +#else +# define test_stack (S ,E ,L ) (S == L) +#endif + +static void open_self_maps_4 (const struct open_self_maps_data *d, +const MapInfo *mi,abi_ptr start, +abi_ptr end,unsigned flags) +{ +const struct image_info *info = d->ts->info; +const char *path = mi->path; +uint64_t offset; +int fd = d->fd; +int count; + +if (test_stack (start, end, info->stack_limit)) { + path ="[stack]" ; + } + +/* Except null device (MAP_ANON), adjust offset for this fragment. */ + offset = mi->offset; +if (mi->dev) { +uintptr_t hstart = (uintptr_t )g2h_untagged (start); + offset += hstart - mi->itree.start; + } + + count =dprintf (fd, TARGET_ABI_FMT_ptr"-" TARGET_ABI_FMT_ptr +" %c%c%c%c %08" PRIx64" %02x:%02x %" PRId64, + start, end, + (flags &PAGE_READ ) ?'r' :'-' , + (flags &PAGE_WRITE_ORG ) ?'w' :'-' , + (flags &PAGE_EXEC ) ?'x' :'-' , + mi->is_priv ?'p' :'s' , + offset,major (mi->dev),minor (mi->dev), + (uint64_t )mi->inode); +if (path) { +dprintf (fd,"%*s%s\n" ,73 - count,"" , path); + }else { +dprintf (fd,"\n" ); + } + +if (d->smaps) { +unsigned long size = end - start; +unsigned long page_size_kb =TARGET_PAGE_SIZE >>10 ; +unsigned long size_kb = size >>10 ; + +dprintf (fd,"Size: %lu kB\n" "KernelPageSize: %lu kB\n" "MMUPageSize: %lu kB\n" "Rss: 0 kB\n"
@@ -8121,91 +8175,75 @@ static void show_smaps(int fd, unsigned long size)"Swap: 0 kB\n" "SwapPss: 0 kB\n" "Locked: 0 kB\n" - "THPeligible: 0\n", size_kb, page_size_kb, page_size_kb); +"THPeligible: 0\n" +"VmFlags:%s%s%s%s%s%s%s%s\n" , + size_kb, page_size_kb, page_size_kb, + (flags &PAGE_READ ) ?" rd" :"" , + (flags &PAGE_WRITE_ORG ) ?" wr" :"" , + (flags &PAGE_EXEC ) ?" ex" :"" , + mi->is_priv ?"" :" sh" , + (flags &PAGE_READ ) ?" mr" :"" , + (flags &PAGE_WRITE_ORG ) ?" mw" :"" , + (flags &PAGE_EXEC ) ?" me" :"" , + mi->is_priv ? "" : " ms"); + } } -static int open_self_maps_1 (CPUArchState *cpu_env,int fd,bool smaps) +/* +* Callback for walk_memory_regions, when read_self_maps() fails. +* Proceed without the benefit of host /proc/self/maps cross-check. +*/ +static int open_self_maps_3 (void *opaque,target_ulong guest_start, +target_ulong guest_end,unsigned long flags) { -CPUState *cpu =env_cpu (cpu_env); -TaskState *ts = cpu->opaque; -IntervalTreeRoot *map_info =read_self_maps (); -IntervalTreeNode *s; -int count; +static const MapInfo mi = { .is_priv = true }; -for (s =interval_tree_iter_first (map_info,0 ,-1 ); s; - s =interval_tree_iter_next (s,0 ,-1 )) { -MapInfo *e =container_of (s, MapInfo, itree); +open_self_maps_4 (opaque, &mi, guest_start, guest_end, flags); +return 0 ; +} -if (h2g_valid (e->itree.start)) { -unsigned long min = e->itree.start; -unsigned long max = e->itree.last +1 ; -int flags =page_get_flags (h2g (min)); -const char *path; +/* +* Callback for walk_memory_regions, when read_self_maps() succeeds. +*/ +static int open_self_maps_2 (void *opaque,target_ulong guest_start, +target_ulong guest_end,unsigned long flags) +{ +const struct open_self_maps_data *d = opaque; +uintptr_t host_start = (uintptr_t )g2h_untagged (guest_start); +uintptr_t host_last = (uintptr_t )g2h_untagged (guest_end -1 ); - max =h2g_valid (max -1 ) ? - max : (uintptr_t )g2h_untagged (GUEST_ADDR_MAX ) +1 ; +while (1 ) { +IntervalTreeNode *n = +interval_tree_iter_first (d->host_maps, host_start, host_start); +MapInfo *mi =container_of (n, MapInfo, itree); +uintptr_t this_hlast =MIN (host_last, n->last); +target_ulong this_gend =h2g (this_hlast) +1 ; -if (!page_check_range (h2g (min), max - min, flags)) { -continue ; - } +open_self_maps_4 (d, mi, guest_start, this_gend, flags); -#ifdef TARGET_HPPA -if (h2g (max) == ts->info->stack_limit) { -#else -if (h2g (min) == ts->info->stack_limit) { -#endif - path ="[stack]" ; - }else { - path = e->path; - } - - count =dprintf (fd, TARGET_ABI_FMT_ptr"-" TARGET_ABI_FMT_ptr -" %c%c%c%c %08" PRIx64" %02x:%02x %" PRId64, -h2g (min),h2g (max -1 ) +1 , - (flags &PAGE_READ ) ?'r' :'-' , - (flags &PAGE_WRITE_ORG ) ?'w' :'-' , - (flags &PAGE_EXEC ) ?'x' :'-' , - e->is_priv ?'p' :'s' , - (uint64_t )e->offset, -major (e->dev),minor (e->dev), - (uint64_t )e->inode); -if (path) { -dprintf (fd,"%*s%s\n" ,73 - count,"" , path); - }else { -dprintf (fd,"\n" ); - } -if (smaps) { -show_smaps (fd, max - min); -dprintf (fd,"VmFlags:%s%s%s%s%s%s%s%s\n" , - (flags &PAGE_READ ) ?" rd" :"" , - (flags &PAGE_WRITE_ORG ) ?" wr" :"" , - (flags &PAGE_EXEC ) ?" ex" :"" , - e->is_priv ?"" :" sh" , - (flags &PAGE_READ ) ?" mr" :"" , - (flags &PAGE_WRITE_ORG ) ?" mw" :"" , - (flags &PAGE_EXEC ) ?" me" :"" , - e->is_priv ?"" :" ms" ); - } +if (this_hlast == host_last) { +return 0 ; } + host_start = this_hlast +1 ; + guest_start =h2g (host_start); } +} -free_self_maps (map_info); +static int open_self_maps_1 (CPUArchState *env,int fd,bool smaps) +{ +struct open_self_maps_data d = { + .ts =env_cpu (env)->opaque, + .host_maps =read_self_maps (), + .fd = fd, + .smaps = smaps + }; -#ifdef TARGET_VSYSCALL_PAGE -/* -* We only support execution from the vsyscall page. -* This is as if CONFIG_LEGACY_VSYSCALL_XONLY=y from v5.3. -*/ - count =dprintf (fd, TARGET_FMT_lx"-" TARGET_FMT_lx -" --xp 00000000 00:00 0" , -TARGET_VSYSCALL_PAGE ,TARGET_VSYSCALL_PAGE +TARGET_PAGE_SIZE ); -dprintf (fd,"%*s%s\n" ,73 - count,"" ,"[vsyscall]" ); -if (smaps) { -show_smaps (fd,TARGET_PAGE_SIZE ); -dprintf (fd,"VmFlags: ex\n" ); +if (d.host_maps) { +walk_memory_regions (&d, open_self_maps_2); +free_self_maps (d.host_maps); + }else { +walk_memory_regions (&d, open_self_maps_3); } -#endif -return 0 ; }
Signature · 1 line
2.34.1
PATCH 6/13 linux-user: Adjust brk for load_bias
In reply to Richard HendersonPIE executables are usually linked at offset 0 and are relocated somewhere during load. The hiaddr needs to be adjusted to keep the brk next to the executable.
--- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/elfload.c +1 -1
@@ -3326,7 +3326,7 @@ static void load_elf_image(const char *image_name, int image_fd, 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); + info->brk =TARGET_PAGE_ALIGN (hiaddr + load_bias); info->elf_flags = ehdr->e_flags; prot_exec =PROT_EXEC ;
Signature · 1 line
2.34.1
PATCH 7/13 linux-user: Show heap address in /proc/pid/maps
In reply to Richard Henderson--- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+)
linux-user/syscall.c +2 -0
@@ -8125,6 +8125,8 @@ static void open_self_maps_4(const struct open_self_maps_data *d,if (test_stack (start, end, info->stack_limit)) { path ="[stack]" ; + }else if (start == info->brk) { + path ="[heap]" ; }/* Except null device (MAP_ANON), adjust offset for this fragment. */
Signature · 1 line
2.34.1
Re: [PATCH 07/13] linux-user: Show heap address in /proc/pid/maps
Quoted 6 lines · Richard Henderson
Tested-by Helge Deller <[email protected]>Reviewed-by Ilya Leoshkevich <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+)
PATCH 8/13 linux-user: Emulate the Anonymous: keyword in /proc/self/smaps
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
Core dumps produced by gdb's gcore when connected to qemu's gdbstub lack stack. The reason is that gdb includes only anonymous memory in core dumps, which is distinguished by a non-0 Anonymous: value.
Consider the mappings with PAGE_ANON fully anonymous, and the mappings without it fully non-anonymous.
--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/syscall.c +2 -1
@@ -8167,7 +8167,7 @@ static void open_self_maps_4(const struct open_self_maps_data *d,"Private_Clean: 0 kB\n" "Private_Dirty: 0 kB\n" "Referenced: 0 kB\n" -"Anonymous: 0 kB\n" +"Anonymous: %lu kB\n" "LazyFree: 0 kB\n" "AnonHugePages: 0 kB\n" "ShmemPmdMapped: 0 kB\n"
@@ -8180,6 +8180,7 @@ static void open_self_maps_4(const struct open_self_maps_data *d,"THPeligible: 0\n" "VmFlags:%s%s%s%s%s%s%s%s\n" , size_kb, page_size_kb, page_size_kb, + (flags &PAGE_ANON ? size_kb :0 ), (flags &PAGE_READ ) ?" rd" :"" , (flags &PAGE_WRITE_ORG ) ?" wr" :"" , (flags & PAGE_EXEC) ? " ex" : "",
Signature · 1 line
2.34.1
Re: [PATCH 08/13] linux-user: Emulate the Anonymous: keyword in /proc/self/smaps
Quoted 9 lines · Richard Henderson
From: Ilya Leoshkevich <[email protected]>
Core dumps produced by gdb's gcore when connected to qemu's gdbstub lack stack. The reason is that gdb includes only anonymous memory in core dumps, which is distinguished by a non-0 Anonymous: value.
Consider the mappings with
PAGE_ANONfully anonymous, and the mappings without it fully non-anonymous.
Quoted 6 lines
Signed-off-by Ilya Leoshkevich <[email protected]>[rth: Update for open_self_maps_* rewrite]Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
PATCH 9/13 linux-user: Remove ELF_START_MMAP and image_info.start_mmap
In reply to Richard HendersonThe start_mmap value is write-only.
Remove the field and the defines that populated it. Logically, this has been replaced by task_unmapped_base.
--- linux-user/qemu.h | 1 - linux-user/elfload.c | 38 -------------------------------------- 2 files changed, 39 deletions(-)
linux-user/qemu.h +0 -1
@@ -30,7 +30,6 @@ struct image_info {abi_ulong start_data;abi_ulong end_data;abi_ulong brk; -abi_ulong start_mmap;abi_ulong start_stack;abi_ulong stack_limit;abi_ulong entry;
linux-user/elfload.c +0 -38
@@ -143,8 +143,6 @@ static uint32_t get_elf_hwcap(void) }#ifdef TARGET_X86_64 -#define ELF_START_MMAP 0x2aaaaab000ULL -#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_X86_64
@@ -221,8 +219,6 @@ static bool init_guest_commpage(void)#endif #else -#define ELF_START_MMAP 0x80000000 -/* * This is used to ensure we don't load something for the wrong architecture. */
@@ -308,8 +304,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en#ifndef TARGET_AARCH64 /* 32 bit ARM definitions */ -#define ELF_START_MMAP 0x80000000 -#define ELF_ARCH EM_ARM#define ELF_CLASS ELFCLASS32#define EXSTACK_DEFAULT true
@@ -600,7 +594,6 @@ static const char *get_elf_platform(void)#else /* 64 bit ARM definitions */ -#define ELF_START_MMAP 0x80000000#define ELF_ARCH EM_AARCH64#define ELF_CLASS ELFCLASS64
@@ -871,7 +864,6 @@ const char *elf_hwcap2_str(uint32_t bit)#ifdef TARGET_SPARC #ifdef TARGET_SPARC64 -#define ELF_START_MMAP 0x80000000#define ELF_HWCAP (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | HWCAP_SPARC_SWAP \ | HWCAP_SPARC_MULDIV | HWCAP_SPARC_V9)#ifndef TARGET_ABI32
@@ -883,7 +875,6 @@ const char *elf_hwcap2_str(uint32_t bit)#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_SPARCV9#else -#define ELF_START_MMAP 0x80000000#define ELF_HWCAP (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | HWCAP_SPARC_SWAP \ | HWCAP_SPARC_MULDIV)#define ELF_CLASS ELFCLASS32
@@ -905,7 +896,6 @@ static inline void init_thread(struct target_pt_regs *regs,#ifdef TARGET_PPC #define ELF_MACHINE PPC_ELF_MACHINE -#define ELF_START_MMAP 0x80000000#if defined(TARGET_PPC64 )
@@ -1108,8 +1098,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en#ifdef TARGET_LOONGARCH64 -#define ELF_START_MMAP 0x80000000 -#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_LOONGARCH#define EXSTACK_DEFAULT true
@@ -1200,8 +1188,6 @@ static uint32_t get_elf_hwcap(void)#ifdef TARGET_MIPS -#define ELF_START_MMAP 0x80000000 -#ifdef TARGET_MIPS64 #define ELF_CLASS ELFCLASS64#else
@@ -1359,8 +1345,6 @@ static uint32_t get_elf_hwcap(void)#ifdef TARGET_MICROBLAZE -#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ( (x) == EM_MICROBLAZE || (x) == EM_MICROBLAZE_OLD)#define ELF_CLASS ELFCLASS32
@@ -1401,8 +1385,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env#ifdef TARGET_NIOS2 -#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ((x) == EM_ALTERA_NIOS2)#define ELF_CLASS ELFCLASS32
@@ -1498,8 +1480,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#ifdef TARGET_OPENRISC -#define ELF_START_MMAP 0x08000000 -#define ELF_ARCH EM_OPENRISC#define ELF_CLASS ELFCLASS32#define ELF_DATA ELFDATA2MSB
@@ -1536,8 +1516,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#ifdef TARGET_SH4 -#define ELF_START_MMAP 0x80000000 -#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_SH
@@ -1618,8 +1596,6 @@ static uint32_t get_elf_hwcap(void)#ifdef TARGET_CRIS -#define ELF_START_MMAP 0x80000000 -#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_CRIS
@@ -1635,8 +1611,6 @@ static inline void init_thread(struct target_pt_regs *regs,#ifdef TARGET_M68K -#define ELF_START_MMAP 0x80000000 -#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_68K
@@ -1686,8 +1660,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *e#ifdef TARGET_ALPHA -#define ELF_START_MMAP (0x30000000000ULL) -#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_ALPHA
@@ -1705,8 +1677,6 @@ static inline void init_thread(struct target_pt_regs *regs,#ifdef TARGET_S390X -#define ELF_START_MMAP (0x20000000000ULL) -#define ELF_CLASS ELFCLASS64#define ELF_DATA ELFDATA2MSB#define ELF_ARCH EM_S390
@@ -1816,7 +1786,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#ifdef TARGET_RISCV -#define ELF_START_MMAP 0x80000000#define ELF_ARCH EM_RISCV#ifdef TARGET_RISCV32
@@ -1852,7 +1821,6 @@ static inline void init_thread(struct target_pt_regs *regs,#ifdef TARGET_HPPA -#define ELF_START_MMAP 0x80000000#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_PARISC#define ELF_PLATFORM "PARISC"
@@ -1904,8 +1872,6 @@ static bool init_guest_commpage(void)#ifdef TARGET_XTENSA -#define ELF_START_MMAP 0x20000000 -#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_XTENSA
@@ -1971,8 +1937,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#ifdef TARGET_HEXAGON -#define ELF_START_MMAP 0x20000000 -#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_HEXAGON
@@ -3689,8 +3653,6 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) interp_info.fp_abi =MIPS_ABI_FP_UNKNOWN ;#endif - info->start_mmap = (abi_ulong )ELF_START_MMAP ; -load_elf_image (bprm->filename, bprm->fd, info, &elf_interpreter, bprm->buf);
Signature · 1 line
2.34.1
PATCH 10/13 linux-user: Move shmat and shmdt implementations to mmap.c
In reply to Richard HendersonRename from do_* to target_*. Fix some minor checkpatch errors.
--- linux-user/user-mmap.h | 4 ++ linux-user/mmap.c | 138 +++++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 143 ++--------------------------------------- 3 files changed, 146 insertions(+), 139 deletions(-)
linux-user/user-mmap.h +4 -0
@@ -58,4 +58,8 @@ abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong);void mmap_fork_start (void );void mmap_fork_end (int child); +abi_ulong target_shmat (CPUArchState *cpu_env,int shmid, +abi_ulong shmaddr,int shmflg); +abi_long target_shmdt (abi_ulong shmaddr); +#endif /* LINUX_USER_USER_MMAP_H */
linux-user/mmap.c +138 -0
153 lines not on this page · raw message
linux-user/syscall.c +4 -139
176 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 11/13 linux-user: Use WITH_MMAP_LOCK_GUARD in target_{shmat, shmdt}
In reply to Richard HendersonMove the CF_PARALLEL setting outside of the mmap lock.
--- linux-user/mmap.c | 98 ++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 52 deletions(-)
linux-user/mmap.c +46 -52
@@ -1017,9 +1017,8 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid, {CPUState *cpu =env_cpu (cpu_env);abi_ulong raddr; -void *host_raddr;struct shmid_ds shm_info; -int i, ret; +int ret;abi_ulong shmlba;/* shmat pointers are always untagged */
@@ -1044,7 +1043,43 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid,return -TARGET_EINVAL ; } -mmap_lock (); + WITH_MMAP_LOCK_GUARD() { +void *host_raddr; + +if (shmaddr) { + host_raddr =shmat (shmid, (void *)g2h_untagged (shmaddr), shmflg); + }else { +abi_ulong mmap_start; + +/* In order to use the host shmat, we need to honor host SHMLBA. */ + mmap_start =mmap_find_vma (0 , shm_info.shm_segsz, +MAX (SHMLBA , shmlba)); + +if (mmap_start ==-1 ) { +return -TARGET_ENOMEM ; + } + host_raddr =shmat (shmid,g2h_untagged (mmap_start), + shmflg |SHM_REMAP ); + } + +if (host_raddr == (void *)-1 ) { +return get_errno (-1 ); + } + raddr =h2g (host_raddr); + +page_set_flags (raddr, raddr + shm_info.shm_segsz -1 , +PAGE_VALID |PAGE_RESET |PAGE_READ | + (shmflg &SHM_RDONLY ?0 :PAGE_WRITE )); + +for (int i =0 ; i <N_SHM_REGIONS ; i++) { +if (!shm_regions[i].in_use) { + shm_regions[i].in_use = true; + shm_regions[i].start = raddr; + shm_regions[i].size = shm_info.shm_segsz; +break ; + } + } + }/* * We're mapping shared memory, so ensure we generate code for parallel
@@ -1057,65 +1092,24 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid,tb_flush (cpu); } -if (shmaddr) { - host_raddr =shmat (shmid, (void *)g2h_untagged (shmaddr), shmflg); - }else { -abi_ulong mmap_start; - -/* In order to use the host shmat, we need to honor host SHMLBA. */ - mmap_start =mmap_find_vma (0 , shm_info.shm_segsz,MAX (SHMLBA , shmlba)); - -if (mmap_start ==-1 ) { - errno =ENOMEM ; - host_raddr = (void *)-1 ; - }else { - host_raddr =shmat (shmid,g2h_untagged (mmap_start), - shmflg |SHM_REMAP ); - } - } - -if (host_raddr == (void *)-1 ) { -mmap_unlock (); -return get_errno ((intptr_t )host_raddr); - } - raddr =h2g ((uintptr_t )host_raddr); - -page_set_flags (raddr, raddr + shm_info.shm_segsz -1 , -PAGE_VALID |PAGE_RESET |PAGE_READ | - (shmflg &SHM_RDONLY ?0 :PAGE_WRITE )); - -for (i =0 ; i <N_SHM_REGIONS ; i++) { -if (!shm_regions[i].in_use) { - shm_regions[i].in_use = true; - shm_regions[i].start = raddr; - shm_regions[i].size = shm_info.shm_segsz; -break ; - } - } - -mmap_unlock ();return raddr; }abi_long target_shmdt (abi_ulong shmaddr) { -int i;abi_long rv;/* shmdt pointers are always untagged */ -mmap_lock (); - -for (i =0 ; i <N_SHM_REGIONS ; ++i) { -if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { - shm_regions[i].in_use = false; -page_set_flags (shmaddr, shmaddr + shm_regions[i].size -1 ,0 ); -break ; + WITH_MMAP_LOCK_GUARD() { +for (int i =0 ; i <N_SHM_REGIONS ; ++i) { +if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { + shm_regions[i].in_use = false; +page_set_flags (shmaddr, shmaddr + shm_regions[i].size -1 ,0 ); +break ; + } } + rv =get_errno (shmdt (g2h_untagged (shmaddr))); } - rv =get_errno (shmdt (g2h_untagged (shmaddr))); - -mmap_unlock (); -return rv; }
Signature · 1 line
2.34.1
Re: [PATCH 11/13] linux-user: Use WITH_MMAP_LOCK_GUARD in target_{shmat, shmdt}
Quoted 3 lines · Richard Henderson
Move the
CF_PARALLELsetting outside of the mmap lock.Signed-off-by Richard Henderson <[email protected]>
Quoted 138 lines
--- linux-user/mmap.c | 98 ++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 52 deletions(-)linux-user/mmap.c +46
-52@@ -1017,9 +1017,8 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid, {CPUState *cpu =env_cpu (cpu_env);abi_ulong raddr; -void *host_raddr;struct shmid_ds shm_info; -int i, ret; +int ret;abi_ulong shmlba;/* shmat pointers are always untagged */ @@ -1044,7 +1043,43 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid,return -TARGET_EINVAL ; } -mmap_lock (); + WITH_MMAP_LOCK_GUARD() { +void *host_raddr; + +if (shmaddr) { + host_raddr =shmat (shmid, (void *)g2h_untagged (shmaddr), shmflg); + }else { +abi_ulong mmap_start; + +/* In order to use the host shmat, we need to honor host SHMLBA. */ + mmap_start =mmap_find_vma (0 , shm_info.shm_segsz, +MAX (SHMLBA , shmlba)); + +if (mmap_start ==-1 ) { +return -TARGET_ENOMEM ; + } + host_raddr =shmat (shmid,g2h_untagged (mmap_start), + shmflg |SHM_REMAP ); + } + +if (host_raddr == (void *)-1 ) { +return get_errno (-1 ); + } + raddr =h2g (host_raddr); + +page_set_flags (raddr, raddr + shm_info.shm_segsz -1 , +PAGE_VALID |PAGE_RESET |PAGE_READ | + (shmflg &SHM_RDONLY ?0 :PAGE_WRITE )); + +for (int i =0 ; i <N_SHM_REGIONS ; i++) { +if (!shm_regions[i].in_use) { + shm_regions[i].in_use = true; + shm_regions[i].start = raddr; + shm_regions[i].size = shm_info.shm_segsz; +break ; + } + } + }/* * We're mapping shared memory, so ensure we generate code for parallel @@ -1057,65 +1092,24 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid,tb_flush (cpu); } -if (shmaddr) { - host_raddr =shmat (shmid, (void *)g2h_untagged (shmaddr), shmflg); - }else { -abi_ulong mmap_start; - -/* In order to use the host shmat, we need to honor host SHMLBA. */ - mmap_start =mmap_find_vma (0 , shm_info.shm_segsz,MAX (SHMLBA , shmlba)); - -if (mmap_start ==-1 ) { - errno =ENOMEM ; - host_raddr = (void *)-1 ; - }else { - host_raddr =shmat (shmid,g2h_untagged (mmap_start), - shmflg |SHM_REMAP ); - } - } - -if (host_raddr == (void *)-1 ) { -mmap_unlock (); -return get_errno ((intptr_t )host_raddr); - } - raddr =h2g ((uintptr_t )host_raddr); - -page_set_flags (raddr, raddr + shm_info.shm_segsz -1 , -PAGE_VALID |PAGE_RESET |PAGE_READ | - (shmflg &SHM_RDONLY ?0 :PAGE_WRITE )); - -for (i =0 ; i <N_SHM_REGIONS ; i++) { -if (!shm_regions[i].in_use) { - shm_regions[i].in_use = true; - shm_regions[i].start = raddr; - shm_regions[i].size = shm_info.shm_segsz; -break ; - } - } - -mmap_unlock ();return raddr; }abi_long target_shmdt (abi_ulong shmaddr) { -int i;abi_long rv;/* shmdt pointers are always untagged */ -mmap_lock (); - -for (i =0 ; i <N_SHM_REGIONS ; ++i) { -if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { - shm_regions[i].in_use = false; -page_set_flags (shmaddr, shmaddr + shm_regions[i].size -1 ,0 ); -break ; + WITH_MMAP_LOCK_GUARD() { +for (int i =0 ; i <N_SHM_REGIONS ; ++i) { +if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { + shm_regions[i].in_use = false; +page_set_flags (shmaddr, shmaddr + shm_regions[i].size -1 ,0 ); +break ; + } } + rv =get_errno (shmdt (g2h_untagged (shmaddr))); } - rv =get_errno (shmdt (g2h_untagged (shmaddr))); - -mmap_unlock (); -return rv; }
PATCH 12/13 linux-user: Fix shmdt
In reply to Richard HendersonIf the shm region is not mapped at shmaddr, EINVAL. Do not unmap the region until the syscall succeeds. Use mmap_reserve_or_unmap to preserve reserved_va semantics.
--- linux-user/mmap.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
linux-user/mmap.c +14 -3
@@ -1102,14 +1102,25 @@ abi_long target_shmdt(abi_ulong shmaddr)/* shmdt pointers are always untagged */ WITH_MMAP_LOCK_GUARD() { -for (int i =0 ; i <N_SHM_REGIONS ; ++i) { +int i; + +for (i =0 ; i <N_SHM_REGIONS ; ++i) {if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { - shm_regions[i].in_use = false; -page_set_flags (shmaddr, shmaddr + shm_regions[i].size -1 ,0 );break ; } } +if (i ==N_SHM_REGIONS ) { +return -TARGET_EINVAL ; + } + rv =get_errno (shmdt (g2h_untagged (shmaddr))); +if (rv ==0 ) { +abi_ulong size = shm_regions[i].size; + + shm_regions[i].in_use = false; +page_set_flags (shmaddr, shmaddr + size -1 ,0 ); +mmap_reserve_or_unmap (shmaddr, size); + } }return rv; }
Signature · 1 line
2.34.1
Re: [PATCH 12/13] linux-user: Fix shmdt
Quoted 8 lines · Richard Henderson
If the shm region is not mapped at shmaddr, EINVAL. Do not unmap the region until the syscall succeeds. Use
mmap_reserve_or_unmapto preservereserved_vasemantics.Signed-off-by Richard Henderson <[email protected]>--- linux-user/mmap.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
PATCH 13/13 linux-user: Track shm regions with an interval tree
In reply to Richard HendersonRemove the fixed size shm_regions[] array. Remove references when other mappings completely remove or replace a region.
--- linux-user/mmap.c | 81 +++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 28 deletions(-)
linux-user/mmap.c +53 -28
@@ -24,18 +24,11 @@#include "user-internals.h" #include "user-mmap.h" #include "target_mman.h" +#include "qemu/interval-tree.h" static pthread_mutex_t mmap_mutex =PTHREAD_MUTEX_INITIALIZER ;static __threadint mmap_lock_count; -#define N_SHM_REGIONS 32 - -static struct shm_region { -abi_ulong start; -abi_ulong size; -bool in_use; -} shm_regions[N_SHM_REGIONS ]; -void mmap_lock (void ) {if (mmap_lock_count++ ==0 ) {
@@ -73,6 +66,44 @@ void mmap_fork_end(int child) } } +/* Protected by mmap_lock. */ +static IntervalTreeRoot shm_regions; + +static void shm_region_add (abi_ptr start,abi_ptr last) +{ +IntervalTreeNode *i =g_new0 (IntervalTreeNode,1 ); + + i->start = start; + i->last = last; +interval_tree_insert (i, &shm_regions); +} + +static abi_ptr shm_region_find (abi_ptr start) +{ +IntervalTreeNode *i; + +for (i =interval_tree_iter_first (&shm_regions, start, start); i; + i =interval_tree_iter_next (i, start, start)) { +if (i->start == start) { +return i->last; + } + } +return 0 ; +} + +static void shm_region_rm_complete (abi_ptr start,abi_ptr last) +{ +IntervalTreeNode *i, *n; + +for (i =interval_tree_iter_first (&shm_regions, start, last); i; i = n) { + n =interval_tree_iter_next (i, start, last); +if (i->start >= start && i->last <= last) { +interval_tree_remove (i, &shm_regions); +g_free (i); + } + } +} +/* * Validate target prot bitmask. * Return the prot bitmask for the host in *HOST_PROT.
@@ -729,6 +760,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot,page_set_flags (passthrough_last +1 , last, page_flags); } } +shm_region_rm_complete (start, last); the_end:trace_target_mmap_complete (start);if (qemu_loglevel_mask (CPU_LOG_PAGE )) {
@@ -826,6 +858,7 @@ int target_munmap(abi_ulong start, abi_ulong len)mmap_lock ();mmap_reserve_or_unmap (start, len);page_set_flags (start, start + len -1 ,0 ); +shm_region_rm_complete (start, start + len -1 );mmap_unlock ();return 0 ;
@@ -915,8 +948,10 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, new_addr =h2g (host_addr); prot =page_get_flags (old_addr);page_set_flags (old_addr, old_addr + old_size -1 ,0 ); +shm_region_rm_complete (old_addr, old_addr + old_size -1 );page_set_flags (new_addr, new_addr + new_size -1 , prot |PAGE_VALID |PAGE_RESET ); +shm_region_rm_complete (new_addr, new_addr + new_size -1 ); }mmap_unlock ();return new_addr;
@@ -1045,6 +1080,7 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid, WITH_MMAP_LOCK_GUARD() {void *host_raddr; +abi_ulong last;if (shmaddr) { host_raddr =shmat (shmid, (void *)g2h_untagged (shmaddr), shmflg);
@@ -1066,19 +1102,14 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid,return get_errno (-1 ); } raddr =h2g (host_raddr); + last = raddr + shm_info.shm_segsz -1 ; -page_set_flags (raddr, raddr + shm_info.shm_segsz -1 , +page_set_flags (raddr, last,PAGE_VALID |PAGE_RESET |PAGE_READ | (shmflg &SHM_RDONLY ?0 :PAGE_WRITE )); -for (int i =0 ; i <N_SHM_REGIONS ; i++) { -if (!shm_regions[i].in_use) { - shm_regions[i].in_use = true; - shm_regions[i].start = raddr; - shm_regions[i].size = shm_info.shm_segsz; -break ; - } - } +shm_region_rm_complete (raddr, last); +shm_region_add (raddr, last); }/*
@@ -1102,23 +1133,17 @@ abi_long target_shmdt(abi_ulong shmaddr)/* shmdt pointers are always untagged */ WITH_MMAP_LOCK_GUARD() { -int i; - -for (i =0 ; i <N_SHM_REGIONS ; ++i) { -if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { -break ; - } - } -if (i ==N_SHM_REGIONS ) { +abi_ulong last =shm_region_find (shmaddr); +if (last ==0 ) {return -TARGET_EINVAL ; } rv =get_errno (shmdt (g2h_untagged (shmaddr)));if (rv ==0 ) { -abi_ulong size = shm_regions[i].size; +abi_ulong size = last - shmaddr +1 ; - shm_regions[i].in_use = false; -page_set_flags (shmaddr, shmaddr + size -1 ,0 ); +page_set_flags (shmaddr, last,0 ); +shm_region_rm_complete (shmaddr, last);mmap_reserve_or_unmap (shmaddr, size); } }
Signature · 1 line
2.34.1
Re: [PATCH 13/13] linux-user: Track shm regions with an interval tree
Quoted 5 lines · Richard Henderson
Remove the fixed size shm_regions[] array. Remove references when other mappings completely remove or replace a region.
Signed-off-by Richard Henderson <[email protected]>
Ping.
Quoted 93 lines · Richard Henderson
Combine a bunch of smaller linux-user patches:
Supercedes: [email protected]
("[PATCH v2 0/3] linux-user:/proc/cpuinfofix and content emulation for arm")
Supercedes: [email protected]
("[PATCH v2] linux-user: Emulate the Anonymous: keyword in/proc/self/smaps")
Supercedes: [email protected] ("[PATCH 0/6] linux-user: Rewriteopen_self_maps")
Supercedes: [email protected] ("[PATCH 0/4] linux-user: shmat/shmdt improvements")with some additions. Patches needing review:
01-linux-user-Split-out-cpu-target_proc.h.patch 11-linux-user-Use-WITH_MMAP_LOCK_GUARD-in-target_-shmat.patch 12-linux-user-Fix-shmdt.patch 13-linux-user-Track-shm-regions-with-an-interval-tree.patch
r~
Helge Deller (2):
linux-user: Emulate/proc/cpuinfoon aarch64 and arm
linux-user: Emulate/proc/cpuinfofor AlphaIlya Leoshkevich (1):
linux-user: Emulate the Anonymous: keyword in/proc/self/smapsRichard Henderson (10):
linux-user: Split outcpu/target_proc.hutil/selfmap: Usedev_tandino_tin MapInfo
linux-user: Usewalk_memory_regionsforopen_self_maps
linux-user: Adjust brk forload_bias
linux-user: Show heap address in/proc/pid/maps
linux-user: RemoveELF_START_MMAPand image_info.start_mmap
linux-user: Move shmat and shmdt implementations tommap.c
linux-user: UseWITH_MMAP_LOCK_GUARDin target_{shmat,shmdt}
linux-user: Fix shmdt
linux-user: Track shm regions with an interval treeinclude/qemu/selfmap.h | 4 +- linux-user/aarch64/target_proc.h | 1 + linux-user/alpha/target_proc.h | 67 ++++ linux-user/arm/target_proc.h | 101 ++++++ linux-user/cris/target_proc.h | 1 + linux-user/hexagon/target_proc.h | 1 + linux-user/hppa/target_proc.h | 26 ++ linux-user/i386/target_proc.h | 1 + linux-user/loader.h | 6 +- linux-user/loongarch64/target_proc.h | 1 + linux-user/m68k/target_proc.h | 16 + linux-user/microblaze/target_proc.h | 1 + linux-user/mips/target_proc.h | 1 + linux-user/mips64/target_proc.h | 1 + linux-user/nios2/target_proc.h | 1 + linux-user/openrisc/target_proc.h | 1 + linux-user/ppc/target_proc.h | 1 + linux-user/qemu.h | 1 - linux-user/riscv/target_proc.h | 37 ++ linux-user/s390x/target_proc.h | 109 ++++++ linux-user/sh4/target_proc.h | 1 + linux-user/sparc/target_proc.h | 16 + linux-user/user-mmap.h | 4 + linux-user/x86_64/target_proc.h | 1 + linux-user/xtensa/target_proc.h | 1 + linux-user/elfload.c | 170 ++++++--- linux-user/mmap.c | 168 +++++++++ linux-user/syscall.c | 514 +++++++-------------------- util/selfmap.c | 12 +- 29 files changed, 828 insertions(+), 437 deletions(-)create mode 100644
linux-user/aarch64/target_proc.hcreate mode 100644linux-user/alpha/target_proc.hcreate mode 100644linux-user/arm/target_proc.hcreate mode 100644linux-user/cris/target_proc.hcreate mode 100644linux-user/hexagon/target_proc.hcreate mode 100644linux-user/hppa/target_proc.hcreate mode 100644linux-user/i386/target_proc.hcreate mode 100644linux-user/loongarch64/target_proc.hcreate mode 100644linux-user/m68k/target_proc.hcreate mode 100644linux-user/microblaze/target_proc.hcreate mode 100644linux-user/mips/target_proc.hcreate mode 100644linux-user/mips64/target_proc.hcreate mode 100644linux-user/nios2/target_proc.hcreate mode 100644linux-user/openrisc/target_proc.hcreate mode 100644linux-user/ppc/target_proc.hcreate mode 100644linux-user/riscv/target_proc.hcreate mode 100644linux-user/s390x/target_proc.hcreate mode 100644linux-user/sh4/target_proc.hcreate mode 100644linux-user/sparc/target_proc.hcreate mode 100644linux-user/x86_64/target_proc.hcreate mode 100644linux-user/xtensa/target_proc.h
Helge Deller
Tested-byQuoted 1 line · Richard Henderson
Ping.
Basic testing with my chroots seems to give no
problems, so for the series:
Helge
Quoted 97 lines · Richard Henderson
Quoted 93 lines
Combine a bunch of smaller linux-user patches:
Supercedes: [email protected]
("[PATCH v2 0/3] linux-user:/proc/cpuinfofix and content emulation for arm")
Supercedes: [email protected]
("[PATCH v2] linux-user: Emulate the Anonymous: keyword in/proc/self/smaps")
Supercedes: [email protected] ("[PATCH 0/6] linux-user: Rewriteopen_self_maps")
Supercedes: [email protected] ("[PATCH 0/4] linux-user: shmat/shmdt improvements")with some additions. Patches needing review:
01-linux-user-Split-out-cpu-target_proc.h.patch 11-linux-user-Use-WITH_MMAP_LOCK_GUARD-in-target_-shmat.patch 12-linux-user-Fix-shmdt.patch 13-linux-user-Track-shm-regions-with-an-interval-tree.patch
r~
Helge Deller (2):
linux-user: Emulate/proc/cpuinfoon aarch64 and arm
linux-user: Emulate/proc/cpuinfofor AlphaIlya Leoshkevich (1):
linux-user: Emulate the Anonymous: keyword in/proc/self/smapsRichard Henderson (10):
linux-user: Split outcpu/target_proc.hutil/selfmap: Usedev_tandino_tin MapInfo
linux-user: Usewalk_memory_regionsforopen_self_maps
linux-user: Adjust brk forload_bias
linux-user: Show heap address in/proc/pid/maps
linux-user: RemoveELF_START_MMAPand image_info.start_mmap
linux-user: Move shmat and shmdt implementations tommap.c
linux-user: UseWITH_MMAP_LOCK_GUARDin target_{shmat,shmdt}
linux-user: Fix shmdt
linux-user: Track shm regions with an interval treeinclude/qemu/selfmap.h | 4 +- linux-user/aarch64/target_proc.h | 1 + linux-user/alpha/target_proc.h | 67 ++++ linux-user/arm/target_proc.h | 101 ++++++ linux-user/cris/target_proc.h | 1 + linux-user/hexagon/target_proc.h | 1 + linux-user/hppa/target_proc.h | 26 ++ linux-user/i386/target_proc.h | 1 + linux-user/loader.h | 6 +-
linux-user/loongarch64/target_proc.h| 1 + linux-user/m68k/target_proc.h | 16 + linux-user/microblaze/target_proc.h | 1 + linux-user/mips/target_proc.h | 1 + linux-user/mips64/target_proc.h | 1 + linux-user/nios2/target_proc.h | 1 + linux-user/openrisc/target_proc.h | 1 + linux-user/ppc/target_proc.h | 1 + linux-user/qemu.h | 1 - linux-user/riscv/target_proc.h | 37 ++ linux-user/s390x/target_proc.h | 109 ++++++ linux-user/sh4/target_proc.h | 1 + linux-user/sparc/target_proc.h | 16 + linux-user/user-mmap.h | 4 + linux-user/x86_64/target_proc.h | 1 + linux-user/xtensa/target_proc.h | 1 + linux-user/elfload.c | 170 ++++++--- linux-user/mmap.c | 168 +++++++++ linux-user/syscall.c | 514 +++++++-------------------- util/selfmap.c | 12 +-29 files changed, 828 insertions(+), 437 deletions(-)create mode 100644
linux-user/aarch64/target_proc.hcreate mode 100644linux-user/alpha/target_proc.hcreate mode 100644linux-user/arm/target_proc.hcreate mode 100644linux-user/cris/target_proc.hcreate mode 100644linux-user/hexagon/target_proc.hcreate mode 100644linux-user/hppa/target_proc.hcreate mode 100644linux-user/i386/target_proc.hcreate mode 100644linux-user/loongarch64/target_proc.hcreate mode 100644linux-user/m68k/target_proc.hcreate mode 100644linux-user/microblaze/target_proc.hcreate mode 100644linux-user/mips/target_proc.hcreate mode 100644linux-user/mips64/target_proc.hcreate mode 100644linux-user/nios2/target_proc.hcreate mode 100644linux-user/openrisc/target_proc.hcreate mode 100644linux-user/ppc/target_proc.hcreate mode 100644linux-user/riscv/target_proc.hcreate mode 100644linux-user/s390x/target_proc.hcreate mode 100644linux-user/sh4/target_proc.hcreate mode 100644linux-user/sparc/target_proc.hcreate mode 100644linux-user/x86_64/target_proc.hcreate mode 100644linux-user/xtensa/target_proc.h