hw/microblaze: Allow running cross-endian vCPUs
v3 cover hw/microblaze: Allow running cross-endian vCPUs
Missing review: 4 (new) & 10
Since v2:
- Addressed Richard's review comments
Since v1:
- Make device endianness configurable (Edgar)
- Convert more Xilinx devices
- Avoid preprocessor #if (Richard)
- Add R-b tags
Make machines endianness-agnostic, allowing to run a big-endian vCPU on the little-endian 'qemu-system-microblazeel' binary, and a little endian one on the big-endian 'qemu-system-microblaze' binary.
Tests added, following combinations covered:
- little-endian vCPU using little-endian binary (in-tree)
- little-endian vCPU using big-endian binary (new)
- big-endian vCPU using little-endian binary (new)
- big-endian vCPU using big-endian binary (in-tree)
To make a target endian-agnostic we need to remove the MO_TE uses. In order to do that, we propagate the MemOp from earlier in the call stack, or we extract it from the vCPU env (on MicroBlaze the CPU endianness is exposed by the 'ENDI' bit).
Next step: Look at unifying binaries.
Please review,
Phil.
Philippe Mathieu-Daudé (17):
hw/microblaze: Restrict MemoryRegionOps are implemented as 32-bit hw/microblaze: Propagate CPU endianness to microblaze_load_kernel() hw/intc/xilinx_intc: Make device endianness configurable RFC hw/net/xilinx_ethlite: Simplify by having configurable endianness RFC hw/timer/xilinx_timer: Allow down to 8-bit memory access hw/timer/xilinx_timer: Make device endianness configurable hw/char/xilinx_uartlite: Make device endianness configurable hw/ssi/xilinx_spi: Make device endianness configurable hw/ssi/xilinx_spips: Make device endianness configurable hw/arm/xlnx-zynqmp: Use &error_abort for programming errors target/microblaze: Explode MO_TExx -> MO_TE | MO_xx target/microblaze: Set MO_TE once in do_load() / do_store() target/microblaze: Introduce mo_endian() helper target/microblaze: Consider endianness while translating code hw/microblaze: Support various endianness for s3adsp1800 machines tests/functional: Explicit endianness of microblaze assets tests/functional: Add microblaze cross-endianness tests
hw/microblaze/boot.h | 4 +- include/hw/ssi/xilinx_spips.h | 1 + target/microblaze/cpu.h | 7 +++ hw/arm/xilinx_zynq.c | 1 + hw/arm/xlnx-zynqmp.c | 40 +++++-------- hw/char/xilinx_uartlite.c | 31 ++++++---- hw/intc/xilinx_intc.c | 50 ++++++++++++---- hw/microblaze/boot.c | 8 +-- hw/microblaze/petalogix_ml605_mmu.c | 4 +- hw/microblaze/petalogix_s3adsp1800_mmu.c | 58 ++++++++++++++++--- hw/microblaze/xlnx-zynqmp-pmu.c | 2 +- hw/net/xilinx_ethlite.c | 42 +++++++++----- hw/ppc/virtex_ml507.c | 1 + hw/ssi/xilinx_spi.c | 24 +++++--- hw/ssi/xilinx_spips.c | 36 +++++++----- hw/timer/xilinx_timer.c | 33 +++++++---- target/microblaze/translate.c | 49 ++++++++++------ .../functional/test_microblaze_s3adsp1800.py | 27 ++++++++- .../test_microblazeel_s3adsp1800.py | 25 +++++++- 19 files changed, 309 insertions(+), 134 deletions(-)
Signature · 1 line
2.45.2
PATCH v3 1/17 hw/microblaze: Restrict MemoryRegionOps are implemented as 32-bit
All these MemoryRegionOps read() and write() handlers are implemented expecting 32-bit accesses. Clarify that setting .impl.min/max_access_size fields.
Message-Id: <[email protected]>
--- hw/char/xilinx_uartlite.c | 4 ++++ hw/intc/xilinx_intc.c | 4 ++++ hw/net/xilinx_ethlite.c | 4 ++++ hw/timer/xilinx_timer.c | 4 ++++ 4 files changed, 16 insertions(+)
hw/char/xilinx_uartlite.c +4 -0
@@ -170,6 +170,10 @@ static const MemoryRegionOps uart_ops = { .read = uart_read, .write = uart_write, .endianness = DEVICE_NATIVE_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, .valid = { .min_access_size =1 , .max_access_size = 4
hw/intc/xilinx_intc.c +4 -0
@@ -144,6 +144,10 @@ static const MemoryRegionOps pic_ops = { .read = pic_read, .write = pic_write, .endianness = DEVICE_NATIVE_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, .valid = { .min_access_size =4 , .max_access_size = 4
hw/net/xilinx_ethlite.c +4 -0
@@ -170,6 +170,10 @@ static const MemoryRegionOps eth_ops = { .read = eth_read, .write = eth_write, .endianness = DEVICE_NATIVE_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, .valid = { .min_access_size =4 , .max_access_size = 4
hw/timer/xilinx_timer.c +4 -0
@@ -193,6 +193,10 @@ static const MemoryRegionOps timer_ops = { .read = timer_read, .write = timer_write, .endianness = DEVICE_NATIVE_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, .valid = { .min_access_size =4 , .max_access_size = 4
Signature · 1 line
2.45.2
PATCH v3 2/17 hw/microblaze: Propagate CPU endianness to microblaze_load_kernel()
In reply to Philippe Mathieu-DaudéPass vCPU endianness as argument so we can load kernels with different endianness (different from the qemu-system-binary builtin one).
--- hw/microblaze/boot.h | 4 ++-- hw/microblaze/boot.c | 8 ++++---- hw/microblaze/petalogix_ml605_mmu.c | 2 +- hw/microblaze/petalogix_s3adsp1800_mmu.c | 2 +- hw/microblaze/xlnx-zynqmp-pmu.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
hw/microblaze/boot.h +2 -2
@@ -2,8 +2,8 @@#define MICROBLAZE_BOOT_H -void microblaze_load_kernel (MicroBlazeCPU *cpu,hwaddr ddr_base, -uint32_t ramsize, +void microblaze_load_kernel (MicroBlazeCPU *cpu,bool is_little_endian, +hwaddr ddr_base,uint32_t ramsize,const char *initrd_filename,const char *dtb_filename,void (*machine_cpu_reset)(MicroBlazeCPU *));
hw/microblaze/boot.c +4 -4
@@ -114,8 +114,8 @@ static uint64_t translate_kernel_address(void *opaque, uint64_t addr)return addr -0x30000000LL ; } -void microblaze_load_kernel (MicroBlazeCPU *cpu,hwaddr ddr_base, -uint32_t ramsize, +void microblaze_load_kernel (MicroBlazeCPU *cpu,bool is_little_endian, +hwaddr ddr_base,uint32_t ramsize,const char *initrd_filename,const char *dtb_filename,void (*machine_cpu_reset)(MicroBlazeCPU *))
@@ -144,13 +144,13 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,/* Boots a kernel elf binary. */ kernel_size =load_elf (kernel_filename,NULL ,NULL ,NULL , &entry,NULL , &high,NULL , -TARGET_BIG_ENDIAN ,EM_MICROBLAZE ,0 ,0 ); + !is_little_endian,EM_MICROBLAZE ,0 ,0 ); base32 = entry;if (base32 ==0xc0000000 ) { kernel_size =load_elf (kernel_filename,NULL , translate_kernel_address,NULL , &entry,NULL ,NULL ,NULL , -TARGET_BIG_ENDIAN ,EM_MICROBLAZE ,0 ,0 ); + !is_little_endian,EM_MICROBLAZE ,0 ,0 ); }/* Always boot into physical ram. */ boot_info.bootstrap_pc = (uint32_t )entry;
hw/microblaze/petalogix_ml605_mmu.c +1 -1
@@ -204,7 +204,7 @@ petalogix_ml605_init(MachineState *machine) cpu->cfg.pvr_regs[5 ] =0xc56be000 ; cpu->cfg.pvr_regs[10 ] =0x0e000000 ;/* virtex 6 */ -microblaze_load_kernel (cpu,MEMORY_BASEADDR , ram_size, +microblaze_load_kernel (cpu, true,MEMORY_BASEADDR , ram_size, machine->initrd_filename,BINARY_DEVICE_TREE_FILE ,NULL );
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -1
@@ -129,7 +129,7 @@ petalogix_s3adsp1800_init(MachineState *machine)create_unimplemented_device ("xps_gpio" ,GPIO_BASEADDR ,0x10000 ); -microblaze_load_kernel (cpu, ddr_base, ram_size, +microblaze_load_kernel (cpu, !TARGET_BIG_ENDIAN , ddr_base, ram_size, machine->initrd_filename,BINARY_DEVICE_TREE_FILE ,NULL );
hw/microblaze/xlnx-zynqmp-pmu.c +1 -1
@@ -172,7 +172,7 @@ static void xlnx_zynqmp_pmu_init(MachineState *machine)qdev_realize (DEVICE (pmu),NULL , &error_fatal);/* Load the kernel */ - microblaze_load_kernel(&pmu->cpu, XLNX_ZYNQMP_PMU_RAM_ADDR, + microblaze_load_kernel(&pmu->cpu, true, XLNX_ZYNQMP_PMU_RAM_ADDR, machine->ram_size, machine->initrd_filename, machine->dtb,
Signature · 1 line
2.45.2
PATCH v3 3/17 hw/intc/xilinx_intc: Make device endianness configurable
In reply to Philippe Mathieu-DaudéReplace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device endianness, defaulting to little endian.
Set the proper endianness for each machine using the device.
--- hw/intc/xilinx_intc.c | 52 +++++++++++++++++------- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + 3 files changed, 40 insertions(+), 14 deletions(-)
hw/intc/xilinx_intc.c +38 -14
@@ -3,6 +3,9 @@* * Copyright (c) 2009 Edgar E. Iglesias. * +* https://docs.amd.com/v/u/en-US/xps_intc +* DS572: LogiCORE IP XPS Interrupt Controller (v2.01a) +* * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights
@@ -49,6 +52,7 @@ struct XpsIntc {SysBusDevice parent_obj; +bool little_endian_model;MemoryRegion mmio;qemu_irq parent_irq;
@@ -140,18 +144,29 @@ static void pic_write(void *opaque, hwaddr addr,update_irq (p); } -static const MemoryRegionOps pic_ops = { - .read = pic_read, - .write = pic_write, - .endianness =DEVICE_NATIVE_ENDIAN , - .impl = { - .min_access_size =4 , - .max_access_size =4 , +static const MemoryRegionOps pic_ops[2 ] = { + [0 ...1 ] = { + .read = pic_read, + .write = pic_write, + .endianness =DEVICE_BIG_ENDIAN , + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, + .valid = { +/* +* All XPS INTC registers are accessed through the PLB interface. +* The base address for these registers is provided by the +* configuration parameter, C_BASEADDR. Each register is 32 bits +* although some bits may be unused and is accessed on a 4-byte +* boundary offset from the base address. +*/ + .min_access_size =4 , + .max_access_size =4 , + }, }, - .valid = { - .min_access_size =4 , - .max_access_size =4 - } + [0 ].endianness =DEVICE_BIG_ENDIAN , + [1 ].endianness =DEVICE_LITTLE_ENDIAN , };static void irq_handler (void *opaque,int irq,int level)
@@ -174,13 +189,21 @@ static void xilinx_intc_init(Object *obj)qdev_init_gpio_in (DEVICE (obj), irq_handler,32 );sysbus_init_irq (SYS_BUS_DEVICE (obj), &p->parent_irq); - -memory_region_init_io (&p->mmio, obj, &pic_ops, p,"xlnx.xps-intc" , -R_MAX *4 );sysbus_init_mmio (SYS_BUS_DEVICE (obj), &p->mmio); } +static void xilinx_intc_realize (DeviceState *dev,Error **errp) +{ +XpsIntc *p =XILINX_INTC (dev); + +memory_region_init_io (&p->mmio,OBJECT (dev), + &pic_ops[p->little_endian_model], + p,"xlnx.xps-intc" , +R_MAX *4 ); +} +static Property xilinx_intc_properties[] = { +DEFINE_PROP_BOOL ("little-endian" , XpsIntc, little_endian_model, true),DEFINE_PROP_UINT32 ("kind-of-intr" , XpsIntc, c_kind_of_intr,0 ),DEFINE_PROP_END_OF_LIST (), };
@@ -189,6 +212,7 @@ static void xilinx_intc_class_init(ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass); + dc->realize = xilinx_intc_realize;device_class_set_props (dc, xilinx_intc_properties); }
hw/microblaze/petalogix_ml605_mmu.c +1 -0
@@ -111,6 +111,7 @@ petalogix_ml605_init(MachineState *machine) dev =qdev_new ("xlnx.xps-intc" ); +qdev_prop_set_bit (dev,"little-endian" , true);qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<TIMER_IRQ );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,INTC_BASEADDR );
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -0
@@ -95,6 +95,7 @@ petalogix_s3adsp1800_init(MachineState *machine) 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); dev =qdev_new ("xlnx.xps-intc" ); +qdev_prop_set_bit (dev,"little-endian" , !TARGET_BIG_ENDIAN );qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<ETHLITE_IRQ |1 <<UARTLITE_IRQ );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
Signature · 1 line
2.45.2
RFC PATCH v3 4/17 hw/net/xilinx_ethlite: Simplify by having configurable endianness
In reply to Philippe Mathieu-DaudéThe Xilinx 'ethlite' device was added in commit b43848a100 ("xilinx: Add ethlite emulation"), being only built back then for a big-endian MicroBlaze target (see commit 72b675caac "microblaze: Hook into the build-system").
I/O endianness access was then clarified in commit d48751ed4f ("xilinx-ethlite: Simplify byteswapping to/from brams"). Here the 'fix' was to use tswap32(). Since the machine was built as big-endian target, tswap32() use means the fix was for a little endian host. While the datasheet (reference added in file header) is not precise about it, we interpret such change as the device expects accesses in big-endian order.
Instead of having a double swapping, one in the core memory layer due to DEVICE_NATIVE_ENDIAN and a second one with the tswap calls, allow the machine code to select the proper endianness desired, removing the need of tswap().
Replace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device endianness, defaulting to little endian.
Set the proper endianness on the single machine using the device.
---
RFC until I digest Paolo's review from v1:
https://lore.kernel.org/qemu-devel/[email protected]/
--- hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + hw/net/xilinx_ethlite.c | 44 +++++++++++++++--------- 2 files changed, 28 insertions(+), 17 deletions(-)
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -0
@@ -121,6 +121,7 @@ petalogix_s3adsp1800_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]); dev =qdev_new ("xlnx.xps-ethernetlite" ); +qdev_prop_set_bit (dev,"little-endian" , !TARGET_BIG_ENDIAN );qemu_configure_nic_device (dev, true,NULL );qdev_prop_set_uint32 (dev,"tx-ping-pong" ,0 );qdev_prop_set_uint32 (dev,"rx-ping-pong" ,0 );
hw/net/xilinx_ethlite.c +27 -17
97 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [RFC PATCH v3 04/17] hw/net/xilinx_ethlite: Simplify by having configurable endianness
Quoted 24 lines · Philippe Mathieu-Daudé
The Xilinx 'ethlite' device was added in commit
b43848a100("xilinx: Add ethlite emulation"), being only built back then for a big-endian MicroBlaze target (see commit72b675caac"microblaze: Hook into the build-system").I/O endianness access was then clarified in commit
d48751ed4f("xilinx-ethlite: Simplify byteswapping to/from brams"). Here the 'fix' was to usetswap32(). Since the machine was built as big-endian target,tswap32()use means the fix was for a little endian host. While the datasheet (reference added in file header) is not precise about it, we interpret such change as the device expects accesses in big-endian order.Instead of having a double swapping, one in the core memory layer due to
DEVICE_NATIVE_ENDIANand a second one with the tswap calls, allow the machine code to select the proper endianness desired, removing the need oftswap().Replace the
DEVICE_NATIVE_ENDIANMemoryRegionOps by a pair ofDEVICE_LITTLE_ENDIAN/DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device endianness, defaulting to little endian.
Set the proper endianness on the single machine using the device.
Quoted 4 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC until I digest Paolo's review from v1:
https://lore.kernel.org/qemu-devel/[email protected]/
tl;dr: this works but would break migration compatibility with the previous version. If you want to keep that, you need to add
hw/net/xilinx_ethlite.c eth_read(void *opaque, hwaddr addr, unsigned int size) · line 109
Quoted 2 lines
hw/net/xilinx_ethlite.c +1
-1- r =tswap32 (s->regs[addr]); + r = s->regs[addr];
if (s->little_endian_model)
r = cpu_to_le32(r); else r = cpu_to_be32(r);
hw/net/xilinx_ethlite.c eth_write(void *opaque, hwaddr addr, · line 167
Quoted 4 lines
hw/net/xilinx_ethlite.c +0
-0@@ -161,23 +165,26 @@ eth_write(void *opaque, hwaddr addr,break ;default :
if (s->little_endian_model)
r = le32_to_cpu(r); else r = be32_to_cpu(r);
hw/net/xilinx_ethlite.c eth_write(void *opaque, hwaddr addr, · line 169
Quoted 3 lines
hw/net/xilinx_ethlite.c +1
-1- s->regs[addr] =tswap32 (value); + s->regs[addr] = value;break ;
These pairs ensure that RAM goes through an even number of swaps. I don't think they are needed but you decide.
However, I am wondering if the double MemoryRegionOps are needed *at all*. Since petalogix is arguably a little-endian only machine, can you just use DEVICE_LITTLE_ENDIAN?
Paolo
Re: [RFC PATCH v3 04/17] hw/net/xilinx_ethlite: Simplify by having configurable endianness
Quoted 50 lines · Paolo Bonzini
Quoted 24 lines · Philippe Mathieu-Daudé
The Xilinx 'ethlite' device was added in commit
b43848a100("xilinx: Add ethlite emulation"), being only built back then for a big-endian MicroBlaze target (see commit72b675caac"microblaze: Hook into the build-system").I/O endianness access was then clarified in commit
d48751ed4f("xilinx-ethlite: Simplify byteswapping to/from brams"). Here the 'fix' was to usetswap32(). Since the machine was built as big-endian target,tswap32()use means the fix was for a little endian host. While the datasheet (reference added in file header) is not precise about it, we interpret such change as the device expects accesses in big-endian order.Instead of having a double swapping, one in the core memory layer due to
DEVICE_NATIVE_ENDIANand a second one with the tswap calls, allow the machine code to select the proper endianness desired, removing the need oftswap().Replace the
DEVICE_NATIVE_ENDIANMemoryRegionOps by a pair ofDEVICE_LITTLE_ENDIAN/DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device endianness, defaulting to little endian.
Set the proper endianness on the single machine using the device.Quoted 4 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC until I digest Paolo's review from v1:
https://lore.kernel.org/qemu-devel/[email protected]/tl;dr: this works but would break migration compatibility with the previous version. If you want to keep that, you need to add
Quoted 2 lines
- r =
tswap32(s->regs[addr]);
+ r = s->regs[addr];if (
s->little_endian_model)
r =cpu_to_le32(r);
else
r =cpu_to_be32(r);Quoted 3 lines
(quoted diff) +0
-0@@ -161,23 +165,26 @@ eth_write(void *opaque, hwaddr addr, break;default:
if (
s->little_endian_model)
r =le32_to_cpu(r);
else
r =be32_to_cpu(r);
Quoted 5 lines
Quoted 3 lines
- s->regs[addr] = tswap32(value);
+ s->regs[addr] = value;
break;These pairs ensure that RAM goes through an even number of swaps. I don't think they are needed but you decide.
Indeed; I didn't realize it was RAM.
Quoted 1 line
However, I am wondering if the double MemoryRegionOps are needed *at all*. Since petalogix is arguably a little-endian only machine, can you just use
DEVICE_LITTLE_ENDIAN?
1/ This petalogix machine is actually built in the big-endian binary 2/ As Edgar mentioned elsewhere, Petalogic IP can be synthetized as
big-endian
3/ This machine is used to prove we can remove the TARGET_BIG_ENDIAN
definition and unify big/little endian binaries in our build system.
RFC PATCH v3 5/17 hw/timer/xilinx_timer: Allow down to 8-bit memory access
In reply to Philippe Mathieu-DaudéAllow down to 8-bit access, per the datasheet (reference added in previous commit):
"Timer Counter registers are accessed as one of the following types:
• Byte (8 bits)
• Half word (2 bytes)
• Word (4 bytes)"
---
RFC: This breaks the UART qtest, instead of having TX register receiving 'T' = 0x54, it receives 0x54000000, converted to '\0' char. It works if we use SWI instead of SBI (storing 32-bit).
--- hw/timer/xilinx_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/timer/xilinx_timer.c +1 -1
@@ -198,7 +198,7 @@ static const MemoryRegionOps timer_ops = { .max_access_size = 4, }, .valid = { - .min_access_size = 4, + .min_access_size = 1, .max_access_size = 4 } };
Signature · 1 line
2.45.2
PATCH v3 6/17 hw/timer/xilinx_timer: Make device endianness configurable
In reply to Philippe Mathieu-DaudéReplace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device endianness, defaulting to little endian.
Set the proper endianness for each machine using the device.
--- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + hw/ppc/virtex_ml507.c | 1 + hw/timer/xilinx_timer.c | 35 +++++++++++++++--------- 4 files changed, 25 insertions(+), 13 deletions(-)
hw/microblaze/petalogix_ml605_mmu.c +1 -0
@@ -127,6 +127,7 @@ petalogix_ml605_init(MachineState *machine)/* 2 timers at irq 2 @ 100 Mhz. */ dev =qdev_new ("xlnx.xps-timer" ); +qdev_prop_set_bit (dev,"little-endian" , true);qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,100 *1000000 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -0
@@ -114,6 +114,7 @@ petalogix_s3adsp1800_init(MachineState *machine)/* 2 timers at irq 2 @ 62 Mhz. */ dev =qdev_new ("xlnx.xps-timer" ); +qdev_prop_set_bit (dev,"little-endian" , !TARGET_BIG_ENDIAN );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,62 *1000000 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/ppc/virtex_ml507.c +1 -0
@@ -230,6 +230,7 @@ static void virtex_init(MachineState *machine)/* 2 timers at irq 2 @ 62 Mhz. */ dev =qdev_new ("xlnx.xps-timer" ); +qdev_prop_set_bit (dev,"little-endian" , false);qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,62 *1000000 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/timer/xilinx_timer.c +22 -13
@@ -3,6 +3,9 @@* * Copyright (c) 2009 Edgar E. Iglesias. * +* DS573: https://docs.amd.com/v/u/en-US/xps_timer +* LogiCORE IP XPS Timer/Counter (v1.02a) +* * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights
@@ -69,6 +72,7 @@ struct XpsTimerState {SysBusDevice parent_obj; +bool little_endian_model;MemoryRegion mmio;qemu_irq irq;uint8_t one_timer_only;
@@ -189,18 +193,21 @@ timer_write(void *opaque, hwaddr addr,timer_update_irq (t); } -static const MemoryRegionOps timer_ops = { - .read = timer_read, - .write = timer_write, - .endianness =DEVICE_NATIVE_ENDIAN , - .impl = { - .min_access_size =4 , - .max_access_size =4 , +static const MemoryRegionOps timer_ops[2 ] = { + [0 ...1 ] = { + .read = timer_read, + .write = timer_write, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, + .valid = { + .min_access_size =1 , + .max_access_size =4 , + }, }, - .valid = { - .min_access_size =1 , - .max_access_size =4 - } + [0 ].endianness =DEVICE_BIG_ENDIAN , + [1 ].endianness =DEVICE_LITTLE_ENDIAN , };static void timer_hit (void *opaque)
@@ -233,8 +240,9 @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp)ptimer_transaction_commit (xt->ptimer); } -memory_region_init_io (&t->mmio,OBJECT (t), &timer_ops, t,"xlnx.xps-timer" , -R_MAX *4 *num_timers (t)); +memory_region_init_io (&t->mmio,OBJECT (t), + &timer_ops[t->little_endian_model], t, +"xlnx.xps-timer" ,R_MAX *4 *num_timers (t));sysbus_init_mmio (SYS_BUS_DEVICE (dev), &t->mmio); }
@@ -247,6 +255,7 @@ static void xilinx_timer_init(Object *obj) }static Property xilinx_timer_properties[] = { +DEFINE_PROP_BOOL ("little-endian" , XpsTimerState, little_endian_model, true),DEFINE_PROP_UINT32 ("clock-frequency" , XpsTimerState, freq_hz,62 *1000000 ),DEFINE_PROP_UINT8 ("one-timer-only" , XpsTimerState, one_timer_only,0 ),DEFINE_PROP_END_OF_LIST (),
Signature · 1 line
2.45.2
PATCH v3 7/17 hw/char/xilinx_uartlite: Make device endianness configurable
In reply to Philippe Mathieu-DaudéReplace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device endianness, defaulting to little endian.
Set the proper endianness on the single machine using the device.
--- hw/char/xilinx_uartlite.c | 33 ++++++++++++++---------- hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + 2 files changed, 20 insertions(+), 14 deletions(-)
hw/char/xilinx_uartlite.c +19 -14
@@ -57,6 +57,7 @@struct XilinxUARTLite {SysBusDevice parent_obj; +bool little_endian_model;MemoryRegion mmio;CharBackend chr;qemu_irq irq;
@@ -166,21 +167,25 @@ uart_write(void *opaque, hwaddr addr,uart_update_irq (s); } -static const MemoryRegionOps uart_ops = { - .read = uart_read, - .write = uart_write, - .endianness =DEVICE_NATIVE_ENDIAN , - .impl = { - .min_access_size =4 , - .max_access_size =4 , +static const MemoryRegionOps uart_ops[2 ] = { + [0 ...1 ] = { + .read = uart_read, + .write = uart_write, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, + .valid = { + .min_access_size =1 , + .max_access_size =4 , + }, }, - .valid = { - .min_access_size =1 , - .max_access_size =4 - } + [0 ].endianness =DEVICE_BIG_ENDIAN , + [1 ].endianness =DEVICE_LITTLE_ENDIAN , };static Property xilinx_uartlite_properties[] = { +DEFINE_PROP_BOOL ("little-endian" , XilinxUARTLite, little_endian_model, true),DEFINE_PROP_CHR ("chardev" , XilinxUARTLite, chr),DEFINE_PROP_END_OF_LIST (), };
@@ -219,6 +224,9 @@ static void xilinx_uartlite_realize(DeviceState *dev, Error **errp) {XilinxUARTLite *s =XILINX_UARTLITE (dev); +memory_region_init_io (&s->mmio,OBJECT (dev), + &uart_ops[s->little_endian_model], + s,"xlnx.xps-uartlite" ,R_MAX *4 );qemu_chr_fe_set_handlers (&s->chr, uart_can_rx, uart_rx, uart_event,NULL , s,NULL , true); }
@@ -228,9 +236,6 @@ static void xilinx_uartlite_init(Object *obj)XilinxUARTLite *s =XILINX_UARTLITE (obj);sysbus_init_irq (SYS_BUS_DEVICE (obj), &s->irq); - -memory_region_init_io (&s->mmio, obj, &uart_ops, s, -"xlnx.xps-uartlite" ,R_MAX *4 );sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->mmio); }
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -0
@@ -107,6 +107,7 @@ petalogix_s3adsp1800_init(MachineState *machine) } dev =qdev_new (TYPE_XILINX_UARTLITE ); +qdev_prop_set_bit (dev,"little-endian" , !TARGET_BIG_ENDIAN );qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,UARTLITE_BASEADDR );
Signature · 1 line
2.45.2
PATCH v3 8/17 hw/ssi/xilinx_spi: Make device endianness configurable
In reply to Philippe Mathieu-DaudéReplace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device endianness, defaulting to little endian.
Set the proper endianness on the single machine using the device.
--- hw/arm/xlnx-zynqmp.c | 4 ++++ hw/ssi/xilinx_spi.c | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-)
hw/arm/xlnx-zynqmp.c +4 -0
@@ -714,6 +714,10 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i <XLNX_ZYNQMP_NUM_SPIS ; i++) {gchar *bus_name; +if (!object_property_set_bool (OBJECT (&s->spi[i])),"little-endian" , + true, errp)) { +return ; + }if (!sysbus_realize (SYS_BUS_DEVICE (&s->spi[i]), errp)) {return ; }
hw/ssi/xilinx_spi.c +15 -9
@@ -83,6 +83,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(XilinxSPI, XILINX_SPI)struct XilinxSPI {SysBusDevice parent_obj; +bool little_endian_model;MemoryRegion mmio;qemu_irq irq;
@@ -313,14 +314,17 @@ done:xlx_spi_update_irq (s); } -static const MemoryRegionOps spi_ops = { - .read = spi_read, - .write = spi_write, - .endianness =DEVICE_NATIVE_ENDIAN , - .valid = { - .min_access_size =4 , - .max_access_size =4 - } +static const MemoryRegionOps spi_ops[2 ] = { + [0 ...1 ] = { + .read = spi_read, + .write = spi_write, + .valid = { + .min_access_size =4 , + .max_access_size =4 , + }, + }, + [0 ].endianness =DEVICE_BIG_ENDIAN , + [1 ].endianness =DEVICE_LITTLE_ENDIAN , };static void xilinx_spi_realize (DeviceState *dev,Error **errp)
@@ -339,7 +343,8 @@ static void xilinx_spi_realize(DeviceState *dev, Error **errp)sysbus_init_irq (sbd, &s->cs_lines[i]); } -memory_region_init_io (&s->mmio,OBJECT (s), &spi_ops, s, +memory_region_init_io (&s->mmio,OBJECT (s), + &spi_ops[s->little_endian_model], s,"xilinx-spi" ,R_MAX *4 );sysbus_init_mmio (sbd, &s->mmio);
@@ -362,6 +367,7 @@ static const VMStateDescription vmstate_xilinx_spi = { };static Property xilinx_spi_properties[] = { +DEFINE_PROP_BOOL ("little-endian" , XilinxSPI, little_endian_model, true),DEFINE_PROP_UINT8 ("num-ss-bits" , XilinxSPI, num_cs,1 ),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
2.45.2
PATCH v3 9/17 hw/ssi/xilinx_spips: Make device endianness configurable
In reply to Philippe Mathieu-DaudéReplace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device endianness, defaulting to little endian.
Set the proper endianness on the single machine using the device.
--- include/hw/ssi/xilinx_spips.h | 1 + hw/arm/xilinx_zynq.c | 1 + hw/ssi/xilinx_spips.c | 36 ++++++++++++++++++++++------------- 3 files changed, 25 insertions(+), 13 deletions(-)
include/hw/ssi/xilinx_spips.h +1 -0
@@ -91,6 +91,7 @@ struct XilinxSPIPS {struct XilinxQSPIPS {XilinxSPIPS parent_obj; +bool little_endian_model;uint8_t lqspi_buf[LQSPI_CACHE_SIZE ];hwaddr lqspi_cached_addr;Error *migration_blocker;
hw/arm/xilinx_zynq.c +1 -0
@@ -142,6 +142,7 @@ static inline int zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,int num_ss = is_qspi ?NUM_QSPI_FLASHES :NUM_SPI_FLASHES ; dev =qdev_new (is_qspi ?"xlnx.ps7-qspi" :"xlnx.ps7-spi" ); +qdev_prop_set_bit (dev,"little-endian" , true);qdev_prop_set_uint8 (dev,"num-txrx-bytes" , is_qspi ?4 :1 );qdev_prop_set_uint8 (dev,"num-ss-bits" , num_ss);qdev_prop_set_uint8 (dev,"num-busses" , num_busses);
hw/ssi/xilinx_spips.c +23 -13
@@ -1251,18 +1251,21 @@ static MemTxResult lqspi_write(void *opaque, hwaddr offset, uint64_t value,return MEMTX_ERROR ; } -static const MemoryRegionOps lqspi_ops = { - .read_with_attrs = lqspi_read, - .write_with_attrs = lqspi_write, - .endianness =DEVICE_NATIVE_ENDIAN , - .impl = { - .min_access_size =4 , - .max_access_size =4 , +static const MemoryRegionOps lqspi_ops[2 ] = { + [0 ...1 ] = { + .read_with_attrs = lqspi_read, + .write_with_attrs = lqspi_write, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, + .valid = { + .min_access_size =1 , + .max_access_size =4 + }, }, - .valid = { - .min_access_size =1 , - .max_access_size =4 - } + [0 ].endianness =DEVICE_BIG_ENDIAN , + [1 ].endianness =DEVICE_LITTLE_ENDIAN , };static void xilinx_spips_realize (DeviceState *dev,Error **errp)
@@ -1325,8 +1328,9 @@ static void xilinx_qspips_realize(DeviceState *dev, Error **errp) s->num_txrx_bytes =4 ;xilinx_spips_realize (dev, errp); -memory_region_init_io (&s->mmlqspi,OBJECT (s), &lqspi_ops, s,"lqspi" , - (1 <<LQSPI_ADDRESS_BITS ) *2 ); +memory_region_init_io (&s->mmlqspi,OBJECT (s), + &lqspi_ops[q->little_endian_model], + s,"lqspi" , (1 <<LQSPI_ADDRESS_BITS ) *2 );sysbus_init_mmio (sbd, &s->mmlqspi); q->lqspi_cached_addr = ~0ULL ;
@@ -1432,12 +1436,18 @@ static Property xilinx_spips_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static Property xilinx_qspips_properties[] = { +DEFINE_PROP_BOOL ("little-endian" , XilinxQSPIPS, little_endian_model, true), +DEFINE_PROP_END_OF_LIST (), +}; +static void xilinx_qspips_class_init (ObjectClass *klass,void * data) {DeviceClass *dc =DEVICE_CLASS (klass);XilinxSPIPSClass *xsc =XILINX_SPIPS_CLASS (klass); dc->realize = xilinx_qspips_realize; +device_class_set_props (dc, xilinx_qspips_properties); xsc->reg_ops = &qspips_ops; xsc->reg_size =XLNX_SPIPS_R_MAX *4 ; xsc->rx_fifo_size =RXFF_A_Q ;
Signature · 1 line
2.45.2
PATCH v3 10/17 hw/arm/xlnx-zynqmp: Use &error_abort for programming errors
In reply to Philippe Mathieu-DaudéWhen a property value is static (not provided by QMP or CLI), error shouldn't happen, otherwise it is a programming error. Therefore simplify and use &error_abort as this can't fail.
--- hw/arm/xlnx-zynqmp.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-)
hw/arm/xlnx-zynqmp.c +14 -30
@@ -689,16 +689,10 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)* - SDIO Specification Version 3.0 * - eMMC Specification Version 4.51 */ -if (!object_property_set_uint (sdhci,"sd-spec-version" ,3 , errp)) { -return ; - } -if (!object_property_set_uint (sdhci,"capareg" ,SDHCI_CAPABILITIES , - errp)) { -return ; - } -if (!object_property_set_uint (sdhci,"uhs" ,UHS_I , errp)) { -return ; - } +object_property_set_uint (sdhci,"sd-spec-version" ,3 , &error_abort); +object_property_set_uint (sdhci,"capareg" ,SDHCI_CAPABILITIES , + &error_abort); +object_property_set_uint (sdhci,"uhs" ,UHS_I , &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (sdhci), errp)) {return ; }
@@ -714,10 +708,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i <XLNX_ZYNQMP_NUM_SPIS ; i++) {gchar *bus_name; -if (!object_property_set_bool (OBJECT (&s->spi[i])),"little-endian" , - true, errp)) { -return ; - } +object_property_set_bool (OBJECT (&s->spi[i]),"little-endian" , + true, &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->spi[i]), errp)) {return ; }
@@ -767,14 +759,10 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)xlnx_zynqmp_create_unimp_mmio (s);for (i =0 ; i <XLNX_ZYNQMP_NUM_GDMA_CH ; i++) { -if (!object_property_set_uint (OBJECT (&s->gdma[i]),"bus-width" ,128 , - errp)) { -return ; - } -if (!object_property_set_link (OBJECT (&s->gdma[i]),"dma" , -OBJECT (system_memory), errp)) { -return ; - } +object_property_set_uint (OBJECT (&s->gdma[i]),"bus-width" ,128 , + &error_abort); +object_property_set_link (OBJECT (&s->gdma[i]),"dma" , +OBJECT (system_memory), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->gdma[i]), errp)) {return ; }
@@ -815,10 +803,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->qspi_dma),0 ,qdev_get_gpio_in (DEVICE (&s->qspi_irq_orgate),0 )); -if (!object_property_set_link (OBJECT (&s->qspi),"stream-connected-dma" , -OBJECT (&s->qspi_dma), errp)) { -return ; - } +object_property_set_link (OBJECT (&s->qspi),"stream-connected-dma" , +OBJECT (&s->qspi_dma), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->qspi), errp)) {return ; }
@@ -837,10 +823,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) }for (i =0 ; i <XLNX_ZYNQMP_NUM_USB ; i++) { -if (!object_property_set_link (OBJECT (&s->usb[i].sysbus_xhci),"dma" , -OBJECT (system_memory), errp)) { -return ; - } +object_property_set_link (OBJECT (&s->usb[i].sysbus_xhci),"dma" , +OBJECT (system_memory), &error_abort);qdev_prop_set_uint32 (DEVICE (&s->usb[i].sysbus_xhci),"intrs" ,4 );qdev_prop_set_uint32 (DEVICE (&s->usb[i].sysbus_xhci),"slots" ,2 );
Signature · 1 line
2.45.2
Re: [PATCH v3 10/17] hw/arm/xlnx-zynqmp: Use &error_abort for programming errors
ping for trivial review?
Quoted 93 lines · Philippe Mathieu-Daudé
When a property value is static (not provided by QMP or CLI), error shouldn't happen, otherwise it is a programming error. Therefore simplify and use
&error_abortas this can't fail.Reported-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/xlnx-zynqmp.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-)hw/arm/xlnx-zynqmp.c +14
-30@@ -689,16 +689,10 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)* - SDIO Specification Version 3.0 * - eMMC Specification Version 4.51 */ -if (!object_property_set_uint (sdhci,"sd-spec-version" ,3 , errp)) { -return ; - } -if (!object_property_set_uint (sdhci,"capareg" ,SDHCI_CAPABILITIES , - errp)) { -return ; - } -if (!object_property_set_uint (sdhci,"uhs" ,UHS_I , errp)) { -return ; - } +object_property_set_uint (sdhci,"sd-spec-version" ,3 , &error_abort); +object_property_set_uint (sdhci,"capareg" ,SDHCI_CAPABILITIES , + &error_abort); +object_property_set_uint (sdhci,"uhs" ,UHS_I , &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (sdhci), errp)) {return ; }@@ -714,10 +708,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i <XLNX_ZYNQMP_NUM_SPIS ; i++) {gchar *bus_name; -if (!object_property_set_bool (OBJECT (&s->spi[i])),"little-endian" , - true, errp)) { -return ; - } +object_property_set_bool (OBJECT (&s->spi[i]),"little-endian" , + true, &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->spi[i]), errp)) {return ; }@@ -767,14 +759,10 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)xlnx_zynqmp_create_unimp_mmio (s);for (i =0 ; i <XLNX_ZYNQMP_NUM_GDMA_CH ; i++) { -if (!object_property_set_uint (OBJECT (&s->gdma[i]),"bus-width" ,128 , - errp)) { -return ; - } -if (!object_property_set_link (OBJECT (&s->gdma[i]),"dma" , -OBJECT (system_memory), errp)) { -return ; - } +object_property_set_uint (OBJECT (&s->gdma[i]),"bus-width" ,128 , + &error_abort); +object_property_set_link (OBJECT (&s->gdma[i]),"dma" , +OBJECT (system_memory), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->gdma[i]), errp)) {return ; }@@ -815,10 +803,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->qspi_dma),0 ,qdev_get_gpio_in (DEVICE (&s->qspi_irq_orgate),0 )); -if (!object_property_set_link (OBJECT (&s->qspi),"stream-connected-dma" , -OBJECT (&s->qspi_dma), errp)) { -return ; - } +object_property_set_link (OBJECT (&s->qspi),"stream-connected-dma" , +OBJECT (&s->qspi_dma), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->qspi), errp)) {return ; }@@ -837,10 +823,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) }for (i =0 ; i <XLNX_ZYNQMP_NUM_USB ; i++) { -if (!object_property_set_link (OBJECT (&s->usb[i].sysbus_xhci),"dma" , -OBJECT (system_memory), errp)) { -return ; - } +object_property_set_link (OBJECT (&s->usb[i].sysbus_xhci),"dma" , +OBJECT (system_memory), &error_abort);qdev_prop_set_uint32 (DEVICE (&s->usb[i].sysbus_xhci),"intrs" ,4 );qdev_prop_set_uint32 (DEVICE (&s->usb[i].sysbus_xhci),"slots" ,2 );
Anton Johansson via
Reviewed-by Anton JohanssonRe: [PATCH v3 10/17] hw/arm/xlnx-zynqmp: Use &error_abort for programming errors
Quoted 13 lines · Philippe Mathieu-Daudé
ping for trivial review?
Quoted 10 lines · Philippe Mathieu-Daudé
When a property value is static (not provided by QMP or CLI), error shouldn't happen, otherwise it is a programming error. Therefore simplify and use
&error_abortas this can't fail.Reported-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/xlnx-zynqmp.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-)
Makes sense!:)
PATCH v3 11/17 target/microblaze: Explode MO_TExx -> MO_TE | MO_xx
In reply to Philippe Mathieu-DaudéExtract the implicit MO_TE definition in order to replace it by runtime variable in the next commit.
Mechanical change using:
$ for n in UW UL UQ UO SW SL SQ; do \
sed -i -e "s/MO_TE$n/MO_TE | MO_$n/" \
$(git grep -l MO_TE$n target/microblaze); \
done--- target/microblaze/translate.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
target/microblaze/translate.c +18 -18
@@ -779,13 +779,13 @@ static bool trans_lbui(DisasContext *dc, arg_typeb *arg)static bool trans_lhu (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TEUW , dc->mem_index, false); +return do_load (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, false); }static bool trans_lhur (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TEUW , dc->mem_index, true); +return do_load (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, true); }static bool trans_lhuea (DisasContext *dc,arg_typea *arg)
@@ -797,26 +797,26 @@ static bool trans_lhuea(DisasContext *dc, arg_typea *arg)return true;#else TCGv addr =compute_ldst_addr_ea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TEUW ,MMU_NOMMU_IDX , false); +return do_load (dc, arg->rd, addr,MO_TE |MO_UW ,MMU_NOMMU_IDX , false);#endif }static bool trans_lhui (DisasContext *dc,arg_typeb *arg) {TCGv addr =compute_ldst_addr_typeb (dc, arg->ra, arg->imm); -return do_load (dc, arg->rd, addr,MO_TEUW , dc->mem_index, false); +return do_load (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, false); }static bool trans_lw (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TEUL , dc->mem_index, false); +return do_load (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, false); }static bool trans_lwr (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TEUL , dc->mem_index, true); +return do_load (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, true); }static bool trans_lwea (DisasContext *dc,arg_typea *arg)
@@ -828,14 +828,14 @@ static bool trans_lwea(DisasContext *dc, arg_typea *arg)return true;#else TCGv addr =compute_ldst_addr_ea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TEUL ,MMU_NOMMU_IDX , false); +return do_load (dc, arg->rd, addr,MO_TE |MO_UL ,MMU_NOMMU_IDX , false);#endif }static bool trans_lwi (DisasContext *dc,arg_typeb *arg) {TCGv addr =compute_ldst_addr_typeb (dc, arg->ra, arg->imm); -return do_load (dc, arg->rd, addr,MO_TEUL , dc->mem_index, false); +return do_load (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, false); }static bool trans_lwx (DisasContext *dc,arg_typea *arg)
@@ -845,7 +845,7 @@ static bool trans_lwx(DisasContext *dc, arg_typea *arg)/* lwx does not throw unaligned access errors, so force alignment */ tcg_gen_andi_tl (addr, addr, ~3 ); -tcg_gen_qemu_ld_i32 (cpu_res_val, addr, dc->mem_index,MO_TEUL ); +tcg_gen_qemu_ld_i32 (cpu_res_val, addr, dc->mem_index,MO_TE |MO_UL );tcg_gen_mov_tl (cpu_res_addr, addr);if (arg->rd) {
@@ -929,13 +929,13 @@ static bool trans_sbi(DisasContext *dc, arg_typeb *arg)static bool trans_sh (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TEUW , dc->mem_index, false); +return do_store (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, false); }static bool trans_shr (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TEUW , dc->mem_index, true); +return do_store (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, true); }static bool trans_shea (DisasContext *dc,arg_typea *arg)
@@ -947,26 +947,26 @@ static bool trans_shea(DisasContext *dc, arg_typea *arg)return true;#else TCGv addr =compute_ldst_addr_ea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TEUW ,MMU_NOMMU_IDX , false); +return do_store (dc, arg->rd, addr,MO_TE |MO_UW ,MMU_NOMMU_IDX , false);#endif }static bool trans_shi (DisasContext *dc,arg_typeb *arg) {TCGv addr =compute_ldst_addr_typeb (dc, arg->ra, arg->imm); -return do_store (dc, arg->rd, addr,MO_TEUW , dc->mem_index, false); +return do_store (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, false); }static bool trans_sw (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TEUL , dc->mem_index, false); +return do_store (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, false); }static bool trans_swr (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TEUL , dc->mem_index, true); +return do_store (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, true); }static bool trans_swea (DisasContext *dc,arg_typea *arg)
@@ -978,14 +978,14 @@ static bool trans_swea(DisasContext *dc, arg_typea *arg)return true;#else TCGv addr =compute_ldst_addr_ea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TEUL ,MMU_NOMMU_IDX , false); +return do_store (dc, arg->rd, addr,MO_TE |MO_UL ,MMU_NOMMU_IDX , false);#endif }static bool trans_swi (DisasContext *dc,arg_typeb *arg) {TCGv addr =compute_ldst_addr_typeb (dc, arg->ra, arg->imm); -return do_store (dc, arg->rd, addr,MO_TEUL , dc->mem_index, false); +return do_store (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, false); }static bool trans_swx (DisasContext *dc,arg_typea *arg)
@@ -1014,7 +1014,7 @@ static bool trans_swx(DisasContext *dc, arg_typea *arg)tcg_gen_atomic_cmpxchg_i32 (tval, cpu_res_addr, cpu_res_val,reg_for_write (dc, arg->rd), - dc->mem_index,MO_TEUL ); + dc->mem_index,MO_TE |MO_UL );tcg_gen_brcond_i32 (TCG_COND_NE , cpu_res_val, tval, swx_fail);
Signature · 1 line
2.45.2
PATCH v3 12/17 target/microblaze: Set MO_TE once in do_load() / do_store()
In reply to Philippe Mathieu-DaudéAll callers of do_load() / do_store() set MO_TE flag. Set it once in the callees.
--- target/microblaze/translate.c | 36 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-)
target/microblaze/translate.c +20 -16
@@ -712,6 +712,8 @@ static bool do_load(DisasContext *dc, int rd, TCGv addr, MemOp mop, {MemOp size = mop &MO_SIZE ; + mop |=MO_TE ; +/* * When doing reverse accesses we need to do two things. *
@@ -779,13 +781,13 @@ static bool trans_lbui(DisasContext *dc, arg_typeb *arg)static bool trans_lhu (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, false); +return do_load (dc, arg->rd, addr,MO_UW , dc->mem_index, false); }static bool trans_lhur (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, true); +return do_load (dc, arg->rd, addr,MO_UW , dc->mem_index, true); }static bool trans_lhuea (DisasContext *dc,arg_typea *arg)
@@ -797,26 +799,26 @@ static bool trans_lhuea(DisasContext *dc, arg_typea *arg)return true;#else TCGv addr =compute_ldst_addr_ea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TE |MO_UW ,MMU_NOMMU_IDX , false); +return do_load (dc, arg->rd, addr,MO_UW ,MMU_NOMMU_IDX , false);#endif }static bool trans_lhui (DisasContext *dc,arg_typeb *arg) {TCGv addr =compute_ldst_addr_typeb (dc, arg->ra, arg->imm); -return do_load (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, false); +return do_load (dc, arg->rd, addr,MO_UW , dc->mem_index, false); }static bool trans_lw (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, false); +return do_load (dc, arg->rd, addr,MO_UL , dc->mem_index, false); }static bool trans_lwr (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, true); +return do_load (dc, arg->rd, addr,MO_UL , dc->mem_index, true); }static bool trans_lwea (DisasContext *dc,arg_typea *arg)
@@ -828,14 +830,14 @@ static bool trans_lwea(DisasContext *dc, arg_typea *arg)return true;#else TCGv addr =compute_ldst_addr_ea (dc, arg->ra, arg->rb); -return do_load (dc, arg->rd, addr,MO_TE |MO_UL ,MMU_NOMMU_IDX , false); +return do_load (dc, arg->rd, addr,MO_UL ,MMU_NOMMU_IDX , false);#endif }static bool trans_lwi (DisasContext *dc,arg_typeb *arg) {TCGv addr =compute_ldst_addr_typeb (dc, arg->ra, arg->imm); -return do_load (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, false); +return do_load (dc, arg->rd, addr,MO_UL , dc->mem_index, false); }static bool trans_lwx (DisasContext *dc,arg_typea *arg)
@@ -862,6 +864,8 @@ static bool do_store(DisasContext *dc, int rd, TCGv addr, MemOp mop, {MemOp size = mop &MO_SIZE ; + mop |=MO_TE ; +/* * When doing reverse accesses we need to do two things. *
@@ -929,13 +933,13 @@ static bool trans_sbi(DisasContext *dc, arg_typeb *arg)static bool trans_sh (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, false); +return do_store (dc, arg->rd, addr,MO_UW , dc->mem_index, false); }static bool trans_shr (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, true); +return do_store (dc, arg->rd, addr,MO_UW , dc->mem_index, true); }static bool trans_shea (DisasContext *dc,arg_typea *arg)
@@ -947,26 +951,26 @@ static bool trans_shea(DisasContext *dc, arg_typea *arg)return true;#else TCGv addr =compute_ldst_addr_ea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TE |MO_UW ,MMU_NOMMU_IDX , false); +return do_store (dc, arg->rd, addr,MO_UW ,MMU_NOMMU_IDX , false);#endif }static bool trans_shi (DisasContext *dc,arg_typeb *arg) {TCGv addr =compute_ldst_addr_typeb (dc, arg->ra, arg->imm); -return do_store (dc, arg->rd, addr,MO_TE |MO_UW , dc->mem_index, false); +return do_store (dc, arg->rd, addr,MO_UW , dc->mem_index, false); }static bool trans_sw (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, false); +return do_store (dc, arg->rd, addr,MO_UL , dc->mem_index, false); }static bool trans_swr (DisasContext *dc,arg_typea *arg) {TCGv addr =compute_ldst_addr_typea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, true); +return do_store (dc, arg->rd, addr,MO_UL , dc->mem_index, true); }static bool trans_swea (DisasContext *dc,arg_typea *arg)
@@ -978,14 +982,14 @@ static bool trans_swea(DisasContext *dc, arg_typea *arg)return true;#else TCGv addr =compute_ldst_addr_ea (dc, arg->ra, arg->rb); -return do_store (dc, arg->rd, addr,MO_TE |MO_UL ,MMU_NOMMU_IDX , false); +return do_store (dc, arg->rd, addr,MO_UL ,MMU_NOMMU_IDX , false);#endif }static bool trans_swi (DisasContext *dc,arg_typeb *arg) {TCGv addr =compute_ldst_addr_typeb (dc, arg->ra, arg->imm); -return do_store (dc, arg->rd, addr,MO_TE |MO_UL , dc->mem_index, false); +return do_store (dc, arg->rd, addr,MO_UL , dc->mem_index, false); }static bool trans_swx (DisasContext *dc,arg_typea *arg)
Signature · 1 line
2.45.2
PATCH v3 13/17 target/microblaze: Introduce mo_endian() helper
In reply to Philippe Mathieu-Daudémo_endian() returns the target endianness, currently static.
--- target/microblaze/translate.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
target/microblaze/translate.c +10 -4
@@ -707,12 +707,17 @@ static void record_unaligned_ess(DisasContext *dc, int rd, }#endif +static inline MemOp mo_endian (DisasContext *dc) +{ +return MO_TE ; +} +static bool do_load (DisasContext *dc,int rd,TCGv addr,MemOp mop,int mem_index,bool rev) {MemOp size = mop &MO_SIZE ; - mop |=MO_TE ; + mop |=mo_endian (dc);/* * When doing reverse accesses we need to do two things.
@@ -847,7 +852,8 @@ static bool trans_lwx(DisasContext *dc, arg_typea *arg)/* lwx does not throw unaligned access errors, so force alignment */ tcg_gen_andi_tl (addr, addr, ~3 ); -tcg_gen_qemu_ld_i32 (cpu_res_val, addr, dc->mem_index,MO_TE |MO_UL ); +tcg_gen_qemu_ld_i32 (cpu_res_val, addr, dc->mem_index, +mo_endian (dc) |MO_UL );tcg_gen_mov_tl (cpu_res_addr, addr);if (arg->rd) {
@@ -864,7 +870,7 @@ static bool do_store(DisasContext *dc, int rd, TCGv addr, MemOp mop, {MemOp size = mop &MO_SIZE ; - mop |=MO_TE ; + mop |=mo_endian (dc);/* * When doing reverse accesses we need to do two things.
@@ -1018,7 +1024,7 @@ static bool trans_swx(DisasContext *dc, arg_typea *arg)tcg_gen_atomic_cmpxchg_i32 (tval, cpu_res_addr, cpu_res_val,reg_for_write (dc, arg->rd), - dc->mem_index,MO_TE |MO_UL ); + dc->mem_index,mo_endian (dc) |MO_UL );tcg_gen_brcond_i32 (TCG_COND_NE , cpu_res_val, tval, swx_fail);
Signature · 1 line
2.45.2
PATCH v3 14/17 target/microblaze: Consider endianness while translating code
In reply to Philippe Mathieu-DaudéConsider the CPU ENDI bit, swap instructions when the CPU endianness doesn't match the binary one.
--- target/microblaze/cpu.h | 7 +++++++ target/microblaze/translate.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-)
target/microblaze/cpu.h +7 -0
@@ -412,6 +412,13 @@ void mb_tcg_init(void);/* Ensure there is no overlap between the two masks. */ QEMU_BUILD_BUG_ON (MSR_TB_MASK &IFLAGS_TB_MASK ); +static inline bool mb_cpu_is_big_endian (CPUState *cs) +{ +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); + +return !cpu->cfg.endi; +} +static inline void cpu_get_tb_cpu_state (CPUMBState *env,vaddr *pc,uint64_t *cs_base,uint32_t *flags) {
target/microblaze/translate.c +3 -2
@@ -709,7 +709,7 @@ static void record_unaligned_ess(DisasContext *dc, int rd,static inline MemOp mo_endian (DisasContext *dc) { -return MO_TE ; +return dc->cfg->endi ?MO_LE :MO_BE ; } static bool do_load(DisasContext *dc, int rd, TCGv addr, MemOp mop,
@@ -1646,7 +1646,8 @@ static void mb_tr_translate_insn(DisasContextBase *dcb, CPUState *cs) dc->tb_flags_to_set =0 ; - ir =translator_ldl (cpu_env (cs), &dc->base, dc->base.pc_next); + ir =translator_ldl_swap (cpu_env (cs), &dc->base, dc->base.pc_next, +mb_cpu_is_big_endian (cs) !=TARGET_BIG_ENDIAN );if (!decode (dc, ir)) {trap_illegal (dc, true); }
Signature · 1 line
2.45.2
PATCH v3 15/17 hw/microblaze: Support various endianness for s3adsp1800 machines
In reply to Philippe Mathieu-DaudéIntroduce an abstract machine parent class which defines the 'little_endian' property. Duplicate the current machine, which endian is tied to the binary endianness, to one big endian and a little endian machine; updating the machine description. Keep the current default machine for each binary.
'petalogix-s3adsp1800' machine is aliased as:
- 'petalogix-s3adsp1800-be' on big-endian binary,
- 'petalogix-s3adsp1800-le' on little-endian one.
--- hw/microblaze/petalogix_s3adsp1800_mmu.c | 62 +++++++++++++++++++----- 1 file changed, 51 insertions(+), 11 deletions(-)
hw/microblaze/petalogix_s3adsp1800_mmu.c +51 -11
@@ -55,8 +55,17 @@#define ETHLITE_IRQ 1#define UARTLITE_IRQ 3 +typedef struct PetalogixS3adsp1800MachineClass { +MachineClass parent_obj; + +bool little_endian; +}PetalogixS3adsp1800MachineClass ; +#define TYPE_PETALOGIX_S3ADSP1800_MACHINE \ - MACHINE_TYPE_NAME("petalogix-s3adsp1800") + MACHINE_TYPE_NAME("petalogix-s3adsp1800-common") +DECLARE_CLASS_CHECKERS (PetalogixS3adsp1800MachineClass, +PETALOGIX_S3ADSP1800_MACHINE , + TYPE_PETALOGIX_S3ADSP1800_MACHINE)static void petalogix_s3adsp1800_init (MachineState *machine)
@@ -71,11 +80,13 @@ petalogix_s3adsp1800_init(MachineState *machine)MemoryRegion *phys_ram =g_new (MemoryRegion,1 );qemu_irq irq[32 ];MemoryRegion *sysmem =get_system_memory (); +PetalogixS3adsp1800MachineClass *pmc; + pmc =PETALOGIX_S3ADSP1800_MACHINE_GET_CLASS (machine); cpu =MICROBLAZE_CPU (object_new (TYPE_MICROBLAZE_CPU ));object_property_set_str (OBJECT (cpu),"version" ,"7.10.d" , &error_abort);object_property_set_bool (OBJECT (cpu),"little-endian" , - !TARGET_BIG_ENDIAN , &error_abort); + pmc->little_endian, &error_abort);qdev_realize (DEVICE (cpu),NULL , &error_abort);/* Attach emulated BRAM through the LMB. */
@@ -95,7 +106,7 @@ petalogix_s3adsp1800_init(MachineState *machine) 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); dev =qdev_new ("xlnx.xps-intc" ); -qdev_prop_set_bit (dev,"little-endian" , !TARGET_BIG_ENDIAN ); +qdev_prop_set_bit (dev,"little-endian" , pmc->little_endian);qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<ETHLITE_IRQ |1 <<UARTLITE_IRQ );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -107,7 +118,7 @@ petalogix_s3adsp1800_init(MachineState *machine) } dev =qdev_new (TYPE_XILINX_UARTLITE ); -qdev_prop_set_bit (dev,"little-endian" , !TARGET_BIG_ENDIAN ); +qdev_prop_set_bit (dev,"little-endian" , pmc->little_endian);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,UARTLITE_BASEADDR );
@@ -115,7 +126,7 @@ petalogix_s3adsp1800_init(MachineState *machine)/* 2 timers at irq 2 @ 62 Mhz. */ dev =qdev_new ("xlnx.xps-timer" ); -qdev_prop_set_bit (dev,"little-endian" , !TARGET_BIG_ENDIAN ); +qdev_prop_set_bit (dev,"little-endian" , pmc->little_endian);qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,62 *1000000 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -123,7 +134,7 @@ petalogix_s3adsp1800_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]); dev =qdev_new ("xlnx.xps-ethernetlite" ); -qdev_prop_set_bit (dev,"little-endian" , !TARGET_BIG_ENDIAN ); +qdev_prop_set_bit (dev,"little-endian" , pmc->little_endian);qemu_configure_nic_device (dev, true,NULL );qdev_prop_set_uint32 (dev,"tx-ping-pong" ,0 );qdev_prop_set_uint32 (dev,"rx-ping-pong" ,0 );
@@ -133,26 +144,55 @@ petalogix_s3adsp1800_init(MachineState *machine)create_unimplemented_device ("xps_gpio" ,GPIO_BASEADDR ,0x10000 ); -microblaze_load_kernel (cpu, !TARGET_BIG_ENDIAN , ddr_base, ram_size, +microblaze_load_kernel (cpu, pmc->little_endian, ddr_base, ram_size, machine->initrd_filename,BINARY_DEVICE_TREE_FILE ,NULL ); } -static void petalogix_s3adsp1800_machine_class_init (ObjectClass *oc,void *data) +static void petalogix_s3adsp1800_machine_class_init (ObjectClass *oc, +bool little_endian) {MachineClass *mc =MACHINE_CLASS (oc); +PetalogixS3adsp1800MachineClass *pmc =PETALOGIX_S3ADSP1800_MACHINE_CLASS (oc); - mc->desc ="PetaLogix linux refdesign for xilinx Spartan 3ADSP1800" ; mc->init = petalogix_s3adsp1800_init; - mc->is_default = true; + pmc->little_endian = little_endian; + mc->desc = little_endian + ?"PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (little endian)" + :"PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (big endian)" ; +if (little_endian == !TARGET_BIG_ENDIAN ) { + mc->is_default = true; + mc->alias ="petalogix-s3adsp1800" ; + } +} + +static void petalogix_s3adsp1800_machine_class_init_be (ObjectClass *oc,void *data) +{ +petalogix_s3adsp1800_machine_class_init (oc, false); +} + +static void petalogix_s3adsp1800_machine_class_init_le (ObjectClass *oc,void *data) +{ +petalogix_s3adsp1800_machine_class_init (oc, true); }static const TypeInfo petalogix_s3adsp1800_machine_types[] = { { .name =TYPE_PETALOGIX_S3ADSP1800_MACHINE , .parent =TYPE_MACHINE , - .class_init = petalogix_s3adsp1800_machine_class_init, + .abstract = true, + .class_size =sizeof (PetalogixS3adsp1800MachineClass), + }, + { + .name =MACHINE_TYPE_NAME ("petalogix-s3adsp1800-be" ), + .parent =TYPE_PETALOGIX_S3ADSP1800_MACHINE , + .class_init = petalogix_s3adsp1800_machine_class_init_be, + }, + { + .name =MACHINE_TYPE_NAME ("petalogix-s3adsp1800-le" ), + .parent =TYPE_PETALOGIX_S3ADSP1800_MACHINE , + .class_init = petalogix_s3adsp1800_machine_class_init_le, }, };
Signature · 1 line
2.45.2
Re: [PATCH v3 15/17] hw/microblaze: Support various endianness for s3adsp1800 machines
Quoted 15 lines · Philippe Mathieu-Daudé
Introduce an abstract machine parent class which defines the '
little_endian' property. Duplicate the current machine, which endian is tied to the binary endianness, to one big endian and a little endian machine; updating the machine description. Keep the current default machine for each binary.'petalogix-s3adsp1800' machine is aliased as:
- 'petalogix-s3adsp1800-be' on big-endian binary,
- 'petalogix-s3adsp1800-le' on little-endian one.Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/microblaze/petalogix_s3adsp1800_mmu.c | 62 +++++++++++++++++++----- 1 file changed, 51 insertions(+), 11 deletions(-)
...
Quoted 10 lines
static const TypeInfo petalogix_s3adsp1800_machine_types[] = { { .name = TYPE_PETALOGIX_S3ADSP1800_MACHINE, .parent = TYPE_MACHINE,hw/microblaze/petalogix_s3adsp1800_mmu.c +4
-1- .class_init = petalogix_s3adsp1800_machine_class_init, + .abstract = true, + .class_size = sizeof(PetalogixS3adsp1800MachineClass), + }, + {
hw/microblaze/petalogix_s3adsp1800_mmu.c petalogix_s3adsp1800_init(MachineState *machine) · line 197
Quoted 10 lines
hw/microblaze/petalogix_s3adsp1800_mmu.c +8
-0+ .name = MACHINE_TYPE_NAME("petalogix-s3adsp1800-be"), + .parent = TYPE_PETALOGIX_S3ADSP1800_MACHINE, + .class_init = petalogix_s3adsp1800_machine_class_init_be, + }, + { + .name = MACHINE_TYPE_NAME("petalogix-s3adsp1800-le"), + .parent = TYPE_PETALOGIX_S3ADSP1800_MACHINE, + .class_init = petalogix_s3adsp1800_machine_class_init_le, }, };
Do we really want additional machine types for this? Can't we simply let the user set the machine property instead? (otherwise, all tests that run for each machine types (see qtest_cb_for_every_machine) will now be executed three times instead of only once). IMHO it should be sufficient to have a machine property for this and add proper documentation for the machine.
Thomas
Re: [PATCH v3 15/17] hw/microblaze: Support various endianness for s3adsp1800 machines
Quoted 37 lines · Thomas Huth
Quoted 15 lines · Philippe Mathieu-Daudé
Introduce an abstract machine parent class which defines the '
little_endian' property. Duplicate the current machine, which endian is tied to the binary endianness, to one big endian and a little endian machine; updating the machine description. Keep the current default machine for each binary.'petalogix-s3adsp1800' machine is aliased as:
- 'petalogix-s3adsp1800-be' on big-endian binary,
- 'petalogix-s3adsp1800-le' on little-endian one.Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/microblaze/petalogix_s3adsp1800_mmu.c| 62 +++++++++++++++++++-----1 file changed, 51 insertions(+), 11 deletions(-)...
Quoted 11 lines
static const TypeInfo petalogix_s3adsp1800_machine_types[] = { {
.name =TYPE_PETALOGIX_S3ADSP1800_MACHINE, .parent =TYPE_MACHINE,
- .class_init =petalogix_s3adsp1800_machine_class_init, + .abstract = true,
+ .class_size = sizeof(PetalogixS3adsp1800MachineClass), + },
+ {
+ .name =MACHINE_TYPE_NAME("petalogix-s3adsp1800-be"), + .parent =TYPE_PETALOGIX_S3ADSP1800_MACHINE,Quoted 8 lines
+ .class_init =
petalogix_s3adsp1800_machine_class_init_be, + },
+ {
+ .name =MACHINE_TYPE_NAME("petalogix-s3adsp1800-le"), + .parent =TYPE_PETALOGIX_S3ADSP1800_MACHINE, + .class_init =petalogix_s3adsp1800_machine_class_init_le, },
};
Quoted 1 line
Do we really want additional machine types for this? Can't we simply let the user set the machine property instead? (otherwise, all tests that run for each machine types (see
qtest_cb_for_every_machine) will now be executed three times instead of only once). IMHO it should be sufficient to have a machine property for this and add proper documentation for the machine.
Machine property was my first approach but then I figured when merging the 2 binaries in one, it is confusing for the CLI users.
Having 3 more tests until we unify the endianness binary doesn't seem a high price to pay to me. Besides, not we are not exercising the same code path. We need to prove the tests are really duplicated so we can merge the binaries. If you really insist I can modify qtests to skip these machines meanwhile.
Quoted 3 lines
Thomas
Re: [PATCH v3 15/17] hw/microblaze: Support various endianness for s3adsp1800 machines
Quoted 40 lines · Philippe Mathieu-Daudé
Quoted 37 lines · Thomas Huth
Quoted 15 lines · Philippe Mathieu-Daudé
Introduce an abstract machine parent class which defines the '
little_endian' property. Duplicate the current machine, which endian is tied to the binary endianness, to one big endian and a little endian machine; updating the machine description. Keep the current default machine for each binary.'petalogix-s3adsp1800' machine is aliased as:
- 'petalogix-s3adsp1800-be' on big-endian binary,
- 'petalogix-s3adsp1800-le' on little-endian one.Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/microblaze/petalogix_s3adsp1800_mmu.c| 62 +++++++++++++++++++-----1 file changed, 51 insertions(+), 11 deletions(-)...
Quoted 11 lines
static const TypeInfo petalogix_s3adsp1800_machine_types[] = { {
.name =TYPE_PETALOGIX_S3ADSP1800_MACHINE, .parent =TYPE_MACHINE,
- .class_init =petalogix_s3adsp1800_machine_class_init, + .abstract = true,
+ .class_size = sizeof(PetalogixS3adsp1800MachineClass), + },
+ {
+ .name =MACHINE_TYPE_NAME("petalogix-s3adsp1800-be"), + .parent =TYPE_PETALOGIX_S3ADSP1800_MACHINE,Quoted 8 lines
+ .class_init =
petalogix_s3adsp1800_machine_class_init_be, + },
+ {
+ .name =MACHINE_TYPE_NAME("petalogix-s3adsp1800-le"), + .parent =TYPE_PETALOGIX_S3ADSP1800_MACHINE, + .class_init =petalogix_s3adsp1800_machine_class_init_le, },
};Quoted 1 line
Do we really want additional machine types for this? Can't we simply let the user set the machine property instead? (otherwise, all tests that run for each machine types (see
qtest_cb_for_every_machine) will now be executed three times instead of only once). IMHO it should be sufficient to have a machine property for this and add proper documentation for the machine.
Quoted 8 lines
Machine property was my first approach but then I figured when merging the 2 binaries in one, it is confusing for the CLI users.
Having 3 more tests until we unify the endianness binary doesn't seem a high price to pay to me. Besides, not we are not exercising the same code path. We need to prove the tests are really duplicated so we can merge the binaries. If you really insist I can modify qtests to skip these machines meanwhile.
Ok, I don't insist, if unify the two endianness binaries into one in the end, that's a much bigger win, I think, so let's keep this patch as it is.
Thomas
PATCH v3 16/17 tests/functional: Explicit endianness of microblaze assets
In reply to Philippe Mathieu-DaudéThe archive used in test_microblaze_s3adsp1800.py (testing a big-endian target) contains a big-endian kernel. Rename using the _BE suffix.
Similarly, the archive in test_microblazeel_s3adsp1800 (testing a little-endian target) contains a little-endian kernel. Rename using _LE suffix.
These changes will help when adding cross-endian kernel tests.
--- tests/functional/test_microblaze_s3adsp1800.py | 6 +++--- tests/functional/test_microblazeel_s3adsp1800.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
tests/functional/test_microblaze_s3adsp1800.py +3 -3
@@ -17,14 +17,14 @@ class MicroblazeMachine(QemuSystemTest): timeout = 90 - ASSET_IMAGE = Asset( + ASSET_IMAGE_BE = Asset( ('https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/' 'day17.tar.xz'), '3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057') - def test_microblaze_s3adsp1800(self): + def test_microblaze_s3adsp1800_be(self): self.set_machine('petalogix-s3adsp1800') - file_path = self.ASSET_IMAGE.fetch() + file_path = self.ASSET_IMAGE_BE.fetch() archive_extract(file_path, self.workdir) self.vm.set_console() self.vm.add_args('-kernel', self.workdir + '/day17/ballerina.bin')
tests/functional/test_microblazeel_s3adsp1800.py +3 -3
@@ -17,14 +17,14 @@ class MicroblazeelMachine(QemuSystemTest): timeout = 90 - ASSET_IMAGE = Asset( + ASSET_IMAGE_LE = Asset( ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'), 'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22') - def test_microblazeel_s3adsp1800(self): + def test_microblazeel_s3adsp1800_le(self): self.require_netdev('user') self.set_machine('petalogix-s3adsp1800') - file_path = self.ASSET_IMAGE.fetch() + file_path = self.ASSET_IMAGE_LE.fetch() archive_extract(file_path, self.workdir) self.vm.set_console() self.vm.add_args('-kernel', self.workdir + '/day13/xmaton.bin')
Signature · 1 line
2.45.2
Re: [PATCH v3 16/17] tests/functional: Explicit endianness of microblaze assets
Quoted 8 lines · Philippe Mathieu-Daudé
The archive used in
test_microblaze_s3adsp1800.py(testing a big-endian target) contains a big-endian kernel. Rename using the_BEsuffix.Similarly, the archive in
test_microblazeel_s3adsp1800(testing a little-endian target) contains a little-endian kernel. Rename using_LEsuffix.
Quoted 8 lines
These changes will help when adding cross-endian kernel tests.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- tests/functional/test_microblaze_s3adsp1800.py | 6 +++--- tests/functional/test_microblazeel_s3adsp1800.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
PATCH v3 17/17 tests/functional: Add microblaze cross-endianness tests
In reply to Philippe Mathieu-DaudéCopy/paste the current tests, but call the opposite endianness machines, testing:
- petalogix-s3adsp1800-le machine (little-endian CPU) on the qemu-system-microblaze binary (big-endian)
- petalogix-s3adsp1800-be machine (big-endian CPU) on the qemu-system-microblazeel binary (little-endian).
--- .../functional/test_microblaze_s3adsp1800.py | 21 +++++++++++++++++++ .../test_microblazeel_s3adsp1800.py | 19 +++++++++++++++++ 2 files changed, 40 insertions(+)
tests/functional/test_microblaze_s3adsp1800.py +21 -0
@@ -36,5 +36,26 @@ def test_microblaze_s3adsp1800_be(self): # message, that's why we don't test for a later string here. This # needs some investigation by a microblaze wizard one day... + ASSET_IMAGE_LE = Asset( + ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'), + 'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22') + + def test_microblaze_s3adsp1800_le(self): + self.require_netdev('user') + self.set_machine('petalogix-s3adsp1800-le') + file_path = self.ASSET_IMAGE_LE.fetch() + archive_extract(file_path, self.workdir) + self.vm.set_console() + self.vm.add_args('-kernel', self.workdir + '/day13/xmaton.bin') + self.vm.add_args('-nic', 'user,tftp=' + self.workdir + '/day13/') + self.vm.launch() + wait_for_console_pattern(self, 'QEMU Advent Calendar 2023') + time.sleep(0.1) + exec_command(self, 'root') + time.sleep(0.1) + exec_command_and_wait_for_pattern(self, + 'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png', + '821cd3cab8efd16ad6ee5acc3642a8ea') + if __name__ == '__main__': QemuSystemTest.main()
tests/functional/test_microblazeel_s3adsp1800.py +19 -0
@@ -38,5 +38,24 @@ def test_microblazeel_s3adsp1800_le(self): 'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png', '821cd3cab8efd16ad6ee5acc3642a8ea') + ASSET_IMAGE_BE = Asset( + ('https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/' + 'day17.tar.xz'), + '3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057') + + def test_microblazeel_s3adsp1800_be(self): + self.set_machine('petalogix-s3adsp1800-be') + file_path = self.ASSET_IMAGE_BE.fetch() + archive_extract(file_path, self.workdir) + self.vm.set_console() + self.vm.add_args('-kernel', self.workdir + '/day17/ballerina.bin') + self.vm.launch() + wait_for_console_pattern(self, 'This architecture does not have ' + 'kernel memory protection') + # Note: + # The kernel sometimes gets stuck after the "This architecture ..." + # message, that's why we don't test for a later string here. This + # needs some investigation by a microblaze wizard one day... + if __name__ == '__main__': QemuSystemTest.main()
Signature · 1 line
2.45.2
Re: [PATCH v3 17/17] tests/functional: Add microblaze cross-endianness tests
Quoted 64 lines · Philippe Mathieu-Daudé
Copy/paste the current tests, but call the opposite endianness machines, testing:
- petalogix-s3adsp1800-le machine (little-endian CPU) on the qemu-system-microblaze binary (big-endian)
- petalogix-s3adsp1800-be machine (big-endian CPU) on the qemu-system-microblazeel binary (little-endian).Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- .../functional/test_microblaze_s3adsp1800.py | 21 +++++++++++++++++++ .../test_microblazeel_s3adsp1800.py | 19 +++++++++++++++++ 2 files changed, 40 insertions(+)tests/functional/test_microblaze_s3adsp1800.py +21
-0@@ -36,5 +36,26 @@ def test_microblaze_s3adsp1800_be(self): # message, that's why we don't test for a later string here. This # needs some investigation by a microblaze wizard one day... + ASSET_IMAGE_LE = Asset( + ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'), + 'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22') + + def test_microblaze_s3adsp1800_le(self): + self.require_netdev('user') + self.set_machine('petalogix-s3adsp1800-le') + file_path = self.ASSET_IMAGE_LE.fetch() + archive_extract(file_path, self.workdir) + self.vm.set_console() + self.vm.add_args('-kernel', self.workdir + '/day13/xmaton.bin') + self.vm.add_args('-nic', 'user,tftp=' + self.workdir + '/day13/') + self.vm.launch() + wait_for_console_pattern(self, 'QEMU Advent Calendar 2023') + time.sleep(0.1) + exec_command(self, 'root') + time.sleep(0.1) + exec_command_and_wait_for_pattern(self, + 'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png', + '821cd3cab8efd16ad6ee5acc3642a8ea') + if __name__ == '__main__': QemuSystemTest.main()tests/functional/test_microblazeel_s3adsp1800.py +11
-0@@ -38,5 +38,24 @@ def test_microblazeel_s3adsp1800_le(self): 'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png', '821cd3cab8efd16ad6ee5acc3642a8ea') + ASSET_IMAGE_BE = Asset( + ('https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/' + 'day17.tar.xz'), + '3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057') + + def test_microblazeel_s3adsp1800_be(self): + self.set_machine('petalogix-s3adsp1800-be') + file_path = self.ASSET_IMAGE_BE.fetch() + archive_extract(file_path, self.workdir) + self.vm.set_console() + self.vm.add_args('-kernel', self.workdir + '/day17/ballerina.bin')
tests/functional/test_microblazeel_s3adsp1800.py def test_microblazeel_s3adsp1800_le(self): · line 61
Quoted 10 lines
tests/functional/test_microblazeel_s3adsp1800.py +8
-0+ self.vm.launch() + wait_for_console_pattern(self, 'This architecture does not have ' + 'kernel memory protection') + # Note: + # The kernel sometimes gets stuck after the "This architecture ..." + # message, that's why we don't test for a later string here. This + # needs some investigation by a microblaze wizard one day... + if __name__ == '__main__': QemuSystemTest.main()
Duplicating code is ugly. I think I'd rather prefer to merge the two files into one and then add that test to both targets in meson.build.
Thomas
Re: [PATCH v3 17/17] tests/functional: Add microblaze cross-endianness tests
Quoted 75 lines · Thomas Huth
Quoted 74 lines · Philippe Mathieu-Daudé
Copy/paste the current tests, but call the opposite endianness machines, testing:
- petalogix-s3adsp1800-le machine (little-endian CPU) on the qemu-system-microblaze binary (big-endian)
- petalogix-s3adsp1800-be machine (big-endian CPU) on the qemu-system-microblazeel binary (little-endian).Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>---
.../functional/test_microblaze_s3adsp1800.py | 21 +++++++++++++++++++ .../test_microblazeel_s3adsp1800.py | 19 +++++++++++++++++2 files changed, 40 insertions(+)tests/functional/test_microblaze_s3adsp1800.py +21
-0@@ -36,5 +36,26 @@ def test_microblaze_s3adsp1800_be(self): # message, that's why we don't test for a later string here. This # needs some investigation by a microblaze wizard one day... + ASSET_IMAGE_LE = Asset( + ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'), + 'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22') + + def test_microblaze_s3adsp1800_le(self): + self.require_netdev('user') + self.set_machine('petalogix-s3adsp1800-le') + file_path = self.ASSET_IMAGE_LE.fetch() + archive_extract(file_path, self.workdir) + self.vm.set_console() + self.vm.add_args('-kernel', self.workdir + '/day13/xmaton.bin') + self.vm.add_args('-nic', 'user,tftp=' + self.workdir + '/day13/') + self.vm.launch() + wait_for_console_pattern(self, 'QEMU Advent Calendar 2023') + time.sleep(0.1) + exec_command(self, 'root') + time.sleep(0.1) + exec_command_and_wait_for_pattern(self, + 'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png', + '821cd3cab8efd16ad6ee5acc3642a8ea') +if
__name__== '__main__':
QemuSystemTest.main()tests/functional/test_microblazeel_s3adsp1800.py +13
-0@@ -38,5 +38,24 @@ def test_microblazeel_s3adsp1800_le(self): 'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png', '821cd3cab8efd16ad6ee5acc3642a8ea') + ASSET_IMAGE_BE = Asset( + ('https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/' + 'day17.tar.xz'), + '3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057') + + def test_microblazeel_s3adsp1800_be(self): + self.set_machine('petalogix-s3adsp1800-be') + file_path = self.ASSET_IMAGE_BE.fetch() + archive_extract(file_path, self.workdir) + self.vm.set_console() + self.vm.add_args('-kernel', self.workdir + '/day17/ballerina.bin') + self.vm.launch() + wait_for_console_pattern(self, 'This architecture does nothave '
+ 'kernel memory protection') + # Note:
+ # The kernel sometimes gets stuck after the "This architecture ..."
Quoted 8 lines
Quoted 6 lines
+ # message, that's why we don't test for a later string here. This
+ # needs some investigation by a microblaze wizard one day... +
if__name__== '__main__':
QemuSystemTest.main()Duplicating code is ugly. I think I'd rather prefer to merge the two files into one and then add that test to both targets in meson.build.
In v2 I mentioned I'll merge them in a following up patch. I'll try to do that for v4.