hw: Preparatory cleanups previous to remove DEVICE_NATIVE_ENDIAN
v2 cover hw: Preparatory cleanups previous to remove DEVICE_NATIVE_ENDIAN
We want to remove the bogus DEVICE_NATIVE_ENDIAN definition, by making it explicit (either big or little).
I'll follow with one series for each architecture. These devices seem used by more than one, so I took them apart.
Also remove from rust API ASAP.
tag: https://gitlab.com/philmd/qemu/-/tags/endian_misc_hw-v2
CI: https://gitlab.com/philmd/qemu/-/pipelines/2231223066
Philippe Mathieu-Daudé (8):
hw/arm/Kconfig: Have FSL_IMX6UL SoC select IMX_USBPHY hw/net/opencores: Clarify MMIO read/write handlers expect 32-bit
access
hw/char/serial: Let compiler pick serial_mm_ops[] array length hw/misc/pvpanic: Expose MMIO interface as little-endian hw/timer/hpet: Mark implementation as being little-endian hw/char/pl011: Mark implementation as being little-endian rust/system: Stop exposing bogus DEVICE_NATIVE_ENDIAN symbol target/hexagon: Include missing 'cpu.h' header in 'internal.h'
target/hexagon/internal.h | 2 +- hw/char/pl011.c | 2 +- hw/char/serial-mm.c | 2 +- hw/misc/pvpanic.c | 1 + hw/net/opencores_eth.c | 15 +++++++++------ hw/timer/hpet.c | 2 +- hw/arm/Kconfig | 1 + hw/usb/Kconfig | 1 - rust/hw/char/pl011/src/device.rs | 2 +- rust/hw/timer/hpet/src/device.rs | 2 +- rust/system/src/memory.rs | 6 ------ 11 files changed, 17 insertions(+), 19 deletions(-)
Signature · 1 line
2.52.0
PATCH v2 1/8 hw/arm/Kconfig: Have FSL_IMX6UL SoC select IMX_USBPHY
Since commit 17372bd812d, the SoC used by the mcimx6ul-evk machine requires the IMX USB PHY component.
As this component is only used by 2 machines, do not select it by default (it will be automatically selected when necessary).
--- hw/arm/Kconfig | 1 + hw/usb/Kconfig | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
hw/arm/Kconfig +1 -0
@@ -638,6 +638,7 @@ config FSL_IMX6UL select IMX select IMX_FEC select IMX_I2C + select IMX_USBPHY select WDT_IMX2 select SDHCI select USB_CHIPIDEA
hw/usb/Kconfig +0 -1
@@ -132,7 +132,6 @@ config USB_CANOKEY config IMX_USBPHY bool - default y depends on USB config USB_DWC3
Signature · 1 line
2.52.0
Re: [PATCH v2 1/8] hw/arm/Kconfig: Have FSL_IMX6UL SoC select IMX_USBPHY
Quoted 6 lines · Philippe Mathieu-Daudé
Since commit
17372bd812d, the SoC used by the mcimx6ul-evk machine requires the IMX USB PHY component.
As this component is only used by 2 machines, do not select it by default (it will be automatically selected when necessary).
Quoted 7 lines
Fixes 17372bd812d ("hw/arm/fsl-imx6ul: Wire up USB controllers")Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Thomas Huth<[email protected]>--- hw/arm/Kconfig | 1 + hw/usb/Kconfig | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
r~
PATCH v2 2/8 hw/net/opencores: Clarify MMIO read/write handlers expect 32-bit access
In reply to Philippe Mathieu-DaudéThe read/write handlers access array of 32-bit register by index:
277 struct OpenEthState {
..
287 uint32_t regs[REG_MAX];
..
291 };
546 static uint64_t open_eth_reg_read(void *opaque,
547 hwaddr addr, unsigned int size)
548 {
..
551 OpenEthState *s = opaque;
552 unsigned idx = addr / 4;
..
559 v = s->regs[idx];
..
563 return v;
564 }
This is a 32-bit implementation. Make that explicit in the MemoryRegionOps structure (this doesn't change the maximum access size, which -- being unset -- is 64-bit).
Move the structure just after the handlers to ease code review.
--- hw/net/opencores_eth.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
hw/net/opencores_eth.c +9 -6
@@ -682,6 +682,15 @@ static void open_eth_reg_write(void *opaque, } } +static const MemoryRegionOps open_eth_reg_ops = { + .read = open_eth_reg_read, + .write = open_eth_reg_write, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, +}; +static uint64_t open_eth_desc_read (void *opaque,hwaddr addr,unsigned int size) {
@@ -705,12 +714,6 @@ static void open_eth_desc_write(void *opaque,open_eth_check_start_xmit (s); } - -static const MemoryRegionOps open_eth_reg_ops = { - .read = open_eth_reg_read, - .write = open_eth_reg_write, -}; -static const MemoryRegionOps open_eth_desc_ops = { .read = open_eth_desc_read, .write = open_eth_desc_write,
Signature · 1 line
2.52.0
PATCH v2 3/8 hw/char/serial: Let compiler pick serial_mm_ops[] array length
In reply to Philippe Mathieu-DaudéNo need to enforce the MemoryRegionOps array length. We index by device_endian enum, the compiler will easily pick the correct length. Besides, this allow further adjustments in the device_endian enum itself.
--- hw/char/serial-mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/serial-mm.c +1 -1
@@ -44,7 +44,7 @@ static void serial_mm_write(void *opaque, hwaddr addr, serial_io_ops.write (&s->serial, addr >> s->regshift, value,1 ); } -static const MemoryRegionOps serial_mm_ops[3 ] = { +static const MemoryRegionOps serial_mm_ops[] = { [DEVICE_NATIVE_ENDIAN ] = { .read = serial_mm_read, .write = serial_mm_write,
Signature · 1 line
2.52.0
PATCH v2 4/8 hw/misc/pvpanic: Expose MMIO interface as little-endian
In reply to Philippe Mathieu-DaudéMake the PVPanic MMIO interface behave like the ISA and PCI
variants: access it using little endianness.
--- hw/misc/pvpanic.c | 1 + 1 file changed, 1 insertion(+)
hw/misc/pvpanic.c +1 -0
@@ -62,6 +62,7 @@ static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val, }static const MemoryRegionOps pvpanic_ops = { + .endianness =DEVICE_LITTLE_ENDIAN , .read = pvpanic_read, .write = pvpanic_write, .impl = {
Signature · 1 line
2.52.0
Re: [PATCH v2 4/8] hw/misc/pvpanic: Expose MMIO interface as little-endian
+Alex/Phil
Quoted 21 lines · Philippe Mathieu-Daudé
Make the PVPanic MMIO interface behave like the ISA and PCI
variants: access it using little endianness.Fixes a89607c4d0e ("hw/misc/pvpanic: Add MMIO interface")Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/misc/pvpanic.c | 1 + 1 file changed, 1 insertion(+)hw/misc/pvpanic.c +1
-0@@ -62,6 +62,7 @@ static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val, }static const MemoryRegionOps pvpanic_ops = { + .endianness =DEVICE_LITTLE_ENDIAN , .read = pvpanic_read, .write = pvpanic_write, .impl = {
Re: [PATCH v2 4/8] hw/misc/pvpanic: Expose MMIO interface as little-endian
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
Make the PVPanic MMIO interface behave like the ISA and PCI
variants: access it using little endianness.Fixes a89607c4d0e ("hw/misc/pvpanic: Add MMIO interface")Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 18 lines
hw/misc/pvpanic.c | 1 + 1 file changed, 1 insertion(+)hw/misc/pvpanic.c +1
-1@@ -62,6 +62,7 @@ static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val, }static const MemoryRegionOps pvpanic_ops = { + .endianness =DEVICE_LITTLE_ENDIAN , .read = pvpanic_read, .write = pvpanic_write, .impl = { --2.52.0
PATCH v2 5/8 hw/timer/hpet: Mark implementation as being little-endian
In reply to Philippe Mathieu-DaudéThe HPET component is only built / used by X86 targets, which are only built in little endianness. Thus we only ever built as little endian, never testing the big-endian possibility of the DEVICE_NATIVE_ENDIAN definition. Simplify by only keeping the little endian variant.
--- hw/timer/hpet.c | 2 +- rust/hw/timer/hpet/src/device.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/timer/hpet.c +1 -1
@@ -648,7 +648,7 @@ static const MemoryRegionOps hpet_ram_ops = { .min_access_size = 4, .max_access_size = 8, }, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, };static void hpet_reset (DeviceState *d)
rust/hw/timer/hpet/src/device.rs +1 -1
@@ -708,7 +708,7 @@ unsafe fn init(mut this: ParentInit<Self>) {MemoryRegionOpsBuilder ::<HPETState >::new () .read (&HPETState ::read) .write (&HPETState ::write) - .native_endian () + .little_endian () .valid_sizes (4 ,8 ) .impl_sizes (4 ,8 ) .build ();
Signature · 1 line
2.52.0
Re: [PATCH v2 5/8] hw/timer/hpet: Mark implementation as being little-endian
Quoted 12 lines · Philippe Mathieu-Daudé
Date: Wed, 24 Dec 2025 14:46:41 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v2 5/8] hw/timer/hpet: Mark implementation as being
little-endian
X-Mailer: git-send-email 2.52.0The HPET component is only built / used by X86 targets, which are only built in little endianness. Thus we only ever built as little endian, never testing the big-endian possibility of the
DEVICE_NATIVE_ENDIANdefinition. Simplify by only keeping the little endian variant.
Quoted 6 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- hw/timer/hpet.c | 2 +- rust/hw/timer/hpet/src/device.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
PATCH v2 6/8 hw/char/pl011: Mark implementation as being little-endian
In reply to Philippe Mathieu-DaudéThe PL011 component is only built / used by ARM targets, which are only built in little endianness. Thus we only ever built as little endian, never testing the big-endian possibility of the DEVICE_NATIVE_ENDIAN definition. Simplify by only keeping the little endian variant.
--- hw/char/pl011.c | 2 +- rust/hw/char/pl011/src/device.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/char/pl011.c +1 -1
@@ -538,7 +538,7 @@ static void pl011_clock_update(void *opaque, ClockEvent event)static const MemoryRegionOps pl011_ops = { .read = pl011_read, .write = pl011_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_LITTLE_ENDIAN , .impl.min_access_size =4 , .impl.max_access_size =4 , };
rust/hw/char/pl011/src/device.rs +1 -1
@@ -495,7 +495,7 @@ unsafe fn init(mut this: ParentInit<Self>) {static PL011_OPS :MemoryRegionOps <PL011State > =MemoryRegionOpsBuilder ::<PL011State >::new () .read (&PL011State ::read) .write (&PL011State ::write) - .native_endian () + .little_endian () .impl_sizes (4 ,4 ) .build ();
Signature · 1 line
2.52.0
Re: [PATCH v2 6/8] hw/char/pl011: Mark implementation as being little-endian
Quoted 10 lines · Philippe Mathieu-Daudé
The PL011 component is only built / used by ARM targets, which are only built in little endianness. Thus we only ever built as little endian, never testing the big-endian possibility of the
DEVICE_NATIVE_ENDIANdefinition. Simplify by only keeping the little endian variant.Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>---
FWIW
Quoted 33 lines
hw/char/pl011.c | 2 +- rust/hw/char/pl011/src/device.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/char/pl011.c +1
-1@@ -538,7 +538,7 @@ static void pl011_clock_update(void *opaque, ClockEvent event)static const MemoryRegionOps pl011_ops = { .read = pl011_read, .write = pl011_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_LITTLE_ENDIAN , .impl.min_access_size =4 , .impl.max_access_size =4 , };rust/hw/char/pl011/src/device.rs +1
-2@@ -495,7 +495,7 @@ unsafe fn init(mut this: ParentInit<Self>) {static PL011_OPS :MemoryRegionOps <PL011State > =MemoryRegionOpsBuilder ::<PL011State >::new () .read (&PL011State ::read) .write (&PL011State ::write) - .native_endian () + .little_endian () .impl_sizes (4 ,4 ) .build (); --2.52.0
Re: [PATCH v2 6/8] hw/char/pl011: Mark implementation as being little-endian
In reply to Philippe Mathieu-DaudéQuoted 12 lines · Philippe Mathieu-Daudé
Date: Wed, 24 Dec 2025 14:46:42 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v2 6/8] hw/char/pl011: Mark implementation as being
little-endian
X-Mailer: git-send-email 2.52.0The PL011 component is only built / used by ARM targets, which are only built in little endianness. Thus we only ever built as little endian, never testing the big-endian possibility of the
DEVICE_NATIVE_ENDIANdefinition. Simplify by only keeping the little endian variant.
Quoted 6 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- hw/char/pl011.c | 2 +- rust/hw/char/pl011/src/device.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
PATCH v2 7/8 rust/system: Stop exposing bogus DEVICE_NATIVE_ENDIAN symbol
In reply to Philippe Mathieu-DaudéWe want to remove the bogus DEVICE_NATIVE_ENDIAN definition (by only having it explicit, either big or little one). Stop exposing it to rust devices to avoid it spreading further.
--- rust/system/src/memory.rs | 6 ------ 1 file changed, 6 deletions(-)
rust/system/src/memory.rs +0 -6
@@ -78,12 +78,6 @@ pub const fn little_endian(mut self) -> Self { self } -#[must_use] -pub const fn native_endian (mut self) ->Self { - self.0 .endianness = device_endian::DEVICE_NATIVE_ENDIAN ; - self - } -#[must_use] pub const fn valid_sizes (mut self, min:u32 , max:u32 ) ->Self { self.0 .valid.min_access_size = min;
Signature · 1 line
2.52.0
Re: [PATCH v2 7/8] rust/system: Stop exposing bogus DEVICE_NATIVE_ENDIAN symbol
Quoted 8 lines · Philippe Mathieu-Daudé
We want to remove the bogus
DEVICE_NATIVE_ENDIANdefinition (by only having it explicit, either big or little one). Stop exposing it to rust devices to avoid it spreading further.Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>---
Quoted 23 lines
rust/system/src/memory.rs | 6 ------ 1 file changed, 6 deletions(-)rust/system/src/memory.rs +0
-7@@ -78,12 +78,6 @@ pub const fn little_endian(mut self) -> Self { self } -#[must_use] -pub const fn native_endian (mut self) ->Self { - self.0 .endianness = device_endian::DEVICE_NATIVE_ENDIAN ; - self - } -#[must_use] pub const fn valid_sizes (mut self, min:u32 , max:u32 ) ->Self { self.0 .valid.min_access_size = min; --2.52.0
Re: [PATCH v2 7/8] rust/system: Stop exposing bogus DEVICE_NATIVE_ENDIAN symbol
In reply to Philippe Mathieu-DaudéQuoted 10 lines · Philippe Mathieu-Daudé
Date: Wed, 24 Dec 2025 14:46:43 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v2 7/8]rust/system: Stop exposing bogus
DEVICE_NATIVE_ENDIANsymbol
X-Mailer: git-send-email 2.52.0We want to remove the bogus
DEVICE_NATIVE_ENDIANdefinition (by only having it explicit, either big or little one). Stop exposing it to rust devices to avoid it spreading further.
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- rust/system/src/memory.rs | 6 ------ 1 file changed, 6 deletions(-)
Good. I suppose this could help simplify vm-memory support.
PATCH v2 8/8 target/hexagon: Include missing 'cpu.h' header in 'internal.h'
In reply to Philippe Mathieu-DaudéBoth CPUHexagonState and TOTAL_PER_THREAD_REGS are defined in "cpu.h" which is luckily indirectly included. However when refactoring unrelated files we get:
In file included from target/hexagon/helper.h:18,
from include/exec/helper-proto.h.inc:56,
from include/exec/helper-proto.h:13,
from target/hexagon/op_helper.c:22:
target/hexagon/internal.h: At top level:
target/hexagon/internal.h:29:25: error: unknown type name ‘CPUHexagonState’; did you mean ‘CPUPluginState’?
29 | void hexagon_debug_vreg(CPUHexagonState *env, int regnum);
| ^~~~~~~~~~~~~~~
| CPUPluginState
target/hexagon/internal.h:30:25: error: unknown type name ‘CPUHexagonState’; did you mean ‘CPUPluginState’?
30 | void hexagon_debug_qreg(CPUHexagonState *env, int regnum);
| ^~~~~~~~~~~~~~~
| CPUPluginState
target/hexagon/internal.h:31:20: error: unknown type name ‘CPUHexagonState’; did you mean ‘CPUPluginState’?
31 | void hexagon_debug(CPUHexagonState *env);
| ^~~~~~~~~~~~~~~
| CPUPluginState
target/hexagon/internal.h:33:44: error: ‘TOTAL_PER_THREAD_REGS’ undeclared here (not in a function)
33 | extern const char * const hexagon_regnames[TOTAL_PER_THREAD_REGS];
| ^~~~~~~~~~~~~~~~~~~~~Fix that by including the missing header.
We don't need the "qemu/log.h" since commit 0cb73cb5a02 ("target/hexagon:
Remove HEX_DEBUG/HEX_DEBUG_LOG"): remove it.
--- target/hexagon/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/hexagon/internal.h +1 -1
@@ -18,7 +18,7 @@#ifndef HEXAGON_INTERNAL_H #define HEXAGON_INTERNAL_H -#include "qemu/log.h" +#include "target/hexagon/cpu.h" int hexagon_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int hexagon_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
Signature · 1 line
2.52.0
Quoted 10 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (8):
hw/arm/Kconfig: HaveFSL_IMX6ULSoC selectIMX_USBPHYhw/net/opencores: Clarify MMIO read/write handlers expect 32-bit
access
hw/char/serial: Let compiler pick serial_mm_ops[] array length hw/misc/pvpanic: Expose MMIO interface as little-endian hw/timer/hpet: Mark implementation as being little-endian hw/char/pl011: Mark implementation as being little-endianrust/system: Stop exposing bogusDEVICE_NATIVE_ENDIANsymbol target/hexagon: Include missing 'cpu.h' header in 'internal.h'
Series queued.