Skip to content

Commit

Permalink
Merge tag 'pull-lu-20230901' of https://gitlab.com/rth7680/qemu into …
Browse files Browse the repository at this point in the history
…staging

linux-user: Rewrite and improve /proc/pid/maps
linux-user: Fix shmdt and improve shm region tracking
linux-user: Remove ELF_START_MMAP and image_info.start_mmap

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmTyTEcdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV8aZAf/UVKDv0FwEzxn3wzx
# pT+NbP4adHCew5ovDq94In9OpwG4+PtZj3x+EdPCFxAvVb9KdOs001a9zSRYSwWi
# 0p9ZkOgtq58/Wr34dl6C8oPZP8bnw7hfVcXWYwdsBq9K+dmW9Tu4LgZSc92NWYiE
# SGBATB/cF4keLlDJrm1YBfb6cVKmYHdgQzMHr4g4TitBOO3lic8HQglXN8eKvQyd
# ZKuMxFwfSGjaNXsoBLmzPBEqJCLzj5JNtOb8maIN9oPTkkC66XvkBmD/4UrQ7K3x
# aX2QgZpxZYZsyKfWJd4EkrJl+0JZYvGW4vBX1c+vBdIYQZoBHlWwZQBqsi+AMA6J
# ASc3hQ==
# =QWfr
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 01 Sep 2023 16:40:39 EDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* tag 'pull-lu-20230901' of https://gitlab.com/rth7680/qemu:
  linux-user: Track shm regions with an interval tree
  linux-user: Fix shmdt
  linux-user: Use WITH_MMAP_LOCK_GUARD in target_{shmat,shmdt}
  linux-user: Move shmat and shmdt implementations to mmap.c
  linux-user: Remove ELF_START_MMAP and image_info.start_mmap
  linux-user: Emulate the Anonymous: keyword in /proc/self/smaps
  linux-user: Show heap address in /proc/pid/maps
  linux-user: Adjust brk for load_bias
  linux-user: Use walk_memory_regions for open_self_maps
  util/selfmap: Use dev_t and ino_t in MapInfo
  linux-user: Emulate /proc/cpuinfo for Alpha
  linux-user: Emulate /proc/cpuinfo on aarch64 and arm
  linux-user: Split out cpu/target_proc.h

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Sep 6, 2023
2 parents e00ad52 + 044e95c commit f3e3151
Show file tree
Hide file tree
Showing 29 changed files with 827 additions and 436 deletions.
4 changes: 2 additions & 2 deletions include/qemu/selfmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
1 change: 1 addition & 0 deletions linux-user/aarch64/target_proc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../arm/target_proc.h"
67 changes: 67 additions & 0 deletions linux-user/alpha/target_proc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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 */
101 changes: 101 additions & 0 deletions linux-user/arm/target_proc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Arm specific proc functions for linux-user
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef ARM_TARGET_PROC_H
#define ARM_TARGET_PROC_H

static int open_cpuinfo(CPUArchState *cpu_env, int fd)
{
ARMCPU *cpu = env_archcpu(cpu_env);
int arch, midr_rev, midr_part, midr_var, midr_impl;
target_ulong elf_hwcap = get_elf_hwcap();
target_ulong elf_hwcap2 = get_elf_hwcap2();
const char *elf_name;
int num_cpus, len_part, len_var;

#if TARGET_BIG_ENDIAN
# define END_SUFFIX "b"
#else
# define END_SUFFIX "l"
#endif

arch = 8;
elf_name = "v8" END_SUFFIX;
midr_rev = FIELD_EX32(cpu->midr, MIDR_EL1, REVISION);
midr_part = FIELD_EX32(cpu->midr, MIDR_EL1, PARTNUM);
midr_var = FIELD_EX32(cpu->midr, MIDR_EL1, VARIANT);
midr_impl = FIELD_EX32(cpu->midr, MIDR_EL1, IMPLEMENTER);
len_part = 3;
len_var = 1;

#ifndef TARGET_AARCH64
/* For simplicity, treat ARMv8 as an arm64 kernel with CONFIG_COMPAT. */
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
if (arm_feature(&cpu->env, ARM_FEATURE_V7)) {
arch = 7;
midr_var = (cpu->midr >> 16) & 0x7f;
len_var = 2;
if (arm_feature(&cpu->env, ARM_FEATURE_M)) {
elf_name = "armv7m" END_SUFFIX;
} else {
elf_name = "armv7" END_SUFFIX;
}
} else {
midr_part = cpu->midr >> 4;
len_part = 7;
if (arm_feature(&cpu->env, ARM_FEATURE_V6)) {
arch = 6;
elf_name = "armv6" END_SUFFIX;
} else if (arm_feature(&cpu->env, ARM_FEATURE_V5)) {
arch = 5;
elf_name = "armv5t" END_SUFFIX;
} else {
arch = 4;
elf_name = "armv4" END_SUFFIX;
}
}
}
#endif

#undef END_SUFFIX

num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
for (int i = 0; i < num_cpus; i++) {
dprintf(fd,
"processor\t: %d\n"
"model name\t: ARMv%d Processor rev %d (%s)\n"
"BogoMIPS\t: 100.00\n"
"Features\t:",
i, arch, midr_rev, elf_name);

for (target_ulong j = elf_hwcap; j ; j &= j - 1) {
dprintf(fd, " %s", elf_hwcap_str(ctz64(j)));
}
for (target_ulong j = elf_hwcap2; j ; j &= j - 1) {
dprintf(fd, " %s", elf_hwcap2_str(ctz64(j)));
}

dprintf(fd, "\n"
"CPU implementer\t: 0x%02x\n"
"CPU architecture: %d\n"
"CPU variant\t: 0x%0*x\n",
midr_impl, arch, len_var, midr_var);
if (arch >= 7) {
dprintf(fd, "CPU part\t: 0x%0*x\n", len_part, midr_part);
}
dprintf(fd, "CPU revision\t: %d\n\n", midr_rev);
}

if (arch < 8) {
dprintf(fd, "Hardware\t: QEMU v%s %s\n", QEMU_VERSION,
cpu->dtb_compatible ? : "");
dprintf(fd, "Revision\t: 0000\n");
dprintf(fd, "Serial\t\t: 0000000000000000\n");
}
return 0;
}
#define HAVE_ARCH_PROC_CPUINFO

#endif /* ARM_TARGET_PROC_H */
1 change: 1 addition & 0 deletions linux-user/cris/target_proc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* No target-specific /proc support */

0 comments on commit f3e3151

Please sign in to comment.