misc: Use explicit endian LD/ST API
cover misc: Use explicit endian LD/ST API
For targets (or HW) which are only built for a particular endianness, the generic LD/ST helpers are defined as the target endianness variant. For example, on big-endian targets, stl_p() is equivalent of stl_be_p().
This series replaces in bulk these LD/ST calls.
This is helpful for the single binary project where we want to build a single binary for multiple targets of different endianness.
Philippe Mathieu-Daudé (16):
qemu/bswap: Undefine CPU_CONVERT() once done exec/memop: Remove unused memop_big_endian() helper linux-user/i386: Use explicit little-endian LD/ST API hw/i386: Use explicit little-endian LD/ST API target/i386: Use explicit little-endian LD/ST API hw/m68k: Use explicit big-endian LD/ST API target/m68k: Use explicit big-endian LD/ST API hw/ppc/e500: Use explicit big-endian LD/ST API hw/s390x: Use explicit big-endian LD/ST API target/s390x: Use explicit big-endian LD/ST API hw/sparc: Use explicit big-endian LD/ST API target/sparc: Use explicit big-endian LD/ST API target/avr: Use explicit little-endian LD/ST API target/hppa: Use explicit big-endian LD/ST API target/loongarch: Use explicit little-endian LD/ST API target/tricore: Use explicit big-endian LD/ST API
hw/m68k/bootinfo.h | 28 ++--- include/exec/memop.h | 6 - include/qemu/bswap.h | 2 + hw/i386/multiboot.c | 36 +++--- hw/i386/x86-common.c | 26 ++--- hw/m68k/mcf5208.c | 2 +- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 4 +- hw/ppc/ppce500_spin.c | 24 ++-- hw/s390x/ipl.c | 4 +- hw/s390x/s390-pci-inst.c | 166 +++++++++++++-------------- hw/sparc/leon3.c | 42 +++---- hw/sparc/sun4m.c | 6 +- hw/sparc64/sun4u.c | 6 +- linux-user/i386/signal.c | 4 +- target/avr/gdbstub.c | 4 +- target/hppa/gdbstub.c | 2 +- target/i386/gdbstub.c | 26 ++--- target/i386/tcg/sysemu/excp_helper.c | 4 +- target/i386/xsave_helper.c | 32 +++--- target/loongarch/gdbstub.c | 8 +- target/m68k/gdbstub.c | 2 +- target/m68k/helper.c | 10 +- target/s390x/gdbstub.c | 4 +- target/s390x/ioinst.c | 2 +- target/sparc/gdbstub.c | 4 +- target/tricore/gdbstub.c | 2 +- 27 files changed, 227 insertions(+), 231 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/16 qemu/bswap: Undefine CPU_CONVERT() once done
Better undefined macros once we are done with them, like we do few lines later with DO_STN_LDN_P().
--- include/qemu/bswap.h | 2 ++ 1 file changed, 2 insertions(+)
include/qemu/bswap.h +2 -0
@@ -140,6 +140,8 @@ CPU_CONVERT(le, 16, uint16_t) CPU_CONVERT(le, 32, uint32_t) CPU_CONVERT(le, 64, uint64_t) +#undef CPU_CONVERT +/* * Same as cpu_to_le{16,32,64}, except that gcc will figure the result is * a compile-time constant if you pass in a constant. So this can be
Signature · 1 line
2.45.2
Re: [PATCH 01/16] qemu/bswap: Undefine CPU_CONVERT() once done
Quoted 13 lines · Philippe Mathieu-Daudé
Better undefined macros once we are done with them, like we do few lines later with
DO_STN_LDN_P().Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/bswap.h | 2 ++ 1 file changed, 2 insertions(+)include/qemu/bswap.h +0
-0
include/qemu/bswap.h CPU_CONVERT(le, 16, uint16_t) · line 144
Quoted 5 lines
include/qemu/bswap.h +2
-0@@ -140,6 +140,8 @@ CPU_CONVERT(le, 16, uint16_t) CPU_CONVERT(le, 32, uint32_t) CPU_CONVERT(le, 64, uint64_t) +#undef CPU_CONVERT +
PATCH 2/16 exec/memop: Remove unused memop_big_endian() helper
In reply to Philippe Mathieu-DaudéLast use of memop_big_endian() was removed in commit 592134617c9 ("accel/tcg: Reorg system mode store helpers").
--- include/exec/memop.h | 6 ------ 1 file changed, 6 deletions(-)
include/exec/memop.h +0 -6
@@ -164,10 +164,4 @@ static inline MemOp size_memop(unsigned size) return (MemOp)ctz32(size); } -/* Big endianness from MemOp. */ -static inline bool memop_big_endian (MemOp op) -{ -return (op &MO_BSWAP ) ==MO_BE ; -} -#endif
Signature · 1 line
2.45.2
Re: [PATCH 02/16] exec/memop: Remove unused memop_big_endian() helper
Quoted 13 lines · Philippe Mathieu-Daudé
Last use of
memop_big_endian()was removed in commit592134617c9("accel/tcg: Reorg system mode store helpers").Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/memop.h | 6 ------ 1 file changed, 6 deletions(-)include/exec/memop.h +0
-0
include/exec/memop.h static inline MemOp size_memop(unsigned size) · line 167
Quoted 10 lines
include/exec/memop.h +0
-6@@ -164,10 +164,4 @@ static inline MemOp size_memop(unsigned size) return (MemOp)ctz32(size); } -/* Big endianness from MemOp. */ -static inline bool memop_big_endian (MemOp op) -{ -return (op &MO_BSWAP ) ==MO_BE ; -} -#endif
PATCH 3/16 linux-user/i386: Use explicit little-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe x86 architecture uses little endianness. Directly use the little-endian LD/ST API.
--- linux-user/i386/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/i386/signal.c +2 -2
@@ -754,8 +754,8 @@ static bool restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc) env->eip =tswapl (sc->rip);#endif -cpu_x86_load_seg (env,R_CS ,lduw_p (&sc->cs) |3 ); -cpu_x86_load_seg (env,R_SS ,lduw_p (&sc->ss) |3 ); +cpu_x86_load_seg (env,R_CS ,lduw_le_p (&sc->cs) |3 ); +cpu_x86_load_seg (env,R_SS ,lduw_le_p (&sc->ss) |3 ); tmpflags =tswapl (sc->eflags); env->eflags = (env->eflags & ~0x40DD5 ) | (tmpflags &0x40DD5 );
Signature · 1 line
2.45.2
Re: [PATCH 03/16] linux-user/i386: Use explicit little-endian LD/ST API
Quoted 13 lines · Philippe Mathieu-Daudé
The x86 architecture uses little endianness. Directly use the little-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/i386/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/i386/signal.c +0
-0
linux-user/i386/signal.c static bool restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc) · line 761
Quoted 10 lines
linux-user/i386/signal.c +2
-2@@ -754,8 +754,8 @@ static bool restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc) env->eip =tswapl (sc->rip);#endif -cpu_x86_load_seg (env,R_CS ,lduw_p (&sc->cs) |3 ); -cpu_x86_load_seg (env,R_SS ,lduw_p (&sc->ss) |3 ); +cpu_x86_load_seg (env,R_CS ,lduw_le_p (&sc->cs) |3 ); +cpu_x86_load_seg (env,R_SS ,lduw_le_p (&sc->ss) |3 ); tmpflags =tswapl (sc->eflags); env->eflags = (env->eflags & ~0x40DD5 ) | (tmpflags &0x40DD5 );
PATCH 4/16 hw/i386: Use explicit little-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe x86 architecture uses little endianness. Directly use the little-endian LD/ST API.
--- hw/i386/multiboot.c | 36 ++++++++++++++++++------------------ hw/i386/x86-common.c | 26 +++++++++++++------------- 2 files changed, 31 insertions(+), 31 deletions(-)
hw/i386/multiboot.c +18 -18
@@ -133,9 +133,9 @@ static void mb_add_mod(MultibootState *s, p = (char *)s->mb_buf + s->offset_mbinfo +MB_MOD_SIZE * s->mb_mods_count; -stl_p (p +MB_MOD_START , start); -stl_p (p +MB_MOD_END , end); -stl_p (p +MB_MOD_CMDLINE , cmdline_phys); +stl_le_p (p +MB_MOD_START , start); +stl_le_p (p +MB_MOD_END , end); +stl_le_p (p +MB_MOD_CMDLINE , cmdline_phys);mb_debug ("mod%02d: " HWADDR_FMT_plx" - " HWADDR_FMT_plx, s->mb_mods_count, start, end);
@@ -168,9 +168,9 @@ int load_multiboot(X86MachineState *x86ms,/* Ok, let's see if it is a multiboot image. The header is 12x32bit long, so the latest entry may be 8192 - 48. */ for (i =0 ; i < (8192 -48 ); i +=4 ) { -if (ldl_p (header+i) ==0x1BADB002 ) { -uint32_t checksum =ldl_p (header+i+8 ); - flags =ldl_p (header+i+4 ); +if (ldl_le_p (header+i) ==0x1BADB002 ) { +uint32_t checksum =ldl_le_p (header+i+8 ); + flags =ldl_le_p (header+i+4 ); checksum += flags; checksum += (uint32_t )0x1BADB002 ;if (!checksum) {
@@ -223,11 +223,11 @@ int load_multiboot(X86MachineState *x86ms, mb_kernel_size, (size_t)mh_entry_addr); }else {/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ -uint32_t mh_header_addr =ldl_p (header+i+12 ); -uint32_t mh_load_end_addr =ldl_p (header+i+20 ); -uint32_t mh_bss_end_addr =ldl_p (header+i+24 ); +uint32_t mh_header_addr =ldl_le_p (header+i+12 ); +uint32_t mh_load_end_addr =ldl_le_p (header+i+20 ); +uint32_t mh_bss_end_addr =ldl_le_p (header+i+24 ); - mh_load_addr =ldl_p (header+i+16 ); + mh_load_addr =ldl_le_p (header+i+16 );if (mh_header_addr < mh_load_addr) {error_report ("invalid load_addr address" );exit (1 );
@@ -239,7 +239,7 @@ int load_multiboot(X86MachineState *x86ms,uint32_t mb_kernel_text_offset = i - (mh_header_addr - mh_load_addr);uint32_t mb_load_size =0 ; - mh_entry_addr =ldl_p (header+i+28 ); + mh_entry_addr =ldl_le_p (header+i+28 );if (mh_load_end_addr) {if (mh_load_end_addr < mh_load_addr) {
@@ -364,22 +364,22 @@ int load_multiboot(X86MachineState *x86ms,/* Commandline support */ kcmdline =g_strdup_printf ("%s %s" , kernel_filename, kernel_cmdline); -stl_p (bootinfo +MBI_CMDLINE ,mb_add_cmdline (&mbs, kcmdline)); +stl_le_p (bootinfo +MBI_CMDLINE ,mb_add_cmdline (&mbs, kcmdline)); -stl_p (bootinfo +MBI_BOOTLOADER ,mb_add_bootloader (&mbs, bootloader_name)); +stl_le_p (bootinfo +MBI_BOOTLOADER ,mb_add_bootloader (&mbs, bootloader_name)); -stl_p (bootinfo +MBI_MODS_ADDR , mbs.mb_buf_phys + mbs.offset_mbinfo); -stl_p (bootinfo +MBI_MODS_COUNT , mbs.mb_mods_count);/* mods_count */ +stl_le_p (bootinfo +MBI_MODS_ADDR , mbs.mb_buf_phys + mbs.offset_mbinfo); +stl_le_p (bootinfo +MBI_MODS_COUNT , mbs.mb_mods_count);/* mods_count */ /* the kernel is where we want it to be now */ -stl_p (bootinfo +MBI_FLAGS ,MULTIBOOT_FLAGS_MEMORY +stl_le_p (bootinfo +MBI_FLAGS ,MULTIBOOT_FLAGS_MEMORY |MULTIBOOT_FLAGS_BOOT_DEVICE |MULTIBOOT_FLAGS_CMDLINE |MULTIBOOT_FLAGS_MODULES |MULTIBOOT_FLAGS_MMAP |MULTIBOOT_FLAGS_BOOTLOADER ); -stl_p (bootinfo +MBI_BOOT_DEVICE ,0x8000ffff );/* XXX: use the -boot switch? */ -stl_p (bootinfo +MBI_MMAP_ADDR ,ADDR_E820_MAP ); +stl_le_p (bootinfo +MBI_BOOT_DEVICE ,0x8000ffff );/* XXX: use the -boot switch? */ +stl_le_p (bootinfo +MBI_MMAP_ADDR ,ADDR_E820_MAP );mb_debug ("multiboot: entry_addr = %#x" , mh_entry_addr);mb_debug (" mb_buf_phys = " HWADDR_FMT_plx, mbs.mb_buf_phys);
hw/i386/x86-common.c +13 -13
@@ -586,7 +586,7 @@ static bool load_elfboot(const char *kernel_filename,uint64_t elf_low, elf_high;int kernel_size; -if (ldl_p (header) !=0x464c457f ) { +if (ldl_le_p (header) !=0x464c457f ) {return false;/* no elfboot */ }
@@ -669,8 +669,8 @@ void x86_load_linux(X86MachineState *x86ms,* kernel protocol version. * Please see https://www.kernel.org/doc/Documentation/x86/boot.txt */ -if (ldl_p (header +0x202 ) ==0x53726448 )/* Magic signature "HdrS" */ { - protocol =lduw_p (header +0x206 ); +if (ldl_le_p (header +0x202 ) ==0x53726448 )/* Magic signature "HdrS" */ { + protocol =lduw_be_p (header +0x206 ); }else {/* * This could be a multiboot kernel. If it is, let's stop treating it
@@ -762,7 +762,7 @@ void x86_load_linux(X86MachineState *x86ms,/* highest address for loading the initrd */ if (protocol >=0x20c && -lduw_p (header +0x236 ) &XLF_CAN_BE_LOADED_ABOVE_4G ) { +lduw_be_p (header +0x236 ) &XLF_CAN_BE_LOADED_ABOVE_4G ) {/* * Linux has supported initrd up to 4 GB for a very long time (2007, * long before XLF_CAN_BE_LOADED_ABOVE_4G which was added in 2013),
@@ -781,7 +781,7 @@ void x86_load_linux(X86MachineState *x86ms,*/ initrd_max =UINT32_MAX ; }else if (protocol >=0x203 ) { - initrd_max =ldl_p (header +0x22c ); + initrd_max =ldl_le_p (header +0x22c ); }else { initrd_max =0x37ffffff ; }
@@ -797,10 +797,10 @@ void x86_load_linux(X86MachineState *x86ms, sev_load_ctx.cmdline_size =strlen (kernel_cmdline) +1 ;if (protocol >=0x202 ) { -stl_p (header +0x228 , cmdline_addr); +stl_le_p (header +0x228 , cmdline_addr); }else { -stw_p (header +0x20 ,0xA33F ); -stw_p (header +0x22 , cmdline_addr - real_addr); +stw_le_p (header +0x20 ,0xA33F ); +stw_le_p (header +0x22 , cmdline_addr - real_addr); }/* handle vga= parameter */
@@ -824,7 +824,7 @@ void x86_load_linux(X86MachineState *x86ms,exit (1 ); } } -stw_p (header +0x1fa , video_mode); +stw_le_p (header +0x1fa , video_mode); }/* loader type */
@@ -839,7 +839,7 @@ void x86_load_linux(X86MachineState *x86ms,/* heap */ if (protocol >=0x201 ) { header[0x211 ] |=0x80 ;/* CAN_USE_HEAP */ -stw_p (header +0x224 , cmdline_addr - real_addr -0x200 ); +stw_le_p (header +0x224 , cmdline_addr - real_addr -0x200 ); }/* load initrd */
@@ -879,8 +879,8 @@ void x86_load_linux(X86MachineState *x86ms, sev_load_ctx.initrd_data = initrd_data; sev_load_ctx.initrd_size = initrd_size; -stl_p (header +0x218 , initrd_addr); -stl_p (header +0x21c , initrd_size); +stl_le_p (header +0x218 , initrd_addr); +stl_le_p (header +0x21c , initrd_size); }/* load kernel and setup */
@@ -926,7 +926,7 @@ void x86_load_linux(X86MachineState *x86ms, kernel_size = setup_data_offset +sizeof (struct setup_data ) + dtb_size; kernel =g_realloc (kernel, kernel_size); -stq_p (header +0x250 , prot_addr + setup_data_offset); +stq_le_p (header +0x250 , prot_addr + setup_data_offset); setup_data = (struct setup_data *)(kernel + setup_data_offset); setup_data->next =0 ;
Signature · 1 line
2.45.2
Re: [PATCH 04/16] hw/i386: Use explicit little-endian LD/ST API
Quoted 24 lines · Philippe Mathieu-Daudé
The x86 architecture uses little endianness. Directly use the little-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/i386/multiboot.c | 36 ++++++++++++++++++------------------ hw/i386/x86-common.c | 26 +++++++++++++------------- 2 files changed, 31 insertions(+), 31 deletions(-)hw/i386/x86-common.c +1
-1@@ -586,7 +586,7 @@ static bool load_elfboot(const char *kernel_filename,uint64_t elf_low, elf_high;int kernel_size; -if (ldl_p (header) !=0x464c457f ) { +if (ldl_le_p (header) !=0x464c457f ) {return false;/* no elfboot */ }
hw/i386/x86-common.c void x86_load_linux(X86MachineState *x86ms, · line 673
Quoted 7 lines
hw/i386/x86-common.c +2
-2@@ -669,8 +669,8 @@ void x86_load_linux(X86MachineState *x86ms,* kernel protocol version. * Please see https://www.kernel.org/doc/Documentation/x86/boot.txt */ -if (ldl_p (header +0x202 ) ==0x53726448 )/* Magic signature "HdrS" */ { - protocol =lduw_p (header +0x206 ); +if (ldl_le_p (header +0x202 ) ==0x53726448 )/* Magic signature "HdrS" */ { + protocol =lduw_be_p (header +0x206 );
Oops.
Quoted 12 lines
hw/i386/x86-common.c +1
-1}else {/* * This could be a multiboot kernel. If it is, let's stop treating it @@ -762,7 +762,7 @@ void x86_load_linux(X86MachineState *x86ms,/* highest address for loading the initrd */ if (protocol >=0x20c && -lduw_p (header +0x236 ) &XLF_CAN_BE_LOADED_ABOVE_4G ) { +lduw_be_p (header +0x236 ) &XLF_CAN_BE_LOADED_ABOVE_4G ) {/* * Linux has supported initrd up to 4 GB for a very long time (2007, * long before XLF_CAN_BE_LOADED_ABOVE_4G which was added in 2013),
PATCH 5/16 target/i386: Use explicit little-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe x86 architecture uses little endianness. Directly use the little-endian LD/ST API.
--- target/i386/gdbstub.c | 26 +++++++++++----------- target/i386/tcg/sysemu/excp_helper.c | 4 ++-- target/i386/xsave_helper.c | 32 ++++++++++++++-------------- 3 files changed, 31 insertions(+), 31 deletions(-)
target/i386/gdbstub.c +13 -13
@@ -89,10 +89,10 @@ static int gdb_read_reg_cs64(uint32_t hflags, GByteArray *buf, target_ulong val)static int gdb_write_reg_cs64 (uint32_t hflags,uint8_t *buf,target_ulong *val) {if (hflags &HF_CS64_MASK ) { - *val =ldq_p (buf); + *val =ldq_le_p (buf);return 8 ; } - *val =ldl_p (buf); + *val =ldl_le_p (buf);return 4 ; }
@@ -221,7 +221,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)static int x86_cpu_gdb_load_seg (X86CPU *cpu,X86Seg sreg,uint8_t *mem_buf) {CPUX86State *env = &cpu->env; -uint16_t selector =ldl_p (mem_buf); +uint16_t selector =ldl_le_p (mem_buf);if (selector != env->segs[sreg].selector) {#if defined(CONFIG_USER_ONLY )
@@ -270,7 +270,7 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) }else if (n <CPU_NB_REGS32 ) { n = gpr_map32[n]; env->regs[n] &= ~0xffffffffUL ; - env->regs[n] |= (uint32_t )ldl_p (mem_buf); + env->regs[n] |= (uint32_t )ldl_le_p (mem_buf);return 4 ; } }else if (n >=IDX_FP_REGS && n <IDX_FP_REGS +8 ) {
@@ -281,8 +281,8 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) }else if (n >=IDX_XMM_REGS && n <IDX_XMM_REGS +CPU_NB_REGS ) { n -=IDX_XMM_REGS ;if (n <CPU_NB_REGS32 ||TARGET_LONG_BITS ==64 ) { - env->xmm_regs[n].ZMM_Q (0 ) =ldq_p (mem_buf); - env->xmm_regs[n].ZMM_Q (1 ) =ldq_p (mem_buf +8 ); + env->xmm_regs[n].ZMM_Q (0 ) =ldq_le_p (mem_buf); + env->xmm_regs[n].ZMM_Q (1 ) =ldq_le_p (mem_buf +8 );return 16 ; } }else {
@@ -290,18 +290,18 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)case IDX_IP_REG :if (TARGET_LONG_BITS ==64 ) {if (env->hflags &HF_CS64_MASK ) { - env->eip =ldq_p (mem_buf); + env->eip =ldq_le_p (mem_buf); }else { - env->eip =ldq_p (mem_buf) &0xffffffffUL ; + env->eip =ldq_le_p (mem_buf) &0xffffffffUL ; }return 8 ; }else { env->eip &= ~0xffffffffUL ; - env->eip |= (uint32_t )ldl_p (mem_buf); + env->eip |= (uint32_t )ldl_le_p (mem_buf);return 4 ; }case IDX_FLAGS_REG : - env->eflags =ldl_p (mem_buf); + env->eflags =ldl_le_p (mem_buf);return 4 ;case IDX_SEG_REGS :
@@ -327,10 +327,10 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)return 4 ;case IDX_FP_REGS +8 : -cpu_set_fpuc (env,ldl_p (mem_buf)); +cpu_set_fpuc (env,ldl_le_p (mem_buf));return 4 ;case IDX_FP_REGS +9 : - tmp =ldl_p (mem_buf); + tmp =ldl_le_p (mem_buf); env->fpstt = (tmp >>11 ) &7 ; env->fpus = tmp & ~0x3800 ;return 4 ;
@@ -348,7 +348,7 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)return 4 ;case IDX_MXCSR_REG : -cpu_set_mxcsr (env,ldl_p (mem_buf)); +cpu_set_mxcsr (env,ldl_le_p (mem_buf));return 4 ;case IDX_CTL_CR0_REG :
target/i386/tcg/sysemu/excp_helper.c +2 -2
@@ -86,7 +86,7 @@ static bool ptw_translate(PTETranslate *inout, hwaddr addr, uint64_t ra)static inline uint32_t ptw_ldl (const PTETranslate *in,uint64_t ra) {if (likely (in->haddr)) { -return ldl_p (in->haddr); +return ldl_le_p (in->haddr); }return cpu_ldl_mmuidx_ra (in->env, in->gaddr, in->ptw_idx, ra); }
@@ -94,7 +94,7 @@ static inline uint32_t ptw_ldl(const PTETranslate *in, uint64_t ra)static inline uint64_t ptw_ldq (const PTETranslate *in,uint64_t ra) {if (likely (in->haddr)) { -return ldq_p (in->haddr); +return ldq_le_p (in->haddr); }return cpu_ldq_mmuidx_ra (in->env, in->gaddr, in->ptw_idx, ra); }
target/i386/xsave_helper.c +16 -16
@@ -43,8 +43,8 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen)for (i =0 ; i <CPU_NB_REGS ; i++) {uint8_t *xmm = legacy->xmm_regs[i]; -stq_p (xmm, env->xmm_regs[i].ZMM_Q (0 )); -stq_p (xmm +8 , env->xmm_regs[i].ZMM_Q (1 )); +stq_le_p (xmm, env->xmm_regs[i].ZMM_Q (0 )); +stq_le_p (xmm +8 , env->xmm_regs[i].ZMM_Q (1 )); } header->xstate_bv = env->xstate_bv;
@@ -58,8 +58,8 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen)for (i =0 ; i <CPU_NB_REGS ; i++) {uint8_t *ymmh = avx->ymmh[i]; -stq_p (ymmh, env->xmm_regs[i].ZMM_Q (2 )); -stq_p (ymmh +8 , env->xmm_regs[i].ZMM_Q (3 )); +stq_le_p (ymmh, env->xmm_regs[i].ZMM_Q (2 )); +stq_le_p (ymmh +8 , env->xmm_regs[i].ZMM_Q (3 )); } }
@@ -101,10 +101,10 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen)for (i =0 ; i <CPU_NB_REGS ; i++) {uint8_t *zmmh = zmm_hi256->zmm_hi256[i]; -stq_p (zmmh, env->xmm_regs[i].ZMM_Q (4 )); -stq_p (zmmh +8 , env->xmm_regs[i].ZMM_Q (5 )); -stq_p (zmmh +16 , env->xmm_regs[i].ZMM_Q (6 )); -stq_p (zmmh +24 , env->xmm_regs[i].ZMM_Q (7 )); +stq_le_p (zmmh, env->xmm_regs[i].ZMM_Q (4 )); +stq_le_p (zmmh +8 , env->xmm_regs[i].ZMM_Q (5 )); +stq_le_p (zmmh +16 , env->xmm_regs[i].ZMM_Q (6 )); +stq_le_p (zmmh +24 , env->xmm_regs[i].ZMM_Q (7 )); }#ifdef TARGET_X86_64
@@ -177,8 +177,8 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *buf, uint32_t buflen)for (i =0 ; i <CPU_NB_REGS ; i++) {const uint8_t *xmm = legacy->xmm_regs[i]; - env->xmm_regs[i].ZMM_Q (0 ) =ldq_p (xmm); - env->xmm_regs[i].ZMM_Q (1 ) =ldq_p (xmm +8 ); + env->xmm_regs[i].ZMM_Q (0 ) =ldq_le_p (xmm); + env->xmm_regs[i].ZMM_Q (1 ) =ldq_le_p (xmm +8 ); } env->xstate_bv = header->xstate_bv;
@@ -191,8 +191,8 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *buf, uint32_t buflen)for (i =0 ; i <CPU_NB_REGS ; i++) {const uint8_t *ymmh = avx->ymmh[i]; - env->xmm_regs[i].ZMM_Q (2 ) =ldq_p (ymmh); - env->xmm_regs[i].ZMM_Q (3 ) =ldq_p (ymmh +8 ); + env->xmm_regs[i].ZMM_Q (2 ) =ldq_le_p (ymmh); + env->xmm_regs[i].ZMM_Q (3 ) =ldq_le_p (ymmh +8 ); } }
@@ -241,10 +241,10 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *buf, uint32_t buflen)for (i =0 ; i <CPU_NB_REGS ; i++) {const uint8_t *zmmh = zmm_hi256->zmm_hi256[i]; - env->xmm_regs[i].ZMM_Q (4 ) =ldq_p (zmmh); - env->xmm_regs[i].ZMM_Q (5 ) =ldq_p (zmmh +8 ); - env->xmm_regs[i].ZMM_Q (6 ) =ldq_p (zmmh +16 ); - env->xmm_regs[i].ZMM_Q (7 ) =ldq_p (zmmh +24 ); + env->xmm_regs[i].ZMM_Q (4 ) =ldq_le_p (zmmh); + env->xmm_regs[i].ZMM_Q (5 ) =ldq_le_p (zmmh +8 ); + env->xmm_regs[i].ZMM_Q (6 ) =ldq_le_p (zmmh +16 ); + env->xmm_regs[i].ZMM_Q (7 ) =ldq_le_p (zmmh +24 ); }#ifdef TARGET_X86_64
Signature · 1 line
2.45.2
PATCH 6/16 hw/m68k: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe M68K architecture uses big endianness. Directly use the big-endian LD/ST API.
--- hw/m68k/bootinfo.h | 28 ++++++++++++++-------------- hw/m68k/mcf5208.c | 2 +- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-)
hw/m68k/bootinfo.h +14 -14
@@ -14,39 +14,39 @@#define BOOTINFO0 (base, id) \ do { \ - stw_p(base, id); \ + stw_be_p(base, id); \ base += 2; \ - stw_p(base, sizeof(struct bi_record)); \ + stw_be_p(base, sizeof(struct bi_record)); \ base += 2; \ } while (0)#define BOOTINFO1 (base, id, value) \ do { \ - stw_p(base, id); \ + stw_be_p(base, id); \ base += 2; \ - stw_p(base, sizeof(struct bi_record) + 4); \ + stw_be_p(base, sizeof(struct bi_record) + 4); \ base += 2; \ - stl_p(base, value); \ + stl_be_p(base, value); \ base += 4; \ } while (0)#define BOOTINFO2 (base, id, value1, value2) \ do { \ - stw_p(base, id); \ + stw_be_p(base, id); \ base += 2; \ - stw_p(base, sizeof(struct bi_record) + 8); \ + stw_be_p(base, sizeof(struct bi_record) + 8); \ base += 2; \ - stl_p(base, value1); \ + stl_be_p(base, value1); \ base += 4; \ - stl_p(base, value2); \ + stl_be_p(base, value2); \ base += 4; \ } while (0)#define BOOTINFOSTR (base, id, string) \ do { \ - stw_p(base, id); \ + stw_be_p(base, id); \ base += 2; \ - stw_p(base, \ + stw_be_p(base, \ (sizeof(struct bi_record) + strlen(string) + \ 1 /* null termination */ + 3 /* padding */) & ~3); \ base +=2 ; \
@@ -59,13 +59,13 @@#define BOOTINFODATA (base, id, data, len) \ do { \ - stw_p(base, id); \ + stw_be_p(base, id); \ base += 2; \ - stw_p(base, \ + stw_be_p(base, \ (sizeof(struct bi_record) + len + \ 2 /* length field */ + 3 /* padding */) & ~3); \ base +=2 ; \ -stw_p (base, len); \ +stw_be_p (base, len); \ base +=2 ; \for (unsigned i_ =0 ; i_ < len; ++i_) { \stb_p (base++, data[i_]); \
hw/m68k/mcf5208.c +1 -1
@@ -359,7 +359,7 @@ static void mcf5208evb_init(MachineState *machine)/* Initial PC is always at offset 4 in firmware binaries */ ptr =rom_ptr (0x4 ,4 );assert (ptr !=NULL ); - env->pc =ldl_p (ptr); + env->pc =ldl_be_p (ptr); }/* Load kernel. */
hw/m68k/next-cube.c +1 -1
@@ -1036,7 +1036,7 @@ static void next_cube_init(MachineState *machine)/* Initial PC is always at offset 4 in firmware binaries */ ptr =rom_ptr (0x01000004 ,4 );g_assert (ptr !=NULL ); - env->pc =ldl_p (ptr); + env->pc =ldl_be_p (ptr);if (env->pc >=0x01020000 ) {error_report ("'%s' does not seem to be a valid firmware image." , bios_name);
hw/m68k/q800.c +2 -2
@@ -684,9 +684,9 @@ static void q800_machine_init(MachineState *machine) ptr =rom_ptr (MACROM_ADDR , bios_size);assert (ptr !=NULL ); -stl_phys (cs->as,0 ,ldl_p (ptr));/* reset initial SP */ +stl_phys (cs->as,0 ,ldl_be_p (ptr));/* reset initial SP */ stl_phys (cs->as,4 , -MACROM_ADDR +ldl_p (ptr +4 ));/* reset initial PC */ +MACROM_ADDR +ldl_be_p (ptr +4 ));/* reset initial PC */ } } }
Signature · 1 line
2.45.2
Re: [PATCH 06/16] hw/m68k: Use explicit big-endian LD/ST API
Am Fri, 4 Oct 2024 01:42:01 +0200
schrieb Philippe Mathieu-Daudé <[email protected]>:
Quoted 10 lines
The M68K architecture uses big endianness. Directly use the big-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/m68k/bootinfo.h | 28 ++++++++++++++-------------- hw/m68k/mcf5208.c | 2 +- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-)
PATCH 7/16 target/m68k: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe M68K architecture uses big endianness. Directly use the big-endian LD/ST API.
--- target/m68k/gdbstub.c | 2 +- target/m68k/helper.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
target/m68k/gdbstub.c +1 -1
@@ -52,7 +52,7 @@ int m68k_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)CPUM68KState *env =cpu_env (cs);uint32_t tmp; - tmp =ldl_p (mem_buf); + tmp =ldl_be_p (mem_buf);if (n <8 ) {/* D0-D7 */
target/m68k/helper.c +5 -5
@@ -57,15 +57,15 @@ static int cf_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n)if (n <8 ) {float_status s; - env->fregs[n].d =float64_to_floatx80 (ldq_p (mem_buf), &s); + env->fregs[n].d =float64_to_floatx80 (ldq_be_p (mem_buf), &s);return 8 ; }switch (n) {case 8 :/* fpcontrol */ -cpu_m68k_set_fpcr (env,ldl_p (mem_buf)); +cpu_m68k_set_fpcr (env,ldl_be_p (mem_buf));return 4 ;case 9 :/* fpstatus */ - env->fpsr =ldl_p (mem_buf); + env->fpsr =ldl_be_p (mem_buf);return 4 ;case 10 :/* fpiar, not implemented */ return 4 ;
@@ -107,10 +107,10 @@ static int m68k_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n) }switch (n) {case 8 :/* fpcontrol */ -cpu_m68k_set_fpcr (env,ldl_p (mem_buf)); +cpu_m68k_set_fpcr (env,ldl_be_p (mem_buf));return 4 ;case 9 :/* fpstatus */ -cpu_m68k_set_fpsr (env,ldl_p (mem_buf)); +cpu_m68k_set_fpsr (env,ldl_be_p (mem_buf));return 4 ;case 10 :/* fpiar, not implemented */ return 4 ;
Signature · 1 line
2.45.2
Re: [PATCH 07/16] target/m68k: Use explicit big-endian LD/ST API
Am Fri, 4 Oct 2024 01:42:02 +0200
schrieb Philippe Mathieu-Daudé <[email protected]>:
Quoted 8 lines
The M68K architecture uses big endianness. Directly use the big-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/m68k/gdbstub.c | 2 +- target/m68k/helper.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
PATCH 8/16 hw/ppc/e500: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe 32-bit PPC architecture uses big endianness. Directly use the big-endian LD/ST API for the E500 hardware.
--- hw/ppc/ppce500_spin.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
hw/ppc/ppce500_spin.c +12 -12
@@ -64,9 +64,9 @@ static void spin_reset(DeviceState *dev)for (i =0 ; i <MAX_CPUS ; i++) {SpinInfo *info = &s->spin[i]; -stl_p (&info->pir, i); -stq_p (&info->r3, i); -stq_p (&info->addr,1 ); +stl_be_p (&info->pir, i); +stq_be_p (&info->r3, i); +stq_be_p (&info->addr,1 ); } }
@@ -96,9 +96,9 @@ static void spin_kick(CPUState *cs, run_on_cpu_data data)hwaddr map_start;cpu_synchronize_state (cs); -stl_p (&curspin->pir, env->spr[SPR_BOOKE_PIR ]); - env->nip =ldq_p (&curspin->addr) & (map_size -1 ); - env->gpr[3 ] =ldq_p (&curspin->r3); +stl_be_p (&curspin->pir, env->spr[SPR_BOOKE_PIR ]); + env->nip =ldq_be_p (&curspin->addr) & (map_size -1 ); + env->gpr[3 ] =ldq_be_p (&curspin->r3); env->gpr[4 ] =0 ; env->gpr[5 ] =0 ; env->gpr[6 ] =0 ;
@@ -106,7 +106,7 @@ static void spin_kick(CPUState *cs, run_on_cpu_data data) env->gpr[8 ] =0 ; env->gpr[9 ] =0 ; - map_start =ldq_p (&curspin->addr) & ~(map_size -1 ); + map_start =ldq_be_p (&curspin->addr) & ~(map_size -1 );mmubooke_create_initial_mapping (env,0 , map_start, map_size); cs->halted =0 ;
@@ -141,14 +141,14 @@ static void spin_write(void *opaque, hwaddr addr, uint64_t value,stb_p (curspin_p, value);break ;case 2 : -stw_p (curspin_p, value); +stw_be_p (curspin_p, value);break ;case 4 : -stl_p (curspin_p, value); +stl_be_p (curspin_p, value);break ; } -if (!(ldq_p (&curspin->addr) &1 )) { +if (!(ldq_be_p (&curspin->addr) &1 )) {/* run CPU */ run_on_cpu (cpu, spin_kick,RUN_ON_CPU_HOST_PTR (curspin)); }
@@ -163,9 +163,9 @@ static uint64_t spin_read(void *opaque, hwaddr addr, unsigned len)case 1 :return ldub_p (spin_p);case 2 : -return lduw_p (spin_p); +return lduw_be_p (spin_p);case 4 : -return ldl_p (spin_p); +return ldl_be_p (spin_p);default :hw_error ("ppce500: unexpected %s with len = %u" , __func__, len); }
Signature · 1 line
2.45.2
PATCH 9/16 hw/s390x: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe S390 architecture uses big endianness. Directly use the big-endian LD/ST API.
--- hw/s390x/ipl.c | 4 +- hw/s390x/s390-pci-inst.c | 166 +++++++++++++++++++-------------------- 2 files changed, 85 insertions(+), 85 deletions(-)
hw/s390x/ipl.c +2 -2
@@ -252,8 +252,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)*/ romptr =rom_ptr (INITRD_PARM_START ,16 );if (romptr) { -stq_p (romptr, initrd_offset); -stq_p (romptr +1 , initrd_size); +stq_be_p (romptr, initrd_offset); +stq_be_p (romptr +1 , initrd_size); } } }
hw/s390x/s390-pci-inst.c +83 -83
376 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH 09/16] hw/s390x: Use explicit big-endian LD/ST API
Quoted 8 lines · Philippe Mathieu-Daudé
The S390 architecture uses big endianness. Directly use the big-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/s390x/ipl.c | 4 +- hw/s390x/s390-pci-inst.c | 166 +++++++++++++++++++-------------------- 2 files changed, 85 insertions(+), 85 deletions(-)
PATCH 10/16 target/s390x: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe S390 architecture uses big endianness. Directly use the big-endian LD/ST API.
--- target/s390x/gdbstub.c | 4 ++-- target/s390x/ioinst.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
target/s390x/gdbstub.c +2 -2
@@ -88,7 +88,7 @@ static int cpu_write_ac_reg(CPUState *cs, uint8_t *mem_buf, int n)switch (n) { case S390_A0_REGNUM ... S390_A15_REGNUM: - env->aregs[n] =ldl_p (mem_buf); + env->aregs[n] =ldl_be_p (mem_buf);cpu_synchronize_post_init (env_cpu (env));return 4 ;default :
@@ -123,7 +123,7 @@ static int cpu_write_fp_reg(CPUState *cs, uint8_t *mem_buf, int n)switch (n) {case S390_FPC_REGNUM : - env->fpc =ldl_p (mem_buf); + env->fpc =ldl_be_p (mem_buf);return 4 ; case S390_F0_REGNUM ... S390_F15_REGNUM: *get_freg (env, n -S390_F0_REGNUM ) =ldtul_p (mem_buf);
target/s390x/ioinst.c +1 -1
@@ -603,7 +603,7 @@ static int chsc_sei_nt2_have_event(void)#define CHSC_SEI_NT2 (1ULL << 61)static void ioinst_handle_chsc_sei (ChscReq *req,ChscResp *res) { -uint64_t selection_mask =ldq_p (&req->param1); +uint64_t selection_mask =ldq_be_p (&req->param1);uint8_t *res_flags = (uint8_t *)res->data;int have_event =0 ;int have_more =0 ;
Signature · 1 line
2.45.2
Re: [PATCH 10/16] target/s390x: Use explicit big-endian LD/ST API
Quoted 8 lines · Philippe Mathieu-Daudé
The S390 architecture uses big endianness. Directly use the big-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/s390x/gdbstub.c | 4 ++-- target/s390x/ioinst.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
PATCH 11/16 hw/sparc: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
--- hw/sparc/leon3.c | 42 +++++++++++++++++++++--------------------- hw/sparc/sun4m.c | 6 +++--- hw/sparc64/sun4u.c | 6 +++--- 3 files changed, 27 insertions(+), 27 deletions(-)
hw/sparc/leon3.c +21 -21
@@ -78,21 +78,21 @@ typedef struct ResetData {static uint32_t *gen_store_u32 (uint32_t *code,hwaddr addr,uint32_t val) { -stl_p (code++,0x82100000 );/* mov %g0, %g1 */ -stl_p (code++,0x84100000 );/* mov %g0, %g2 */ -stl_p (code++,0x03000000 + +stl_be_p (code++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (code++,0x84100000 );/* mov %g0, %g2 */ +stl_be_p (code++,0x03000000 +extract32 (addr,10 ,22 ));/* sethi %hi(addr), %g1 */ -stl_p (code++,0x82106000 + +stl_be_p (code++,0x82106000 +extract32 (addr,0 ,10 ));/* or %g1, addr, %g1 */ -stl_p (code++,0x05000000 + +stl_be_p (code++,0x05000000 +extract32 (val,10 ,22 ));/* sethi %hi(val), %g2 */ -stl_p (code++,0x8410a000 + +stl_be_p (code++,0x8410a000 +extract32 (val,0 ,10 ));/* or %g2, val, %g2 */ -stl_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ +stl_be_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ return code; }
@@ -112,13 +112,13 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr)/* If we are running on a secondary CPU, jump directly to the kernel. */ -stl_p (p++,0x85444000 );/* rd %asr17, %g2 */ -stl_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ -stl_p (p++,0x80908000 );/* tst %g2 */ +stl_be_p (p++,0x85444000 );/* rd %asr17, %g2 */ +stl_be_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ +stl_be_p (p++,0x80908000 );/* tst %g2 */ /* Filled below. */ sec_cpu_branch_p = p; -stl_p (p++,0x0BADC0DE );/* bne xxx */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x0BADC0DE );/* bne xxx */ +stl_be_p (p++,0x01000000 );/* nop */ /* Initialize the UARTs */ /* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */
@@ -133,17 +133,17 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr) p =gen_store_u32 (p,0x80000318 ,3 );/* Now, the relative branch above can be computed. */ -stl_p (sec_cpu_branch_p,0x12800000 - + (p - sec_cpu_branch_p)); +stl_be_p (sec_cpu_branch_p,0x12800000 + + (p - sec_cpu_branch_p));/* JUMP to the entry point */ -stl_p (p++,0x82100000 );/* mov %g0, %g1 */ -stl_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); -/* sethi %hi(kernel_addr), %g1 */ -stl_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); -/* or kernel_addr, %g1 */ -stl_p (p++,0x81c04000 );/* jmp %g1 */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); +/* sethi %hi(kernel_addr), %g1 */ +stl_be_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); +/* or kernel_addr, %g1 */ +stl_be_p (p++,0x81c04000 );/* jmp %g1 */ +stl_be_p (p++,0x01000000 );/* nop */ }static void leon3_cpu_reset (void *opaque)
hw/sparc/sun4m.c +3 -3
@@ -271,9 +271,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (KERNEL_LOAD_ADDR + i,24 ); -if (ptr &&ldl_p (ptr) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +16 ,INITRD_LOAD_ADDR ); -stl_p (ptr +20 , *initrd_size); +if (ptr &&ldl_be_p (ptr) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +16 ,INITRD_LOAD_ADDR ); +stl_be_p (ptr +20 , *initrd_size);break ; } }
hw/sparc64/sun4u.c +3 -3
@@ -210,9 +210,9 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (*kernel_addr + i,32 ); -if (ptr &&ldl_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +24 , *initrd_addr + *kernel_addr); -stl_p (ptr +28 , *initrd_size); +if (ptr &&ldl_be_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +24 , *initrd_addr + *kernel_addr); +stl_be_p (ptr +28 , *initrd_size);break ; } }
Signature · 1 line
2.45.2
Re: [PATCH 11/16] hw/sparc: Use explicit big-endian LD/ST API
Quoted 113 lines · Philippe Mathieu-Daudé
The SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/sparc/leon3.c | 42 +++++++++++++++++++++--------------------- hw/sparc/sun4m.c | 6 +++--- hw/sparc64/sun4u.c | 6 +++--- 3 files changed, 27 insertions(+), 27 deletions(-)hw/sparc/leon3.c +21
-21@@ -78,21 +78,21 @@ typedef struct ResetData {static uint32_t *gen_store_u32 (uint32_t *code,hwaddr addr,uint32_t val) { -stl_p (code++,0x82100000 );/* mov %g0, %g1 */ -stl_p (code++,0x84100000 );/* mov %g0, %g2 */ -stl_p (code++,0x03000000 + +stl_be_p (code++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (code++,0x84100000 );/* mov %g0, %g2 */ +stl_be_p (code++,0x03000000 +extract32 (addr,10 ,22 ));/* sethi %hi(addr), %g1 */ -stl_p (code++,0x82106000 + +stl_be_p (code++,0x82106000 +extract32 (addr,0 ,10 ));/* or %g1, addr, %g1 */ -stl_p (code++,0x05000000 + +stl_be_p (code++,0x05000000 +extract32 (val,10 ,22 ));/* sethi %hi(val), %g2 */ -stl_p (code++,0x8410a000 + +stl_be_p (code++,0x8410a000 +extract32 (val,0 ,10 ));/* or %g2, val, %g2 */ -stl_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ +stl_be_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ return code; }@@ -112,13 +112,13 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr)/* If we are running on a secondary CPU, jump directly to the kernel. */ -stl_p (p++,0x85444000 );/* rd %asr17, %g2 */ -stl_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ -stl_p (p++,0x80908000 );/* tst %g2 */ +stl_be_p (p++,0x85444000 );/* rd %asr17, %g2 */ +stl_be_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ +stl_be_p (p++,0x80908000 );/* tst %g2 */ /* Filled below. */ sec_cpu_branch_p = p; -stl_p (p++,0x0BADC0DE );/* bne xxx */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x0BADC0DE );/* bne xxx */ +stl_be_p (p++,0x01000000 );/* nop */ /* Initialize the UARTs */ /* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */ @@ -133,17 +133,17 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr) p =gen_store_u32 (p,0x80000318 ,3 );/* Now, the relative branch above can be computed. */ -stl_p (sec_cpu_branch_p,0x12800000 - + (p - sec_cpu_branch_p)); +stl_be_p (sec_cpu_branch_p,0x12800000 + + (p - sec_cpu_branch_p));/* JUMP to the entry point */ -stl_p (p++,0x82100000 );/* mov %g0, %g1 */ -stl_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); -/* sethi %hi(kernel_addr), %g1 */ -stl_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); -/* or kernel_addr, %g1 */ -stl_p (p++,0x81c04000 );/* jmp %g1 */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); +/* sethi %hi(kernel_addr), %g1 */ +stl_be_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); +/* or kernel_addr, %g1 */ +stl_be_p (p++,0x81c04000 );/* jmp %g1 */ +stl_be_p (p++,0x01000000 );/* nop */ }static void leon3_cpu_reset (void *opaque)hw/sparc/sun4m.c +3
-3@@ -271,9 +271,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (KERNEL_LOAD_ADDR + i,24 ); -if (ptr &&ldl_p (ptr) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +16 ,INITRD_LOAD_ADDR ); -stl_p (ptr +20 , *initrd_size); +if (ptr &&ldl_be_p (ptr) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +16 ,INITRD_LOAD_ADDR ); +stl_be_p (ptr +20 , *initrd_size);break ; } }hw/sparc64/sun4u.c +0
-0@@ -210,9 +210,9 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) {
hw/sparc64/sun4u.c static uint64_t sun4u_load_kernel(const char *kernel_filename, · line 218
Quoted 10 lines
hw/sparc64/sun4u.c +3
-3ptr =rom_ptr (*kernel_addr + i,32 ); -if (ptr &&ldl_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +24 , *initrd_addr + *kernel_addr); -stl_p (ptr +28 , *initrd_size); +if (ptr &&ldl_be_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +24 , *initrd_addr + *kernel_addr); +stl_be_p (ptr +28 , *initrd_size);break ; } }
For sun4m and sun4u:
ATB,
Mark.
Re: [PATCH 11/16] hw/sparc: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéQuoted 125 lines · Philippe Mathieu-Daudé
The SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/sparc/leon3.c | 42 +++++++++++++++++++++--------------------- hw/sparc/sun4m.c | 6 +++--- hw/sparc64/sun4u.c | 6 +++--- 3 files changed, 27 insertions(+), 27 deletions(-)hw/sparc/leon3.c +21
-21@@ -78,21 +78,21 @@ typedef struct ResetData {static uint32_t *gen_store_u32 (uint32_t *code,hwaddr addr,uint32_t val) { -stl_p (code++,0x82100000 );/* mov %g0, %g1 */ -stl_p (code++,0x84100000 );/* mov %g0, %g2 */ -stl_p (code++,0x03000000 + +stl_be_p (code++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (code++,0x84100000 );/* mov %g0, %g2 */ +stl_be_p (code++,0x03000000 +extract32 (addr,10 ,22 ));/* sethi %hi(addr), %g1 */ -stl_p (code++,0x82106000 + +stl_be_p (code++,0x82106000 +extract32 (addr,0 ,10 ));/* or %g1, addr, %g1 */ -stl_p (code++,0x05000000 + +stl_be_p (code++,0x05000000 +extract32 (val,10 ,22 ));/* sethi %hi(val), %g2 */ -stl_p (code++,0x8410a000 + +stl_be_p (code++,0x8410a000 +extract32 (val,0 ,10 ));/* or %g2, val, %g2 */ -stl_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ +stl_be_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ return code; }@@ -112,13 +112,13 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr)/* If we are running on a secondary CPU, jump directly to the kernel. */ -stl_p (p++,0x85444000 );/* rd %asr17, %g2 */ -stl_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ -stl_p (p++,0x80908000 );/* tst %g2 */ +stl_be_p (p++,0x85444000 );/* rd %asr17, %g2 */ +stl_be_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ +stl_be_p (p++,0x80908000 );/* tst %g2 */ /* Filled below. */ sec_cpu_branch_p = p; -stl_p (p++,0x0BADC0DE );/* bne xxx */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x0BADC0DE );/* bne xxx */ +stl_be_p (p++,0x01000000 );/* nop */ /* Initialize the UARTs */ /* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */ @@ -133,17 +133,17 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr) p =gen_store_u32 (p,0x80000318 ,3 );/* Now, the relative branch above can be computed. */ -stl_p (sec_cpu_branch_p,0x12800000 - + (p - sec_cpu_branch_p)); +stl_be_p (sec_cpu_branch_p,0x12800000 + + (p - sec_cpu_branch_p));/* JUMP to the entry point */ -stl_p (p++,0x82100000 );/* mov %g0, %g1 */ -stl_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); -/* sethi %hi(kernel_addr), %g1 */ -stl_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); -/* or kernel_addr, %g1 */ -stl_p (p++,0x81c04000 );/* jmp %g1 */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); +/* sethi %hi(kernel_addr), %g1 */ +stl_be_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); +/* or kernel_addr, %g1 */ +stl_be_p (p++,0x81c04000 );/* jmp %g1 */ +stl_be_p (p++,0x01000000 );/* nop */ }static void leon3_cpu_reset (void *opaque)hw/sparc/sun4m.c +3
-3@@ -271,9 +271,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (KERNEL_LOAD_ADDR + i,24 ); -if (ptr &&ldl_p (ptr) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +16 ,INITRD_LOAD_ADDR ); -stl_p (ptr +20 , *initrd_size); +if (ptr &&ldl_be_p (ptr) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +16 ,INITRD_LOAD_ADDR ); +stl_be_p (ptr +20 , *initrd_size);break ; } }hw/sparc64/sun4u.c +3
-4@@ -210,9 +210,9 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (*kernel_addr + i,32 ); -if (ptr &&ldl_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +24 , *initrd_addr + *kernel_addr); -stl_p (ptr +28 , *initrd_size); +if (ptr &&ldl_be_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +24 , *initrd_addr + *kernel_addr); +stl_be_p (ptr +28 , *initrd_size);break ; } } --
Quoted 1 line
2.45.2
For leon3:
PATCH 12/16 target/sparc: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
--- target/sparc/gdbstub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/sparc/gdbstub.c +2 -2
@@ -110,7 +110,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)#if defined(TARGET_ABI32 )uint32_t tmp; - tmp =ldl_p (mem_buf); + tmp =ldl_be_p (mem_buf);#else target_ulong tmp;
@@ -165,7 +165,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)#else else if (n < 64) {/* f0-f31 */ - tmp =ldl_p (mem_buf); + tmp =ldl_be_p (mem_buf);if (n &1 ) { env->fpr[(n -32 ) /2 ].l.lower = tmp; }else {
Signature · 1 line
2.45.2
Re: [PATCH 12/16] target/sparc: Use explicit big-endian LD/ST API
Quoted 22 lines · Philippe Mathieu-Daudé
The SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/sparc/gdbstub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/sparc/gdbstub.c +1
-1@@ -110,7 +110,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)#if defined(TARGET_ABI32 )uint32_t tmp; - tmp =ldl_p (mem_buf); + tmp =ldl_be_p (mem_buf);#else target_ulong tmp;
target/sparc/gdbstub.c int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) · line 171
Quoted 8 lines
target/sparc/gdbstub.c +1
-1@@ -165,7 +165,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)#else else if (n < 64) {/* f0-f31 */ - tmp =ldl_p (mem_buf); + tmp =ldl_be_p (mem_buf);if (n &1 ) { env->fpr[(n -32 ) /2 ].l.lower = tmp; }else {
ATB,
Mark.