mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:56:38 +00:00
Merge tag 'linux-user-pull-request' of https://github.com/hdeller/qemu-hppa into staging
linux-user patches One frame pointer memory locking fix for the xtensa architecture, a generic loader fix for programs with modified headers, and two patches to emulate /proc/cpuinfo for loogarch and m68k CPUs. # -----BEGIN PGP SIGNATURE----- # # iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCajRo/gAKCRD3ErUQojoP # X+3IAQCPg/Z8KRa43miOMpOJVRxel3eg5h9+A/Sh4SwPp9Sk2gD/U6gh4l64Bl2O # CT30o35Afd7rl1G1dD9rsB/H9tU/gwM= # =mTKh # -----END PGP SIGNATURE----- # gpg: Signature made Thu 18 Jun 2026 17:54:06 EDT # gpg: using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F # gpg: Good signature from "Helge Deller <deller@gmx.de>" [unknown] # gpg: aka "Helge Deller <deller@kernel.org>" [unknown] # gpg: aka "Helge Deller <deller@debian.org>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 4544 8228 2CD9 10DB EF3D 25F8 3E5F 3D04 A7A2 4603 # Subkey fingerprint: BCE9 123E 1AD2 9F07 C049 BBDE F712 B510 A23A 0F5F * tag 'linux-user-pull-request' of https://github.com/hdeller/qemu-hppa: linux-user/xtensa: fix unlock of uninitialized frame pointer on sigreturn linux-user: Implement /proc/cpuinfo for m68k CPU linux-user: Implement /proc/cpuinfo for loongarch cpus linux-user: Fix AT_PHDR when program headers are relocated into their own segment Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
@@ -699,7 +699,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
|
||||
/* There must be exactly DLINFO_ITEMS entries here, or the assert
|
||||
* on info->auxv_len will trigger.
|
||||
*/
|
||||
NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff));
|
||||
NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->phdr_addr));
|
||||
NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr)));
|
||||
NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum));
|
||||
NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE));
|
||||
@@ -1469,6 +1469,12 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
|
||||
info->data_offset = load_bias;
|
||||
info->load_addr = load_addr;
|
||||
info->entry = ehdr->e_entry + load_bias;
|
||||
/*
|
||||
* Fallback for AT_PHDR if the program headers do not fall within
|
||||
* any PT_LOAD segment (see the loop below, which overrides this with
|
||||
* the correct in-memory address when a containing segment is found).
|
||||
*/
|
||||
info->phdr_addr = load_addr + ehdr->e_phoff;
|
||||
info->start_code = -1;
|
||||
info->end_code = 0;
|
||||
info->start_data = -1;
|
||||
@@ -1523,6 +1529,19 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
|
||||
vaddr_ef = vaddr + eppnt->p_filesz;
|
||||
vaddr_em = vaddr + eppnt->p_memsz;
|
||||
|
||||
/*
|
||||
* If this segment contains the program headers, record their
|
||||
* in-memory address for AT_PHDR. This matches the kernel, which
|
||||
* locates the headers via the containing PT_LOAD rather than
|
||||
* assuming load_addr + e_phoff (false when the phdrs are not
|
||||
* mapped 1:1 from file offset 0, e.g. relocated into their own
|
||||
* segment by a binary patcher).
|
||||
*/
|
||||
if (eppnt->p_offset <= ehdr->e_phoff &&
|
||||
ehdr->e_phoff < eppnt->p_offset + eppnt->p_filesz) {
|
||||
info->phdr_addr = vaddr + (ehdr->e_phoff - eppnt->p_offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Some segments may be completely empty, with a non-zero p_memsz
|
||||
* but no backing file segment.
|
||||
|
||||
@@ -28,6 +28,26 @@ enum {
|
||||
HWCAP_LOONGARCH_LBT_MIPS = (1 << 12),
|
||||
};
|
||||
|
||||
const char *elf_hwcap_str(uint32_t bit)
|
||||
{
|
||||
static const char *hwcap_str[] = {
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_CPUCFG )] = "cpucfg",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_LAM )] = "lam",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_UAL )] = "lam_bh",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_FPU )] = "fpu",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_LSX )] = "lsx",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_LASX )] = "lasx",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_CRC32 )] = "crc32",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_COMPLEX )] = "complex",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_CRYPTO )] = "crypto",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_LVZ )] = "lvz",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_LBT_X86 )] = "lbt_x86",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_LBT_ARM )] = "lbt_arm",
|
||||
[__builtin_ctz(HWCAP_LOONGARCH_LBT_MIPS)] = "lbt_mips",
|
||||
};
|
||||
|
||||
return bit < ARRAY_SIZE(hwcap_str) ? hwcap_str[bit] : NULL;
|
||||
}
|
||||
abi_ulong get_elf_hwcap(CPUState *cs)
|
||||
{
|
||||
LoongArchCPU *cpu = LOONGARCH_CPU(cs);
|
||||
|
||||
@@ -1 +1,78 @@
|
||||
/* No target-specific /proc support */
|
||||
/*
|
||||
* Loongson specific proc functions for linux-user
|
||||
*
|
||||
* Copyright (c) 2026 Helge Deller
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#ifndef LOONGARCH_TARGET_PROC_H
|
||||
#define LOONGARCH_TARGET_PROC_H
|
||||
|
||||
static int open_cpuinfo(CPUArchState *cpu_env, int fd)
|
||||
{
|
||||
uint32_t elf_hwcap = get_elf_hwcap(env_cpu(cpu_env));
|
||||
uint32_t prid, ser_id, pabits, vabits, i, n, num_cpus;
|
||||
bool is_64bit = is_la64(cpu_env);
|
||||
const char *hwcap_str;
|
||||
struct timespec res;
|
||||
double freq_mhz;
|
||||
|
||||
#if TARGET_LONG_BITS == 32
|
||||
pabits = 31;
|
||||
vabits = 31;
|
||||
#else
|
||||
pabits = FIELD_EX32(cpu_env->cpucfg[1], CPUCFG1, PALEN);
|
||||
vabits = FIELD_EX32(cpu_env->cpucfg[1], CPUCFG1, VALEN);
|
||||
#endif
|
||||
|
||||
if (clock_getres(CLOCK_REALTIME, &res) == -1) {
|
||||
res.tv_nsec = 1;
|
||||
}
|
||||
freq_mhz = 1000.0 / res.tv_nsec;
|
||||
|
||||
ser_id = FIELD_EX32(cpu_env->cpucfg[0], CPUCFG0, SERID);
|
||||
prid = FIELD_EX32(cpu_env->cpucfg[0], CPUCFG0, PRID);
|
||||
|
||||
dprintf(fd, "system type\t\t: generic-loongson-machine\n");
|
||||
|
||||
num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
for (n = 0; n < num_cpus; n++) {
|
||||
dprintf(fd, "\nprocessor\t\t: %d\n", n);
|
||||
dprintf(fd, "package\t\t\t: 0\n");
|
||||
dprintf(fd, "core\t\t\t: %d\n", n);
|
||||
dprintf(fd, "global_id\t\t: %d\n", n);
|
||||
dprintf(fd, "CPU Family\t\t: Loongson-%dbit\n", is_64bit ? 64 : 32);
|
||||
dprintf(fd, "Model Name\t\t: QEMU_user-v" QEMU_VERSION "\n");
|
||||
dprintf(fd, "PRID\t\t\t: %s (%08x)\n",
|
||||
ser_id == PRID_SERIES_LA464 ? "LA464" :
|
||||
ser_id == PRID_SERIES_LA132 ? "LA132" : "Unknown",
|
||||
cpu_env->cpucfg[0]);
|
||||
dprintf(fd, "CPU Revision\t\t: 0x%02x\n", prid);
|
||||
dprintf(fd, "FPU Revision\t\t: 0x%02x\n",
|
||||
FIELD_EX32(cpu_env->cpucfg[2], CPUCFG2, FP_VER));
|
||||
dprintf(fd, "CPU MHz\t\t\t: %.2f\n", freq_mhz);
|
||||
dprintf(fd, "Address Sizes\t\t: %d bits physical, %d bits virtual\n",
|
||||
pabits + 1, vabits + 1);
|
||||
|
||||
dprintf(fd, "ISA\t\t\t:%s", " loongarch32r loongarch32s");
|
||||
if (is_64bit) {
|
||||
dprintf(fd, " loongarch64");
|
||||
}
|
||||
|
||||
dprintf(fd, "\nFeatures\t\t:");
|
||||
for (i = 0; i < sizeof(elf_hwcap) * 8; i++) {
|
||||
if (!(elf_hwcap & (1 << i))) {
|
||||
continue;
|
||||
}
|
||||
hwcap_str = elf_hwcap_str(i);
|
||||
if (hwcap_str) {
|
||||
dprintf(fd, " %s", hwcap_str);
|
||||
}
|
||||
}
|
||||
dprintf(fd, "\nHardware Watchpoint\t: no\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#define HAVE_ARCH_PROC_CPUINFO
|
||||
|
||||
#endif /* LOONGARCH_TARGET_PROC_H */
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* M68K specific proc functions for linux-user
|
||||
*
|
||||
* Copyright (c) 2026 Helge Deller
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#ifndef M68K_TARGET_PROC_H
|
||||
@@ -13,4 +15,48 @@ static int open_hardware(CPUArchState *cpu_env, int fd)
|
||||
}
|
||||
#define HAVE_ARCH_PROC_HARDWARE
|
||||
|
||||
|
||||
static int open_cpuinfo(CPUArchState *cpu_env, int fd)
|
||||
{
|
||||
const char *cpu, *fpu;
|
||||
struct timespec res;
|
||||
double freq_mhz;
|
||||
|
||||
if (clock_getres(CLOCK_REALTIME, &res) == -1) {
|
||||
res.tv_nsec = 1;
|
||||
}
|
||||
freq_mhz = 1000.0 / res.tv_nsec;
|
||||
|
||||
if (m68k_feature(cpu_env, M68K_FEATURE_M68010)) {
|
||||
cpu = "68010";
|
||||
} else if (m68k_feature(cpu_env, M68K_FEATURE_M68020)) {
|
||||
cpu = "68020";
|
||||
} else if (m68k_feature(cpu_env, M68K_FEATURE_M68030)) {
|
||||
cpu = "68030";
|
||||
} else if (m68k_feature(cpu_env, M68K_FEATURE_M68040)) {
|
||||
cpu = "68040";
|
||||
} else if (m68k_feature(cpu_env, M68K_FEATURE_M68060)) {
|
||||
cpu = "68060";
|
||||
} else {
|
||||
cpu = "680x0";
|
||||
}
|
||||
|
||||
if (m68k_feature(cpu_env, M68K_FEATURE_FPU)) {
|
||||
fpu = cpu;
|
||||
} else {
|
||||
fpu = "none(soft float)";
|
||||
}
|
||||
|
||||
dprintf(fd, "CPU:\t\t%s\n"
|
||||
"MMU:\t\t%s\n"
|
||||
"FPU:\t\t%s\n"
|
||||
"Clocking:\t%.1fMHz\n"
|
||||
"Model:\t\tQEMU user v" QEMU_VERSION "\n",
|
||||
cpu, cpu, fpu, freq_mhz);
|
||||
/* dropped BogoMips and Calibration for now */
|
||||
|
||||
return 0;
|
||||
}
|
||||
#define HAVE_ARCH_PROC_CPUINFO
|
||||
|
||||
#endif /* M68K_TARGET_PROC_H */
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
struct image_info {
|
||||
abi_ulong load_bias;
|
||||
abi_ulong load_addr;
|
||||
abi_ulong phdr_addr;
|
||||
abi_ulong start_code;
|
||||
abi_ulong end_code;
|
||||
abi_ulong start_data;
|
||||
|
||||
@@ -355,7 +355,8 @@ long do_rt_sigreturn(CPUXtensaState *env)
|
||||
|
||||
trace_user_do_rt_sigreturn(env, frame_addr);
|
||||
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
|
||||
goto badframe;
|
||||
force_sig(TARGET_SIGSEGV);
|
||||
return -QEMU_ESIGRETURN;
|
||||
}
|
||||
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
|
||||
set_sigmask(&set);
|
||||
|
||||
Reference in New Issue
Block a user