* [PATCH v7 01/10] hw/qdev-properties-system: Introduce EndianMode QAPI enum
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-13 10:07 ` Markus Armbruster
2025-02-12 12:36 ` [PATCH v7 02/10] hw/intc/xilinx_intc: Make device endianness configurable Philippe Mathieu-Daudé
` (8 subsequent siblings)
9 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
Philippe Mathieu-Daudé
Introduce the EndianMode type and the DEFINE_PROP_ENDIAN() macros.
Endianness can be BIG, LITTLE or unspecified (default).
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
qapi/common.json | 16 ++++++++++++++++
include/hw/qdev-properties-system.h | 7 +++++++
hw/core/qdev-properties-system.c | 11 +++++++++++
3 files changed, 34 insertions(+)
diff --git a/qapi/common.json b/qapi/common.json
index 6ffc7a37890..33d8df19f67 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -212,3 +212,19 @@
##
{ 'struct': 'HumanReadableText',
'data': { 'human-readable-text': 'str' } }
+
+##
+# @EndianMode:
+#
+# An enumeration of three options: little, big, and unspecified
+#
+# @unspecified: Endianness not specified
+#
+# @little: Little endianness
+#
+# @big: Big endianness
+#
+# Since: 10.0
+##
+{ 'enum': 'EndianMode',
+ 'data': [ 'unspecified', 'little', 'big' ] }
diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h
index 7ec37f6316c..ead4dfc2f02 100644
--- a/include/hw/qdev-properties-system.h
+++ b/include/hw/qdev-properties-system.h
@@ -30,6 +30,7 @@ extern const PropertyInfo qdev_prop_pcie_link_speed;
extern const PropertyInfo qdev_prop_pcie_link_width;
extern const PropertyInfo qdev_prop_cpus390entitlement;
extern const PropertyInfo qdev_prop_iothread_vq_mapping_list;
+extern const PropertyInfo qdev_prop_endian_mode;
#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
@@ -97,4 +98,10 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_list;
DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list, \
IOThreadVirtQueueMappingList *)
+#define DEFINE_PROP_ENDIAN(_name, _state, _field, _default) \
+ DEFINE_PROP_UNSIGNED(_name, _state, _field, _default, \
+ qdev_prop_endian_mode, EndianMode)
+#define DEFINE_PROP_ENDIAN_NODEFAULT(_name, _state, _field) \
+ DEFINE_PROP_ENDIAN(_name, _state, _field, ENDIAN_MODE_UNSPECIFIED)
+
#endif
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index a96675beb0d..89f954f569e 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -1283,3 +1283,14 @@ const PropertyInfo qdev_prop_iothread_vq_mapping_list = {
.set = set_iothread_vq_mapping_list,
.release = release_iothread_vq_mapping_list,
};
+
+/* --- Endian modes */
+
+const PropertyInfo qdev_prop_endian_mode = {
+ .name = "EndianMode",
+ .description = "Endian mode, big/little/unspecified",
+ .enum_table = &EndianMode_lookup,
+ .get = qdev_propinfo_get_enum,
+ .set = qdev_propinfo_set_enum,
+ .set_default_value = qdev_propinfo_set_default_value_enum,
+};
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v7 01/10] hw/qdev-properties-system: Introduce EndianMode QAPI enum
2025-02-12 12:36 ` [PATCH v7 01/10] hw/qdev-properties-system: Introduce EndianMode QAPI enum Philippe Mathieu-Daudé
@ 2025-02-13 10:07 ` Markus Armbruster
0 siblings, 0 replies; 19+ messages in thread
From: Markus Armbruster @ 2025-02-13 10:07 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson,
qemu-ppc, Sai Pavan Boddu, Edgar E. Iglesias, Alistair Francis,
Daniel P. Berrangé
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Introduce the EndianMode type and the DEFINE_PROP_ENDIAN() macros.
> Endianness can be BIG, LITTLE or unspecified (default).
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> qapi/common.json | 16 ++++++++++++++++
> include/hw/qdev-properties-system.h | 7 +++++++
> hw/core/qdev-properties-system.c | 11 +++++++++++
> 3 files changed, 34 insertions(+)
>
> diff --git a/qapi/common.json b/qapi/common.json
> index 6ffc7a37890..33d8df19f67 100644
> --- a/qapi/common.json
> +++ b/qapi/common.json
> @@ -212,3 +212,19 @@
> ##
> { 'struct': 'HumanReadableText',
> 'data': { 'human-readable-text': 'str' } }
> +
> +##
> +# @EndianMode:
> +#
> +# An enumeration of three options: little, big, and unspecified
Not sure this sentence is worth its keep. It's consistent with existing
practice in this file, though.
> +#
> +# @unspecified: Endianness not specified
> +#
> +# @little: Little endianness
> +#
> +# @big: Big endianness
> +#
> +# Since: 10.0
> +##
> +{ 'enum': 'EndianMode',
> + 'data': [ 'unspecified', 'little', 'big' ] }
Acked-by: Markus Armbruster <armbru@redhat.com>
[...]
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v7 02/10] hw/intc/xilinx_intc: Make device endianness configurable
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
2025-02-12 12:36 ` [PATCH v7 01/10] hw/qdev-properties-system: Introduce EndianMode QAPI enum Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-12 12:39 ` Philippe Mathieu-Daudé
2025-02-12 12:56 ` Thomas Huth
2025-02-12 12:36 ` [PATCH v7 03/10] hw/net/xilinx_ethlite: " Philippe Mathieu-Daudé
` (7 subsequent siblings)
9 siblings, 2 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/intc/xilinx_intc.c | 59 ++++++++++++++++++------
hw/microblaze/petalogix_ml605_mmu.c | 1 +
hw/microblaze/petalogix_s3adsp1800_mmu.c | 3 ++
hw/ppc/virtex_ml507.c | 1 +
hw/riscv/microblaze-v-generic.c | 1 +
5 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c
index 6930f83907a..ab1c4a32221 100644
--- a/hw/intc/xilinx_intc.c
+++ b/hw/intc/xilinx_intc.c
@@ -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
@@ -23,10 +26,12 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "hw/sysbus.h"
#include "qemu/module.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
+#include "hw/qdev-properties-system.h"
#include "qom/object.h"
#define D(x)
@@ -49,6 +54,7 @@ struct XpsIntc
{
SysBusDevice parent_obj;
+ EndianMode model_endianness;
MemoryRegion mmio;
qemu_irq parent_irq;
@@ -140,18 +146,28 @@ 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,
+ .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_LITTLE_ENDIAN,
+ [1].endianness = DEVICE_BIG_ENDIAN,
};
static void irq_handler(void *opaque, int irq, int level)
@@ -174,13 +190,27 @@ 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);
+
+ if (p->model_endianness == ENDIAN_MODE_UNSPECIFIED) {
+ error_setg(errp, TYPE_XILINX_INTC " property 'endianness'"
+ " must be set to 'big' or 'little'");
+ return;
+ }
+
+ memory_region_init_io(&p->mmio, OBJECT(dev),
+ &pic_ops[p->model_endianness == ENDIAN_MODE_BIG],
+ p, "xlnx.xps-intc",
+ R_MAX * 4);
+}
+
static const Property xilinx_intc_properties[] = {
+ DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XpsIntc, model_endianness),
DEFINE_PROP_UINT32("kind-of-intr", XpsIntc, c_kind_of_intr, 0),
};
@@ -188,6 +218,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);
}
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index 8b44be75a22..55398cc67d1 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -111,6 +111,7 @@ petalogix_ml605_init(MachineState *machine)
dev = qdev_new("xlnx.xps-intc");
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
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);
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index 2c0d8c34cd2..15cabe11777 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -71,6 +71,8 @@ petalogix_s3adsp1800_init(MachineState *machine)
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq irq[32];
MemoryRegion *sysmem = get_system_memory();
+ EndianMode endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG
+ : ENDIAN_MODE_LITTLE;
cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort);
@@ -95,6 +97,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1);
dev = qdev_new("xlnx.xps-intc");
+ qdev_prop_set_enum(dev, "endianness", endianness);
qdev_prop_set_uint32(dev, "kind-of-intr",
1 << ETHLITE_IRQ | 1 << UARTLITE_IRQ);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index 23238119273..df8f9644829 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -217,6 +217,7 @@ static void virtex_init(MachineState *machine)
cpu_irq = qdev_get_gpio_in(DEVICE(cpu), PPC40x_INPUT_INT);
dev = qdev_new("xlnx.xps-intc");
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_BIG);
qdev_prop_set_uint32(dev, "kind-of-intr", 0);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR);
diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c
index 26788a1824a..ebdd461ae98 100644
--- a/hw/riscv/microblaze-v-generic.c
+++ b/hw/riscv/microblaze-v-generic.c
@@ -79,6 +79,7 @@ static void mb_v_generic_init(MachineState *machine)
memory_region_add_subregion(sysmem, ddr_base, phys_ram);
dev = qdev_new("xlnx.xps-intc");
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
qdev_prop_set_uint32(dev, "kind-of-intr",
1 << UARTLITE_IRQ);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v7 02/10] hw/intc/xilinx_intc: Make device endianness configurable
2025-02-12 12:36 ` [PATCH v7 02/10] hw/intc/xilinx_intc: Make device endianness configurable Philippe Mathieu-Daudé
@ 2025-02-12 12:39 ` Philippe Mathieu-Daudé
2025-02-12 12:56 ` Thomas Huth
1 sibling, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:39 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé
On 12/2/25 13:36, Philippe Mathieu-Daudé wrote:
> 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.
Grr, please read:
Add the "endianness" property to select the device endianness.
This property is unspecified by default, and machines need to
make it explicit.
(same in following patches).
> Set the proper endianness for each machine using the device.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/intc/xilinx_intc.c | 59 ++++++++++++++++++------
> hw/microblaze/petalogix_ml605_mmu.c | 1 +
> hw/microblaze/petalogix_s3adsp1800_mmu.c | 3 ++
> hw/ppc/virtex_ml507.c | 1 +
> hw/riscv/microblaze-v-generic.c | 1 +
> 5 files changed, 51 insertions(+), 14 deletions(-)
>
> diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c
> index 6930f83907a..ab1c4a32221 100644
> --- a/hw/intc/xilinx_intc.c
> +++ b/hw/intc/xilinx_intc.c
> @@ -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
> @@ -23,10 +26,12 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qapi/error.h"
> #include "hw/sysbus.h"
> #include "qemu/module.h"
> #include "hw/irq.h"
> #include "hw/qdev-properties.h"
> +#include "hw/qdev-properties-system.h"
> #include "qom/object.h"
>
> #define D(x)
> @@ -49,6 +54,7 @@ struct XpsIntc
> {
> SysBusDevice parent_obj;
>
> + EndianMode model_endianness;
> MemoryRegion mmio;
> qemu_irq parent_irq;
>
> @@ -140,18 +146,28 @@ 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,
> + .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_LITTLE_ENDIAN,
> + [1].endianness = DEVICE_BIG_ENDIAN,
> };
>
> static void irq_handler(void *opaque, int irq, int level)
> @@ -174,13 +190,27 @@ 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);
> +
> + if (p->model_endianness == ENDIAN_MODE_UNSPECIFIED) {
> + error_setg(errp, TYPE_XILINX_INTC " property 'endianness'"
> + " must be set to 'big' or 'little'");
> + return;
> + }
> +
> + memory_region_init_io(&p->mmio, OBJECT(dev),
> + &pic_ops[p->model_endianness == ENDIAN_MODE_BIG],
> + p, "xlnx.xps-intc",
> + R_MAX * 4);
> +}
> +
> static const Property xilinx_intc_properties[] = {
> + DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XpsIntc, model_endianness),
> DEFINE_PROP_UINT32("kind-of-intr", XpsIntc, c_kind_of_intr, 0),
> };
>
> @@ -188,6 +218,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);
> }
>
> diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
> index 8b44be75a22..55398cc67d1 100644
> --- a/hw/microblaze/petalogix_ml605_mmu.c
> +++ b/hw/microblaze/petalogix_ml605_mmu.c
> @@ -111,6 +111,7 @@ petalogix_ml605_init(MachineState *machine)
>
>
> dev = qdev_new("xlnx.xps-intc");
> + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
> 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);
> diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
> index 2c0d8c34cd2..15cabe11777 100644
> --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
> +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
> @@ -71,6 +71,8 @@ petalogix_s3adsp1800_init(MachineState *machine)
> MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
> qemu_irq irq[32];
> MemoryRegion *sysmem = get_system_memory();
> + EndianMode endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG
> + : ENDIAN_MODE_LITTLE;
>
> cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
> object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort);
> @@ -95,6 +97,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
> 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1);
>
> dev = qdev_new("xlnx.xps-intc");
> + qdev_prop_set_enum(dev, "endianness", endianness);
> qdev_prop_set_uint32(dev, "kind-of-intr",
> 1 << ETHLITE_IRQ | 1 << UARTLITE_IRQ);
> sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
> index 23238119273..df8f9644829 100644
> --- a/hw/ppc/virtex_ml507.c
> +++ b/hw/ppc/virtex_ml507.c
> @@ -217,6 +217,7 @@ static void virtex_init(MachineState *machine)
>
> cpu_irq = qdev_get_gpio_in(DEVICE(cpu), PPC40x_INPUT_INT);
> dev = qdev_new("xlnx.xps-intc");
> + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_BIG);
> qdev_prop_set_uint32(dev, "kind-of-intr", 0);
> sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR);
> diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c
> index 26788a1824a..ebdd461ae98 100644
> --- a/hw/riscv/microblaze-v-generic.c
> +++ b/hw/riscv/microblaze-v-generic.c
> @@ -79,6 +79,7 @@ static void mb_v_generic_init(MachineState *machine)
> memory_region_add_subregion(sysmem, ddr_base, phys_ram);
>
> dev = qdev_new("xlnx.xps-intc");
> + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
> qdev_prop_set_uint32(dev, "kind-of-intr",
> 1 << UARTLITE_IRQ);
> sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v7 02/10] hw/intc/xilinx_intc: Make device endianness configurable
2025-02-12 12:36 ` [PATCH v7 02/10] hw/intc/xilinx_intc: Make device endianness configurable Philippe Mathieu-Daudé
2025-02-12 12:39 ` Philippe Mathieu-Daudé
@ 2025-02-12 12:56 ` Thomas Huth
2025-02-13 12:15 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 19+ messages in thread
From: Thomas Huth @ 2025-02-12 12:56 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-riscv, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé
On 12/02/2025 13.36, Philippe Mathieu-Daudé wrote:
> 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.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
...
> diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
> index 8b44be75a22..55398cc67d1 100644
> --- a/hw/microblaze/petalogix_ml605_mmu.c
> +++ b/hw/microblaze/petalogix_ml605_mmu.c
> @@ -111,6 +111,7 @@ petalogix_ml605_init(MachineState *machine)
>
>
> dev = qdev_new("xlnx.xps-intc");
> + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
Do we still need a TARGET_BIG_ENDIAN ?: check here, too? ... the
petalogix_ml605_machine_init() code still contains it, though big endian is
marked as deprecated and untested ...
Anyway, assuming that nobody uses this in big endian anymore:
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v7 02/10] hw/intc/xilinx_intc: Make device endianness configurable
2025-02-12 12:56 ` Thomas Huth
@ 2025-02-13 12:15 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-13 12:15 UTC (permalink / raw)
To: Thomas Huth, qemu-devel
Cc: qemu-riscv, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé
On 12/2/25 13:56, Thomas Huth wrote:
> On 12/02/2025 13.36, Philippe Mathieu-Daudé wrote:
>> 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.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
> ...
>> diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/
>> petalogix_ml605_mmu.c
>> index 8b44be75a22..55398cc67d1 100644
>> --- a/hw/microblaze/petalogix_ml605_mmu.c
>> +++ b/hw/microblaze/petalogix_ml605_mmu.c
>> @@ -111,6 +111,7 @@ petalogix_ml605_init(MachineState *machine)
>> dev = qdev_new("xlnx.xps-intc");
>> + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
>
> Do we still need a TARGET_BIG_ENDIAN ?: check here, too? ... the
> petalogix_ml605_machine_init() code still contains it, though big endian
> is marked as deprecated and untested ...
Oops, I guess my mind already discarded it...
> Anyway, assuming that nobody uses this in big endian anymore:
> Reviewed-by: Thomas Huth <thuth@redhat.com>
Thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v7 03/10] hw/net/xilinx_ethlite: Make device endianness configurable
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
2025-02-12 12:36 ` [PATCH v7 01/10] hw/qdev-properties-system: Introduce EndianMode QAPI enum Philippe Mathieu-Daudé
2025-02-12 12:36 ` [PATCH v7 02/10] hw/intc/xilinx_intc: Make device endianness configurable Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-12 13:01 ` Thomas Huth
2025-02-12 12:36 ` [PATCH v7 04/10] hw/timer/xilinx_timer: " Philippe Mathieu-Daudé
` (6 subsequent siblings)
9 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 +
hw/net/xilinx_ethlite.c | 29 +++++++++++++++++++-----
hw/riscv/microblaze-v-generic.c | 1 +
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index 15cabe11777..d419dc49a25 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -123,6 +123,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_enum(dev, "endianness", endianness);
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);
diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
index 14bf2b2e17a..15d9b95aa80 100644
--- a/hw/net/xilinx_ethlite.c
+++ b/hw/net/xilinx_ethlite.c
@@ -34,6 +34,7 @@
#include "hw/sysbus.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
+#include "hw/qdev-properties-system.h"
#include "hw/misc/unimp.h"
#include "net/net.h"
#include "trace.h"
@@ -85,6 +86,7 @@ struct XlnxXpsEthLite
{
SysBusDevice parent_obj;
+ EndianMode model_endianness;
MemoryRegion container;
qemu_irq irq;
NICState *nic;
@@ -183,10 +185,10 @@ static void port_tx_write(void *opaque, hwaddr addr, uint64_t value,
}
}
-static const MemoryRegionOps eth_porttx_ops = {
+static const MemoryRegionOps eth_porttx_ops[2] = {
+ [0 ... 1] = {
.read = port_tx_read,
.write = port_tx_write,
- .endianness = DEVICE_NATIVE_ENDIAN,
.impl = {
.min_access_size = 4,
.max_access_size = 4,
@@ -195,6 +197,9 @@ static const MemoryRegionOps eth_porttx_ops = {
.min_access_size = 4,
.max_access_size = 4,
},
+ },
+ [0].endianness = DEVICE_LITTLE_ENDIAN,
+ [1].endianness = DEVICE_BIG_ENDIAN,
};
static uint64_t port_rx_read(void *opaque, hwaddr addr, unsigned int size)
@@ -232,10 +237,10 @@ static void port_rx_write(void *opaque, hwaddr addr, uint64_t value,
}
}
-static const MemoryRegionOps eth_portrx_ops = {
+static const MemoryRegionOps eth_portrx_ops[2] = {
+ [0 ... 1] = {
.read = port_rx_read,
.write = port_rx_write,
- .endianness = DEVICE_NATIVE_ENDIAN,
.impl = {
.min_access_size = 4,
.max_access_size = 4,
@@ -244,6 +249,9 @@ static const MemoryRegionOps eth_portrx_ops = {
.min_access_size = 4,
.max_access_size = 4,
},
+ },
+ [0].endianness = DEVICE_LITTLE_ENDIAN,
+ [1].endianness = DEVICE_BIG_ENDIAN,
};
static bool eth_can_rx(NetClientState *nc)
@@ -300,6 +308,14 @@ static NetClientInfo net_xilinx_ethlite_info = {
static void xilinx_ethlite_realize(DeviceState *dev, Error **errp)
{
XlnxXpsEthLite *s = XILINX_ETHLITE(dev);
+ unsigned ops_index;
+
+ if (s->model_endianness == ENDIAN_MODE_UNSPECIFIED) {
+ error_setg(errp, TYPE_XILINX_ETHLITE " property 'endianness'"
+ " must be set to 'big' or 'little'");
+ return;
+ }
+ ops_index = s->model_endianness == ENDIAN_MODE_BIG ? 1 : 0;
memory_region_init(&s->container, OBJECT(dev),
"xlnx.xps-ethernetlite", 0x2000);
@@ -328,7 +344,7 @@ static void xilinx_ethlite_realize(DeviceState *dev, Error **errp)
BUFSZ_MAX, &error_abort);
memory_region_add_subregion(&s->container, 0x0800 * i, &s->port[i].txbuf);
memory_region_init_io(&s->port[i].txio, OBJECT(dev),
- ð_porttx_ops, s,
+ ð_porttx_ops[ops_index], s,
i ? "ethlite.tx[1]io" : "ethlite.tx[0]io",
4 * TX_MAX);
memory_region_add_subregion(&s->container, i ? A_TX_BASE1 : A_TX_BASE0,
@@ -340,7 +356,7 @@ static void xilinx_ethlite_realize(DeviceState *dev, Error **errp)
memory_region_add_subregion(&s->container, 0x1000 + 0x0800 * i,
&s->port[i].rxbuf);
memory_region_init_io(&s->port[i].rxio, OBJECT(dev),
- ð_portrx_ops, s,
+ ð_portrx_ops[ops_index], s,
i ? "ethlite.rx[1]io" : "ethlite.rx[0]io",
4 * RX_MAX);
memory_region_add_subregion(&s->container, i ? A_RX_BASE1 : A_RX_BASE0,
@@ -363,6 +379,7 @@ static void xilinx_ethlite_init(Object *obj)
}
static const Property xilinx_ethlite_properties[] = {
+ DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XlnxXpsEthLite, model_endianness),
DEFINE_PROP_UINT32("tx-ping-pong", XlnxXpsEthLite, c_tx_pingpong, 1),
DEFINE_PROP_UINT32("rx-ping-pong", XlnxXpsEthLite, c_rx_pingpong, 1),
DEFINE_NIC_PROPERTIES(XlnxXpsEthLite, conf),
diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c
index ebdd461ae98..a21fdfbe6db 100644
--- a/hw/riscv/microblaze-v-generic.c
+++ b/hw/riscv/microblaze-v-generic.c
@@ -120,6 +120,7 @@ static void mb_v_generic_init(MachineState *machine)
/* Emaclite */
dev = qdev_new("xlnx.xps-ethernetlite");
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
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);
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v7 03/10] hw/net/xilinx_ethlite: Make device endianness configurable
2025-02-12 12:36 ` [PATCH v7 03/10] hw/net/xilinx_ethlite: " Philippe Mathieu-Daudé
@ 2025-02-12 13:01 ` Thomas Huth
0 siblings, 0 replies; 19+ messages in thread
From: Thomas Huth @ 2025-02-12 13:01 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-riscv, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé
On 12/02/2025 13.36, Philippe Mathieu-Daudé wrote:
> 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.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v7 04/10] hw/timer/xilinx_timer: Make device endianness configurable
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-02-12 12:36 ` [PATCH v7 03/10] hw/net/xilinx_ethlite: " Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-12 13:04 ` Thomas Huth
2025-02-12 12:36 ` [PATCH v7 05/10] hw/char/xilinx_uartlite: " Philippe Mathieu-Daudé
` (5 subsequent siblings)
9 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/microblaze/petalogix_ml605_mmu.c | 1 +
hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 +
hw/ppc/virtex_ml507.c | 1 +
hw/riscv/microblaze-v-generic.c | 2 ++
hw/timer/xilinx_timer.c | 43 +++++++++++++++++-------
5 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index 55398cc67d1..490640e9428 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -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_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
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);
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index d419dc49a25..caaea222a8c 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -116,6 +116,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
/* 2 timers at irq 2 @ 62 Mhz. */
dev = qdev_new("xlnx.xps-timer");
+ qdev_prop_set_enum(dev, "endianness", endianness);
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);
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index df8f9644829..a01354d991d 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -231,6 +231,7 @@ static void virtex_init(MachineState *machine)
/* 2 timers at irq 2 @ 62 Mhz. */
dev = qdev_new("xlnx.xps-timer");
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_BIG);
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);
diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c
index a21fdfbe6db..3c79f5733b2 100644
--- a/hw/riscv/microblaze-v-generic.c
+++ b/hw/riscv/microblaze-v-generic.c
@@ -104,6 +104,7 @@ static void mb_v_generic_init(MachineState *machine)
/* 2 timers at irq 0 @ 100 Mhz. */
dev = qdev_new("xlnx.xps-timer");
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
qdev_prop_set_uint32(dev, "one-timer-only", 0);
qdev_prop_set_uint32(dev, "clock-frequency", 100000000);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
@@ -112,6 +113,7 @@ static void mb_v_generic_init(MachineState *machine)
/* 2 timers at irq 3 @ 100 Mhz. */
dev = qdev_new("xlnx.xps-timer");
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
qdev_prop_set_uint32(dev, "one-timer-only", 0);
qdev_prop_set_uint32(dev, "clock-frequency", 100000000);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c
index 6595cf5f517..4620528f985 100644
--- a/hw/timer/xilinx_timer.c
+++ b/hw/timer/xilinx_timer.c
@@ -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
@@ -23,10 +26,12 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "hw/sysbus.h"
#include "hw/irq.h"
#include "hw/ptimer.h"
#include "hw/qdev-properties.h"
+#include "hw/qdev-properties-system.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "qom/object.h"
@@ -69,6 +74,7 @@ struct XpsTimerState
{
SysBusDevice parent_obj;
+ EndianMode model_endianness;
MemoryRegion mmio;
qemu_irq irq;
uint8_t one_timer_only;
@@ -189,18 +195,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 = 4,
+ .max_access_size = 4,
+ },
},
- .valid = {
- .min_access_size = 4,
- .max_access_size = 4
- }
+ [0].endianness = DEVICE_LITTLE_ENDIAN,
+ [1].endianness = DEVICE_BIG_ENDIAN,
};
static void timer_hit(void *opaque)
@@ -220,6 +229,12 @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp)
XpsTimerState *t = XILINX_TIMER(dev);
unsigned int i;
+ if (t->model_endianness == ENDIAN_MODE_UNSPECIFIED) {
+ error_setg(errp, TYPE_XILINX_TIMER " property 'endianness'"
+ " must be set to 'big' or 'little'");
+ return;
+ }
+
/* Init all the ptimers. */
t->timers = g_malloc0(sizeof t->timers[0] * num_timers(t));
for (i = 0; i < num_timers(t); i++) {
@@ -233,8 +248,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->model_endianness == ENDIAN_MODE_BIG],
+ t, "xlnx.xps-timer", R_MAX * 4 * num_timers(t));
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &t->mmio);
}
@@ -247,6 +263,7 @@ static void xilinx_timer_init(Object *obj)
}
static const Property xilinx_timer_properties[] = {
+ DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XpsTimerState, model_endianness),
DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 1000000),
DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0),
};
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v7 04/10] hw/timer/xilinx_timer: Make device endianness configurable
2025-02-12 12:36 ` [PATCH v7 04/10] hw/timer/xilinx_timer: " Philippe Mathieu-Daudé
@ 2025-02-12 13:04 ` Thomas Huth
0 siblings, 0 replies; 19+ messages in thread
From: Thomas Huth @ 2025-02-12 13:04 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-riscv, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé
On 12/02/2025 13.36, Philippe Mathieu-Daudé wrote:
> 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.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/microblaze/petalogix_ml605_mmu.c | 1 +
> hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 +
> hw/ppc/virtex_ml507.c | 1 +
> hw/riscv/microblaze-v-generic.c | 2 ++
> hw/timer/xilinx_timer.c | 43 +++++++++++++++++-------
> 5 files changed, 35 insertions(+), 13 deletions(-)
>
> diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
> index 55398cc67d1..490640e9428 100644
> --- a/hw/microblaze/petalogix_ml605_mmu.c
> +++ b/hw/microblaze/petalogix_ml605_mmu.c
> @@ -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_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
> 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);
Same question as in the second patch: Do we still need to take care of
TARGET_BIG_ENDIAN here?
Anyway,
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v7 05/10] hw/char/xilinx_uartlite: Make device endianness configurable
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-02-12 12:36 ` [PATCH v7 04/10] hw/timer/xilinx_timer: " Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-12 13:06 ` Thomas Huth
2025-02-12 12:36 ` [PATCH v7 06/10] hw/ssi/xilinx_spi: " Philippe Mathieu-Daudé
` (4 subsequent siblings)
9 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/char/xilinx_uartlite.c | 34 ++++++++++++++++--------
hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 +
hw/riscv/microblaze-v-generic.c | 1 +
3 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/hw/char/xilinx_uartlite.c b/hw/char/xilinx_uartlite.c
index 56955e0d74a..4037c937eeb 100644
--- a/hw/char/xilinx_uartlite.c
+++ b/hw/char/xilinx_uartlite.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
+#include "qapi/error.h"
#include "hw/char/xilinx_uartlite.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
@@ -57,6 +58,7 @@
struct XilinxUARTLite {
SysBusDevice parent_obj;
+ EndianMode model_endianness;
MemoryRegion mmio;
CharBackend chr;
qemu_irq irq;
@@ -166,17 +168,21 @@ 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,
- .valid = {
- .min_access_size = 1,
- .max_access_size = 4
- }
+static const MemoryRegionOps uart_ops[2] = {
+ [0 ... 1] = {
+ .read = uart_read,
+ .write = uart_write,
+ .valid = {
+ .min_access_size = 1,
+ .max_access_size = 4,
+ },
+ },
+ [0].endianness = DEVICE_LITTLE_ENDIAN,
+ [1].endianness = DEVICE_BIG_ENDIAN,
};
static const Property xilinx_uartlite_properties[] = {
+ DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XilinxUARTLite, model_endianness),
DEFINE_PROP_CHR("chardev", XilinxUARTLite, chr),
};
@@ -214,6 +220,15 @@ static void xilinx_uartlite_realize(DeviceState *dev, Error **errp)
{
XilinxUARTLite *s = XILINX_UARTLITE(dev);
+ if (s->model_endianness == ENDIAN_MODE_UNSPECIFIED) {
+ error_setg(errp, TYPE_XILINX_UARTLITE " property 'endianness'"
+ " must be set to 'big' or 'little'");
+ return;
+ }
+
+ memory_region_init_io(&s->mmio, OBJECT(dev),
+ &uart_ops[s->model_endianness == ENDIAN_MODE_BIG],
+ 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);
}
@@ -223,9 +238,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);
}
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index caaea222a8c..bdba2006b72 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -109,6 +109,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
}
dev = qdev_new(TYPE_XILINX_UARTLITE);
+ qdev_prop_set_enum(dev, "endianness", endianness);
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);
diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c
index 3c79f5733b2..d8e67906d26 100644
--- a/hw/riscv/microblaze-v-generic.c
+++ b/hw/riscv/microblaze-v-generic.c
@@ -92,6 +92,7 @@ static void mb_v_generic_init(MachineState *machine)
/* Uartlite */
dev = qdev_new(TYPE_XILINX_UARTLITE);
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
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);
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v7 05/10] hw/char/xilinx_uartlite: Make device endianness configurable
2025-02-12 12:36 ` [PATCH v7 05/10] hw/char/xilinx_uartlite: " Philippe Mathieu-Daudé
@ 2025-02-12 13:06 ` Thomas Huth
0 siblings, 0 replies; 19+ messages in thread
From: Thomas Huth @ 2025-02-12 13:06 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-riscv, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé
On 12/02/2025 13.36, Philippe Mathieu-Daudé wrote:
> 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.
With the patch description fixed (as you mentioned in patch 02):
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v7 06/10] hw/ssi/xilinx_spi: Make device endianness configurable
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-02-12 12:36 ` [PATCH v7 05/10] hw/char/xilinx_uartlite: " Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-12 13:10 ` Thomas Huth
2025-02-12 12:36 ` [PATCH v7 07/10] tests/functional: Explicit endianness of microblaze assets Philippe Mathieu-Daudé
` (3 subsequent siblings)
9 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/microblaze/petalogix_ml605_mmu.c | 1 +
hw/ssi/xilinx_spi.c | 32 +++++++++++++++++++++--------
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index 490640e9428..b34edf13796 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -175,6 +175,7 @@ petalogix_ml605_init(MachineState *machine)
SSIBus *spi;
dev = qdev_new("xlnx.xps-spi");
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES);
busdev = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(busdev, &error_fatal);
diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c
index fd1ff12eb1d..be5baa6b350 100644
--- a/hw/ssi/xilinx_spi.c
+++ b/hw/ssi/xilinx_spi.c
@@ -25,6 +25,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "hw/sysbus.h"
#include "migration/vmstate.h"
#include "qemu/module.h"
@@ -32,6 +33,7 @@
#include "hw/irq.h"
#include "hw/qdev-properties.h"
+#include "hw/qdev-properties-system.h"
#include "hw/ssi/ssi.h"
#include "qom/object.h"
@@ -83,6 +85,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(XilinxSPI, XILINX_SPI)
struct XilinxSPI {
SysBusDevice parent_obj;
+ EndianMode model_endianness;
MemoryRegion mmio;
qemu_irq irq;
@@ -313,14 +316,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_LITTLE_ENDIAN,
+ [1].endianness = DEVICE_BIG_ENDIAN,
};
static void xilinx_spi_realize(DeviceState *dev, Error **errp)
@@ -329,6 +335,12 @@ static void xilinx_spi_realize(DeviceState *dev, Error **errp)
XilinxSPI *s = XILINX_SPI(dev);
int i;
+ if (s->model_endianness == ENDIAN_MODE_UNSPECIFIED) {
+ error_setg(errp, TYPE_XILINX_SPI " property 'endianness'"
+ " must be set to 'big' or 'little'");
+ return;
+ }
+
DB_PRINT("\n");
s->spi = ssi_create_bus(dev, "spi");
@@ -339,7 +351,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->model_endianness == ENDIAN_MODE_BIG], s,
"xilinx-spi", R_MAX * 4);
sysbus_init_mmio(sbd, &s->mmio);
@@ -362,6 +375,7 @@ static const VMStateDescription vmstate_xilinx_spi = {
};
static const Property xilinx_spi_properties[] = {
+ DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XilinxSPI, model_endianness),
DEFINE_PROP_UINT8("num-ss-bits", XilinxSPI, num_cs, 1),
};
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v7 06/10] hw/ssi/xilinx_spi: Make device endianness configurable
2025-02-12 12:36 ` [PATCH v7 06/10] hw/ssi/xilinx_spi: " Philippe Mathieu-Daudé
@ 2025-02-12 13:10 ` Thomas Huth
0 siblings, 0 replies; 19+ messages in thread
From: Thomas Huth @ 2025-02-12 13:10 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-riscv, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé
On 12/02/2025 13.36, Philippe Mathieu-Daudé wrote:
> 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.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/microblaze/petalogix_ml605_mmu.c | 1 +
> hw/ssi/xilinx_spi.c | 32 +++++++++++++++++++++--------
> 2 files changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
> index 490640e9428..b34edf13796 100644
> --- a/hw/microblaze/petalogix_ml605_mmu.c
> +++ b/hw/microblaze/petalogix_ml605_mmu.c
> @@ -175,6 +175,7 @@ petalogix_ml605_init(MachineState *machine)
> SSIBus *spi;
>
> dev = qdev_new("xlnx.xps-spi");
> + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE);
> qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES);
> busdev = SYS_BUS_DEVICE(dev);
> sysbus_realize_and_unref(busdev, &error_fatal);
TARGET_BIG_ENDIAN required again?
Anyway,
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v7 07/10] tests/functional: Explicit endianness of microblaze assets
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-02-12 12:36 ` [PATCH v7 06/10] hw/ssi/xilinx_spi: " Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-12 12:36 ` [PATCH v7 08/10] tests/functional: Allow microblaze tests to take a machine name argument Philippe Mathieu-Daudé
` (2 subsequent siblings)
9 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20250206131052.30207-13-philmd@linaro.org>
---
tests/functional/test_microblaze_s3adsp1800.py | 6 +++---
tests/functional/test_microblazeel_s3adsp1800.py | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/functional/test_microblaze_s3adsp1800.py b/tests/functional/test_microblaze_s3adsp1800.py
index 2c4464bd05a..fac364b1ea9 100755
--- a/tests/functional/test_microblaze_s3adsp1800.py
+++ b/tests/functional/test_microblaze_s3adsp1800.py
@@ -15,14 +15,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')
- self.archive_extract(self.ASSET_IMAGE)
+ self.archive_extract(self.ASSET_IMAGE_BE)
self.vm.set_console()
self.vm.add_args('-kernel',
self.scratch_file('day17', 'ballerina.bin'))
diff --git a/tests/functional/test_microblazeel_s3adsp1800.py b/tests/functional/test_microblazeel_s3adsp1800.py
index c382afe6bfa..5d353dba5d2 100755
--- a/tests/functional/test_microblazeel_s3adsp1800.py
+++ b/tests/functional/test_microblazeel_s3adsp1800.py
@@ -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')
- self.archive_extract(self.ASSET_IMAGE)
+ self.archive_extract(self.ASSET_IMAGE_LE)
self.vm.set_console()
self.vm.add_args('-kernel', self.scratch_file('day13', 'xmaton.bin'))
tftproot = self.scratch_file('day13')
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v7 08/10] tests/functional: Allow microblaze tests to take a machine name argument
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-02-12 12:36 ` [PATCH v7 07/10] tests/functional: Explicit endianness of microblaze assets Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-12 12:36 ` [PATCH v7 09/10] tests/functional: Remove sleep() kludges from microblaze tests Philippe Mathieu-Daudé
2025-02-12 12:36 ` [PATCH v7 10/10] tests/functional: Have microblaze tests inherit common parent class Philippe Mathieu-Daudé
9 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
Philippe Mathieu-Daudé
Make microblaze tests a bit more generic.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20250206131052.30207-14-philmd@linaro.org>
---
tests/functional/test_microblaze_s3adsp1800.py | 7 +++++--
tests/functional/test_microblazeel_s3adsp1800.py | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tests/functional/test_microblaze_s3adsp1800.py b/tests/functional/test_microblaze_s3adsp1800.py
index fac364b1ea9..c4226f49cf3 100755
--- a/tests/functional/test_microblaze_s3adsp1800.py
+++ b/tests/functional/test_microblaze_s3adsp1800.py
@@ -20,8 +20,8 @@ class MicroblazeMachine(QemuSystemTest):
'day17.tar.xz'),
'3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057')
- def test_microblaze_s3adsp1800_be(self):
- self.set_machine('petalogix-s3adsp1800')
+ def do_ballerina_be_test(self, machine):
+ self.set_machine(machine)
self.archive_extract(self.ASSET_IMAGE_BE)
self.vm.set_console()
self.vm.add_args('-kernel',
@@ -34,5 +34,8 @@ 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...
+ def test_microblaze_s3adsp1800_legacy_be(self):
+ self.do_ballerina_be_test('petalogix-s3adsp1800')
+
if __name__ == '__main__':
QemuSystemTest.main()
diff --git a/tests/functional/test_microblazeel_s3adsp1800.py b/tests/functional/test_microblazeel_s3adsp1800.py
index 5d353dba5d2..715ef3f79ac 100755
--- a/tests/functional/test_microblazeel_s3adsp1800.py
+++ b/tests/functional/test_microblazeel_s3adsp1800.py
@@ -21,9 +21,9 @@ class MicroblazeelMachine(QemuSystemTest):
('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'),
'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22')
- def test_microblazeel_s3adsp1800_le(self):
+ def do_xmaton_le_test(self, machine):
self.require_netdev('user')
- self.set_machine('petalogix-s3adsp1800')
+ self.set_machine(machine)
self.archive_extract(self.ASSET_IMAGE_LE)
self.vm.set_console()
self.vm.add_args('-kernel', self.scratch_file('day13', 'xmaton.bin'))
@@ -38,5 +38,8 @@ def test_microblazeel_s3adsp1800_le(self):
'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png',
'821cd3cab8efd16ad6ee5acc3642a8ea')
+ def test_microblaze_s3adsp1800_legacy_le(self):
+ self.do_xmaton_le_test('petalogix-s3adsp1800')
+
if __name__ == '__main__':
QemuSystemTest.main()
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v7 09/10] tests/functional: Remove sleep() kludges from microblaze tests
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-02-12 12:36 ` [PATCH v7 08/10] tests/functional: Allow microblaze tests to take a machine name argument Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
2025-02-12 12:36 ` [PATCH v7 10/10] tests/functional: Have microblaze tests inherit common parent class Philippe Mathieu-Daudé
9 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
Philippe Mathieu-Daudé
Commit f0ec14c78c4 ("tests/avocado: Fix console data loss") fixed
QEMUMachine's problem with console, we don't need to use the sleep()
kludges.
Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250206131052.30207-15-philmd@linaro.org>
---
tests/functional/test_microblazeel_s3adsp1800.py | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/tests/functional/test_microblazeel_s3adsp1800.py b/tests/functional/test_microblazeel_s3adsp1800.py
index 715ef3f79ac..60aab4a45e8 100755
--- a/tests/functional/test_microblazeel_s3adsp1800.py
+++ b/tests/functional/test_microblazeel_s3adsp1800.py
@@ -7,8 +7,7 @@
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
-import time
-from qemu_test import exec_command, exec_command_and_wait_for_pattern
+from qemu_test import exec_command_and_wait_for_pattern
from qemu_test import QemuSystemTest, Asset
from qemu_test import wait_for_console_pattern
@@ -31,9 +30,8 @@ def do_xmaton_le_test(self, machine):
self.vm.add_args('-nic', f'user,tftp={tftproot}')
self.vm.launch()
wait_for_console_pattern(self, 'QEMU Advent Calendar 2023')
- time.sleep(0.1)
- exec_command(self, 'root')
- time.sleep(0.1)
+ wait_for_console_pattern(self, 'buildroot login:')
+ exec_command_and_wait_for_pattern(self, 'root', '#')
exec_command_and_wait_for_pattern(self,
'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png',
'821cd3cab8efd16ad6ee5acc3642a8ea')
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v7 10/10] tests/functional: Have microblaze tests inherit common parent class
2025-02-12 12:36 [PATCH v7 00/10] hw/microblaze: Allow running cross-endian vCPUs Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-02-12 12:36 ` [PATCH v7 09/10] tests/functional: Remove sleep() kludges from microblaze tests Philippe Mathieu-Daudé
@ 2025-02-12 12:36 ` Philippe Mathieu-Daudé
9 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-12 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, Thomas Huth, qemu-arm, Richard Henderson, qemu-ppc,
Sai Pavan Boddu, Markus Armbruster, Edgar E. Iglesias,
Alistair Francis, Daniel P. Berrangé,
Philippe Mathieu-Daudé
Have the MicroblazeMachine class being common to both
MicroblazeBigEndianMachine and MicroblazeLittleEndianMachine
classes. Move the xmaton and ballerina tests to the parent class.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20250206131052.30207-16-philmd@linaro.org>
---
.../functional/test_microblaze_s3adsp1800.py | 23 +++++++++++++++
.../test_microblazeel_s3adsp1800.py | 29 ++-----------------
2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/tests/functional/test_microblaze_s3adsp1800.py b/tests/functional/test_microblaze_s3adsp1800.py
index c4226f49cf3..177c8a685bc 100755
--- a/tests/functional/test_microblaze_s3adsp1800.py
+++ b/tests/functional/test_microblaze_s3adsp1800.py
@@ -7,6 +7,7 @@
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
+from qemu_test import exec_command_and_wait_for_pattern
from qemu_test import QemuSystemTest, Asset
from qemu_test import wait_for_console_pattern
@@ -20,6 +21,10 @@ class MicroblazeMachine(QemuSystemTest):
'day17.tar.xz'),
'3ba7439dfbea7af4876662c97f8e1f0cdad9231fc166e4861d17042489270057')
+ ASSET_IMAGE_LE = Asset(
+ ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'),
+ 'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22')
+
def do_ballerina_be_test(self, machine):
self.set_machine(machine)
self.archive_extract(self.ASSET_IMAGE_BE)
@@ -34,6 +39,24 @@ def do_ballerina_be_test(self, machine):
# message, that's why we don't test for a later string here. This
# needs some investigation by a microblaze wizard one day...
+ def do_xmaton_le_test(self, machine):
+ self.require_netdev('user')
+ self.set_machine(machine)
+ self.archive_extract(self.ASSET_IMAGE_LE)
+ self.vm.set_console()
+ self.vm.add_args('-kernel', self.scratch_file('day13', 'xmaton.bin'))
+ tftproot = self.scratch_file('day13')
+ self.vm.add_args('-nic', f'user,tftp={tftproot}')
+ self.vm.launch()
+ wait_for_console_pattern(self, 'QEMU Advent Calendar 2023')
+ wait_for_console_pattern(self, 'buildroot login:')
+ exec_command_and_wait_for_pattern(self, 'root', '#')
+ exec_command_and_wait_for_pattern(self,
+ 'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png',
+ '821cd3cab8efd16ad6ee5acc3642a8ea')
+
+class MicroblazeBigEndianMachine(MicroblazeMachine):
+
def test_microblaze_s3adsp1800_legacy_be(self):
self.do_ballerina_be_test('petalogix-s3adsp1800')
diff --git a/tests/functional/test_microblazeel_s3adsp1800.py b/tests/functional/test_microblazeel_s3adsp1800.py
index 60aab4a45e8..56645bd0bb2 100755
--- a/tests/functional/test_microblazeel_s3adsp1800.py
+++ b/tests/functional/test_microblazeel_s3adsp1800.py
@@ -7,34 +7,11 @@
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
-from qemu_test import exec_command_and_wait_for_pattern
-from qemu_test import QemuSystemTest, Asset
-from qemu_test import wait_for_console_pattern
+from qemu_test import QemuSystemTest
+from test_microblaze_s3adsp1800 import MicroblazeMachine
-class MicroblazeelMachine(QemuSystemTest):
-
- timeout = 90
-
- ASSET_IMAGE_LE = Asset(
- ('http://www.qemu-advent-calendar.org/2023/download/day13.tar.gz'),
- 'b9b3d43c5dd79db88ada495cc6e0d1f591153fe41355e925d791fbf44de50c22')
-
- def do_xmaton_le_test(self, machine):
- self.require_netdev('user')
- self.set_machine(machine)
- self.archive_extract(self.ASSET_IMAGE_LE)
- self.vm.set_console()
- self.vm.add_args('-kernel', self.scratch_file('day13', 'xmaton.bin'))
- tftproot = self.scratch_file('day13')
- self.vm.add_args('-nic', f'user,tftp={tftproot}')
- self.vm.launch()
- wait_for_console_pattern(self, 'QEMU Advent Calendar 2023')
- wait_for_console_pattern(self, 'buildroot login:')
- exec_command_and_wait_for_pattern(self, 'root', '#')
- exec_command_and_wait_for_pattern(self,
- 'tftp -g -r xmaton.png 10.0.2.2 ; md5sum xmaton.png',
- '821cd3cab8efd16ad6ee5acc3642a8ea')
+class MicroblazeLittleEndianMachine(MicroblazeMachine):
def test_microblaze_s3adsp1800_legacy_le(self):
self.do_xmaton_le_test('petalogix-s3adsp1800')
--
2.47.1
^ permalink raw reply related [flat|nested] 19+ messages in thread