target/i386: Stop using the legacy ldst_phys() API
cover target/i386: Stop using the legacy ldst_phys() API
Mostly mechanical changes to stop using the legacy ldst_phys() API on the x86 targets.
Philippe Mathieu-Daudé (4):
target/i386: Use explicit little-endian LD/ST API hw/intc: Mark x86-specific [IO]APIC peripherals as little-endian hw/intc/ioapic: Replace legacy st_phys() -> address_space_st() configs/targets: Restrict the legacy ldst_phys() API on x86 targets
configs/targets/i386-softmmu.mak | 1 + configs/targets/x86_64-softmmu.mak | 1 + hw/intc/apic.c | 2 +- hw/intc/ioapic.c | 5 +++-- target/i386/helper.c | 12 ++++++------ target/i386/tcg/system/misc_helper.c | 16 ++++++++-------- 6 files changed, 20 insertions(+), 17 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/4 target/i386: Use explicit little-endian LD/ST API
The x86 architecture uses little endianness. Directly use the little-endian LD/ST API.
Mechanical change running:
$ for a in uw w l q; do \
sed -i -e "s/ld${a}_p(/ld${a}_le_p(/" \
$(git grep -wlE '(ld|st)u?[wlq]_p' target/i386/);
doneCoding style adapted manually.
--- target/i386/helper.c | 12 ++++++------ target/i386/tcg/system/misc_helper.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-)
target/i386/helper.c +6 -6
@@ -669,7 +669,7 @@ uint32_t x86_lduw_phys(CPUState *cs, hwaddr addr)MemTxAttrs attrs =cpu_get_mem_attrs (env);AddressSpace *as =cpu_addressspace (cs, attrs); -return address_space_lduw (as, addr, attrs,NULL ); +return address_space_lduw_le (as, addr, attrs,NULL ); }uint32_t x86_ldl_phys (CPUState *cs,hwaddr addr)
@@ -679,7 +679,7 @@ uint32_t x86_ldl_phys(CPUState *cs, hwaddr addr)MemTxAttrs attrs =cpu_get_mem_attrs (env);AddressSpace *as =cpu_addressspace (cs, attrs); -return address_space_ldl (as, addr, attrs,NULL ); +return address_space_ldl_le (as, addr, attrs,NULL ); }uint64_t x86_ldq_phys (CPUState *cs,hwaddr addr)
@@ -689,7 +689,7 @@ uint64_t x86_ldq_phys(CPUState *cs, hwaddr addr)MemTxAttrs attrs =cpu_get_mem_attrs (env);AddressSpace *as =cpu_addressspace (cs, attrs); -return address_space_ldq (as, addr, attrs,NULL ); +return address_space_ldq_le (as, addr, attrs,NULL ); }void x86_stb_phys (CPUState *cs,hwaddr addr,uint8_t val)
@@ -709,7 +709,7 @@ void x86_stw_phys(CPUState *cs, hwaddr addr, uint32_t val)MemTxAttrs attrs =cpu_get_mem_attrs (env);AddressSpace *as =cpu_addressspace (cs, attrs); -address_space_stw (as, addr, val, attrs,NULL ); +address_space_stw_le (as, addr, val, attrs,NULL ); }void x86_stl_phys (CPUState *cs,hwaddr addr,uint32_t val)
@@ -719,7 +719,7 @@ void x86_stl_phys(CPUState *cs, hwaddr addr, uint32_t val)MemTxAttrs attrs =cpu_get_mem_attrs (env);AddressSpace *as =cpu_addressspace (cs, attrs); -address_space_stl (as, addr, val, attrs,NULL ); +address_space_stl_le (as, addr, val, attrs,NULL ); }void x86_stq_phys (CPUState *cs,hwaddr addr,uint64_t val)
@@ -729,6 +729,6 @@ void x86_stq_phys(CPUState *cs, hwaddr addr, uint64_t val)MemTxAttrs attrs =cpu_get_mem_attrs (env);AddressSpace *as =cpu_addressspace (cs, attrs); - address_space_stq(as, addr, val, attrs, NULL); + address_space_stq_le(as, addr, val, attrs, NULL); }#endif
target/i386/tcg/system/misc_helper.c +8 -8
@@ -42,26 +42,26 @@ target_ulong helper_inb(CPUX86State *env, uint32_t port)void helper_outw (CPUX86State *env,uint32_t port,uint32_t data) { -address_space_stw (&address_space_io, port, data, -cpu_get_mem_attrs (env),NULL ); +address_space_stw_le (&address_space_io, port, data, +cpu_get_mem_attrs (env),NULL ); }target_ulong helper_inw (CPUX86State *env,uint32_t port) { -return address_space_lduw (&address_space_io, port, -cpu_get_mem_attrs (env),NULL ); +return address_space_lduw_le (&address_space_io, port, +cpu_get_mem_attrs (env),NULL ); }void helper_outl (CPUX86State *env,uint32_t port,uint32_t data) { -address_space_stl (&address_space_io, port, data, -cpu_get_mem_attrs (env),NULL ); +address_space_stl_le (&address_space_io, port, data, +cpu_get_mem_attrs (env),NULL ); }target_ulong helper_inl (CPUX86State *env,uint32_t port) { -return address_space_ldl (&address_space_io, port, -cpu_get_mem_attrs (env),NULL ); +return address_space_ldl_le (&address_space_io, port, +cpu_get_mem_attrs (env),NULL ); }target_ulong helper_read_cr8 (CPUX86State *env)
Signature · 1 line
2.52.0
PATCH 2/4 hw/intc: Mark x86-specific [IO]APIC peripherals as little-endian
In reply to Philippe Mathieu-DaudéThese devices are only used by the x86 targets, which are only built as little-endian. Therefore the DEVICE_NATIVE_ENDIAN definition expand to DEVICE_LITTLE_ENDIAN (besides, the DEVICE_BIG_ENDIAN case isn't tested). Simplify directly using DEVICE_LITTLE_ENDIAN.
--- hw/intc/apic.c | 2 +- hw/intc/ioapic.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/intc/apic.c +1 -1
@@ -1108,7 +1108,7 @@ static const MemoryRegionOps apic_io_ops = { .impl.max_access_size = 4, .valid.min_access_size = 1, .valid.max_access_size = 4, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, };static void apic_realize (DeviceState *dev,Error **errp)
hw/intc/ioapic.c +1 -1
@@ -429,7 +429,7 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t val,static const MemoryRegionOps ioapic_io_ops = { .read = ioapic_mem_read, .write = ioapic_mem_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_LITTLE_ENDIAN , };static void ioapic_machine_done_notify (Notifier *notifier,void *data)
Signature · 1 line
2.52.0
PATCH 3/4 hw/intc/ioapic: Replace legacy st_phys() -> address_space_st()
In reply to Philippe Mathieu-DaudéPrefer the address_space_ld/st API over the legacy ld_phys() because it allow checking for bus access fault. However the IOAPIC datasheet (82093AA Order Number: 290566-001) doesn't mention any fault occuring when the system bus (ISA bus) is accessed. The ISA bus neither offer a way to signal recoverable access faults. Therefore just inline the stl_le_phys() call, not specifying any memory transaction attribute nor expecting transation result, per the definition in "system/memory_ldst_phys_endian.h.inc":
42 static inline void ST_PHYS(l)(ARG1_DECL, hwaddr addr, uint32_t val)
43 {
44 ADDRESS_SPACE_ST(l)(ARG1, addr, val, MEMTXATTRS_UNSPECIFIED, NULL);
45 }No logical change intended.
--- hw/intc/ioapic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/intc/ioapic.c +2 -1
@@ -141,7 +141,8 @@ static void ioapic_service(IOAPICCommonState *s)* the IOAPIC message into a MSI one, and its * address space will decide whether we need a * translation. */ -stl_le_phys (ioapic_as, info.addr, info.data); +address_space_stl_le (ioapic_as, info.addr, info.data, +MEMTXATTRS_UNSPECIFIED ,NULL ); } } }
Signature · 1 line
2.52.0
PATCH 4/4 configs/targets: Restrict the legacy ldst_phys() API on x86 targets
In reply to Philippe Mathieu-DaudéThe x86 targets don't use the legacy ldst_phys() API anymore. Set the TARGET_NOT_USING_LEGACY_LDST_PHYS_API variable to hide the legacy API to the x86 binaries, avoiding further API uses to creep in.
--- configs/targets/i386-softmmu.mak | 1 + configs/targets/x86_64-softmmu.mak | 1 + 2 files changed, 2 insertions(+)
configs/targets/i386-softmmu.mak +1 -0
@@ -3,3 +3,4 @@ TARGET_KVM_HAVE_GUEST_DEBUG=y TARGET_KVM_HAVE_RESET_PARKED_VCPU=y TARGET_XML_FILES= gdb-xml/i386-32bit.xml TARGET_LONG_BITS=32 +TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
configs/targets/x86_64-softmmu.mak +1 -0
@@ -4,3 +4,4 @@ TARGET_KVM_HAVE_GUEST_DEBUG=y TARGET_KVM_HAVE_RESET_PARKED_VCPU=y TARGET_XML_FILES= gdb-xml/i386-64bit.xml gdb-xml/i386-64bit-apx.xml TARGET_LONG_BITS=64 +TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
Signature · 1 line
2.52.0
Quoted 5 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (4):
target/i386: Use explicit little-endian LD/ST API hw/intc: Mark x86-specific [IO]APIC peripherals as little-endian hw/intc/ioapic: Replace legacyst_phys()->address_space_st()configs/targets: Restrict the legacyldst_phys()API on x86 targets
r~
Quoted 5 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (4):
target/i386: Use explicit little-endian LD/ST API hw/intc: Mark x86-specific [IO]APIC peripherals as little-endian hw/intc/ioapic: Replace legacyst_phys()->address_space_st()configs/targets: Restrict the legacyldst_phys()API on x86 targets
Series queued, thanks.