1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/qemu/restore-ppc64abi32.patch
3 # Copyright (C) 2024 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
15 +++ a/configs/targets/ppc64abi32-linux-user.mak
21 +TARGET_SYSTBL_ABI=common,nospu,32
22 +TARGET_SYSTBL=syscall.tbl
24 +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
25 --- b/linux-user/elfload.c
26 +++ a/linux-user/elfload.c
28 #define ELF_MACHINE PPC_ELF_MACHINE
29 #define ELF_START_MMAP 0x80000000
31 +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
32 -#if defined(TARGET_PPC64)
34 #define elf_check_arch(x) ( (x) == EM_PPC64 )
37 static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop)
39 _regs->gpr[1] = infop->start_stack;
40 +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
41 -#if defined(TARGET_PPC64)
42 if (get_ppc64_abi(infop) < 2) {
44 get_user_u64(val, infop->entry + 8);
45 --- b/linux-user/ppc/signal.c
46 +++ a/linux-user/ppc/signal.c
49 #if defined(TARGET_PPC64)
50 struct target_sigcontext *sc = 0;
51 +#if !defined(TARGET_ABI32)
52 struct image_info *image = get_task_state(thread_cpu)->info;
56 rt_sf_addr = get_sigframe(ka, env, sizeof(*rt_sf));
57 if (!lock_user_struct(VERIFY_WRITE, rt_sf, rt_sf_addr, 1))
59 env->gpr[5] = (target_ulong) h2g(&rt_sf->uc);
60 env->gpr[6] = (target_ulong) h2g(rt_sf);
62 +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
63 -#if defined(TARGET_PPC64)
64 if (get_ppc64_abi(image) < 2) {
65 /* ELFv1 PPC64 function pointers are pointers to OPD entries. */
66 struct target_func_ptr *handler =
71 +#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
72 -#if !defined(TARGET_PPC64)
73 long do_sigreturn(CPUPPCState *env)
75 struct target_sigcontext *sc = NULL;
77 if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1))
80 +#if defined(TARGET_PPC64)
81 + set.sig[0] = sc->oldmask + ((uint64_t)(sc->_unused[3]) << 32);
83 __get_user(set.sig[0], &sc->oldmask);
84 __get_user(set.sig[1], &sc->_unused[3]);
87 target_to_host_sigset_internal(&blocked, &set);
88 set_sigmask(&blocked);
90 --- a/linux-user/ppc/target_syscall.h.vanilla
91 +++ b/linux-user/ppc/target_syscall.h
96 -#if defined(TARGET_PPC64)
97 +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
100 abi_ulong mq; /* 601 only (not used at present) */
105 -#if defined(TARGET_PPC64)
106 +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
107 #if TARGET_BIG_ENDIAN
108 #define UNAME_MACHINE "ppc64"
110 --- a/linux-user/syscall_defs.h
111 +++ b/linux-user/syscall_defs.h
112 @@ -1445,7 +1445,7 @@
116 -#if defined(TARGET_PPC64)
117 +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
121 @@ -1466,12 +1466,12 @@
122 abi_ulong target_st_ctime_nsec;
125 -#if defined(TARGET_PPC64)
126 +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
131 -#if !defined(TARGET_PPC64)
132 +#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
133 #define TARGET_HAS_STRUCT_STAT64
134 struct QEMU_PACKED target_stat64 {
137 --- qemu-8.2.2/linux-user/ppc/signal.c.vanilla 2024-03-21 16:29:38.321042834 +0100
138 +++ qemu-8.2.2/linux-user/ppc/signal.c 2024-03-21 16:33:39.347030693 +0100
143 +#if !defined(TARGET_ABI32)
144 QEMU_BUILD_BUG_ON(offsetof(struct target_mcontext, mc_fregs)
145 != offsetof_mcontext_fregs);
146 #if defined(TARGET_PPC64)
148 QEMU_BUILD_BUG_ON(offsetof(struct target_mcontext, mc_vregs)
149 != offsetof_mcontext_vregs);
153 /* See arch/powerpc/include/asm/sigcontext.h. */
154 struct target_sigcontext {
157 } __attribute__((aligned(16)));
159 +#if !defined(TARGET_ABI32)
160 QEMU_BUILD_BUG_ON(offsetof(struct target_rt_sigframe,
161 uc.tuc_sigcontext.mcontext)
162 != offsetof_rt_sigframe_mcontext);
167 --- a/linux-user/ppc/meson.build.vanilla 2024-03-21 17:05:39.796933958 +0100
168 +++ b/linux-user/ppc/meson.build 2024-03-21 17:05:21.739934868 +0100
170 extra_args: ['-r', '__kernel_sigtramp_rt64'])
171 vdso_64le_inc = gen_vdso.process('vdso-64le.so',
172 extra_args: ['-r', '__kernel_sigtramp_rt64'])
173 -linux_user_ss.add(when: 'TARGET_PPC64', if_true: [vdso_64_inc, vdso_64le_inc])
174 +linux_user_ss.add(when: 'TARGET_PPC64', if_true: [vdso_32_inc, vdso_64_inc, vdso_64le_inc])
175 --- qemu-8.2.2/linux-user/elfload.c.vanilla 2024-03-21 16:39:22.546013406 +0100
176 +++ qemu-8.2.2/linux-user/elfload.c 2024-03-21 16:40:30.175009999 +0100
177 @@ -1194,7 +1194,7 @@
178 #define USE_ELF_CORE_DUMP
179 #define ELF_EXEC_PAGESIZE 4096
181 -#ifndef TARGET_PPC64
182 +#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
183 # define VDSO_HEADER "vdso-32.c.inc"
184 #elif TARGET_BIG_ENDIAN
185 # define VDSO_HEADER "vdso-64.c.inc"