Memory API patches for 2026-01-22
The following changes since commit 2339d0a1cfac6ecc667e6e062a593865c1541c35:
Merge tag 'hw-misc-20260120' of https://github.com/philmd/qemu into staging (2026-01-21 07:39:57 +1100)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/memory-api-20260122
for you to fetch changes up to 1280ec826e98342db4e7c35daf7680d09121bde6:
cpus: Allocate maximum number of ASes supported by the arch (2026-01-22 10:48:46 +0100)
----------------------------------------------------------------
Memory API patches
- Use explicit endianness for cpu_ld/st_data*() on some targets
- Reduce 'qemu/bswap.h' uses
- Introduce ldm_p/stm_p (MemOp) load/store helpers
- Allow restricting the legacy 'native-endian' APIs
- Forbid various targets to use legacy native endianness APIs
- Simplify cpu_address_space_init() API
----------------------------------------------------------------
Deliberately ignored checkpatch.pl errors:
ERROR: DEVICE_NATIVE_ENDIAN is not allowed, use DEVICE_LITTLE_ENDIAN or DEVICE_BIG_ENDIAN instead #314: FILE: system/memory_ldst.c.inc:448:
+#define DEVICE_ENDIANNESS DEVICE_NATIVE_ENDIAN
ERROR: DEVICE_NATIVE_ENDIAN is not allowed, use DEVICE_LITTLE_ENDIAN or DEVICE_BIG_ENDIAN instead #182: FILE: system/memory_ldst.c.inc:97:
+ DEVICE_NATIVE_ENDIAN);
ERROR: DEVICE_NATIVE_ENDIAN is not allowed, use DEVICE_LITTLE_ENDIAN or DEVICE_BIG_ENDIAN instead #332: FILE: system/memory_ldst.c.inc:171:
+ DEVICE_NATIVE_ENDIAN);
ERROR: DEVICE_NATIVE_ENDIAN is not allowed, use DEVICE_LITTLE_ENDIAN or DEVICE_BIG_ENDIAN instead #34: FILE: include/system/memory.h:31:
+ DEVICE_NATIVE_ENDIAN = 0,
False negative:
WARNING: added, moved or deleted file(s):
dump/win_dump-stubs.c
dump/win_dump-x86.c
dump/Kconfig Does MAINTAINERS need updating?
Gustavo Romero (3):
target/arm: Initialize AS 0 first target/i386: Add a _MAX sentinel to X86ASIdx enum target/arm: Add a _MAX sentinel to ARMASIdx enum
Philippe Mathieu-Daudé (34):
target/i386: Use little-endian variant of cpu_ld/st_data*() target/riscv: Use little-endian variant of cpu_ld/st_data*() for
vector
target/m68k: Use big-endian variant of cpu_ld/st_data*() target/sparc: Use big-endian variant of cpu_ld/st_data*() target/sh4: Replace cpu_stl_data() call in OCBI helper target/ppc: Simplify endianness handling in Altivec opcodes
bswap: Include missing 'qemu/bswap.h' header
bswap: Use 'qemu/bswap.h' instead of 'qemu/host-utils.h'
bswap: Remove unnecessary 'qemu/bswap.h'
system/memory: Introduce ldm_p() and stm_p() load/store helpers system/memory: Define address_space_ldst[W] endian variants via
template
system/memory: Define address_space_ldst[L] endian variants via
template
system/memory: Define address_space_ldst[Q] endian variants via
template
system/memory: Factor address_space_ldst[M]_internal() helper out system/memory: Pass device_endian argument as MemOp bit system/memory: Use ldm_p() and stm_p() helpers system/memory: Directly call address_space_ldst[M]_internal() helper
system: Allow restricting the legacy ld/st_phys() 'native-endian' API
system: Allow restricting legacy address_space_ldst() native-endian
API
system: Allow restricting the legacy cpu_ld/st() 'native-endian' API
system: Allow restricting the legacy translator_ld() 'native-endian'
API
system: Allow restricting the legacy tswap() 'native-endian' API
system: Allow restricting the legacy MO_TE* 'native-endian'
definitions
system: Allow restricting the legacy DEVICE_NATIVE_ENDIAN definition configs/targets: Forbid Hexagon to use legacy native endianness API configs/targets: Forbid HPPA to use legacy native endianness APIs configs/targets: Forbid LoongArch to use legacy native endianness APIs configs/targets: Forbid OpenRISC to use legacy native endianness APIs configs/targets: Forbid TriCore to use legacy native endianness API configs/targets: Forbid Renesas RX to use legacy native endianness API configs/targets: Forbid s390x to use legacy native endianness APIs
dump: Abort in create_win_dump() on non-x86 guests
dump: Build stubs once for non-x86 targets
cpus: Allocate maximum number of ASes supported by the arch
MAINTAINERS | 1 +
configs/targets/hexagon-linux-user.mak | 1 +
configs/targets/hppa-linux-user.mak | 1 +
configs/targets/hppa-softmmu.mak | 1 +
configs/targets/loongarch64-linux-user.mak | 1 +
configs/targets/loongarch64-softmmu.mak | 1 +
configs/targets/or1k-linux-user.mak | 1 +
configs/targets/or1k-softmmu.mak | 1 +
configs/targets/rx-softmmu.mak | 1 +
configs/targets/s390x-linux-user.mak | 1 +
configs/targets/s390x-softmmu.mak | 1 +
configs/targets/tricore-softmmu.mak | 1 +
block/qcow2.h | 1 +
include/accel/tcg/cpu-ldst.h | 2 +
include/exec/cpu-common.h | 4 -
include/exec/memop.h | 4 +
include/exec/translator.h | 5 +-
include/exec/tswap.h | 3 +
include/hw/core/cpu.h | 7 +-
include/qemu/bswap.h | 72 +++
include/qemu/host-utils.h | 1 -
include/qemu/int128.h | 2 -
include/system/memory.h | 8 +-
include/system/memory_cached.h | 2 +
system/memory-internal.h | 2 +
target/arm/cpu.h | 1 +
target/i386/cpu.h | 1 +
target/i386/ops_sse.h | 12 +-
target/i386/tcg/seg_helper.h | 12 +-
include/system/memory_ldst.h.inc | 52 +--
include/system/memory_ldst_endian.h.inc | 33 ++
include/system/memory_ldst_phys.h.inc | 113 +----
include/system/memory_ldst_phys_endian.h.inc | 57 +++
audio/audio.c | 1 +
block/blklogwrites.c | 1 +
block/export/vduse-blk.c | 1 +
block/export/vhost-user-blk-server.c | 1 +
block/export/virtio-blk-handler.c | 1 +
block/parallels-ext.c | 1 +
dump/win_dump-stubs.c | 21 +
dump/{win_dump.c => win_dump-x86.c} | 20 +-
hw/9pfs/9p-local.c | 1 +
hw/block/cdrom.c | 1 +
hw/block/hd-geometry.c | 1 +
hw/core/cpu-common.c | 1 -
hw/core/cpu-system.c | 2 +-
hw/net/can/ctucan_core.c | 1 +
hw/nvram/xlnx-efuse.c | 1 +
hw/scsi/scsi-generic.c | 1 +
hw/sd/sd.c | 1 +
hw/sd/ssi-sd.c | 1 +
linux-user/vm86.c | 4 +-
net/l2tpv3.c | 1 +
qga/commands-linux.c | 1 +
scsi/pr-manager-helper.c | 1 +
system/cpus.c | 1 -
system/physmem.c | 8 +-
target/arm/cpu.c | 13 +-
target/arm/tcg/arith_helper.c | 1 +
target/i386/cpu.c | 1 +
target/i386/kvm/kvm-cpu.c | 1 -
target/i386/tcg/mem_helper.c | 8 +-
target/i386/tcg/mpx_helper.c | 28 +-
target/i386/tcg/seg_helper.c | 16 +-
target/i386/tcg/system/excp_helper.c | 8 +-
target/i386/tcg/system/svm_helper.c | 69 +--
target/i386/tcg/system/tcg-cpu.c | 1 -
target/m68k/fpu_helper.c | 12 +-
target/m68k/op_helper.c | 91 ++--
target/ppc/mem_helper.c | 31 +-
target/riscv/vector_helper.c | 12 +-
target/sh4/op_helper.c | 5 +-
target/sparc/ldst_helper.c | 6 +-
tests/qtest/acpi-utils.c | 1 +
tests/qtest/ahci-test.c | 2 +-
tests/qtest/aspeed-hace-utils.c | 1 +
tests/qtest/bios-tables-test.c | 1 +
tests/qtest/libqos/ahci.c | 2 +-
tests/qtest/libqos/generic-pcihost.c | 2 +-
tests/qtest/libqos/igb.c | 1 +
tests/qtest/libqos/pci-spapr.c | 2 +-
tests/qtest/libqos/virtio-9p-client.c | 1 +
tests/qtest/migration/framework.c | 1 +
tests/qtest/npcm7xx_emc-test.c | 1 +
tests/qtest/tpm-emu.c | 1 +
tests/qtest/ufs-test.c | 1 +
tests/qtest/vmgenid-test.c | 1 +
tests/unit/test-hbitmap.c | 1 +
util/bitmap.c | 1 +
util/hbitmap.c | 2 +-
system/memory_ldst.c.inc | 449 ++-----------------
system/memory_ldst_endian.c.inc | 70 +++
Kconfig | 1 +
dump/Kconfig | 6 +
dump/meson.build | 3 +-
scripts/make-config-poison.sh | 1 +
96 files changed, 566 insertions(+), 769 deletions(-)
create mode 100644 include/system/memory_ldst_endian.h.inc
create mode 100644 include/system/memory_ldst_phys_endian.h.inc
create mode 100644 dump/win_dump-stubs.c
rename dump/{win_dump.c => win_dump-x86.c} (97%)
create mode 100644 system/memory_ldst_endian.c.inc
create mode 100644 dump/KconfigSignature · 1 line
2.52.0
[PULL v2 01/37] target/i386: Use little-endian variant of cpu_ld/st_data*()
We only build the X86 targets using little endianness order, therefore the cpu_ld/st_data*() definitions expand to the little endian declarations. Use the explicit little-endian variants.
Mechanical change running:
$ tgt=i386; \
end=le; \
for op in data mmuidx_ra; do \
for ac in uw sw l q; do \
sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
for ac in w l q; do \
sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
doneThen adapting indentation in helper_vmload() to pass checkpatch.pl.
Message-Id: <[email protected]>
--- target/i386/ops_sse.h | 12 ++--- target/i386/tcg/seg_helper.h | 12 ++--- linux-user/vm86.c | 4 +- target/i386/tcg/mem_helper.c | 8 ++-- target/i386/tcg/mpx_helper.c | 28 +++++------ target/i386/tcg/seg_helper.c | 16 +++---- target/i386/tcg/system/excp_helper.c | 8 ++-- target/i386/tcg/system/svm_helper.c | 69 +++++++++++++++------------- 8 files changed, 80 insertions(+), 77 deletions(-)
target/i386/ops_sse.h +6 -6
@@ -2326,7 +2326,7 @@ void glue(helper_vpmaskmovd_st, SUFFIX)(CPUX86State *env,for (i =0 ; i < (2 <<SHIFT ); i++) {if (v->L (i) >>31 ) { -cpu_stl_data_ra (env, a0 + i *4 , s->L (i),GETPC ()); +cpu_stl_le_data_ra (env, a0 + i *4 , s->L (i),GETPC ()); } } }
@@ -2338,7 +2338,7 @@ void glue(helper_vpmaskmovq_st, SUFFIX)(CPUX86State *env,for (i =0 ; i < (1 <<SHIFT ); i++) {if (v->Q (i) >>63 ) { -cpu_stq_data_ra (env, a0 + i *8 , s->Q (i),GETPC ()); +cpu_stq_le_data_ra (env, a0 + i *8 , s->Q (i),GETPC ()); } } }
@@ -2369,7 +2369,7 @@ void glue(helper_vpgatherdd, SUFFIX)(CPUX86State *env,if (v->L (i) >>31 ) {target_ulong addr = a0 + ((target_ulong )(int32_t )s->L (i) << scale); - d->L (i) =cpu_ldl_data_ra (env, addr & amask,GETPC ()); + d->L (i) =cpu_ldl_le_data_ra (env, addr & amask,GETPC ()); } v->L (i) =0 ; }
@@ -2383,7 +2383,7 @@ void glue(helper_vpgatherdq, SUFFIX)(CPUX86State *env,if (v->Q (i) >>63 ) {target_ulong addr = a0 + ((target_ulong )(int32_t )s->L (i) << scale); - d->Q (i) =cpu_ldq_data_ra (env, addr & amask,GETPC ()); + d->Q (i) =cpu_ldq_le_data_ra (env, addr & amask,GETPC ()); } v->Q (i) =0 ; }
@@ -2397,7 +2397,7 @@ void glue(helper_vpgatherqd, SUFFIX)(CPUX86State *env,if (v->L (i) >>31 ) {target_ulong addr = a0 + ((target_ulong )(int64_t )s->Q (i) << scale); - d->L (i) =cpu_ldl_data_ra (env, addr & amask,GETPC ()); + d->L (i) =cpu_ldl_le_data_ra (env, addr & amask,GETPC ()); } v->L (i) =0 ; }
@@ -2415,7 +2415,7 @@ void glue(helper_vpgatherqq, SUFFIX)(CPUX86State *env,if (v->Q (i) >>63 ) {target_ulong addr = a0 + ((target_ulong )(int64_t )s->Q (i) << scale); - d->Q (i) =cpu_ldq_data_ra (env, addr & amask,GETPC ()); + d->Q (i) =cpu_ldq_le_data_ra (env, addr & amask,GETPC ()); } v->Q (i) =0 ; }
target/i386/tcg/seg_helper.h +6 -6
@@ -40,18 +40,18 @@ int cpu_mmu_index_kernel(CPUX86State *env);* and use *_mmuidx_ra directly. */ #define cpu_lduw_kernel_ra (e, p, r) \ - cpu_lduw_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r) + cpu_lduw_le_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)#define cpu_ldl_kernel_ra (e, p, r) \ - cpu_ldl_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r) + cpu_ldl_le_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)#define cpu_ldq_kernel_ra (e, p, r) \ - cpu_ldq_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r) + cpu_ldq_le_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)#define cpu_stw_kernel_ra (e, p, v, r) \ - cpu_stw_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r) + cpu_stw_le_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)#define cpu_stl_kernel_ra (e, p, v, r) \ - cpu_stl_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r) + cpu_stl_le_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)#define cpu_stq_kernel_ra (e, p, v, r) \ - cpu_stq_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r) + cpu_stq_le_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)#define cpu_lduw_kernel (e, p) cpu_lduw_kernel_ra(e, p, 0)#define cpu_ldl_kernel (e, p) cpu_ldl_kernel_ra(e, p, 0)
linux-user/vm86.c +2 -2
@@ -44,7 +44,7 @@ static inline int is_revectored(int nr, struct target_revectored_struct *bitmap)static inline void vm_putw (CPUX86State *env,uint32_t segptr,unsigned int reg16,unsigned int val) { -cpu_stw_data (env, segptr + (reg16 &0xffff ), val); +cpu_stw_le_data (env, segptr + (reg16 &0xffff ), val); }void save_v86_state (CPUX86State *env)
@@ -157,7 +157,7 @@ static void do_int(CPUX86State *env, int intno) &ts->vm86plus.int21_revectored)) goto cannot_handle; int_addr = (intno <<2 ); - segoffs =cpu_ldl_data (env, int_addr); + segoffs =cpu_ldl_le_data (env, int_addr);if ((segoffs >>16 ) ==TARGET_BIOSSEG ) goto cannot_handle; LOG_VM86("VM86: emulating int 0x%x. CS:IP=%04x:%04x\n",
target/i386/tcg/mem_helper.c +4 -4
@@ -30,8 +30,8 @@ void helper_boundw(CPUX86State *env, target_ulong a0, int v) {int low, high; - low =cpu_ldsw_data_ra (env, a0,GETPC ()); - high =cpu_ldsw_data_ra (env, a0 +2 ,GETPC ()); + low =cpu_ldsw_le_data_ra (env, a0,GETPC ()); + high =cpu_ldsw_le_data_ra (env, a0 +2 ,GETPC ()); v = (int16_t )v;if (v < low || v > high) {if (env->hflags &HF_MPX_EN_MASK ) {
@@ -45,8 +45,8 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v) {int low, high; - low =cpu_ldl_data_ra (env, a0,GETPC ()); - high =cpu_ldl_data_ra (env, a0 +4 ,GETPC ()); + low =cpu_ldl_le_data_ra (env, a0,GETPC ()); + high =cpu_ldl_le_data_ra (env, a0 +4 ,GETPC ());if (v < low || v > high) {if (env->hflags &HF_MPX_EN_MASK ) { env->bndcs_regs.sts =0 ;
target/i386/tcg/mpx_helper.c +14 -14
@@ -44,7 +44,7 @@ static uint64_t lookup_bte64(CPUX86State *env, uint64_t base, uintptr_t ra) } bde = (extract64 (base,20 ,28 ) <<3 ) + (extract64 (bndcsr,20 ,44 ) <<12 ); - bt =cpu_ldq_data_ra (env, bde, ra); + bt =cpu_ldq_le_data_ra (env, bde, ra);if ((bt &1 ) ==0 ) { env->bndcs_regs.sts = bde |2 ;raise_exception_ra (env,EXCP05_BOUND , ra);
@@ -64,7 +64,7 @@ static uint32_t lookup_bte32(CPUX86State *env, uint32_t base, uintptr_t ra) } bde = (extract32 (base,12 ,20 ) <<2 ) + (bndcsr &TARGET_PAGE_MASK ); - bt =cpu_ldl_data_ra (env, bde, ra); + bt =cpu_ldl_le_data_ra (env, bde, ra);if ((bt &1 ) ==0 ) { env->bndcs_regs.sts = bde |2 ;raise_exception_ra (env,EXCP05_BOUND , ra);
@@ -79,9 +79,9 @@ uint64_t helper_bndldx64(CPUX86State *env, target_ulong base, target_ulong ptr)uint64_t bte, lb, ub, pt; bte =lookup_bte64 (env, base, ra); - lb =cpu_ldq_data_ra (env, bte, ra); - ub =cpu_ldq_data_ra (env, bte +8 , ra); - pt =cpu_ldq_data_ra (env, bte +16 , ra); + lb =cpu_ldq_le_data_ra (env, bte, ra); + ub =cpu_ldq_le_data_ra (env, bte +8 , ra); + pt =cpu_ldq_le_data_ra (env, bte +16 , ra);if (pt != ptr) { lb = ub =0 ;
@@ -96,9 +96,9 @@ uint64_t helper_bndldx32(CPUX86State *env, target_ulong base, target_ulong ptr)uint32_t bte, lb, ub, pt; bte =lookup_bte32 (env, base, ra); - lb =cpu_ldl_data_ra (env, bte, ra); - ub =cpu_ldl_data_ra (env, bte +4 , ra); - pt =cpu_ldl_data_ra (env, bte +8 , ra); + lb =cpu_ldl_le_data_ra (env, bte, ra); + ub =cpu_ldl_le_data_ra (env, bte +4 , ra); + pt =cpu_ldl_le_data_ra (env, bte +8 , ra);if (pt != ptr) { lb = ub =0 ;
@@ -113,9 +113,9 @@ void helper_bndstx64(CPUX86State *env, target_ulong base, target_ulong ptr,uint64_t bte; bte =lookup_bte64 (env, base, ra); -cpu_stq_data_ra (env, bte, lb, ra); -cpu_stq_data_ra (env, bte +8 , ub, ra); -cpu_stq_data_ra (env, bte +16 , ptr, ra); +cpu_stq_le_data_ra (env, bte, lb, ra); +cpu_stq_le_data_ra (env, bte +8 , ub, ra); +cpu_stq_le_data_ra (env, bte +16 , ptr, ra); } void helper_bndstx32(CPUX86State *env, target_ulong base, target_ulong ptr,
@@ -125,9 +125,9 @@ void helper_bndstx32(CPUX86State *env, target_ulong base, target_ulong ptr,uint32_t bte; bte =lookup_bte32 (env, base, ra); -cpu_stl_data_ra (env, bte, lb, ra); -cpu_stl_data_ra (env, bte +4 , ub, ra); -cpu_stl_data_ra (env, bte +8 , ptr, ra); +cpu_stl_le_data_ra (env, bte, lb, ra); +cpu_stl_le_data_ra (env, bte +4 , ub, ra); +cpu_stl_le_data_ra (env, bte +8 , ptr, ra); }void helper_bnd_jmp (CPUX86State *env)
target/i386/tcg/seg_helper.c +8 -8
@@ -65,20 +65,20 @@ typedef struct StackAccessstatic void pushw (StackAccess *sa,uint16_t val) { sa->sp -=2 ; -cpu_stw_mmuidx_ra (sa->env, sa->ss_base + (sa->sp & sa->sp_mask), +cpu_stw_le_mmuidx_ra (sa->env, sa->ss_base + (sa->sp & sa->sp_mask), val, sa->mmu_index, sa->ra); }static void pushl (StackAccess *sa,uint32_t val) { sa->sp -=4 ; -cpu_stl_mmuidx_ra (sa->env, sa->ss_base + (sa->sp & sa->sp_mask), +cpu_stl_le_mmuidx_ra (sa->env, sa->ss_base + (sa->sp & sa->sp_mask), val, sa->mmu_index, sa->ra); }static uint16_t popw (StackAccess *sa) { -uint16_t ret =cpu_lduw_mmuidx_ra (sa->env, +uint16_t ret =cpu_lduw_le_mmuidx_ra (sa->env, sa->ss_base + (sa->sp & sa->sp_mask), sa->mmu_index, sa->ra); sa->sp +=2 ;
@@ -87,7 +87,7 @@ static uint16_t popw(StackAccess *sa)static uint32_t popl (StackAccess *sa) { -uint32_t ret =cpu_ldl_mmuidx_ra (sa->env, +uint32_t ret =cpu_ldl_le_mmuidx_ra (sa->env, sa->ss_base + (sa->sp & sa->sp_mask), sa->mmu_index, sa->ra); sa->sp +=4 ;
@@ -905,12 +905,12 @@ static void do_interrupt_protected(CPUX86State *env, int intno, int is_int,static void pushq (StackAccess *sa,uint64_t val) { sa->sp -=8 ; -cpu_stq_mmuidx_ra (sa->env, sa->sp, val, sa->mmu_index, sa->ra); +cpu_stq_le_mmuidx_ra (sa->env, sa->sp, val, sa->mmu_index, sa->ra); }static uint64_t popq (StackAccess *sa) { -uint64_t ret =cpu_ldq_mmuidx_ra (sa->env, sa->sp, sa->mmu_index, sa->ra); +uint64_t ret =cpu_ldq_le_mmuidx_ra (sa->env, sa->sp, sa->mmu_index, sa->ra); sa->sp +=8 ;return ret; }
@@ -1887,7 +1887,7 @@ void helper_lcall_protected(CPUX86State *env, int new_cs, target_ulong new_eip,pushl (&sa, env->segs[R_SS ].selector);pushl (&sa, env->regs[R_ESP ]);for (i = param_count -1 ; i >=0 ; i--) { - val =cpu_ldl_data_ra (env, + val =cpu_ldl_le_data_ra (env, old_ssp + ((env->regs[R_ESP ] + i *4 ) & old_sp_mask),GETPC ());pushl (&sa, val);
@@ -1896,7 +1896,7 @@ void helper_lcall_protected(CPUX86State *env, int new_cs, target_ulong new_eip,pushw (&sa, env->segs[R_SS ].selector);pushw (&sa, env->regs[R_ESP ]);for (i = param_count -1 ; i >=0 ; i--) { - val =cpu_lduw_data_ra (env, + val =cpu_lduw_le_data_ra (env, old_ssp + ((env->regs[R_ESP ] + i *2 ) & old_sp_mask),GETPC ());pushw (&sa, val);
target/i386/tcg/system/excp_helper.c +4 -4
@@ -90,7 +90,7 @@ static inline uint32_t ptw_ldl(const PTETranslate *in, uint64_t ra)if (likely (in->haddr)) {return ldl_p (in->haddr); } -return cpu_ldl_mmuidx_ra (in->env, in->gaddr, in->ptw_idx, ra); +return cpu_ldl_le_mmuidx_ra (in->env, in->gaddr, in->ptw_idx, ra); }static inline uint64_t ptw_ldq (const PTETranslate *in,uint64_t ra)
@@ -98,7 +98,7 @@ static inline uint64_t ptw_ldq(const PTETranslate *in, uint64_t ra)if (likely (in->haddr)) {return ldq_p (in->haddr); } -return cpu_ldq_mmuidx_ra (in->env, in->gaddr, in->ptw_idx, ra); +return cpu_ldq_le_mmuidx_ra (in->env, in->gaddr, in->ptw_idx, ra); }/*
@@ -116,9 +116,9 @@ static bool ptw_setl_slow(const PTETranslate *in, uint32_t old, uint32_t new)cpu_exec_end (cpu);/* Does x86 really perform a rmw cycle on mmio for ptw? */ start_exclusive (); - cmp =cpu_ldl_mmuidx_ra (in->env, in->gaddr, in->ptw_idx,0 ); + cmp =cpu_ldl_le_mmuidx_ra (in->env, in->gaddr, in->ptw_idx,0 );if (cmp == old) { -cpu_stl_mmuidx_ra (in->env, in->gaddr, new, in->ptw_idx,0 ); +cpu_stl_le_mmuidx_ra (in->env, in->gaddr, new, in->ptw_idx,0 ); }end_exclusive ();cpu_exec_start (cpu);
target/i386/tcg/system/svm_helper.c +36 -33
119 lines not on this page · raw message
Signature · 1 line
2.52.0
[PULL v2 05/37] target/sh4: Replace cpu_stl_data() call in OCBI helper
In reply to Philippe Mathieu-DaudéIn preparation of removing the cpu_stl_data() call, inline it. Set the return address argument.
See commit 852d481faf7 ("SH: Improve movca.l/ocbi emulation") for more context on this code.
Message-Id: <[email protected]>
--- target/sh4/op_helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
target/sh4/op_helper.c +4 -1
@@ -136,6 +136,8 @@ void helper_discard_movcal_backup(CPUSH4State *env)void helper_ocbi (CPUSH4State *env,uint32_t address) { +unsigned mmu_idx =cpu_mmu_index (env_cpu (env), false); +MemOpIdx oi =make_memop_idx (MO_TE |MO_UL |MO_UNALN , mmu_idx);memory_content **current = &(env->movcal_backup);while (*current) {
@@ -143,7 +145,8 @@ void helper_ocbi(CPUSH4State *env, uint32_t address)if ((a & ~0x1F ) == (address & ~0x1F )) {memory_content *next = (*current)->next; -cpu_stl_data (env, a, (*current)->value); + +cpu_stl_mmu (env, a, (*current)->value, oi,GETPC ());if (next ==NULL ) {
Signature · 1 line
2.52.0
[PULL v2 03/37] target/m68k: Use big-endian variant of cpu_ld/st_data*()
In reply to Philippe Mathieu-DaudéWe only build the M68k target using big endianness order, therefore the cpu_ld/st_data*() definitions expand to the big endian declarations. Use the explicit big-endian variants.
Mechanical change running:
$ tgt=m68k; \
end=be; \
for op in data mmuidx_ra; do \
for ac in uw sw l q; do \
sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
for ac in w l q; do \
sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
doneThen adapting indentation in do_stack_frame() to pass checkpatch.pl.
Message-Id: <[email protected]>
--- target/m68k/fpu_helper.c | 12 +++--- target/m68k/op_helper.c | 91 ++++++++++++++++++++-------------------- 2 files changed, 52 insertions(+), 51 deletions(-)
target/m68k/fpu_helper.c +6 -6
@@ -510,8 +510,8 @@ static int cpu_ld_floatx80_ra(CPUM68KState *env, uint32_t addr, FPReg *fp,uint32_t high;uint64_t low; - high =cpu_ldl_data_ra (env, addr, ra); - low =cpu_ldq_data_ra (env, addr +4 , ra); + high =cpu_ldl_be_data_ra (env, addr, ra); + low =cpu_ldq_be_data_ra (env, addr +4 , ra); fp->l.upper = high >>16 ; fp->l.lower = low;
@@ -522,8 +522,8 @@ static int cpu_ld_floatx80_ra(CPUM68KState *env, uint32_t addr, FPReg *fp,static int cpu_st_floatx80_ra (CPUM68KState *env,uint32_t addr,FPReg *fp,uintptr_t ra) { -cpu_stl_data_ra (env, addr, fp->l.upper <<16 , ra); -cpu_stq_data_ra (env, addr +4 , fp->l.lower, ra); +cpu_stl_be_data_ra (env, addr, fp->l.upper <<16 , ra); +cpu_stq_be_data_ra (env, addr +4 , fp->l.lower, ra);return 12 ; }
@@ -533,7 +533,7 @@ static int cpu_ld_float64_ra(CPUM68KState *env, uint32_t addr, FPReg *fp, {uint64_t val; - val =cpu_ldq_data_ra (env, addr, ra); + val =cpu_ldq_be_data_ra (env, addr, ra); fp->d =float64_to_floatx80 (*(float64 *)&val, &env->fp_status);return 8 ;
@@ -545,7 +545,7 @@ static int cpu_st_float64_ra(CPUM68KState *env, uint32_t addr, FPReg *fp,float64 val; val =floatx80_to_float64 (fp->d, &env->fp_status); -cpu_stq_data_ra (env, addr, *(uint64_t *)&val, ra); +cpu_stq_be_data_ra (env, addr, *(uint64_t *)&val, ra);return 8 ; }
target/m68k/op_helper.c +46 -45
207 lines not on this page · raw message
Signature · 1 line
2.52.0
[PULL v2 04/37] target/sparc: Use big-endian variant of cpu_ld/st_data*()
In reply to Philippe Mathieu-DaudéWe only build the SPARC targets using big endianness order, therefore the cpu_ld/st_data*() definitions expand to the big endian declarations. Use the explicit big-endian variants.
Mechanical change running:
$ tgt=sparc; \
end=be; \
for op in data mmuidx_ra; do \
for ac in uw sw l q; do \
sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
for ac in w l q; do \
sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
doneMessage-Id: <[email protected]>
--- target/sparc/ldst_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/sparc/ldst_helper.c +3 -3
@@ -1228,13 +1228,13 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, ret =cpu_ldub_data (env, addr);break ;case 2 : - ret =cpu_lduw_data (env, addr); + ret =cpu_lduw_be_data (env, addr);break ;case 4 : - ret =cpu_ldl_data (env, addr); + ret =cpu_ldl_be_data (env, addr);break ;case 8 : - ret =cpu_ldq_data (env, addr); + ret =cpu_ldq_be_data (env, addr);break ;default :g_assert_not_reached ();
Signature · 1 line
2.52.0
[PULL v2 06/37] target/ppc: Simplify endianness handling in Altivec opcodes
In reply to Philippe Mathieu-DaudéAccess the memory in big-endian order,
swap bytes when MSR.LE is set.
Message-Id: <[email protected]>
--- target/ppc/mem_helper.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
target/ppc/mem_helper.c +10 -21
@@ -31,15 +31,6 @@/* #define DEBUG_OP */ -static inline bool needs_byteswap (const CPUPPCState *env) -{ -#if TARGET_BIG_ENDIAN -return FIELD_EX64 (env->msr,MSR ,LE ); -#else -return !FIELD_EX64 (env->msr,MSR ,LE ); -#endif -} -/*****************************************************************************/ /* Memory load and stores */
@@ -401,11 +392,10 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg,int adjust =HI_IDX * (n_elems -1 ); \int sh =sizeof (r->element[0 ]) >>1 ; \int index = (addr &0xf ) >> sh; \ -if (FIELD_EX64 (env->msr,MSR ,LE )) { \ - index = n_elems - index -1 ; \ - } \ +bool byteswap =FIELD_EX64 (env->msr,MSR ,LE ); \ \ -if (needs_byteswap (env)) { \ +if (byteswap) { \ + index = n_elems - index -1 ; \ r->element[LO_IDX ? index : (adjust - index)] = \swap (access (env, addr,GETPC ())); \ }else { \
@@ -415,8 +405,8 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg, }#define I (x) (x) LVE(LVEBX, cpu_ldub_data_ra, I, u8) -LVE(LVEHX, cpu_lduw_data_ra, bswap16, u16) -LVE(LVEWX, cpu_ldl_data_ra, bswap32, u32) +LVE(LVEHX, cpu_lduw_be_data_ra, bswap16, u16) +LVE(LVEWX, cpu_ldl_be_data_ra, bswap32, u32)#undef I#undef LVE
@@ -428,11 +418,10 @@ LVE(LVEWX, cpu_ldl_data_ra, bswap32, u32)int adjust =HI_IDX * (n_elems -1 ); \int sh =sizeof (r->element[0 ]) >>1 ; \int index = (addr &0xf ) >> sh; \ -if (FIELD_EX64 (env->msr,MSR ,LE )) { \ - index = n_elems - index -1 ; \ - } \ +bool byteswap =FIELD_EX64 (env->msr,MSR ,LE ); \ \ -if (needs_byteswap (env)) { \ +if (byteswap) { \ + index = n_elems - index -1 ; \access (env, addr,swap (r->element[LO_IDX ? index : \ (adjust - index)]), \GETPC ()); \
@@ -443,8 +432,8 @@ LVE(LVEWX, cpu_ldl_data_ra, bswap32, u32) }#define I (x) (x) STVE(STVEBX, cpu_stb_data_ra, I, u8) -STVE(STVEHX, cpu_stw_data_ra, bswap16, u16) -STVE(STVEWX, cpu_stl_data_ra, bswap32, u32) +STVE(STVEHX, cpu_stw_be_data_ra, bswap16, u16) +STVE(STVEWX, cpu_stl_be_data_ra, bswap32, u32)#undef I#undef LVE
Signature · 1 line
2.52.0
[PULL v2 02/37] target/riscv: Use little-endian variant of cpu_ld/st_data*() for vector
In reply to Philippe Mathieu-DaudéRISC-V vector "elements are simply packed in order from the least-signicant to most-signicant bits of the vector register" [*] which is little endianness, therefore the cpu_ld/st_data*() definitions expand to the little endian declarations. Use the explicit little-endian variants.
[*] RISC-V "V" Vector Extension v1.0
Message-Id: <[email protected]>
--- target/riscv/vector_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target/riscv/vector_helper.c +6 -6
@@ -193,9 +193,9 @@ void NAME##_host(void *vd, uint32_t idx, void *host) \ } GEN_VEXT_LD_ELEM(lde_b, uint8_t, H1, ldub) -GEN_VEXT_LD_ELEM(lde_h, uint16_t, H2, lduw) -GEN_VEXT_LD_ELEM(lde_w, uint32_t, H4, ldl) -GEN_VEXT_LD_ELEM(lde_d, uint64_t, H8, ldq) +GEN_VEXT_LD_ELEM(lde_h, uint16_t, H2, lduw_le) +GEN_VEXT_LD_ELEM(lde_w, uint32_t, H4, ldl_le) +GEN_VEXT_LD_ELEM(lde_d, uint64_t, H8, ldq_le)#define GEN_VEXT_ST_ELEM (NAME ,ETYPE ,H ,STSUF ) \ static inline QEMU_ALWAYS_INLINE \
@@ -214,9 +214,9 @@ void NAME##_host(void *vd, uint32_t idx, void *host) \ } GEN_VEXT_ST_ELEM(ste_b, uint8_t, H1, stb) -GEN_VEXT_ST_ELEM(ste_h, uint16_t, H2, stw) -GEN_VEXT_ST_ELEM(ste_w, uint32_t, H4, stl) -GEN_VEXT_ST_ELEM(ste_d, uint64_t, H8, stq) +GEN_VEXT_ST_ELEM(ste_h, uint16_t, H2, stw_le) +GEN_VEXT_ST_ELEM(ste_w, uint32_t, H4, stl_le) +GEN_VEXT_ST_ELEM(ste_d, uint64_t, H8, stq_le) static inline QEMU_ALWAYS_INLINE void vext_continuous_ldst_tlb(CPURISCVState *env, vext_ldst_elem_fn_tlb *ldst_tlb,
Signature · 1 line
2.52.0
Richard Henderson
AppliedQuoted 15 lines · Philippe Mathieu-Daudé
The following changes since commit
2339d0a1cfac6ecc667e6e062a593865c1541c35:Merge tag 'hw-misc-20260120' ofhttps://github.com/philmd/qemu into staging (2026-01-21 07:39:57 +1100)are available in the Git repository at:
https://github.com/philmd/qemu.git tags/memory-api-20260122for you to fetch changes up to
1280ec826e98342db4e7c35daf7680d09121bde6:cpus: Allocate maximum number of ASes supported by the arch (2026-01-22 10:48:46 +0100)
----------------------------------------------------------------
Memory API patches
Quoted 6 lines
- Use explicit endianness for cpu_ld/st_data*() on some targets
- Reduce 'qemu/bswap.h' uses
- Introduce ldm_p/stm_p (MemOp) load/store helpers
- Allow restricting the legacy 'native-endian' APIs
- Forbid various targets to use legacy native endianness APIs
- Simplifycpu_address_space_init()API
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/11.0 as appropriate.
r~