qom: resolve type name conflicts, avoid target_info() in class_init or type_init
v2 cover qom: resolve type name conflicts, avoid target_info() in class_init or type_init
The goal is a single binary that links several targets, where every QOM type is registered once for all of them. Types that share a name go into one bucket per name, each variant tagged with the targets it serves, and the selected target picks the variant at lookup time. For that to work, registering a type and building its class must not depend on which target is selected.
Today some class_init and type_init functions call target_info(), directly or through helpers such as target_s390x(). The result is fixed for the one target selected when the class is built, so the other targets never get their own form of that type.
max-v8 called target_aarch64() from its type_init to pick an instance initializer. scsi-hd, scsi-cd, virtio-blk-pci, virtio-net-pci and virtio-mem called target_s390x() or target_arch() from class_init to add properties. The PetaLogix machine called target_big_endian() from class_init to set the default endianness.
Instead, each target-specific form becomes its own TypeInfo under the same name. Its is_available callback says which target it belongs to. Today QOM registers only the one that matches; a bucket can later keep all of them. LoongArch and Xtensa virt machines are handled the same way, since both share the virt-machine name. PetaLogix keeps one type: its endianness default is "unspecified" until the machine starts. A few target_*() helpers are added for the new callbacks.
v1: https://lore.kernel.org/qemu-devel/[email protected]/
Changes v1 -> v2:
- Drop target_not_s390x() from target-info. v1 exported it for scsi-disk, virtio-blk-pci, and virtio-net-pci. Each file keeps a static copy
- Drop target_not_base_i386() from target-info. Keep target_base_i386(), and a static target_not_base_i386() in virtio-mem
- Split hw/xtensa/virt: select virt machine types with is_available out of the DEFINE_MACHINE expansion, so later only that small patch needs a revert
Yonggang Luo (12):
target-info: add target_loongarch()
hw/loongarch/virt: select virt machine types with is_available
target-info: add target_xtensa()
hw/xtensa: expand DEFINE_MACHINE in virt.c
hw/xtensa/virt: select virt machine types with is_available target/arm: register separate max-v8 CPU types for arm and aarch64 hw/scsi/scsi-disk: register s390x scsi-hd and scsi-cd variants hw/virtio/virtio-pci: pass is_available through
VirtioPCIDeviceTypeInfo
hw/virtio: register s390x virtio-blk-pci and virtio-net-pci variants
target-info: add target_base_i386()
hw/virtio/virtio-mem: register legacy-guest variant with is_available hw/microblaze: defer PetaLogix endianness default until init
hw/loongarch/virt.c | 3 ++ hw/microblaze/petalogix_s3adsp1800_mmu.c | 11 +++-- hw/pci/pci.c | 13 +++--- hw/scsi/scsi-disk.c | 48 +++++++++++++++++----- hw/virtio/virtio-blk-pci.c | 27 +++++++++++- hw/virtio/virtio-mem.c | 52 +++++++++++++++--------- hw/virtio/virtio-net-pci.c | 27 +++++++++++- hw/virtio/virtio-pci.c | 4 ++ hw/xtensa/virt.c | 20 ++++++++- include/hw/virtio/virtio-mem.h | 2 + include/hw/virtio/virtio-pci.h | 1 + include/qemu/target-info.h | 21 ++++++++++ target-info.c | 27 ++++++++++++ target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/tcg/cpu-max-v8.c | 16 ++++++-- 16 files changed, 225 insertions(+), 49 deletions(-)
Signature · 1 line
2.55.0.windows.3
PATCH v2 1/12 target-info: add target_loongarch()
Report whether the selected target architecture is LoongArch.
--- include/qemu/target-info.h | 7 +++++++ target-info.c | 5 +++++ 2 files changed, 12 insertions(+)
include/qemu/target-info.h +7 -0
@@ -92,6 +92,13 @@ bool target_hexagon(void);*/ bool target_or1k (void ); +/** +* target_loongarch: +* +* Returns whether the target architecture is LoongArch. +*/ +bool target_loongarch (void ); +/** * target_base_ppc: *
target-info.c +5 -0
@@ -84,6 +84,11 @@ bool target_or1k(void)return target_arch () ==SYS_EMU_TARGET_OR1K ; } +bool target_loongarch (void ) +{ +return target_arch () ==SYS_EMU_TARGET_LOONGARCH64 ; +} +bool target_base_ppc (void ) {switch (target_arch ()) {
Signature · 1 line
2.55.0.windows.3
PATCH v2 2/12 hw/loongarch/virt: select virt machine types with is_available
In reply to Yonggang LuoLoongArch virt machines use the same QOM names as virt machines on other targets. Register them only when the selected target is LoongArch, via target_loongarch().
--- hw/loongarch/virt.c | 3 +++ 1 file changed, 3 insertions(+)
hw/loongarch/virt.c +3 -0
@@ -11,6 +11,7 @@#include "qapi/error.h" #include "exec/target_page.h" #include "hw/core/boards.h" +#include "qemu/target-info.h" #include "hw/char/serial-mm.h" #include "system/kvm.h" #include "system/tcg.h"
@@ -1553,6 +1554,7 @@ static void virt_class_init(ObjectClass *oc, const void *data) .name = MACHINE_VER_TYPE_NAME("virt", __VA_ARGS__), \ .parent = TYPE_LOONGARCH_VIRT_MACHINE, \ .class_init = MACHINE_VER_SYM(class_init, virt, __VA_ARGS__), \ + .is_available = target_loongarch, \ }; \ static void MACHINE_VER_SYM(register, virt, __VA_ARGS__)(void) \ { \
@@ -1587,6 +1589,7 @@ static const TypeInfo virt_machine_info = { .class_init = virt_class_init, .instance_init = virt_initfn, .instance_finalize = virt_instance_finalize, + .is_available = target_loongarch, .interfaces = (InterfaceInfo []) { {TYPE_HOTPLUG_HANDLER }, { }
Signature · 1 line
2.55.0.windows.3
PATCH v2 3/12 target-info: add target_xtensa()
In reply to Yonggang LuoReport whether the selected target architecture is Xtensa.
--- include/qemu/target-info.h | 7 +++++++ target-info.c | 11 +++++++++++ 2 files changed, 18 insertions(+)
include/qemu/target-info.h +7 -0
@@ -99,6 +99,13 @@ bool target_or1k(void);*/ bool target_loongarch (void ); +/** +* target_xtensa: +* +* Returns whether the target architecture is Xtensa. +*/ +bool target_xtensa (void ); +/** * target_base_ppc: *
target-info.c +11 -0
@@ -89,6 +89,17 @@ bool target_loongarch(void)return target_arch () ==SYS_EMU_TARGET_LOONGARCH64 ; } +bool target_xtensa (void ) +{ +switch (target_arch ()) { +case SYS_EMU_TARGET_XTENSA : +case SYS_EMU_TARGET_XTENSAEB : +return true; +default : +return false; + } +} +bool target_base_ppc (void ) {switch (target_arch ()) {
Signature · 1 line
2.55.0.windows.3
PATCH v2 4/12 hw/xtensa: expand DEFINE_MACHINE in virt.c
In reply to Yonggang LuoExpand DEFINE_MACHINE() in hw/xtensa/virt.c to xtensa_virt_machine_typeinfo and xtensa_virt_machine_register_types() calling type_register_static().
--- hw/xtensa/virt.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
hw/xtensa/virt.c +16 -2
@@ -115,8 +115,10 @@ static void xtensa_virt_init(MachineState *machine)xtensa_sim_load_kernel (cpu, machine); } -static void xtensa_virt_machine_init (MachineClass *mc) +static void xtensa_virt_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="virt machine (" XTENSA_DEFAULT_CPU_MODEL ")" ; mc->init = xtensa_virt_init; mc->max_cpus =32 ;
@@ -124,4 +126,16 @@ static void xtensa_virt_machine_init(MachineClass *mc) mc->default_nic ="virtio-net-pci" ; } -DEFINE_MACHINE ("virt" , xtensa_virt_machine_init) +static const TypeInfo xtensa_virt_machine_typeinfo = { + .name =MACHINE_TYPE_NAME ("virt" ), + .parent =TYPE_MACHINE , + .class_init = xtensa_virt_machine_class_init, + .instance_size =sizeof (MachineState), +}; + +static void xtensa_virt_machine_register_types (void ) +{ +type_register_static (&xtensa_virt_machine_typeinfo); +} + +type_init (xtensa_virt_machine_register_types)
Signature · 1 line
2.55.0.windows.3
Re: [PATCH v2 04/12] hw/xtensa: expand DEFINE_MACHINE in virt.c
Quoted 26 lines · Yonggang Luo
Expand
DEFINE_MACHINE()inhw/xtensa/virt.ctoxtensa_virt_machine_typeinfoandxtensa_virt_machine_register_types()callingtype_register_static().Signed-off-by Yonggang Luo <[email protected]>--- hw/xtensa/virt.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)hw/xtensa/virt.c +3
-1@@ -115,8 +115,10 @@ static void xtensa_virt_init(MachineState *machine)xtensa_sim_load_kernel (cpu, machine); } -static void xtensa_virt_machine_init (MachineClass *mc) +static void xtensa_virt_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="virt machine (" XTENSA_DEFAULT_CPU_MODEL ")" ; mc->init = xtensa_virt_init; mc->max_cpus =32 ;
hw/xtensa/virt.c static void xtensa_virt_machine_init(MachineClass *mc) · line 134
Quoted 10 lines
hw/xtensa/virt.c +6
-1@@ -124,4 +126,16 @@ static void xtensa_virt_machine_init(MachineClass *mc) mc->default_nic ="virtio-net-pci" ; } -DEFINE_MACHINE ("virt" , xtensa_virt_machine_init) +static const TypeInfo xtensa_virt_machine_typeinfo = { + .name =MACHINE_TYPE_NAME ("virt" ), + .parent =TYPE_MACHINE , + .class_init = xtensa_virt_machine_class_init, + .instance_size =sizeof (MachineState), +};
In case I forgot, .instance_size = sizeof(MachineState), should be removed
from this, it's redundant. And maybe for less boilerplate, we should use DEFINE_TYPES
instead.
Quoted 10 lines
hw/xtensa/virt.c +7
-1+ +static void xtensa_virt_machine_register_types (void ) +{ +type_register_static (&xtensa_virt_machine_typeinfo); +} + +type_init (xtensa_virt_machine_register_types) --2.55.0.windows.3
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoPATCH v2 5/12 hw/xtensa/virt: select virt machine types with is_available
In reply to Yonggang LuoThe Xtensa virt machine uses the QOM name virt-machine, which other targets register as well. Register it only when the selected target is Xtensa, via target_xtensa().
--- hw/xtensa/virt.c | 2 ++ 1 file changed, 2 insertions(+)
hw/xtensa/virt.c +2 -0
@@ -29,6 +29,7 @@#include "qapi/error.h" #include "system/reset.h" #include "hw/core/boards.h" +#include "qemu/target-info.h" #include "hw/core/loader.h" #include "hw/pci-host/gpex.h" #include "net/net.h"
@@ -131,6 +132,7 @@ static const TypeInfo xtensa_virt_machine_typeinfo = { .parent = TYPE_MACHINE, .class_init = xtensa_virt_machine_class_init, .instance_size = sizeof(MachineState), + .is_available = target_xtensa, };static void xtensa_virt_machine_register_types (void )
Signature · 1 line
2.55.0.windows.3
PATCH v2 6/12 target/arm: register separate max-v8 CPU types for arm and aarch64
In reply to Yonggang Luomax-v8 was one TypeInfo whose instance initializer was chosen from the selected target at registration. Register both initializers, and let target_arm() and target_aarch64() select which type is available.
--- target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/tcg/cpu-max-v8.c | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-)
target/arm/cpu.c +1 -0
@@ -2695,6 +2695,7 @@ void arm_cpu_register(const ARMCPUInfo *info) .instance_init = arm_cpu_instance_init, .class_init = info->class_init ?: cpu_register_class_init, .class_data = info, + .is_available = info->is_available, }; type_info.name =g_strdup_printf ("%s-" TYPE_ARM_CPU , info->name);
target/arm/cpu.h +1 -0
@@ -1203,6 +1203,7 @@ typedef struct ARMCPUInfo {const char *deprecation_note;void (*initfn)(Object *obj);void (*class_init)(ObjectClass *oc,const void *data); +bool (*is_available)(void ); } ARMCPUInfo;/**
target/arm/tcg/cpu-max-v8.c +12 -4
@@ -121,10 +121,18 @@ void aarch32_max_v8_tcg_initfn(Object *obj)static void cpu_max_v8_register_type (void ) { -static const ARMCPUInfo max_v8[2 ] = { - { .name ="max-v8" , .initfn = aarch32_max_v8_tcg_initfn }, - { .name ="max-v8" , .initfn = aarch64_max_v8_tcg_initfn }, +static const ARMCPUInfo max_v8_aarch32 = { + .name ="max-v8" , + .initfn = aarch32_max_v8_tcg_initfn, + .is_available = target_arm, }; -arm_cpu_register (&max_v8[target_aarch64 ()]); +static const ARMCPUInfo max_v8_aarch64 = { + .name ="max-v8" , + .initfn = aarch64_max_v8_tcg_initfn, + .is_available = target_aarch64, + }; + +arm_cpu_register (&max_v8_aarch32); +arm_cpu_register (&max_v8_aarch64); }type_init (cpu_max_v8_register_type)
Signature · 1 line
2.55.0.windows.3
Re: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
Quoted 53 lines · Yonggang Luo
max-v8 was one TypeInfo whose instance initializer was chosen from the selected target at registration. Register both initializers, and let
target_arm()andtarget_aarch64()select which type is available.Reviewed-by Pierrick Bouvier <[email protected]>Signed-off-by Yonggang Luo <[email protected]>--- target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/tcg/cpu-max-v8.c | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-)target/arm/cpu.c +1
-0@@ -2695,6 +2695,7 @@ void arm_cpu_register(const ARMCPUInfo *info) .instance_init = arm_cpu_instance_init, .class_init = info->class_init ?: cpu_register_class_init, .class_data = info, + .is_available = info->is_available, }; type_info.name =g_strdup_printf ("%s-" TYPE_ARM_CPU , info->name);target/arm/cpu.h +1
-0@@ -1203,6 +1203,7 @@ typedef struct ARMCPUInfo {const char *deprecation_note;void (*initfn)(Object *obj);void (*class_init)(ObjectClass *oc,const void *data); +bool (*is_available)(void ); } ARMCPUInfo;/** target/arm/tcg/cpu-max-v8.c +4
-4@@ -121,10 +121,18 @@ void aarch32_max_v8_tcg_initfn(Object *obj)static void cpu_max_v8_register_type (void ) { -static const ARMCPUInfo max_v8[2 ] = { - { .name ="max-v8" , .initfn = aarch32_max_v8_tcg_initfn }, - { .name ="max-v8" , .initfn = aarch64_max_v8_tcg_initfn }, +static const ARMCPUInfo max_v8_aarch32 = { + .name ="max-v8" , + .initfn = aarch32_max_v8_tcg_initfn, + .is_available = target_arm, }; -arm_cpu_register (&max_v8[target_aarch64 ()]);
target/arm/tcg/cpu-max-v8.c void aarch32_max_v8_tcg_initfn(Object *obj) · line 138
Quoted 10 lines
target/arm/tcg/cpu-max-v8.c +8
-0+static const ARMCPUInfo max_v8_aarch64 = { + .name ="max-v8" , + .initfn = aarch64_max_v8_tcg_initfn, + .is_available = target_aarch64, + }; + +arm_cpu_register (&max_v8_aarch32); +arm_cpu_register (&max_v8_aarch64); }type_init (cpu_max_v8_register_type)
Conceptually these are two separate CPUs one 32-bit featureset and one 64-bit featureset, but both given the same name. The current code registers them only in the respective arm and aarch64 target binaries, but this CPU is an oddity overall.
More generally the aarch64 emulator includes all the 32-bit CPUs that the arm emulator includes, and just adds extra 64-bit CPUs. IOW, excluding the 32-bit max-v8 CPU is a special case - if it were not for the clashing name, it would be included like all the other 32-bit CPUs.
Thus rather than using is_available to continue to exclude it, we must instead resolve the naming problem, such that both models can be included concurrently.
One approach to this is to consider the generic 'max-v8' name to be an alias, that is resolved to the underlying real CPU name 'max-v8-64' vs 'max-v8-32'. Allow the aliases to be ambiguous, and either the selected target_info() disambiguates aliases, or apps can use the canonical name instead of the alias.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
Quoted 62 lines · Daniel P. Berrangé
Quoted 60 lines · Yonggang Luo
max-v8 was one TypeInfo whose instance initializer was chosen from the selected target at registration. Register both initializers, and let
target_arm()andtarget_aarch64()select which type is available.Reviewed-by Pierrick Bouvier <[email protected]>Signed-off-by Yonggang Luo <[email protected]>--- target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/tcg/cpu-max-v8.c | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-)target/arm/cpu.c +1
-0@@ -2695,6 +2695,7 @@ void arm_cpu_register(const ARMCPUInfo *info) .instance_init = arm_cpu_instance_init, .class_init = info->class_init ?: cpu_register_class_init, .class_data = info, + .is_available = info->is_available, }; type_info.name =g_strdup_printf ("%s-" TYPE_ARM_CPU , info->name);target/arm/cpu.h +1
-0@@ -1203,6 +1203,7 @@ typedef struct ARMCPUInfo {const char *deprecation_note;void (*initfn)(Object *obj);void (*class_init)(ObjectClass *oc,const void *data); +bool (*is_available)(void ); } ARMCPUInfo;/** target/arm/tcg/cpu-max-v8.c +11
-4@@ -121,10 +121,18 @@ void aarch32_max_v8_tcg_initfn(Object *obj)static void cpu_max_v8_register_type (void ) { -static const ARMCPUInfo max_v8[2 ] = { - { .name ="max-v8" , .initfn = aarch32_max_v8_tcg_initfn }, - { .name ="max-v8" , .initfn = aarch64_max_v8_tcg_initfn }, +static const ARMCPUInfo max_v8_aarch32 = { + .name ="max-v8" , + .initfn = aarch32_max_v8_tcg_initfn, + .is_available = target_arm, }; -arm_cpu_register (&max_v8[target_aarch64 ()]); +static const ARMCPUInfo max_v8_aarch64 = { + .name ="max-v8" , + .initfn = aarch64_max_v8_tcg_initfn, + .is_available = target_aarch64, + }; + +arm_cpu_register (&max_v8_aarch32);
Quoted 8 lines
target/arm/tcg/cpu-max-v8.c void aarch32_max_v8_tcg_initfn(Object *obj) · line 138
Quoted 3 lines
target/arm/tcg/cpu-max-v8.c +1
-0+arm_cpu_register (&max_v8_aarch64); }type_init (cpu_max_v8_register_type)Conceptually these are two separate CPUs one 32-bit featureset and one 64-bit featureset, but both given the same name. The current code registers them only in the respective arm and aarch64 target binaries, but this CPU is an oddity overall.
This is the one I did before
https://lore.kernel.org/qemu-devel/[email protected]/
target/arm: defer max-v8 initializer selection until CPU creation but rejected, and I think it's fine.
Quoted 10 lines
More generally the aarch64 emulator includes all the 32-bit CPUs that the arm emulator includes, and just adds extra 64-bit CPUs. IOW, excluding the 32-bit max-v8 CPU is a special case - if it were not for the clashing name, it would be included like all the other 32-bit CPUs.
Thus rather than using
is_availableto continue to exclude it, we must instead resolve the naming problem, such that both models can be included concurrently.
I have already implemented the TypeBucket over targets/arch_mask that works properly. That same QOM name will have multiple TypeImpl.
If you allow me, I'd like to post them all with TypeBucket implemented so we have
a clean discussion basepoint.
Quoted 14 lines
One approach to this is to consider the generic 'max-v8' name to be an alias, that is resolved to the underlying real CPU name 'max-v8-64' vs 'max-v8-32'. Allow the aliases to be ambiguous, and either the selected
target_info()disambiguates aliases, or apps can use the canonical name instead of the alias.With regards,
Daniel
--|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoRe: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
Quoted 72 lines · Yonggang Luo
Quoted 62 lines · Daniel P. Berrangé
Quoted 60 lines · Yonggang Luo
max-v8 was one TypeInfo whose instance initializer was chosen from the selected target at registration. Register both initializers, and let
target_arm()andtarget_aarch64()select which type is available.Reviewed-by Pierrick Bouvier <[email protected]>Signed-off-by Yonggang Luo <[email protected]>--- target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/tcg/cpu-max-v8.c | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-)target/arm/cpu.c +1
-0@@ -2695,6 +2695,7 @@ void arm_cpu_register(const ARMCPUInfo *info) .instance_init = arm_cpu_instance_init, .class_init = info->class_init ?: cpu_register_class_init, .class_data = info, + .is_available = info->is_available, }; type_info.name =g_strdup_printf ("%s-" TYPE_ARM_CPU , info->name);target/arm/cpu.h +1
-0@@ -1203,6 +1203,7 @@ typedef struct ARMCPUInfo {const char *deprecation_note;void (*initfn)(Object *obj);void (*class_init)(ObjectClass *oc,const void *data); +bool (*is_available)(void ); } ARMCPUInfo;/** target/arm/tcg/cpu-max-v8.c +11
-4@@ -121,10 +121,18 @@ void aarch32_max_v8_tcg_initfn(Object *obj)static void cpu_max_v8_register_type (void ) { -static const ARMCPUInfo max_v8[2 ] = { - { .name ="max-v8" , .initfn = aarch32_max_v8_tcg_initfn }, - { .name ="max-v8" , .initfn = aarch64_max_v8_tcg_initfn }, +static const ARMCPUInfo max_v8_aarch32 = { + .name ="max-v8" , + .initfn = aarch32_max_v8_tcg_initfn, + .is_available = target_arm, }; -arm_cpu_register (&max_v8[target_aarch64 ()]); +static const ARMCPUInfo max_v8_aarch64 = { + .name ="max-v8" , + .initfn = aarch64_max_v8_tcg_initfn, + .is_available = target_aarch64, + }; + +arm_cpu_register (&max_v8_aarch32);Quoted 8 lines
target/arm/tcg/cpu-max-v8.c void aarch32_max_v8_tcg_initfn(Object *obj) · line 138
Quoted 3 lines
target/arm/tcg/cpu-max-v8.c +1
-0+arm_cpu_register (&max_v8_aarch64); }type_init (cpu_max_v8_register_type)Conceptually these are two separate CPUs one 32-bit featureset and one 64-bit featureset, but both given the same name. The current code registers them only in the respective arm and aarch64 target binaries, but this CPU is an oddity overall.
Quoted 5 lines
This is the one I did before
https://lore.kernel.org/qemu-devel/[email protected]/target/arm: defer max-v8 initializer selection until CPU creation but rejected, and I think it's fine.
So that essentially matches the historical semantics where one CPU class magically changes its behaviour based on what target is running. So in that sense, it works, and is no worse than the semantics we've had for 'max' models forever.
Splitting into 2 distinct types is worthwhile if we want to make it possible for the aarch64 emulator to support a runtime choice of both 32-bit and 64-bit "max" models.
This patch doesn't allow that though, as it is creating two classes with the same name and filtering which is registered. If we don't intend to allow 64-bit target to ever use a 32-bit 'max' CPU, then your original patch is better IMHO.
Quoted 6 lines
Quoted 6 lines
More generally the aarch64 emulator includes all the 32-bit CPUs that the arm emulator includes, and just adds extra 64-bit CPUs. IOW, excluding the 32-bit max-v8 CPU is a special case - if it were not for the clashing name, it would be included like all the other 32-bit CPUs.
Quoted 6 lines
Quoted 3 lines
Thus rather than using
is_availableto continue to exclude it, we must instead resolve the naming problem, such that both models can be included concurrently.I have already implemented the TypeBucket over targets/arch_mask that works properly. That same QOM name will have multiple TypeImpl.
I'm not sure what you mean by TypeBucket, but my general thought is that at the QOM class/type naming level everything must always be unique, such that we have a single object modelk across QEMU.
Any ambiguitity & its resolution (if needed) should live outside core QOM typework, such as with aliases in machines/CPUs.
If we have a common pattern for aliases, perhaps we could create a standard QOM Interface for resolving aliases.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
Quoted 85 lines · Daniel P. Berrangé
Quoted 72 lines · Yonggang Luo
Quoted 62 lines · Daniel P. Berrangé
Quoted 60 lines · Yonggang Luo
max-v8 was one TypeInfo whose instance initializer was chosen from the selected target at registration. Register both initializers, and let
target_arm()andtarget_aarch64()select which type is available.Reviewed-by Pierrick Bouvier <[email protected]>Signed-off-by Yonggang Luo <[email protected]>--- target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/tcg/cpu-max-v8.c | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-)target/arm/cpu.c +1
-0@@ -2695,6 +2695,7 @@ void arm_cpu_register(const ARMCPUInfo *info) .instance_init = arm_cpu_instance_init, .class_init = info->class_init ?: cpu_register_class_init, .class_data = info, + .is_available = info->is_available, }; type_info.name =g_strdup_printf ("%s-" TYPE_ARM_CPU , info->name);target/arm/cpu.h +1
-0@@ -1203,6 +1203,7 @@ typedef struct ARMCPUInfo {const char *deprecation_note;void (*initfn)(Object *obj);void (*class_init)(ObjectClass *oc,const void *data); +bool (*is_available)(void ); } ARMCPUInfo;/** target/arm/tcg/cpu-max-v8.c +11
-4@@ -121,10 +121,18 @@ void aarch32_max_v8_tcg_initfn(Object *obj)static void cpu_max_v8_register_type (void ) { -static const ARMCPUInfo max_v8[2 ] = { - { .name ="max-v8" , .initfn = aarch32_max_v8_tcg_initfn }, - { .name ="max-v8" , .initfn = aarch64_max_v8_tcg_initfn }, +static const ARMCPUInfo max_v8_aarch32 = { + .name ="max-v8" , + .initfn = aarch32_max_v8_tcg_initfn, + .is_available = target_arm, }; -arm_cpu_register (&max_v8[target_aarch64 ()]); +static const ARMCPUInfo max_v8_aarch64 = { + .name ="max-v8" , + .initfn = aarch64_max_v8_tcg_initfn, + .is_available = target_aarch64, + }; + +arm_cpu_register (&max_v8_aarch32);Quoted 8 lines
target/arm/tcg/cpu-max-v8.c void aarch32_max_v8_tcg_initfn(Object *obj) · line 138
Quoted 3 lines
target/arm/tcg/cpu-max-v8.c +1
-0+arm_cpu_register (&max_v8_aarch64); }type_init (cpu_max_v8_register_type)Conceptually these are two separate CPUs one 32-bit featureset and one 64-bit featureset, but both given the same name. The current code registers them only in the respective arm and aarch64 target binaries, but this CPU is an oddity overall.
Quoted 5 lines
This is the one I did before
https://lore.kernel.org/qemu-devel/[email protected]/target/arm: defer max-v8 initializer selection until CPU creation but rejected, and I think it's fine.
So that essentially matches the historical semantics where one CPU class magically changes its behaviour based on what target is running. So in that sense, it works, and is no worse than the semantics we've had for 'max' models forever.
Quoted 8 lines
Splitting into 2 distinct types is worthwhile if we want to make it possible for the aarch64 emulator to support a runtime choice of both 32-bit and 64-bit "max" models.
This patch doesn't allow that though, as it is creating two classes with the same name and filtering which is registered. If we don't intend to allow 64-bit target to ever use a 32-bit 'max' CPU, then your original patch is better IMHO.
Hi Daniel, this is a prepare to allow creating two classes with the same name, the is_available will be removed later.
Maybe I should directly replace is_available with TypeBucket to get things be clear to review,
but that is explicitly rejected by Pierrick
Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
More generally the aarch64 emulator includes all the 32-bit CPUs that the arm emulator includes, and just adds extra 64-bit CPUs. IOW, excluding the 32-bit max-v8 CPU is a special case - if it were not for the clashing name, it would be included like all the other 32-bit CPUs.
Quoted 6 lines
Quoted 3 lines
Thus rather than using
is_availableto continue to exclude it, we must instead resolve the naming problem, such that both models can be included concurrently.I have already implemented the TypeBucket over targets/arch_mask that works properly. That same QOM name will have multiple TypeImpl.
Quoted 6 lines
I'm not sure what you mean by TypeBucket, but my general thought is that at the QOM class/type naming level everything must always be unique, such that we have a single object modelk across QEMU.
Any ambiguitity & its resolution (if needed) should live outside core QOM typework, such as with aliases in machines/CPUs.
Yeap, it's a design choice, both renaming the QOM type with MachineClass::targets;
or using TypeBucket in object.c(so all QOM types do not need rename including "virt" machines)
is implemented by me, it's just finally what we want to do.
Quoted 12 lines
If we have a common pattern for aliases, perhaps we could create a standard QOM Interface for resolving aliases.
With regards,
Daniel
--|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
Quoted 90 lines · Yonggang Luo
Quoted 89 lines · Daniel P. Berrangé
Quoted 72 lines · Yonggang Luo
Quoted 62 lines · Daniel P. Berrangé
Quoted 60 lines · Yonggang Luo
max-v8 was one TypeInfo whose instance initializer was chosen from the selected target at registration. Register both initializers, and let
target_arm()andtarget_aarch64()select which type is available.Reviewed-by Pierrick Bouvier <[email protected]>Signed-off-by Yonggang Luo <[email protected]>--- target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/tcg/cpu-max-v8.c | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-)target/arm/cpu.c +1
-0@@ -2695,6 +2695,7 @@ void arm_cpu_register(const ARMCPUInfo *info) .instance_init = arm_cpu_instance_init, .class_init = info->class_init ?: cpu_register_class_init, .class_data = info, + .is_available = info->is_available, }; type_info.name =g_strdup_printf ("%s-" TYPE_ARM_CPU , info->name);target/arm/cpu.h +1
-0@@ -1203,6 +1203,7 @@ typedef struct ARMCPUInfo {const char *deprecation_note;void (*initfn)(Object *obj);void (*class_init)(ObjectClass *oc,const void *data); +bool (*is_available)(void ); } ARMCPUInfo;/** target/arm/tcg/cpu-max-v8.c +11
-4@@ -121,10 +121,18 @@ void aarch32_max_v8_tcg_initfn(Object *obj)static void cpu_max_v8_register_type (void ) { -static const ARMCPUInfo max_v8[2 ] = { - { .name ="max-v8" , .initfn = aarch32_max_v8_tcg_initfn }, - { .name ="max-v8" , .initfn = aarch64_max_v8_tcg_initfn }, +static const ARMCPUInfo max_v8_aarch32 = { + .name ="max-v8" , + .initfn = aarch32_max_v8_tcg_initfn, + .is_available = target_arm, }; -arm_cpu_register (&max_v8[target_aarch64 ()]); +static const ARMCPUInfo max_v8_aarch64 = { + .name ="max-v8" , + .initfn = aarch64_max_v8_tcg_initfn, + .is_available = target_aarch64, + }; + +arm_cpu_register (&max_v8_aarch32);Quoted 8 lines
target/arm/tcg/cpu-max-v8.c void aarch32_max_v8_tcg_initfn(Object *obj) · line 138
Quoted 3 lines
target/arm/tcg/cpu-max-v8.c +1
-0+arm_cpu_register (&max_v8_aarch64); }type_init (cpu_max_v8_register_type)Conceptually these are two separate CPUs one 32-bit featureset and one 64-bit featureset, but both given the same name. The current code registers them only in the respective arm and aarch64 target binaries, but this CPU is an oddity overall.
Quoted 5 lines
This is the one I did before
https://lore.kernel.org/qemu-devel/[email protected]/target/arm: defer max-v8 initializer selection until CPU creation but rejected, and I think it's fine.
So that essentially matches the historical semantics where one CPU class magically changes its behaviour based on what target is running. So in that sense, it works, and is no worse than the semantics we've had for 'max' models forever.
Splitting into 2 distinct types is worthwhile if we want to make it possible for the aarch64 emulator to support a runtime choice of both 32-bit and 64-bit "max" models.
Quoted 8 lines
Quoted 4 lines
This patch doesn't allow that though, as it is creating two classes with the same name and filtering which is registered. If we don't intend to allow 64-bit target to ever use a 32-bit 'max' CPU, then your original patch is better IMHO.
Hi Daniel, this is a prepare to allow creating two classes with the same name, the
is_availablewill be removed later.
Sending patches to implement an approach which is already planned to be removed is rather making life hard on reviewers.
Quoted 24 lines
Maybe I should directly replace
is_availablewith TypeBucket to get things be clear to review,
but that is explicitly rejected by PierrickQuoted 19 lines
Quoted 8 lines
Quoted 8 lines
More generally the aarch64 emulator includes all the 32-bit CPUs that the arm emulator includes, and just adds extra 64-bit CPUs. IOW, excluding the 32-bit max-v8 CPU is a special case - if it were not for the clashing name, it would be included like all the other 32-bit CPUs.
Quoted 6 lines
Quoted 3 lines
Thus rather than using
is_availableto continue to exclude it, we must instead resolve the naming problem, such that both models can be included concurrently.I have already implemented the TypeBucket over targets/arch_mask that works properly. That same QOM name will have multiple TypeImpl.
I'm not sure what you mean by TypeBucket, but my general thought is that at the QOM class/type naming level everything must always be unique, such that we have a single object modelk across QEMU.
Quoted 8 lines
Quoted 2 lines
Any ambiguitity & its resolution (if needed) should live outside core QOM typework, such as with aliases in machines/CPUs.
Yeap, it's a design choice, both renaming the QOM type with
MachineClass::targets;
or using TypeBucket inobject.c(so all QOM types do not need rename including "virt" machines)
is implemented by me, it's just finally what we want to do.
I don't know what you mean with this TypeBucket concept, can you share more info ?
IMHO, renaming the non-unique QOM types is inescapable. From a POV of introspecting a binary, we need to get to a single uniform type hierarchy across QEMU where the classes are all statically defined and unique. This complements the work to replace instance properties with class properties, to also give us unambiguously introspectable types.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
In reply to Daniel P. BerrangéQuoted 8 lines · Daniel P. Berrangé
So that essentially matches the historical semantics where one CPU class magically changes its behaviour based on what target is running. So in that sense, it works, and is no worse than the semantics we've had for 'max' models forever.
Splitting into 2 distinct types is worthwhile if we want to make it possible for the aarch64 emulator to support a runtime choice of both 32-bit and 64-bit "max" models.
What would the difference between that and configuring the 64-bit capable "max" to not have AArch64 via "-cpu max-v8:aarch64=off" (which should work today) ?
-- PMM
Re: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Daniel P. Berrangé
So that essentially matches the historical semantics where one CPU class magically changes its behaviour based on what target is running. So in that sense, it works, and is no worse than the semantics we've had for 'max' models forever.
Quoted 7 lines
Quoted 3 lines
Splitting into 2 distinct types is worthwhile if we want to make it possible for the aarch64 emulator to support a runtime choice of both 32-bit and 64-bit "max" models.
What would the difference between that and configuring the 64-bit capable "max" to not have AArch64 via "-cpu max-v8:aarch64=off" (which should work today) ?
Is that really the same result ?
It seems like aarch64_max_v8_tcg_initfn does alot more CPU modelling than aarch32_max_v8_tcg_initfn, than just a single flag ?
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
Quoted 12 lines · Daniel P. Berrangé
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Daniel P. Berrangé
So that essentially matches the historical semantics where one CPU class magically changes its behaviour based on what target is running. So in that sense, it works, and is no worse than the semantics we've had for 'max' models forever.
Splitting into 2 distinct types is worthwhile if we want to make it possible for the aarch64 emulator to support a runtime choice of both 32-bit and 64-bit "max" models.
Quoted 8 lines
Quoted 3 lines
What would the difference between that and configuring the 64-bit capable "max" to not have AArch64 via "-cpu max-v8:aarch64=off" (which should work today) ?
Is that really the same result ?
It seems like
aarch64_max_v8_tcg_initfndoes alot more CPU modelling thanaarch32_max_v8_tcg_initfn, than just a single flag ?
Conceptually it gets you to the same place -- a 32-bit only CPU with all the 32-bit features turned on that we support.
aarch64_max_v8_tcg_initfn() sets up all the 64-bit-only ID registers, which is most of what its code is doing. But the handling of "aarch64=off" then clears them all out via arm_clear_aarch64_idregs(), and even if it didn't, any 64-bit-only features are by definition unreachable from 32-bit code.
It's possible it might not get you 100% absolutely an identical thing from the guest's point of view, but any deviations should be minor and I think we might consider them bugs.
There are some minor UI-level things relating to CPU properties, e.g. "qemu-system-arm -cpu max,sve=on" gives a property not found error, but "qemu-system-aarch64 -cpu max-v8,aarch64=off,sve=on" will run (with no visible difference to the guest since SVE is AArch64 only). It probably ought to error out complaining that you've asked for two things that conflict, but this is "minor bug" I think.
-- PMM
Re: [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64
Quoted 35 lines · Peter Maydell
Quoted 12 lines · Daniel P. Berrangé
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Daniel P. Berrangé
So that essentially matches the historical semantics where one CPU class magically changes its behaviour based on what target is running. So in that sense, it works, and is no worse than the semantics we've had for 'max' models forever.
Splitting into 2 distinct types is worthwhile if we want to make it possible for the aarch64 emulator to support a runtime choice of both 32-bit and 64-bit "max" models.
Quoted 8 lines
Quoted 3 lines
What would the difference between that and configuring the 64-bit capable "max" to not have AArch64 via "-cpu max-v8:aarch64=off" (which should work today) ?
Is that really the same result ?
It seems like
aarch64_max_v8_tcg_initfndoes alot more CPU modelling thanaarch32_max_v8_tcg_initfn, than just a single flag ?Conceptually it gets you to the same place -- a 32-bit only CPU with all the 32-bit features turned on that we support.
aarch64_max_v8_tcg_initfn()sets up all the 64-bit-only ID registers, which is most of what its code is doing. But the handling of "aarch64=off" then clears them all out viaarm_clear_aarch64_idregs(), and even if it didn't, any 64-bit-only features are by definition unreachable from 32-bit code.It's possible it might not get you 100% absolutely an identical thing from the guest's point of view, but any deviations should be minor and I think we might consider them bugs.
Quoted 7 lines
There are some minor UI-level things relating to CPU properties, e.g. "qemu-system-arm -cpu max,sve=on" gives a property not found error, but "qemu-system-aarch64 -cpu max-v8,aarch64=off,sve=on" will run (with no visible difference to the guest since SVE is AArch64 only). It probably ought to error out complaining that you've asked for two things that conflict, but this is "minor bug" I think.
Ok, in that case I'd agree aarch64 wouldn't need to expose a distinct 32-bit CPU model for max
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
PATCH v2 7/12 hw/scsi/scsi-disk: register s390x scsi-hd and scsi-cd variants
In reply to Yonggang Luoscsi-hd and scsi-cd added the s390x loadparm property from class_init when target_s390x() was true. Register a second type for each name that always adds loadparm, and select the two with target_s390x() and target_not_s390x().
--- hw/scsi/scsi-disk.c | 48 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-)
hw/scsi/scsi-disk.c +38 -10
@@ -3221,14 +3221,11 @@ static void scsi_property_add_specifics(DeviceClass *dc) {ObjectClass *oc =OBJECT_CLASS (dc); -/* The loadparm property is only supported on s390x */ -if (target_s390x ()) { -object_class_property_add_str (oc,"loadparm" , - scsi_property_get_loadparm, - scsi_property_set_loadparm); -object_class_property_set_description (oc,"loadparm" , -"load parameter (s390x only)" ); - } +object_class_property_add_str (oc,"loadparm" , + scsi_property_get_loadparm, + scsi_property_set_loadparm); +object_class_property_set_description (oc,"loadparm" , +"load parameter (s390x only)" ); }static void scsi_disk_base_class_initfn (ObjectClass *klass,const void *data)
@@ -3362,14 +3359,31 @@ static void scsi_hd_class_initfn(ObjectClass *klass, const void *data) dc->desc ="virtual SCSI disk" ;device_class_set_props (dc, scsi_hd_properties); dc->vmsd = &vmstate_scsi_disk_state; +} + +static void scsi_hd_s390x_class_initfn (ObjectClass *klass,const void *data) +{ +scsi_hd_class_initfn (klass, data); +scsi_property_add_specifics (DEVICE_CLASS (klass)); +} -scsi_property_add_specifics (dc); +static bool target_not_s390x (void ) +{ +return !target_s390x (); }static const TypeInfo scsi_hd_info = { .name ="scsi-hd" , .parent =TYPE_SCSI_DISK_BASE , .class_init = scsi_hd_class_initfn, + .is_available = target_not_s390x, +}; + +static const TypeInfo scsi_hd_s390x_info = { + .name ="scsi-hd" , + .parent =TYPE_SCSI_DISK_BASE , + .class_init = scsi_hd_s390x_class_initfn, + .is_available = target_s390x, };static const Property scsi_cd_properties[] = {
@@ -3405,14 +3419,26 @@ static void scsi_cd_class_initfn(ObjectClass *klass, const void *data) dc->desc ="virtual SCSI CD-ROM" ;device_class_set_props (dc, scsi_cd_properties); dc->vmsd = &vmstate_scsi_disk_state; +} -scsi_property_add_specifics (dc); +static void scsi_cd_s390x_class_initfn (ObjectClass *klass,const void *data) +{ +scsi_cd_class_initfn (klass, data); +scsi_property_add_specifics (DEVICE_CLASS (klass)); }static const TypeInfo scsi_cd_info = { .name ="scsi-cd" , .parent =TYPE_SCSI_DISK_BASE , .class_init = scsi_cd_class_initfn, + .is_available = target_not_s390x, +}; + +static const TypeInfo scsi_cd_s390x_info = { + .name ="scsi-cd" , + .parent =TYPE_SCSI_DISK_BASE , + .class_init = scsi_cd_s390x_class_initfn, + .is_available = target_s390x, };#ifdef __linux__
@@ -3462,7 +3488,9 @@ static void scsi_disk_register_types(void) {type_register_static (&scsi_disk_base_info);type_register_static (&scsi_hd_info); +type_register_static (&scsi_hd_s390x_info);type_register_static (&scsi_cd_info); +type_register_static (&scsi_cd_s390x_info);#ifdef __linux__type_register_static (&scsi_block_info);#endif
Signature · 1 line
2.55.0.windows.3
Re: [PATCH v2 07/12] hw/scsi/scsi-disk: register s390x scsi-hd and scsi-cd variants
Quoted 22 lines · Yonggang Luo
scsi-hd and scsi-cd added the s390x loadparm property from
class_initwhentarget_s390x()was true. Register a second type for each name that always adds loadparm, and select the two withtarget_s390x()andtarget_not_s390x().Signed-off-by Yonggang Luo <[email protected]>--- hw/scsi/scsi-disk.c | 48 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-)hw/scsi/scsi-disk.c +0
-4@@ -3221,14 +3221,11 @@ static void scsi_property_add_specifics(DeviceClass *dc) {ObjectClass *oc =OBJECT_CLASS (dc); -/* The loadparm property is only supported on s390x */ -if (target_s390x ()) { - object_class_property_add_str(oc, "loadparm", - scsi_property_get_loadparm,
hw/scsi/scsi-disk.c static void scsi_property_add_specifics(DeviceClass *dc) · line 3229
Quoted 10 lines
hw/scsi/scsi-disk.c +5
-4- scsi_property_set_loadparm); -object_class_property_set_description (oc,"loadparm" , -"load parameter (s390x only)" ); - } +object_class_property_add_str (oc,"loadparm" , + scsi_property_get_loadparm, + scsi_property_set_loadparm); +object_class_property_set_description (oc,"loadparm" , +"load parameter (s390x only)" ); }
IMHO this is the only change that should be made. It is harmless to have the property unconditionally registered for the class. Creating extra duplicate named classes is expanding a problem that we should be trying to eliminate, such that we have unique named classes.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
PATCH v2 8/12 hw/virtio/virtio-pci: pass is_available through VirtioPCIDeviceTypeInfo
In reply to Yonggang Luovirtio_pci_types_register() builds the base, generic, transitional and non-transitional TypeInfos for one virtio-pci device. Copy an is_available callback onto each of them so a device can register target-specific variants of the same names.
--- hw/virtio/virtio-pci.c | 4 ++++ include/hw/virtio/virtio-pci.h | 1 + 2 files changed, 5 insertions(+)
hw/virtio/virtio-pci.c +4 -0
@@ -2522,11 +2522,13 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) .class_size = t->class_size, .abstract = true, .interfaces = t->interfaces, + .is_available = t->is_available, };TypeInfo generic_type_info = { .name = t->generic_name, .parent = base_type_info.name, .class_init = virtio_pci_generic_class_init, + .is_available = t->is_available, .interfaces = (const InterfaceInfo []) { {INTERFACE_PCIE_DEVICE }, {INTERFACE_CONVENTIONAL_PCI_DEVICE },
@@ -2562,6 +2564,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) .name = t->non_transitional_name, .parent = base_type_info.name, .instance_init = virtio_pci_non_transitional_instance_init, + .is_available = t->is_available, .interfaces = (const InterfaceInfo []) { {INTERFACE_PCIE_DEVICE }, {INTERFACE_CONVENTIONAL_PCI_DEVICE },
@@ -2576,6 +2579,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) .name = t->transitional_name, .parent = base_type_info.name, .instance_init = virtio_pci_transitional_instance_init, + .is_available = t->is_available, .interfaces = (const InterfaceInfo []) {/* * Transitional virtio devices work only as Conventional PCI
include/hw/virtio/virtio-pci.h +1 -0
@@ -236,6 +236,7 @@ typedef struct VirtioPCIDeviceTypeInfo {void (*instance_init)(Object *obj);void (*instance_finalize)(Object *obj);void (*class_init)(ObjectClass *klass,const void *data); +bool (*is_available)(void );const InterfaceInfo *interfaces; } VirtioPCIDeviceTypeInfo;
Signature · 1 line
2.55.0.windows.3
PATCH v2 9/12 hw/virtio: register s390x virtio-blk-pci and virtio-net-pci variants
In reply to Yonggang Luovirtio-blk-pci and virtio-net-pci added the s390x loadparm property from class_init when target_s390x() was true. Register each VirtioPCIDeviceTypeInfo twice. The s390x variant calls pci_qdev_property_add_specifics(), which now always adds loadparm, and the other variant does not. target_s390x() and target_not_s390x() select the two.
--- hw/pci/pci.c | 13 +++++-------- hw/virtio/virtio-blk-pci.c | 27 ++++++++++++++++++++++++++- hw/virtio/virtio-net-pci.c | 27 ++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 10 deletions(-)
hw/pci/pci.c +5 -8
@@ -2901,14 +2901,11 @@ void pci_qdev_property_add_specifics(DeviceClass *dc) {ObjectClass *oc =OBJECT_CLASS (dc); -/* The loadparm property is only supported on s390x */ -if (target_s390x ()) { -object_class_property_add_str (oc,"loadparm" , - pci_qdev_property_get_loadparm, - pci_qdev_property_set_loadparm); -object_class_property_set_description (oc,"loadparm" , -"load parameter (s390x only)" ); - } +object_class_property_add_str (oc,"loadparm" , + pci_qdev_property_get_loadparm, + pci_qdev_property_set_loadparm); +object_class_property_set_description (oc,"loadparm" , +"load parameter (s390x only)" ); }MemoryRegion *pci_address_space (PCIDevice *dev)
hw/virtio/virtio-blk-pci.c +26 -1
@@ -22,6 +22,7 @@#include "hw/virtio/virtio-pci.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qemu/target-info.h" #include "qom/object.h" typedef struct VirtIOBlkPCI VirtIOBlkPCI ;
@@ -71,7 +72,6 @@ static void virtio_blk_pci_class_init(ObjectClass *klass, const void *data)set_bit (DEVICE_CATEGORY_STORAGE , dc->categories);device_class_set_props (dc, virtio_blk_pci_properties); -pci_qdev_property_add_specifics (dc); k->realize = virtio_blk_pci_realize; pcidev_k->vendor_id =PCI_VENDOR_ID_REDHAT_QUMRANET ; pcidev_k->device_id =PCI_DEVICE_ID_VIRTIO_BLOCK ;
@@ -89,6 +89,18 @@ static void virtio_blk_pci_instance_init(Object *obj) "bootindex"); } +static void virtio_blk_pci_s390x_class_init (ObjectClass *klass, +const void *data) +{ +virtio_blk_pci_class_init (klass, data); +pci_qdev_property_add_specifics (DEVICE_CLASS (klass)); +} + +static bool target_not_s390x (void ) +{ +return !target_s390x (); +} +static const VirtioPCIDeviceTypeInfo virtio_blk_pci_info = { .base_name =TYPE_VIRTIO_BLK_PCI , .generic_name ="virtio-blk-pci" ,
@@ -97,11 +109,24 @@ static const VirtioPCIDeviceTypeInfo virtio_blk_pci_info = { .instance_size = sizeof(VirtIOBlkPCI), .instance_init = virtio_blk_pci_instance_init, .class_init = virtio_blk_pci_class_init, + .is_available = target_not_s390x, +}; + +static const VirtioPCIDeviceTypeInfo virtio_blk_pci_s390x_info = { + .base_name =TYPE_VIRTIO_BLK_PCI , + .generic_name ="virtio-blk-pci" , + .transitional_name ="virtio-blk-pci-transitional" , + .non_transitional_name ="virtio-blk-pci-non-transitional" , + .instance_size =sizeof (VirtIOBlkPCI), + .instance_init = virtio_blk_pci_instance_init, + .class_init = virtio_blk_pci_s390x_class_init, + .is_available = target_s390x, };static void virtio_blk_pci_register (void ) {virtio_pci_types_register (&virtio_blk_pci_info); +virtio_pci_types_register (&virtio_blk_pci_s390x_info); }type_init (virtio_blk_pci_register)
hw/virtio/virtio-net-pci.c +26 -1
@@ -22,6 +22,7 @@#include "hw/virtio/virtio-pci.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qemu/target-info.h" #include "qom/object.h" typedef struct VirtIONetPCI VirtIONetPCI ;
@@ -77,7 +78,6 @@ static void virtio_net_pci_class_init(ObjectClass *klass, const void *data) k->sriov_vf_user_creatable = true;set_bit (DEVICE_CATEGORY_NETWORK , dc->categories);device_class_set_props (dc, virtio_net_properties); -pci_qdev_property_add_specifics (dc); vpciklass->realize = virtio_net_pci_realize; }
@@ -91,6 +91,18 @@ static void virtio_net_pci_instance_init(Object *obj) "bootindex"); } +static void virtio_net_pci_s390x_class_init (ObjectClass *klass, +const void *data) +{ +virtio_net_pci_class_init (klass, data); +pci_qdev_property_add_specifics (DEVICE_CLASS (klass)); +} + +static bool target_not_s390x (void ) +{ +return !target_s390x (); +} +static const VirtioPCIDeviceTypeInfo virtio_net_pci_info = { .base_name =TYPE_VIRTIO_NET_PCI , .generic_name ="virtio-net-pci" ,
@@ -99,11 +111,24 @@ static const VirtioPCIDeviceTypeInfo virtio_net_pci_info = { .instance_size = sizeof(VirtIONetPCI), .instance_init = virtio_net_pci_instance_init, .class_init = virtio_net_pci_class_init, + .is_available = target_not_s390x, +}; + +static const VirtioPCIDeviceTypeInfo virtio_net_pci_s390x_info = { + .base_name =TYPE_VIRTIO_NET_PCI , + .generic_name ="virtio-net-pci" , + .transitional_name ="virtio-net-pci-transitional" , + .non_transitional_name ="virtio-net-pci-non-transitional" , + .instance_size =sizeof (VirtIONetPCI), + .instance_init = virtio_net_pci_instance_init, + .class_init = virtio_net_pci_s390x_class_init, + .is_available = target_s390x, };static void virtio_net_pci_register (void ) {virtio_pci_types_register (&virtio_net_pci_info); +virtio_pci_types_register (&virtio_net_pci_s390x_info); }type_init (virtio_net_pci_register)
Signature · 1 line
2.55.0.windows.3
Re: [PATCH v2 09/12] hw/virtio: register s390x virtio-blk-pci and virtio-net-pci variants
Quoted 28 lines · Yonggang Luo
virtio-blk-pci and virtio-net-pci added the s390x loadparm property from
class_initwhentarget_s390x()was true. Register each VirtioPCIDeviceTypeInfo twice. The s390x variant callspci_qdev_property_add_specifics(), which now always adds loadparm, and the other variant does not.target_s390x()andtarget_not_s390x()select the two.Signed-off-by Yonggang Luo <[email protected]>--- hw/pci/pci.c | 13 +++++-------- hw/virtio/virtio-blk-pci.c | 27 ++++++++++++++++++++++++++- hw/virtio/virtio-net-pci.c | 27 ++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 10 deletions(-)hw/pci/pci.c +0
-6@@ -2901,14 +2901,11 @@ void pci_qdev_property_add_specifics(DeviceClass *dc) {ObjectClass *oc =OBJECT_CLASS (dc); -/* The loadparm property is only supported on s390x */ -if (target_s390x ()) { -object_class_property_add_str (oc,"loadparm" , - pci_qdev_property_get_loadparm, - pci_qdev_property_set_loadparm); - object_class_property_set_description(oc, "loadparm",
hw/pci/pci.c void pci_qdev_property_add_specifics(DeviceClass *dc) · line 2911
Quoted 10 lines
hw/pci/pci.c +5
-2- "load parameter (s390x only)"); - } +object_class_property_add_str (oc,"loadparm" , + pci_qdev_property_get_loadparm, + pci_qdev_property_set_loadparm); +object_class_property_set_description (oc,"loadparm" , +"load parameter (s390x only)" ); }MemoryRegion *pci_address_space (PCIDevice *dev)
Again this is the only bit that we need IMHO, as it is harmless to register these properties unconditionally.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH v2 09/12] hw/virtio: register s390x virtio-blk-pci and virtio-net-pci variants
Quoted 39 lines · Daniel P. Berrangé
Quoted 37 lines · Yonggang Luo
virtio-blk-pci and virtio-net-pci added the s390x loadparm property from
class_initwhentarget_s390x()was true. Register each VirtioPCIDeviceTypeInfo twice. The s390x variant callspci_qdev_property_add_specifics(), which now always adds loadparm, and the other variant does not.target_s390x()andtarget_not_s390x()select the two.Signed-off-by Yonggang Luo <[email protected]>--- hw/pci/pci.c | 13 +++++-------- hw/virtio/virtio-blk-pci.c | 27 ++++++++++++++++++++++++++- hw/virtio/virtio-net-pci.c | 27 ++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 10 deletions(-)hw/pci/pci.c +5
-8@@ -2901,14 +2901,11 @@ void pci_qdev_property_add_specifics(DeviceClass *dc) {ObjectClass *oc =OBJECT_CLASS (dc); -/* The loadparm property is only supported on s390x */ -if (target_s390x ()) { -object_class_property_add_str (oc,"loadparm" , - pci_qdev_property_get_loadparm, - pci_qdev_property_set_loadparm); -object_class_property_set_description (oc,"loadparm" , -"load parameter (s390x only)" ); - } +object_class_property_add_str (oc,"loadparm" , + pci_qdev_property_get_loadparm, + pci_qdev_property_set_loadparm); +object_class_property_set_description (oc,"loadparm" , +"load parameter (s390x only)" ); }
Quoted 4 lines
hw/pci/pci.c void pci_qdev_property_add_specifics(DeviceClass *dc) · line 2911
Quoted 1 line
hw/pci/pci.c +0
-0MemoryRegion *pci_address_space (PCIDevice *dev)Again this is the only bit that we need IMHO, as it is harmless to register these properties unconditionally.
Hi that's the first choice of mine, I have did it a long ago
https://patchew.org/QEMU/[email protected]/
Quoted 8 lines
With regards,
Daniel
--|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoRe: [PATCH v2 09/12] hw/virtio: register s390x virtio-blk-pci and virtio-net-pci variants
Quoted 40 lines · Yonggang Luo
Quoted 39 lines · Daniel P. Berrangé
Quoted 37 lines · Yonggang Luo
virtio-blk-pci and virtio-net-pci added the s390x loadparm property from
class_initwhentarget_s390x()was true. Register each VirtioPCIDeviceTypeInfo twice. The s390x variant callspci_qdev_property_add_specifics(), which now always adds loadparm, and the other variant does not.target_s390x()andtarget_not_s390x()select the two.Signed-off-by Yonggang Luo <[email protected]>--- hw/pci/pci.c | 13 +++++-------- hw/virtio/virtio-blk-pci.c | 27 ++++++++++++++++++++++++++- hw/virtio/virtio-net-pci.c | 27 ++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 10 deletions(-)hw/pci/pci.c +5
-8@@ -2901,14 +2901,11 @@ void pci_qdev_property_add_specifics(DeviceClass *dc) {ObjectClass *oc =OBJECT_CLASS (dc); -/* The loadparm property is only supported on s390x */ -if (target_s390x ()) { -object_class_property_add_str (oc,"loadparm" , - pci_qdev_property_get_loadparm, - pci_qdev_property_set_loadparm); -object_class_property_set_description (oc,"loadparm" , -"load parameter (s390x only)" ); - } +object_class_property_add_str (oc,"loadparm" , + pci_qdev_property_get_loadparm, + pci_qdev_property_set_loadparm); +object_class_property_set_description (oc,"loadparm" , +"load parameter (s390x only)" ); }
Quoted 8 lines
Quoted 4 lines
hw/pci/pci.c void pci_qdev_property_add_specifics(DeviceClass *dc) · line 2911
Quoted 1 line
hw/pci/pci.c +0
-0MemoryRegion *pci_address_space (PCIDevice *dev)Again this is the only bit that we need IMHO, as it is harmless to register these properties unconditionally.
Hi that's the first choice of mine, I have did it a long ago
Oh, I missed that series. That is exactly how I think it ought to be done.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
PATCH v2 10/12 target-info: add target_base_i386()
In reply to Yonggang Luotarget_base_arm(), target_base_ppc() and target_base_riscv() report whether the selected target belongs to a CPU family. Add the same predicate for i386 and x86_64.
--- include/qemu/target-info.h | 7 +++++++ target-info.c | 11 +++++++++++ 2 files changed, 18 insertions(+)
include/qemu/target-info.h +7 -0
@@ -57,6 +57,13 @@ bool target_heterogeneous(void);*/ bool target_base_arm (void ); +/** +* target_base_i386: +* +* Returns whether the target architecture is i386 or x86_64. +*/ +bool target_base_i386 (void ); +/** * target_arm: *
target-info.c +11 -0
@@ -59,6 +59,17 @@ bool target_base_arm(void) } } +bool target_base_i386 (void ) +{ +switch (target_arch ()) { +case SYS_EMU_TARGET_I386 : +case SYS_EMU_TARGET_X86_64 : +return true; +default : +return false; + } +} +bool target_arm (void ) {return target_arch () ==SYS_EMU_TARGET_ARM ;
Signature · 1 line
2.55.0.windows.3
PATCH v2 11/12 hw/virtio/virtio-mem: register legacy-guest variant with is_available
In reply to Yonggang Luovirtio-mem decided in class_init and realize whether x86 guests can leave unplugged memory accessible. Register a second virtio-mem type that adds virtio_mem_legacy_guests_properties and sets VirtIOMEMClass.has_legacy_guests. Select the two with target_base_i386() and target_not_base_i386().
--- hw/virtio/virtio-mem.c | 52 +++++++++++++++++++++------------- include/hw/virtio/virtio-mem.h | 2 ++ 2 files changed, 34 insertions(+), 20 deletions(-)
hw/virtio/virtio-mem.c +32 -20
@@ -15,6 +15,7 @@#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/units.h" +#include "qemu/target-info.h" #include "qemu/target-info-qapi.h" #include "system/memory.h" #include "system/numa.h"
@@ -35,22 +36,6 @@static const VMStateDescription vmstate_virtio_mem_device_early; -static bool virtio_mem_has_legacy_guests (void ) -{ -/* -* We only had legacy x86 guests that did not support -* VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have -* legacy guests. -*/ -switch (target_arch ()) { -case SYS_EMU_TARGET_I386 : -case SYS_EMU_TARGET_X86_64 : -return true; -default : -return false; - } -} -/* * Let's not allow blocks smaller than 1 MiB, for example, to keep the tracking * bitmap small.
@@ -859,7 +844,7 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp) rb = vmem->memdev->mr.ram_block; page_size =qemu_ram_pagesize (rb); -if (virtio_mem_has_legacy_guests ()) { +if (VIRTIO_MEM_GET_CLASS (vmem)->has_legacy_guests) {switch (vmem->unplugged_inaccessible) {case ON_OFF_AUTO_AUTO :if (virtio_mem_has_shared_zeropage (rb)) {
@@ -1635,9 +1620,6 @@ static void virtio_mem_class_init(ObjectClass *klass, const void *data)RamDiscardSourceClass *rdsc =RAM_DISCARD_SOURCE_CLASS (klass);device_class_set_props (dc, virtio_mem_properties); -if (virtio_mem_has_legacy_guests ()) { -device_class_set_props (dc, virtio_mem_legacy_guests_properties); - } dc->vmsd = &vmstate_virtio_mem;set_bit (DEVICE_CATEGORY_MISC , dc->categories);
@@ -1660,6 +1642,19 @@ static void virtio_mem_class_init(ObjectClass *klass, const void *data) rdsc->is_populated = virtio_mem_rds_is_populated; } +static void virtio_mem_legacy_class_init (ObjectClass *klass,const void *data) +{ +virtio_mem_class_init (klass, data); +device_class_set_props (DEVICE_CLASS (klass), + virtio_mem_legacy_guests_properties); +VIRTIO_MEM_CLASS (klass)->has_legacy_guests = true; +} + +static bool target_not_base_i386 (void ) +{ +return !target_base_i386 (); +} +static const TypeInfo virtio_mem_info = { .name =TYPE_VIRTIO_MEM , .parent =TYPE_VIRTIO_DEVICE ,
@@ -1668,6 +1663,22 @@ static const TypeInfo virtio_mem_info = { .instance_finalize = virtio_mem_instance_finalize, .class_init = virtio_mem_class_init, .class_size = sizeof(VirtIOMEMClass), + .is_available = target_not_base_i386, + .interfaces = (const InterfaceInfo []) { + {TYPE_RAM_DISCARD_SOURCE }, + { } + }, +}; + +static const TypeInfo virtio_mem_legacy_info = { + .name =TYPE_VIRTIO_MEM , + .parent =TYPE_VIRTIO_DEVICE , + .instance_size =sizeof (VirtIOMEM), + .instance_init = virtio_mem_instance_init, + .instance_finalize = virtio_mem_instance_finalize, + .class_init = virtio_mem_legacy_class_init, + .class_size =sizeof (VirtIOMEMClass), + .is_available = target_base_i386, .interfaces = (const InterfaceInfo []) { {TYPE_RAM_DISCARD_SOURCE }, { }
@@ -1677,6 +1688,7 @@ static const TypeInfo virtio_mem_info = {static void virtio_register_types (void ) {type_register_static (&virtio_mem_info); +type_register_static (&virtio_mem_legacy_info); }type_init (virtio_register_types)
include/hw/virtio/virtio-mem.h +2 -0
@@ -134,6 +134,8 @@ struct VirtIOMEMClass {VirtioDeviceClass parent_class;/* public */ +bool has_legacy_guests; +void (*fill_device_info)(const VirtIOMEM *vmen,VirtioMEMDeviceInfo *vi); MemoryRegion *(*get_memory_region)(VirtIOMEM *vmem, Error **errp);void (*decide_memslots)(VirtIOMEM *vmem,unsigned int limit);
Signature · 1 line
2.55.0.windows.3
Re: [PATCH v2 11/12] hw/virtio/virtio-mem: register legacy-guest variant with is_available
Quoted 57 lines · Yonggang Luo
virtio-mem decided in
class_initand realize whether x86 guests can leave unplugged memory accessible. Register a second virtio-mem type that addsvirtio_mem_legacy_guests_propertiesand sets VirtIOMEMClass.has_legacy_guests. Select the two withtarget_base_i386()andtarget_not_base_i386().Signed-off-by Yonggang Luo <[email protected]>--- hw/virtio/virtio-mem.c | 52 +++++++++++++++++++++------------- include/hw/virtio/virtio-mem.h | 2 ++ 2 files changed, 34 insertions(+), 20 deletions(-)hw/virtio/virtio-mem.c +2
-17@@ -15,6 +15,7 @@#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/units.h" +#include "qemu/target-info.h" #include "qemu/target-info-qapi.h" #include "system/memory.h" #include "system/numa.h" @@ -35,22 +36,6 @@static const VMStateDescription vmstate_virtio_mem_device_early; -static bool virtio_mem_has_legacy_guests (void ) -{ -/* -* We only had legacy x86 guests that did not support -* VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have -* legacy guests. -*/ -switch (target_arch ()) { -case SYS_EMU_TARGET_I386 : -case SYS_EMU_TARGET_X86_64 : -return true; -default : -return false; - } -} -/* * Let's not allow blocks smaller than 1 MiB, for example, to keep the tracking * bitmap small. @@ -859,7 +844,7 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp) rb = vmem->memdev->mr.ram_block; page_size =qemu_ram_pagesize (rb); -if (virtio_mem_has_legacy_guests ()) { +if (VIRTIO_MEM_GET_CLASS (vmem)->has_legacy_guests) {switch (vmem->unplugged_inaccessible) {case ON_OFF_AUTO_AUTO :if (virtio_mem_has_shared_zeropage (rb)) {
hw/virtio/virtio-mem.c static void virtio_mem_class_init(ObjectClass *klass, const void *data) · line 1640
Quoted 6 lines
hw/virtio/virtio-mem.c +0
-3@@ -1635,9 +1620,6 @@ static void virtio_mem_class_init(ObjectClass *klass, const void *data)RamDiscardSourceClass *rdsc =RAM_DISCARD_SOURCE_CLASS (klass);device_class_set_props (dc, virtio_mem_properties); -if (virtio_mem_has_legacy_guests ()) { -device_class_set_props (dc, virtio_mem_legacy_guests_properties); - }
Again IMHO the conditional property registration is an unneccessary step. Just fold virtio_mem_legacy_guests_properties into virtio_mem_properties.
In the realize() method, check virtio_mem_has_legacy_guests() and reject values that are invalid for the non-x86 targets.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
PATCH v2 12/12 hw/microblaze: defer PetaLogix endianness default until init
In reply to Yonggang LuoThe PetaLogix machine read its endianness default from target_big_endian() in class_init. In a multi-target binary the target is not selected yet at class_init, so the default cannot be computed there. Set the property default to "unspecified" instead, and resolve it to big or little in petalogix_s3adsp1800_init(), where the target is known.
Until the machine is initialized, endianness reads back as "unspecified" rather than big or little.
--- hw/microblaze/petalogix_s3adsp1800_mmu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
hw/microblaze/petalogix_s3adsp1800_mmu.c +8 -3
@@ -83,7 +83,13 @@ petalogix_s3adsp1800_init(MachineState *machine)MemoryRegion *phys_ram =g_new (MemoryRegion,1 );qemu_irq irq[32 ];MemoryRegion *sysmem =get_system_memory (); -EndianMode endianness = psms->endianness; +EndianMode endianness; + +if (psms->endianness ==ENDIAN_MODE_UNSPECIFIED ) { + psms->endianness =target_big_endian () ?ENDIAN_MODE_BIG : +ENDIAN_MODE_LITTLE ; + } + endianness = psms->endianness; cpu =MICROBLAZE_CPU (object_new (TYPE_MICROBLAZE_CPU ));object_property_set_str (OBJECT (cpu),"version" ,"7.10.d" , &error_abort);
@@ -178,8 +184,7 @@ static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc, &EndianMode_lookup, machine_get_endianness, machine_set_endianness); -object_property_set_default_str (prop,target_big_endian () ?"big" - :"little" ); +object_property_set_default_str (prop,"unspecified" );object_class_property_set_description (oc,"endianness" ,"Defines whether the machine runs in big or little endian mode" ); }
Signature · 1 line
2.55.0.windows.3