# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/qemu/restore-ppc64abi32.patch # Copyright (C) 2024 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- --- /dev/null +++ a/configs/targets/ppc64abi32-linux-user.mak @@ -0,0 +1,8 @@ +TARGET_ARCH=ppc64 +TARGET_ABI32=y +TARGET_BASE_ARCH=ppc +TARGET_ABI_DIR=ppc +TARGET_SYSTBL_ABI=common,nospu,32 +TARGET_SYSTBL=syscall.tbl +TARGET_BIG_ENDIAN=y +TARGET_XML_FILES= gdb-xml/power64-core.xml gdb-xml/power-fpu.xml gdb-xml/power-altivec.xml gdb-xml/power-spe.xml gdb-xml/power-vsx.xml --- b/linux-user/elfload.c +++ a/linux-user/elfload.c @@ -718,7 +718,7 @@ #define ELF_MACHINE PPC_ELF_MACHINE #define ELF_START_MMAP 0x80000000 +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) -#if defined(TARGET_PPC64) #define elf_check_arch(x) ( (x) == EM_PPC64 ) @@ -870,7 +870,7 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop) { _regs->gpr[1] = infop->start_stack; +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) -#if defined(TARGET_PPC64) if (get_ppc64_abi(infop) < 2) { uint64_t val; get_user_u64(val, infop->entry + 8); --- b/linux-user/ppc/signal.c +++ a/linux-user/ppc/signal.c @@ -490,8 +490,10 @@ int i, err = 0; #if defined(TARGET_PPC64) struct target_sigcontext *sc = 0; +#if !defined(TARGET_ABI32) struct image_info *image = get_task_state(thread_cpu)->info; #endif +#endif rt_sf_addr = get_sigframe(ka, env, sizeof(*rt_sf)); if (!lock_user_struct(VERIFY_WRITE, rt_sf, rt_sf_addr, 1)) @@ -528,7 +530,7 @@ env->gpr[5] = (target_ulong) h2g(&rt_sf->uc); env->gpr[6] = (target_ulong) h2g(rt_sf); +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) -#if defined(TARGET_PPC64) if (get_ppc64_abi(image) < 2) { /* ELFv1 PPC64 function pointers are pointers to OPD entries. */ struct target_func_ptr *handler = @@ -560,7 +562,7 @@ } +#if !defined(TARGET_PPC64) || defined(TARGET_ABI32) -#if !defined(TARGET_PPC64) long do_sigreturn(CPUPPCState *env) { struct target_sigcontext *sc = NULL; @@ -573,9 +575,12 @@ if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1)) goto sigsegv; +#if defined(TARGET_PPC64) + set.sig[0] = sc->oldmask + ((uint64_t)(sc->_unused[3]) << 32); +#else __get_user(set.sig[0], &sc->oldmask); __get_user(set.sig[1], &sc->_unused[3]); +#endif - target_to_host_sigset_internal(&blocked, &set); set_sigmask(&blocked); --- a/linux-user/ppc/target_syscall.h.vanilla +++ b/linux-user/ppc/target_syscall.h @@ -36,7 +36,7 @@ abi_ulong link; abi_ulong xer; abi_ulong ccr; -#if defined(TARGET_PPC64) +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) abi_ulong softe; #else abi_ulong mq; /* 601 only (not used at present) */ @@ -58,7 +58,7 @@ * flags masks */ -#if defined(TARGET_PPC64) +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) #if TARGET_BIG_ENDIAN #define UNAME_MACHINE "ppc64" #else --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1445,7 +1445,7 @@ struct target_stat { abi_ulong st_dev; abi_ulong st_ino; -#if defined(TARGET_PPC64) +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) abi_ulong st_nlink; abi_uint st_mode; #else @@ -1466,12 +1466,12 @@ abi_ulong target_st_ctime_nsec; abi_ulong __unused4; abi_ulong __unused5; -#if defined(TARGET_PPC64) +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) abi_ulong __unused6; #endif }; -#if !defined(TARGET_PPC64) +#if !defined(TARGET_PPC64) || defined(TARGET_ABI32) #define TARGET_HAS_STRUCT_STAT64 struct QEMU_PACKED target_stat64 { abi_ullong st_dev; --- qemu-8.2.2/linux-user/ppc/signal.c.vanilla 2024-03-21 16:29:38.321042834 +0100 +++ qemu-8.2.2/linux-user/ppc/signal.c 2024-03-21 16:33:39.347030693 +0100 @@ -66,6 +66,7 @@ #endif }; +#if !defined(TARGET_ABI32) QEMU_BUILD_BUG_ON(offsetof(struct target_mcontext, mc_fregs) != offsetof_mcontext_fregs); #if defined(TARGET_PPC64) @@ -75,6 +76,7 @@ QEMU_BUILD_BUG_ON(offsetof(struct target_mcontext, mc_vregs) != offsetof_mcontext_vregs); #endif +#endif /* See arch/powerpc/include/asm/sigcontext.h. */ struct target_sigcontext { @@ -192,9 +194,11 @@ char abigap[288]; } __attribute__((aligned(16))); +#if !defined(TARGET_ABI32) QEMU_BUILD_BUG_ON(offsetof(struct target_rt_sigframe, uc.tuc_sigcontext.mcontext) != offsetof_rt_sigframe_mcontext); +#endif #else --- a/linux-user/ppc/meson.build.vanilla 2024-03-21 17:05:39.796933958 +0100 +++ b/linux-user/ppc/meson.build 2024-03-21 17:05:21.739934868 +0100 @@ -14,4 +14,4 @@ extra_args: ['-r', '__kernel_sigtramp_rt64']) vdso_64le_inc = gen_vdso.process('vdso-64le.so', extra_args: ['-r', '__kernel_sigtramp_rt64']) -linux_user_ss.add(when: 'TARGET_PPC64', if_true: [vdso_64_inc, vdso_64le_inc]) +linux_user_ss.add(when: 'TARGET_PPC64', if_true: [vdso_32_inc, vdso_64_inc, vdso_64le_inc]) --- qemu-8.2.2/linux-user/elfload.c.vanilla 2024-03-21 16:39:22.546013406 +0100 +++ qemu-8.2.2/linux-user/elfload.c 2024-03-21 16:40:30.175009999 +0100 @@ -1194,7 +1194,7 @@ #define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#ifndef TARGET_PPC64 +#if !defined(TARGET_PPC64) || defined(TARGET_ABI32) # define VDSO_HEADER "vdso-32.c.inc" #elif TARGET_BIG_ENDIAN # define VDSO_HEADER "vdso-64.c.inc"