mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge tag 'pull-lu-20250830' of https://gitlab.com/rth7680/qemu into staging
linux-user: Finish elfload.c split linux-user: Drop deprecated -p option linux-user: Tidy print_socket_protocol hw/core: Dump cpu_reset in the reset.exit phase hw/core: Use qemu_log_trylock/unlock in cpu_common_reset_exit # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmiyKFIdHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV/LBggAgMBSVMz1BwkPvckY # paakdAwuOqRE5yF2YxQAHALJa3aH18Vqk06ENqM9R5iyqvHBGnvrw8fshIBVZnDP # eQDjNFwnCtSrXuSMdfr0r8jZc+y9R8foQKs9j+KL0ESOi+4VNhORfzFe/yrIEu0y # XM5XhBjBH0kK9+S20uy5x3WXhRkfqq2CZiUt1izqTOwtbdzYENxdvDj8iDk48FwL # fkrXUSnlBBsdsltQCsjbrUbWi1Wqj7skswRIzI8KXsj+psy0JJL2kHthaWzm8tTS # KIXVaOtxtU7LQWhTaknmpcNIkHpnjmEw2ZijxYT29V8WnZtstihVoqqCLbCv6u+7 # JwwQhQ== # =kHx+ # -----END PGP SIGNATURE----- # gpg: Signature made Sat 30 Aug 2025 08:23:14 AM AEST # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate] * tag 'pull-lu-20250830' of https://gitlab.com/rth7680/qemu: (91 commits) linux-user: Remove target_pt_regs from target_syscall.h linux-user/sparc: Create target_ptrace.h linux-user: Remove a.out declarations from elfload.c linux-user: Move arch_parse_elf_property to aarch64/elfload.c linux-user: Remove MAP_DENYWRITE from elfload.c linux-user: Remove ELIBBAD from elfload.c linux-user: Rename elf_check_arch linux-user: Standardize on ELF_MACHINE not ELF_ARCH linux-user: Move elf parameters to hexagon/target_elf.h linux-user: Move elf parameters to xtensa/target_elf.h linux-user: Move elf parameters to hppa/target_elf.h linux-user: Move elf parameters to riscv/target_elf.h linux-user: Move elf parameters to s390x/target_elf.h linux-user: Move elf parameters to alpha/target_elf.h linux-user: Move elf parameters to m68k/target_elf.h linux-user: Move elf parameters to sh4/target_elf.h linux-user: Move elf parameters to openrisc/target_elf.h linux-user: Move elf parameters to microblaze/target_elf.h linux-user: Move elf parameters to {mips,mips64}/target_elf.h linux-user: Move elf parameters to loongarch64/target_elf.h ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
@@ -367,14 +367,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
} else if (!strcmp(r, "L")) {
|
||||
interp_prefix = argv[optind++];
|
||||
} else if (!strcmp(r, "p")) {
|
||||
unsigned size, want = qemu_real_host_page_size();
|
||||
|
||||
r = argv[optind++];
|
||||
if (qemu_strtoui(r, NULL, 10, &size) || size != want) {
|
||||
warn_report("Deprecated page size option cannot "
|
||||
"change host page size (%u)", want);
|
||||
}
|
||||
} else if (!strcmp(r, "g")) {
|
||||
gdbstub = g_strdup(argv[optind++]);
|
||||
} else if (!strcmp(r, "r")) {
|
||||
|
||||
@@ -81,16 +81,6 @@ kernel since 2001. None of the board types QEMU supports need
|
||||
``param_struct`` support, so this option has been deprecated and will
|
||||
be removed in a future QEMU version.
|
||||
|
||||
User-mode emulator command line arguments
|
||||
-----------------------------------------
|
||||
|
||||
``-p`` (since 9.0)
|
||||
''''''''''''''''''
|
||||
|
||||
The ``-p`` option pretends to control the host page size. However,
|
||||
it is not possible to change the host page size, and using the
|
||||
option only causes failures.
|
||||
|
||||
QEMU Machine Protocol (QMP) commands
|
||||
------------------------------------
|
||||
|
||||
|
||||
@@ -571,6 +571,14 @@ The ``-singlestep`` option has been given a name that better reflects
|
||||
what it actually does. For both linux-user and bsd-user, use the
|
||||
``-one-insn-per-tb`` option instead.
|
||||
|
||||
``-p`` (removed in 10.2)
|
||||
''''''''''''''''''''''''
|
||||
|
||||
The ``-p`` option pretends to control the host page size. However,
|
||||
it is not possible to change the host page size; we stopped trying
|
||||
to do anything with the option except print a warning from 9.0,
|
||||
and now the option is removed entirely.
|
||||
|
||||
|
||||
QEMU Machine Protocol (QMP) commands
|
||||
------------------------------------
|
||||
|
||||
@@ -262,9 +262,6 @@ Debug options:
|
||||
Activate logging of the specified items (use '-d help' for a list of
|
||||
log items)
|
||||
|
||||
``-p pagesize``
|
||||
Act as if the host page size was 'pagesize' bytes
|
||||
|
||||
``-one-insn-per-tb``
|
||||
Run the emulation with one guest instruction per translation block.
|
||||
This slows down emulation a lot, but can be useful in some situations,
|
||||
|
||||
+16
-5
@@ -119,11 +119,6 @@ static void cpu_common_reset_hold(Object *obj, ResetType type)
|
||||
{
|
||||
CPUState *cpu = CPU(obj);
|
||||
|
||||
if (qemu_loglevel_mask(CPU_LOG_RESET)) {
|
||||
qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index);
|
||||
log_cpu_state(cpu, cpu->cc->reset_dump_flags);
|
||||
}
|
||||
|
||||
cpu->interrupt_request = 0;
|
||||
cpu->halted = cpu->start_powered_off;
|
||||
cpu->mem_io_pc = 0;
|
||||
@@ -137,6 +132,21 @@ static void cpu_common_reset_hold(Object *obj, ResetType type)
|
||||
cpu_exec_reset_hold(cpu);
|
||||
}
|
||||
|
||||
static void cpu_common_reset_exit(Object *obj, ResetType type)
|
||||
{
|
||||
if (qemu_loglevel_mask(CPU_LOG_RESET)) {
|
||||
FILE *f = qemu_log_trylock();
|
||||
|
||||
if (f) {
|
||||
CPUState *cpu = CPU(obj);
|
||||
|
||||
fprintf(f, "CPU Reset (CPU %d)\n", cpu->cpu_index);
|
||||
cpu_dump_state(cpu, f, cpu->cc->reset_dump_flags);
|
||||
qemu_log_unlock(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
|
||||
{
|
||||
ObjectClass *oc;
|
||||
@@ -380,6 +390,7 @@ static void cpu_common_class_init(ObjectClass *klass, const void *data)
|
||||
dc->realize = cpu_common_realizefn;
|
||||
dc->unrealize = cpu_common_unrealizefn;
|
||||
rc->phases.hold = cpu_common_reset_hold;
|
||||
rc->phases.exit = cpu_common_reset_exit;
|
||||
cpu_class_init_props(dc);
|
||||
/*
|
||||
* Reason: CPUs still need special care by board code: wiring up
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu.h"
|
||||
#include "loader.h"
|
||||
#include "target/arm/cpu-features.h"
|
||||
#include "target_elf.h"
|
||||
#include "elf.h"
|
||||
|
||||
|
||||
const char *get_elf_cpu_model(uint32_t eflags)
|
||||
@@ -347,3 +350,29 @@ const char *get_elf_platform(CPUState *cs)
|
||||
{
|
||||
return TARGET_BIG_ENDIAN ? "aarch64_be" : "aarch64";
|
||||
}
|
||||
|
||||
bool arch_parse_elf_property(uint32_t pr_type, uint32_t pr_datasz,
|
||||
const uint32_t *data,
|
||||
struct image_info *info,
|
||||
Error **errp)
|
||||
{
|
||||
if (pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) {
|
||||
if (pr_datasz != sizeof(uint32_t)) {
|
||||
error_setg(errp, "Ill-formed GNU_PROPERTY_AARCH64_FEATURE_1_AND");
|
||||
return false;
|
||||
}
|
||||
/* We will extract GNU_PROPERTY_AARCH64_FEATURE_1_BTI later. */
|
||||
info->note_flags = *data;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUARMState *env)
|
||||
{
|
||||
for (int i = 0; i < 31; i++) {
|
||||
r->pt.regs[i] = tswap64(env->xregs[i]);
|
||||
}
|
||||
r->pt.sp = tswap64(env->xregs[31]);
|
||||
r->pt.pc = tswap64(env->pc);
|
||||
r->pt.pstate = tswap64(pstate_read((CPUARMState *)env));
|
||||
}
|
||||
|
||||
@@ -8,8 +8,29 @@
|
||||
#ifndef AARCH64_TARGET_ELF_H
|
||||
#define AARCH64_TARGET_ELF_H
|
||||
|
||||
#include "target_ptrace.h"
|
||||
|
||||
#define ELF_MACHINE EM_AARCH64
|
||||
#define ELF_CLASS ELFCLASS64
|
||||
|
||||
#define HAVE_ELF_HWCAP 1
|
||||
#define HAVE_ELF_HWCAP2 1
|
||||
#define HAVE_ELF_PLATFORM 1
|
||||
#define HAVE_ELF_CORE_DUMP 1
|
||||
#define HAVE_ELF_GNU_PROPERTY 1
|
||||
|
||||
/*
|
||||
* See linux kernel: arch/arm64/include/asm/elf.h, where
|
||||
* elf_gregset_t is mapped to struct user_pt_regs via sizeof.
|
||||
*/
|
||||
typedef struct target_elf_gregset_t {
|
||||
struct target_user_pt_regs pt;
|
||||
} target_elf_gregset_t;
|
||||
|
||||
#if TARGET_BIG_ENDIAN
|
||||
# define VDSO_HEADER "vdso-be.c.inc"
|
||||
#else
|
||||
# define VDSO_HEADER "vdso-le.c.inc"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#ifndef AARCH64_TARGET_PTRACE_H
|
||||
#define AARCH64_TARGET_PTRACE_H
|
||||
|
||||
/* See arch/arm64/include/uapi/asm/ptrace.h. */
|
||||
struct target_user_pt_regs {
|
||||
uint64_t regs[31];
|
||||
uint64_t sp;
|
||||
uint64_t pc;
|
||||
uint64_t pstate;
|
||||
};
|
||||
|
||||
#endif /* AARCH64_TARGET_PTRACE_H */
|
||||
@@ -1,13 +1,6 @@
|
||||
#ifndef AARCH64_TARGET_SYSCALL_H
|
||||
#define AARCH64_TARGET_SYSCALL_H
|
||||
|
||||
struct target_pt_regs {
|
||||
uint64_t regs[31];
|
||||
uint64_t sp;
|
||||
uint64_t pc;
|
||||
uint64_t pstate;
|
||||
};
|
||||
|
||||
#if TARGET_BIG_ENDIAN
|
||||
#define UNAME_MACHINE "aarch64_be"
|
||||
#else
|
||||
|
||||
@@ -8,4 +8,7 @@
|
||||
#ifndef ALPHA_TARGET_ELF_H
|
||||
#define ALPHA_TARGET_ELF_H
|
||||
|
||||
#define ELF_CLASS ELFCLASS64
|
||||
#define ELF_MACHINE EM_ALPHA
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,46 +1,6 @@
|
||||
#ifndef ALPHA_TARGET_SYSCALL_H
|
||||
#define ALPHA_TARGET_SYSCALL_H
|
||||
|
||||
/* default linux values for the selectors */
|
||||
#define __USER_DS (1)
|
||||
|
||||
struct target_pt_regs {
|
||||
abi_ulong r0;
|
||||
abi_ulong r1;
|
||||
abi_ulong r2;
|
||||
abi_ulong r3;
|
||||
abi_ulong r4;
|
||||
abi_ulong r5;
|
||||
abi_ulong r6;
|
||||
abi_ulong r7;
|
||||
abi_ulong r8;
|
||||
abi_ulong r19;
|
||||
abi_ulong r20;
|
||||
abi_ulong r21;
|
||||
abi_ulong r22;
|
||||
abi_ulong r23;
|
||||
abi_ulong r24;
|
||||
abi_ulong r25;
|
||||
abi_ulong r26;
|
||||
abi_ulong r27;
|
||||
abi_ulong r28;
|
||||
abi_ulong hae;
|
||||
/* JRP - These are the values provided to a0-a2 by PALcode */
|
||||
abi_ulong trap_a0;
|
||||
abi_ulong trap_a1;
|
||||
abi_ulong trap_a2;
|
||||
/* These are saved by PAL-code: */
|
||||
abi_ulong ps;
|
||||
abi_ulong pc;
|
||||
abi_ulong gp;
|
||||
abi_ulong r16;
|
||||
abi_ulong r17;
|
||||
abi_ulong r18;
|
||||
/* Those is needed by qemu to temporary store the user stack pointer */
|
||||
abi_ulong usp;
|
||||
abi_ulong unique;
|
||||
};
|
||||
|
||||
#define UNAME_MACHINE "alpha"
|
||||
#define UNAME_MINIMUM_RELEASE "2.6.32"
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu.h"
|
||||
#include "loader.h"
|
||||
#include "user-internals.h"
|
||||
#include "target_elf.h"
|
||||
#include "target/arm/cpu-features.h"
|
||||
#include "target_elf.h"
|
||||
#include "elf.h"
|
||||
|
||||
|
||||
const char *get_elf_cpu_model(uint32_t eflags)
|
||||
@@ -199,3 +203,75 @@ const char *get_elf_platform(CPUState *cs)
|
||||
|
||||
#undef END
|
||||
}
|
||||
|
||||
bool init_guest_commpage(void)
|
||||
{
|
||||
ARMCPU *cpu = ARM_CPU(thread_cpu);
|
||||
int host_page_size = qemu_real_host_page_size();
|
||||
abi_ptr commpage;
|
||||
void *want;
|
||||
void *addr;
|
||||
|
||||
/*
|
||||
* M-profile allocates maximum of 2GB address space, so can never
|
||||
* allocate the commpage. Skip it.
|
||||
*/
|
||||
if (arm_feature(&cpu->env, ARM_FEATURE_M)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
commpage = HI_COMMPAGE & -host_page_size;
|
||||
want = g2h_untagged(commpage);
|
||||
addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE |
|
||||
(commpage < reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE),
|
||||
-1, 0);
|
||||
|
||||
if (addr == MAP_FAILED) {
|
||||
perror("Allocating guest commpage");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (addr != want) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Set kernel helper versions; rest of page is 0. */
|
||||
__put_user(5, (uint32_t *)g2h_untagged(0xffff0ffcu));
|
||||
|
||||
if (mprotect(addr, host_page_size, PROT_READ)) {
|
||||
perror("Protecting guest commpage");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
page_set_flags(commpage, commpage | (host_page_size - 1),
|
||||
PAGE_READ | PAGE_EXEC | PAGE_VALID);
|
||||
return true;
|
||||
}
|
||||
|
||||
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUARMState *env)
|
||||
{
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
r->pt.regs[i] = tswapal(env->regs[i]);
|
||||
}
|
||||
r->pt.cpsr = tswapal(cpsr_read((CPUARMState *)env));
|
||||
r->pt.orig_r0 = tswapal(env->regs[0]); /* FIXME */
|
||||
}
|
||||
|
||||
#if TARGET_BIG_ENDIAN
|
||||
# include "vdso-be8.c.inc"
|
||||
# include "vdso-be32.c.inc"
|
||||
#else
|
||||
# include "vdso-le.c.inc"
|
||||
#endif
|
||||
|
||||
const VdsoImageInfo *get_vdso_image_info(uint32_t elf_flags)
|
||||
{
|
||||
#if TARGET_BIG_ENDIAN
|
||||
return (EF_ARM_EABI_VERSION(elf_flags) >= EF_ARM_EABI_VER4
|
||||
&& (elf_flags & EF_ARM_BE8)
|
||||
? &vdso_be8_image_info
|
||||
: &vdso_be32_image_info);
|
||||
#else
|
||||
return &vdso_image_info;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -8,8 +8,26 @@
|
||||
#ifndef ARM_TARGET_ELF_H
|
||||
#define ARM_TARGET_ELF_H
|
||||
|
||||
#include "target_ptrace.h"
|
||||
|
||||
#define ELF_MACHINE EM_ARM
|
||||
#define ELF_CLASS ELFCLASS32
|
||||
#define EXSTACK_DEFAULT true
|
||||
|
||||
#define HAVE_ELF_HWCAP 1
|
||||
#define HAVE_ELF_HWCAP2 1
|
||||
#define HAVE_ELF_PLATFORM 1
|
||||
#define HAVE_ELF_CORE_DUMP 1
|
||||
#define HAVE_VDSO_IMAGE_INFO 1
|
||||
|
||||
#define HI_COMMPAGE ((intptr_t)0xffff0f00u)
|
||||
|
||||
/*
|
||||
* See linux kernel: arch/arm/include/asm/elf.h, where
|
||||
* elf_gregset_t is mapped to struct pt_regs via sizeof.
|
||||
*/
|
||||
typedef struct target_elf_gregset_t {
|
||||
struct target_pt_regs pt;
|
||||
} target_elf_gregset_t;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#ifndef ARM_TARGET_PTRACE_H
|
||||
#define ARM_TARGET_PTRACE_H
|
||||
|
||||
/*
|
||||
* See arch/arm/include/uapi/asm/ptrace.h.
|
||||
* Instead of an array and ARM_xx defines, use proper fields.
|
||||
*/
|
||||
struct target_pt_regs {
|
||||
abi_ulong regs[16];
|
||||
abi_ulong cpsr;
|
||||
abi_ulong orig_r0;
|
||||
};
|
||||
|
||||
#endif /* ARM_TARGET_PTRACE_H */
|
||||
@@ -1,14 +1,6 @@
|
||||
#ifndef ARM_TARGET_SYSCALL_H
|
||||
#define ARM_TARGET_SYSCALL_H
|
||||
|
||||
/* this struct defines the way the registers are stored on the
|
||||
stack during a system call. */
|
||||
|
||||
/* uregs[0..15] are r0 to r15; uregs[16] is CPSR; uregs[17] is ORIG_r0 */
|
||||
struct target_pt_regs {
|
||||
abi_long uregs[18];
|
||||
};
|
||||
|
||||
#define ARM_SYSCALL_BASE 0x900000
|
||||
#define ARM_THUMB_SYSCALL 0
|
||||
|
||||
|
||||
+33
-885
File diff suppressed because it is too large
Load Diff
@@ -18,4 +18,7 @@
|
||||
#ifndef HEXAGON_TARGET_ELF_H
|
||||
#define HEXAGON_TARGET_ELF_H
|
||||
|
||||
#define ELF_CLASS ELFCLASS32
|
||||
#define ELF_MACHINE EM_HEXAGON
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,11 +18,6 @@
|
||||
#ifndef HEXAGON_TARGET_SYSCALL_H
|
||||
#define HEXAGON_TARGET_SYSCALL_H
|
||||
|
||||
struct target_pt_regs {
|
||||
abi_long sepc;
|
||||
abi_long sp;
|
||||
};
|
||||
|
||||
#define UNAME_MACHINE "hexagon"
|
||||
#define UNAME_MINIMUM_RELEASE "4.15.0"
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu.h"
|
||||
#include "loader.h"
|
||||
#include "target_elf.h"
|
||||
|
||||
|
||||
const char *get_elf_cpu_model(uint32_t eflags)
|
||||
@@ -14,3 +15,33 @@ const char *get_elf_platform(CPUState *cs)
|
||||
{
|
||||
return "PARISC";
|
||||
}
|
||||
|
||||
bool init_guest_commpage(void)
|
||||
{
|
||||
/* If reserved_va, then we have already mapped 0 page on the host. */
|
||||
if (!reserved_va) {
|
||||
void *want, *addr;
|
||||
|
||||
want = g2h_untagged(LO_COMMPAGE);
|
||||
addr = mmap(want, TARGET_PAGE_SIZE, PROT_NONE,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
perror("Allocating guest commpage");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (addr != want) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* On Linux, page zero is normally marked execute only + gateway.
|
||||
* Normal read or write is supposed to fail (thus PROT_NONE above),
|
||||
* but specific offsets have kernel code mapped to raise permissions
|
||||
* 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_EXEC | PAGE_VALID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,14 @@
|
||||
#ifndef HPPA_TARGET_ELF_H
|
||||
#define HPPA_TARGET_ELF_H
|
||||
|
||||
#define ELF_CLASS ELFCLASS32
|
||||
#define ELF_MACHINE EM_PARISC
|
||||
|
||||
#define HAVE_ELF_PLATFORM 1
|
||||
|
||||
#define LO_COMMPAGE 0
|
||||
#define STACK_GROWS_DOWN 0
|
||||
#define STACK_ALIGNMENT 64
|
||||
#define VDSO_HEADER "vdso.c.inc"
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user