Replace has_dynamic_sysbus with list of allowed device types
v2 cover Replace has_dynamic_sysbus with list of allowed device types
Changes v1 (RFC) -> v2:
* Patch 1 now just adds TYPE_SYS_BUS_DEVICE to the existing has_dynamic_sysbus=true machines, and other patches make the lists on each machine-type more specific.
* Change the name of the new field to allowed_dynamic_sysbus_devices.
* The q35 allowed list is much shorter because the list of user-creatable sysbus devices in QEMU is shorter.
* Keep the xen_set_dynamic_sysbus() hack, just change it to add 'xen-sysdev" to the allowed list.
* Simplified the arm/virt code.
Summary
-------
This series replaces the existing has_dynamic_sysbus flag (that makes the machine accept every user-creatable sysbus device type on the command-line) with a list of allowed devices.
This will be helpful when implementing the new query-device-slots command, because each machine type will include only the sysbus devices it really supports, instead of including a catch-all TYPE_SYS_BUS_DEVICE "slot".
This will be useful to add support to new sysbus devices on machines like pc_piix, that don't have has_dynamic_sysbus set today.
This also makes the code safer: just compiling a new sysbus device in the same QEMU binary won't make a machine-type automatically start accepting the device.
Eduardo Habkost (6):
machine: Replace has_dynamic_sysbus with list of allowed devices hw/arm/virt: Allow only supported dynamic sysbus devices
ppc: e500: Allow only supported dynamic sysbus devices
spapr: Allow only supported dynamic sysbus devices
xen: Add only xen-sysdev to dynamic sysbus device list
q35: Allow only supported dynamic sysbus devices
include/hw/boards.h | 5 ++++- hw/arm/virt.c | 5 ++++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 5 ++++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 2 +- hw/xen/xen_backend.c | 2 +- 7 files changed, 46 insertions(+), 20 deletions(-)
Signature · 1 line
2.13.6
PATCH v2 1/6 machine: Replace has_dynamic_sysbus with list of allowed devices
The existing has_dynamic_sysbus flag makes the machine accept every user-creatable sysbus device type on the command-line. Replace it with a list of allowed device types, so machines can easily accept some sysbus devices while rejecting others.
To keep exactly the same behavior as before, the existing has_dynamic_sysbus=true assignments are replaced with a TYPE_SYS_BUS_DEVICE entry on the allowed list. Other patches will replace the TYPE_SYS_BUS_DEVICE entries with more specific lists of devices.
---
Changes v1 -> v2:
* Replace "dynamic sysbus whitelist" with "allowed sysbus devices"
* Simply add TYPE_SYS_BUS_DEVICE to the list on existing has_dynamic_sysbus=true machines, and make machine-types more strict in separate patches
--- include/hw/boards.h | 5 ++++- hw/arm/virt.c | 3 ++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 3 ++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 3 ++- hw/xen/xen_backend.c | 7 ++++++- 7 files changed, 48 insertions(+), 20 deletions(-)
include/hw/boards.h +4 -1
@@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine,const CpuInstanceProperties *props, Error **errp); +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type); + +/** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU
@@ -179,7 +182,6 @@ struct MachineClass { no_floppy:1, no_cdrom:1, no_sdcard:1, - has_dynamic_sysbus:1, pci_allow_0_address:1, legacy_fw_cfg_order:1;int is_default;
@@ -197,6 +199,7 @@ struct MachineClass {bool ignore_memory_transaction_failures;int numa_mem_align_shift;const char **valid_cpu_types; +strList *allowed_dynamic_sysbus_devices;bool auto_enable_numa_with_memhp;void (*numa_auto_assign_ram)(MachineClass *mc,NodeInfo *nodes,int nb_nodes,ram_addr_t size);
hw/arm/virt.c +2 -1
@@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)* configuration of the particular instance. */ mc->max_cpus =255 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; mc->pci_allow_0_address = true;
hw/core/machine.c +29 -14
58 lines not on this page · raw message
hw/i386/pc_q35.c +2 -1
@@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; m->no_floppy =1 ; - m->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (m,TYPE_SYS_BUS_DEVICE ); m->max_cpus =288 ; }
hw/ppc/e500plat.c +3 -1
@@ -15,6 +15,7 @@#include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" +#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/ppc/openpic.h" #include "kvm_ppc.h"
@@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }
hw/ppc/spapr.c +2 -1
@@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="" ; mc->default_ram_size =512 *M_BYTE ; mc->kvm_type = spapr_kvm_type; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;
hw/xen/xen_backend.c +6 -1
@@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void)ObjectClass *oc =object_get_class (machine);MachineClass *mc =MACHINE_CLASS (oc); - mc->has_dynamic_sysbus = true; +/* +* Emulate old mc->has_dynamic_sysbus=true assignment +* +*TODO: add only Xen devices to the list +*/ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); }int xen_be_register (const char *type,struct XenDevOps *ops)
Signature · 7 lines
2.13.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 3/6 ppc: e500: Allow only supported dynamic sysbus devices
In reply to Eduardo Habkostplatform_bus_create_devtree() already rejects all dynamic sysbus devices except TYPE_ETSEC_COMMON, so register it as the only allowed dynamic sysbus device for the ppce500 machine-type.
---
Changes series v1 -> v2:
* New patch added to series
--- hw/ppc/e500plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ppc/e500plat.c +2 -2
@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "e500.h" +#include "hw/net/fsl_etsec/etsec.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h"
@@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_ETSEC_COMMON ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }
Signature · 1 line
2.13.6
PATCH v2 2/6 hw/arm/virt: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostReplace the TYPE_SYS_BUS_DEVICE entry in the allowed sysbus device list with the two device types that are really supported by the virt machine: vfio-amd-xgbe and vfio-calxeda-xgmac.
---
Changes series v1 -> v2:
* New patch added to series
--- hw/arm/virt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/arm/virt.c +4 -2
@@ -34,6 +34,8 @@#include "hw/arm/arm.h" #include "hw/arm/primecell.h" #include "hw/arm/virt.h" +#include "hw/vfio/vfio-calxeda-xgmac.h" +#include "hw/vfio/vfio-amd-xgbe.h" #include "hw/devices.h" #include "net/net.h" #include "sysemu/block-backend.h"
@@ -1591,8 +1593,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)* configuration of the particular instance. */ mc->max_cpus =255 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_VFIO_CALXEDA_XGMAC ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_VFIO_AMD_XGBE ); mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; mc->pci_allow_0_address = true;
Signature · 1 line
2.13.6
PATCH v2 4/6 spapr: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostTYPE_SPAPR_PCI_HOST_BRIDGE is the only dynamic sysbus device not rejected by ppc_spapr_reset(), so it can be the only entry on the allowed list.
---
Changes series v1 -> v2:
* New patch added to series
--- hw/ppc/spapr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/ppc/spapr.c +1 -2
@@ -3603,8 +3603,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="" ; mc->default_ram_size =512 *M_BYTE ; mc->kvm_type = spapr_kvm_type; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SPAPR_PCI_HOST_BRIDGE ); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;
Signature · 1 line
2.13.6
PATCH v2 5/6 xen: Add only xen-sysdev to dynamic sysbus device list
In reply to Eduardo HabkostThere's no need to make the machine allow every possible sysbus device. We can now just add xen-sysdev to the allowed list.
---
Changes series v1 -> v2:
* New patch added to series
--- hw/xen/xen_backend.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
hw/xen/xen_backend.c +1 -6
@@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void)ObjectClass *oc =object_get_class (machine);MachineClass *mc =MACHINE_CLASS (oc); -/* -* Emulate old mc->has_dynamic_sysbus=true assignment -* -*TODO: add only Xen devices to the list -*/ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_XENSYSDEV ); }int xen_be_register (const char *type,struct XenDevOps *ops)
Signature · 7 lines
2.13.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 6/6 q35: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostThe only user-creatable sysbus devices in qemu-system-x86_64 are amd-iommu, intel-iommu, and xen-backend. xen-backend is handled by xen_set_dynamic_sysbus(), so we only need to add amd-iommu and intel-iommu.
---
Changes series v1 -> v2:
* New patch added to series
--- hw/i386/pc_q35.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/i386/pc_q35.c +4 -2
@@ -42,6 +42,8 @@#include "exec/address-spaces.h" #include "hw/i386/pc.h" #include "hw/i386/ich9.h" +#include "hw/i386/amd_iommu.h" +#include "hw/i386/intel_iommu.h" #include "hw/smbios/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h"
@@ -299,8 +301,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; m->no_floppy =1 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (m,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_AMD_IOMMU_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_INTEL_IOMMU_DEVICE ); m->max_cpus =288 ; }
Signature · 1 line
2.13.6
Re: [Qemu-arm] [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices
In reply to Eduardo HabkostQuoted 22 lines · On Sat, 25 Nov 2017 13:16:05 -0200 Eduardo Habkost <[email protected]> wrote:
The existing
has_dynamic_sysbusflag makes the machine accept every user-creatable sysbus device type on the command-line. Replace it with a list of allowed device types, so machines can easily accept some sysbus devices while rejecting others.To keep exactly the same behavior as before, the existing has_dynamic_sysbus=true assignments are replaced with a
TYPE_SYS_BUS_DEVICEentry on the allowed list. Other patches will replace theTYPE_SYS_BUS_DEVICEentries with more specific lists of devices.Cc Peter Maydell <[email protected]>Cc Marcel Apfelbaum <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Quoted 1 line
---
Quoted 180 lines
Changes v1 -> v2:
* Replace "dynamic sysbus whitelist" with "allowed sysbus devices"
* Simply addTYPE_SYS_BUS_DEVICEto the list on existing has_dynamic_sysbus=true machines, and make machine-types more strict in separate patches--- include/hw/boards.h | 5 ++++- hw/arm/virt.c | 3 ++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 3 ++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 3 ++- hw/xen/xen_backend.c | 7 ++++++- 7 files changed, 48 insertions(+), 20 deletions(-)include/hw/boards.h +4
-1@@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine,const CpuInstanceProperties *props, Error **errp); +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type); + +/** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU @@ -179,7 +182,6 @@ struct MachineClass { no_floppy:1, no_cdrom:1, no_sdcard:1, - has_dynamic_sysbus:1, pci_allow_0_address:1, legacy_fw_cfg_order:1;int is_default;@@ -197,6 +199,7 @@ struct MachineClass {bool ignore_memory_transaction_failures;int numa_mem_align_shift;const char **valid_cpu_types; +strList *allowed_dynamic_sysbus_devices;bool auto_enable_numa_with_memhp;void (*numa_auto_assign_ram)(MachineClass *mc,NodeInfo *nodes,int nb_nodes,ram_addr_t size);hw/arm/virt.c +2
-1@@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)* configuration of the particular instance. */ mc->max_cpus =255 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; mc->pci_allow_0_address = true;hw/core/machine.c +29
-14@@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp)return ms->enforce_config_section; } -static void error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type) { -error_report ("Option '-device %s' cannot be handled by this machine" , -object_class_get_name (object_get_class (OBJECT (sbdev)))); -exit (1 ); +strList *item =g_new0 (strList,1 ); + + item->value =g_strdup (type); + item->next = mc->allowed_dynamic_sysbus_devices; + mc->allowed_dynamic_sysbus_devices = item; } -static void machine_init_notify (Notifier *notifier,void *data) +static void validate_sysbus_device (SysBusDevice *sbdev,void *opaque) { -Object *machine =qdev_get_machine (); -ObjectClass *oc =object_get_class (machine); -MachineClass *mc =MACHINE_CLASS (oc); +MachineState *machine = opaque; +MachineClass *mc =MACHINE_GET_CLASS (machine); +bool allowed = false; +strList *wl; -if (mc->has_dynamic_sysbus) { -/* Our machine can handle dynamic sysbus devices, we're all good */ -return ; +for (wl = mc->allowed_dynamic_sysbus_devices; + !allowed && wl; + wl = wl->next) { + allowed |= !!object_dynamic_cast (OBJECT (sbdev), wl->value); } +if (!allowed) { +error_report ("Option '-device %s' cannot be handled by this machine" , +object_class_get_name (object_get_class (OBJECT (sbdev)))); +exit (1 ); + } +} + +static void machine_init_notify (Notifier *notifier,void *data) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +/* -* Loop through all dynamically created devices and check whether there -* are sysbus devices among them. If there are, error out. +* Loop through all dynamically created sysbus devices and check if they are +* all allowed. If a device is not allowed, error out. */ -foreach_dynamic_sysbus_device (error_on_sysbus_device,NULL ); +foreach_dynamic_sysbus_device (validate_sysbus_device, machine); }HotpluggableCPUList *machine_query_hotpluggable_cpus (MachineState *machine)hw/i386/pc_q35.c +2
-1@@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; m->no_floppy =1 ; - m->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (m,TYPE_SYS_BUS_DEVICE ); m->max_cpus =288 ; }hw/ppc/e500plat.c +3
-1@@ -15,6 +15,7 @@#include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" +#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/ppc/openpic.h" #include "kvm_ppc.h" @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }hw/ppc/spapr.c +2
-1@@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="" ; mc->default_ram_size =512 *M_BYTE ; mc->kvm_type = spapr_kvm_type; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;hw/xen/xen_backend.c +0
-0@@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void)ObjectClass *oc =object_get_class (machine);MachineClass *mc =MACHINE_CLASS (oc);
hw/xen/xen_backend.c static void xen_set_dynamic_sysbus(void) · line 575
Quoted 10 lines
hw/xen/xen_backend.c +6
-1- mc->has_dynamic_sysbus = true; +/* +* Emulate old mc->has_dynamic_sysbus=true assignment +* +*TODO: add only Xen devices to the list +*/ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); }int xen_be_register (const char *type,struct XenDevOps *ops)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Qemu-devel] [PATCH v2 4/6] spapr: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostQuoted 4 lines · On Sat, 25 Nov 2017 13:16:08 -0200 Eduardo Habkost <[email protected]> wrote:
TYPE_SPAPR_PCI_HOST_BRIDGEis the only dynamic sysbus device not rejected byppc_spapr_reset(), so it can be the only entry on the allowed list.
So we don't need the code that rejects other sysbus devices anymore, right ? We should drop the related code then, but I guess this can be done in a followup patch.
Quoted 25 lines
Cc David Gibson <[email protected]>Cc Alexander Graf <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes series v1 -> v2:
* New patch added to series--- hw/ppc/spapr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/ppc/spapr.c +1
-2@@ -3603,8 +3603,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="" ; mc->default_ram_size =512 *M_BYTE ; mc->kvm_type = spapr_kvm_type; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SPAPR_PCI_HOST_BRIDGE ); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;
Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostQuoted 4 lines · On Sat, 25 Nov 2017 13:16:07 -0200 Eduardo Habkost <[email protected]> wrote:
platform_bus_create_devtree()already rejects all dynamic sysbus devices exceptTYPE_ETSEC_COMMON, so register it as the only allowed dynamic sysbus device for the ppce500 machine-type.
Maybe drop the code that rejects unsupported sysbus devices, but this can be done in a followup patch.
Anyway,
Quoted 33 lines
Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes series v1 -> v2:
* New patch added to series--- hw/ppc/e500plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/ppc/e500plat.c +2
-2@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "e500.h" +#include "hw/net/fsl_etsec/etsec.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_ETSEC_COMMON ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }
Re: [Qemu-arm] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices
In reply to Eduardo HabkostQuoted 11 lines · Eduardo Habkost
The existing
has_dynamic_sysbusflag makes the machine accept every user-creatable sysbus device type on the command-line. Replace it with a list of allowed device types, so machines can easily accept some sysbus devices while rejecting others.To keep exactly the same behavior as before, the existing has_dynamic_sysbus=true assignments are replaced with a
TYPE_SYS_BUS_DEVICEentry on the allowed list. Other patches will replace theTYPE_SYS_BUS_DEVICEentries with more specific lists of devices.
Quoted 11 lines
Cc Peter Maydell <[email protected]>Cc Marcel Apfelbaum <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Quoted 191 lines
---
Changes v1 -> v2:
* Replace "dynamic sysbus whitelist" with "allowed sysbus devices"
* Simply addTYPE_SYS_BUS_DEVICEto the list on existing has_dynamic_sysbus=true machines, and make machine-types more strict in separate patches--- include/hw/boards.h | 5 ++++- hw/arm/virt.c | 3 ++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 3 ++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 3 ++- hw/xen/xen_backend.c | 7 ++++++- 7 files changed, 48 insertions(+), 20 deletions(-)include/hw/boards.h +4
-1@@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine,const CpuInstanceProperties *props, Error **errp); +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type); + +/** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU @@ -179,7 +182,6 @@ struct MachineClass { no_floppy:1, no_cdrom:1, no_sdcard:1, - has_dynamic_sysbus:1, pci_allow_0_address:1, legacy_fw_cfg_order:1;int is_default;@@ -197,6 +199,7 @@ struct MachineClass {bool ignore_memory_transaction_failures;int numa_mem_align_shift;const char **valid_cpu_types; +strList *allowed_dynamic_sysbus_devices;bool auto_enable_numa_with_memhp;void (*numa_auto_assign_ram)(MachineClass *mc,NodeInfo *nodes,int nb_nodes,ram_addr_t size);hw/arm/virt.c +2
-1@@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)* configuration of the particular instance. */ mc->max_cpus =255 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; mc->pci_allow_0_address = true;hw/core/machine.c +29
-14@@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp)return ms->enforce_config_section; } -static void error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type) { -error_report ("Option '-device %s' cannot be handled by this machine" , -object_class_get_name (object_get_class (OBJECT (sbdev)))); -exit (1 ); +strList *item =g_new0 (strList,1 ); + + item->value =g_strdup (type); + item->next = mc->allowed_dynamic_sysbus_devices; + mc->allowed_dynamic_sysbus_devices = item; } -static void machine_init_notify (Notifier *notifier,void *data) +static void validate_sysbus_device (SysBusDevice *sbdev,void *opaque) { -Object *machine =qdev_get_machine (); -ObjectClass *oc =object_get_class (machine); -MachineClass *mc =MACHINE_CLASS (oc); +MachineState *machine = opaque; +MachineClass *mc =MACHINE_GET_CLASS (machine); +bool allowed = false; +strList *wl; -if (mc->has_dynamic_sysbus) { -/* Our machine can handle dynamic sysbus devices, we're all good */ -return ; +for (wl = mc->allowed_dynamic_sysbus_devices; + !allowed && wl; + wl = wl->next) { + allowed |= !!object_dynamic_cast (OBJECT (sbdev), wl->value); } +if (!allowed) { +error_report ("Option '-device %s' cannot be handled by this machine" , +object_class_get_name (object_get_class (OBJECT (sbdev)))); +exit (1 ); + } +} + +static void machine_init_notify (Notifier *notifier,void *data) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +/* -* Loop through all dynamically created devices and check whether there -* are sysbus devices among them. If there are, error out. +* Loop through all dynamically created sysbus devices and check if they are +* all allowed. If a device is not allowed, error out. */ -foreach_dynamic_sysbus_device (error_on_sysbus_device,NULL ); +foreach_dynamic_sysbus_device (validate_sysbus_device, machine); }HotpluggableCPUList *machine_query_hotpluggable_cpus (MachineState *machine)hw/i386/pc_q35.c +2
-1@@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; m->no_floppy =1 ; - m->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (m,TYPE_SYS_BUS_DEVICE ); m->max_cpus =288 ; }hw/ppc/e500plat.c +3
-1@@ -15,6 +15,7 @@#include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" +#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/ppc/openpic.h" #include "kvm_ppc.h" @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }hw/ppc/spapr.c +2
-1@@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="" ; mc->default_ram_size =512 *M_BYTE ; mc->kvm_type = spapr_kvm_type; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;hw/xen/xen_backend.c +6
-1@@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void)ObjectClass *oc =object_get_class (machine);MachineClass *mc =MACHINE_CLASS (oc); - mc->has_dynamic_sysbus = true; +/* +* Emulate old mc->has_dynamic_sysbus=true assignment +* +*TODO: add only Xen devices to the list +*/ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); }int xen_be_register (const char *type,struct XenDevOps *ops)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Qemu-devel] [PATCH v2 4/6] spapr: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostQuoted 8 lines · Eduardo Habkost
TYPE_SPAPR_PCI_HOST_BRIDGEis the only dynamic sysbus device not rejected byppc_spapr_reset(), so it can be the only entry on the allowed list.Cc David Gibson <[email protected]>Cc Alexander Graf <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Again, do you need me to take this through my tree?
Quoted 21 lines
---
Changes series v1 -> v2:
* New patch added to series--- hw/ppc/spapr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/ppc/spapr.c +1
-2@@ -3603,8 +3603,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="" ; mc->default_ram_size =512 *M_BYTE ; mc->kvm_type = spapr_kvm_type; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SPAPR_PCI_HOST_BRIDGE ); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostQuoted 8 lines · Eduardo Habkost
platform_bus_create_devtree()already rejects all dynamic sysbus devices exceptTYPE_ETSEC_COMMON, so register it as the only allowed dynamic sysbus device for the ppce500 machine-type.Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Do you need me to take this through my tree (for 2.12), or do you have another merge patch in mind?
Quoted 29 lines
---
Changes series v1 -> v2:
* New patch added to series--- hw/ppc/e500plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/ppc/e500plat.c +2
-2@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "e500.h" +#include "hw/net/fsl_etsec/etsec.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_ETSEC_COMMON ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-arm] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices
In reply to Eduardo HabkostQuoted 204 lines · Eduardo Habkost
The existing
has_dynamic_sysbusflag makes the machine accept every user-creatable sysbus device type on the command-line. Replace it with a list of allowed device types, so machines can easily accept some sysbus devices while rejecting others.To keep exactly the same behavior as before, the existing has_dynamic_sysbus=true assignments are replaced with a
TYPE_SYS_BUS_DEVICEentry on the allowed list. Other patches will replace theTYPE_SYS_BUS_DEVICEentries with more specific lists of devices.Cc Peter Maydell <[email protected]>Cc Marcel Apfelbaum <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes v1 -> v2:
* Replace "dynamic sysbus whitelist" with "allowed sysbus devices"
* Simply addTYPE_SYS_BUS_DEVICEto the list on existing has_dynamic_sysbus=true machines, and make machine-types more strict in separate patches--- include/hw/boards.h | 5 ++++- hw/arm/virt.c | 3 ++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 3 ++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 3 ++- hw/xen/xen_backend.c | 7 ++++++- 7 files changed, 48 insertions(+), 20 deletions(-)include/hw/boards.h +4
-1@@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine,const CpuInstanceProperties *props, Error **errp); +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type); + +/** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU @@ -179,7 +182,6 @@ struct MachineClass { no_floppy:1, no_cdrom:1, no_sdcard:1, - has_dynamic_sysbus:1, pci_allow_0_address:1, legacy_fw_cfg_order:1;int is_default;@@ -197,6 +199,7 @@ struct MachineClass {bool ignore_memory_transaction_failures;int numa_mem_align_shift;const char **valid_cpu_types; +strList *allowed_dynamic_sysbus_devices;bool auto_enable_numa_with_memhp;void (*numa_auto_assign_ram)(MachineClass *mc,NodeInfo *nodes,int nb_nodes,ram_addr_t size);hw/arm/virt.c +2
-1@@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)* configuration of the particular instance. */ mc->max_cpus =255 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; mc->pci_allow_0_address = true;hw/core/machine.c +29
-14@@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp)return ms->enforce_config_section; } -static void error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type) { -error_report ("Option '-device %s' cannot be handled by this machine" , -object_class_get_name (object_get_class (OBJECT (sbdev)))); -exit (1 ); +strList *item =g_new0 (strList,1 ); + + item->value =g_strdup (type); + item->next = mc->allowed_dynamic_sysbus_devices; + mc->allowed_dynamic_sysbus_devices = item; } -static void machine_init_notify (Notifier *notifier,void *data) +static void validate_sysbus_device (SysBusDevice *sbdev,void *opaque) { -Object *machine =qdev_get_machine (); -ObjectClass *oc =object_get_class (machine); -MachineClass *mc =MACHINE_CLASS (oc); +MachineState *machine = opaque; +MachineClass *mc =MACHINE_GET_CLASS (machine); +bool allowed = false; +strList *wl; -if (mc->has_dynamic_sysbus) { -/* Our machine can handle dynamic sysbus devices, we're all good */ -return ; +for (wl = mc->allowed_dynamic_sysbus_devices; + !allowed && wl; + wl = wl->next) { + allowed |= !!object_dynamic_cast (OBJECT (sbdev), wl->value); } +if (!allowed) { +error_report ("Option '-device %s' cannot be handled by this machine" , +object_class_get_name (object_get_class (OBJECT (sbdev)))); +exit (1 ); + } +} + +static void machine_init_notify (Notifier *notifier,void *data) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +/* -* Loop through all dynamically created devices and check whether there -* are sysbus devices among them. If there are, error out. +* Loop through all dynamically created sysbus devices and check if they are +* all allowed. If a device is not allowed, error out. */ -foreach_dynamic_sysbus_device (error_on_sysbus_device,NULL ); +foreach_dynamic_sysbus_device (validate_sysbus_device, machine); }HotpluggableCPUList *machine_query_hotpluggable_cpus (MachineState *machine)hw/i386/pc_q35.c +2
-1@@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; m->no_floppy =1 ; - m->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (m,TYPE_SYS_BUS_DEVICE ); m->max_cpus =288 ; }hw/ppc/e500plat.c +3
-1@@ -15,6 +15,7 @@#include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" +#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/ppc/openpic.h" #include "kvm_ppc.h" @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }hw/ppc/spapr.c +2
-1@@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="" ; mc->default_ram_size =512 *M_BYTE ; mc->kvm_type = spapr_kvm_type; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;hw/xen/xen_backend.c +0
-0@@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void)ObjectClass *oc =object_get_class (machine);MachineClass *mc =MACHINE_CLASS (oc);
hw/xen/xen_backend.c static void xen_set_dynamic_sysbus(void) · line 575
Quoted 10 lines
hw/xen/xen_backend.c +6
-1- mc->has_dynamic_sysbus = true; +/* +* Emulate old mc->has_dynamic_sysbus=true assignment +* +*TODO: add only Xen devices to the list +*/ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); }int xen_be_register (const char *type,struct XenDevOps *ops)
Thanks,
Marcel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostQuoted 20 lines · Eduardo Habkost
The only user-creatable sysbus devices in qemu-system-x86_64 are amd-iommu, intel-iommu, and xen-backend. xen-backend is handled by
xen_set_dynamic_sysbus(), so we only need to add amd-iommu and intel-iommu.Cc "Michael S. Tsirkin" <[email protected]>Cc Marcel Apfelbaum <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes series v1 -> v2:
* New patch added to series--- hw/i386/pc_q35.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)hw/i386/pc_q35.c +0
-0
hw/i386/pc_q35.c line 46
Quoted 5 lines
hw/i386/pc_q35.c +2
-0@@ -42,6 +42,8 @@#include "exec/address-spaces.h" #include "hw/i386/pc.h" #include "hw/i386/ich9.h" +#include "hw/i386/amd_iommu.h" +#include "hw/i386/intel_iommu.h"
Is a pity we have to add the AMD/Intel header files only for the type, maybe we should have a header only with the type names, anyway out of the scope of this series.
Another question, what about I440FX?
I think the AMD vIOMMU can theoretically work with the conventional PCI machines, I am not sure if it was tested or intended to work with it.
Thanks,
Marcel
Quoted 15 lines
hw/i386/pc_q35.c +2
-2#include "hw/smbios/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" @@ -299,8 +301,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; m->no_floppy =1 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (m,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_AMD_IOMMU_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_INTEL_IOMMU_DEVICE ); m->max_cpus =288 ; }
Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices
In reply to Greg KurzQuoted 10 lines · Greg Kurz
Quoted 4 lines · On Sat, 25 Nov 2017 13:16:07 -0200 Eduardo Habkost <[email protected]> wrote:
platform_bus_create_devtree()already rejects all dynamic sysbus devices exceptTYPE_ETSEC_COMMON, so register it as the only allowed dynamic sysbus device for the ppce500 machine-type.Maybe drop the code that rejects unsupported sysbus devices, but this can be done in a followup patch.
Yes, that's a good idea. Probably an opportunity to provide a better API to handle dynamic sysbus devices.
Quoted 4 lines
Anyway,
Reviewed-by Greg Kurz <[email protected]>
Thanks!
Quoted 35 lines
Quoted 34 lines
Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes series v1 -> v2:
* New patch added to series--- hw/ppc/e500plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/ppc/e500plat.c +2
-2@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "e500.h" +#include "hw/net/fsl_etsec/etsec.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_ETSEC_COMMON ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices
In reply to David GibsonQuoted 11 lines · David Gibson
Quoted 8 lines · Eduardo Habkost
platform_bus_create_devtree()already rejects all dynamic sysbus devices exceptTYPE_ETSEC_COMMON, so register it as the only allowed dynamic sysbus device for the ppce500 machine-type.Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>Acked-by David Gibson <[email protected]>
Thanks!
Quoted 3 lines
Do you need me to take this through my tree (for 2.12), or do you have another merge patch in mind?
As this patch requires patch 1/6 to be applied first and there are patches touching other machines in this series, I can merge this through my machine core tree if you don't mind.
Quoted 36 lines
Quoted 30 lines
---
Changes series v1 -> v2:
* New patch added to series--- hw/ppc/e500plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/ppc/e500plat.c +2
-2@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "e500.h" +#include "hw/net/fsl_etsec/etsec.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_ETSEC_COMMON ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices
In reply to Marcel ApfelbaumQuoted 16 lines · Marcel Apfelbaum
Quoted 15 lines · Eduardo Habkost
The only user-creatable sysbus devices in qemu-system-x86_64 are amd-iommu, intel-iommu, and xen-backend. xen-backend is handled by
xen_set_dynamic_sysbus(), so we only need to add amd-iommu and intel-iommu.Cc "Michael S. Tsirkin" <[email protected]>Cc Marcel Apfelbaum <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes series v1 -> v2:
* New patch added to series--- hw/i386/pc_q35.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 14 lines
hw/i386/pc_q35.c line 46
Quoted 10 lines
hw/i386/pc_q35.c +2
-0@@ -42,6 +42,8 @@#include "exec/address-spaces.h" #include "hw/i386/pc.h" #include "hw/i386/ich9.h" +#include "hw/i386/amd_iommu.h" +#include "hw/i386/intel_iommu.h" Is a pity we have to add the AMD/Intel header files only for the type, maybe we should have a header only with the type names, anyway out of the scope of this series.
Another option is to use the type name strings directly instead of the TYPE_* macros (which I never really liked). But I don't want to deviate from the current practice.
Quoted 5 lines
Another question, what about I440FX?
I think the AMD vIOMMU can theoretically work with the conventional PCI machines, I am not sure if it was tested or intended to work with it.
i440fx still has has_dynamic_sysbus=false. With this series, we can now add amd-iommu to its allowed list, if somebody is willing to support/test it.
Quoted 2 lines
Reviewed-by Marcel Apfelbaum <[email protected]>
Thanks!
Quoted 19 lines
Thanks,
MarcelQuoted 14 lines
hw/i386/pc_q35.c +2
-2#include "hw/smbios/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" @@ -299,8 +301,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; m->no_floppy =1 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (m,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_AMD_IOMMU_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_INTEL_IOMMU_DEVICE ); m->max_cpus =288 ; }
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices
In reply to Eduardo HabkostQuoted 16 lines · Eduardo Habkost
Quoted 11 lines · David Gibson
Quoted 8 lines · Eduardo Habkost
platform_bus_create_devtree()already rejects all dynamic sysbus devices exceptTYPE_ETSEC_COMMON, so register it as the only allowed dynamic sysbus device for the ppce500 machine-type.Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>Acked-by David Gibson <[email protected]>Thanks!
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Do you need me to take this through my tree (for 2.12), or do you have another merge patch in mind?
As this patch requires patch 1/6 to be applied first and there are patches touching other machines in this series, I can merge this through my machine core tree if you don't mind.
Sounds good, thanks.
Quoted 35 lines
Quoted 32 lines
Quoted 31 lines
---
Changes series v1 -> v2:
* New patch added to series--- hw/ppc/e500plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/ppc/e500plat.c +2
-2@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "e500.h" +#include "hw/net/fsl_etsec/etsec.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; -/*TODO: allow only sysbus devices that really work with this machine */ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_ETSEC_COMMON ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-arm] [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices
In reply to Eduardo HabkostHi
Quoted 11 lines · Eduardo Habkost
The existing
has_dynamic_sysbusflag makes the machine accept every user-creatable sysbus device type on the command-line. Replace it with a list of allowed device types, so machines can easily accept some sysbus devices while rejecting others.To keep exactly the same behavior as before, the existing has_dynamic_sysbus=true assignments are replaced with a
TYPE_SYS_BUS_DEVICEentry on the allowed list. Other patches will replace theTYPE_SYS_BUS_DEVICEentries with more specific lists of devices.
Quoted 11 lines
Cc Peter Maydell <[email protected]>Cc Marcel Apfelbaum <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Quoted 51 lines
---
Changes v1 -> v2:
* Replace "dynamic sysbus whitelist" with "allowed sysbus devices"
* Simply addTYPE_SYS_BUS_DEVICEto the list on existing has_dynamic_sysbus=true machines, and make machine-types more strict in separate patches--- include/hw/boards.h | 5 ++++- hw/arm/virt.c | 3 ++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 3 ++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 3 ++- hw/xen/xen_backend.c | 7 ++++++- 7 files changed, 48 insertions(+), 20 deletions(-)include/hw/boards.h +4
-1@@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine,const CpuInstanceProperties *props, Error **errp); +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type); + +/** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU @@ -179,7 +182,6 @@ struct MachineClass { no_floppy:1, no_cdrom:1, no_sdcard:1, - has_dynamic_sysbus:1, pci_allow_0_address:1, legacy_fw_cfg_order:1;int is_default;@@ -197,6 +199,7 @@ struct MachineClass {bool ignore_memory_transaction_failures;int numa_mem_align_shift;const char **valid_cpu_types; +strList *allowed_dynamic_sysbus_devices;bool auto_enable_numa_with_memhp;void (*numa_auto_assign_ram)(MachineClass *mc,NodeInfo *nodes,int nb_nodes,ram_addr_t size);hw/arm/virt.c +0
-0
hw/arm/virt.c static void virt_machine_class_init(ObjectClass *oc, void *data) · line 1594
Quoted 5 lines
hw/arm/virt.c +1
-1@@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)* configuration of the particular instance. */ mc->max_cpus =255 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */
cosmetic: why do you not leave a space between * and TODO ? (you did that repeatedly)
Quoted 139 lines
hw/arm/virt.c +1
-0+machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; mc->pci_allow_0_address = true;hw/core/machine.c +29
-14@@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp)return ms->enforce_config_section; } -static void error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) +void machine_class_allow_dynamic_sysbus_dev (MachineClass *mc,const char *type) { -error_report ("Option '-device %s' cannot be handled by this machine" , -object_class_get_name (object_get_class (OBJECT (sbdev)))); -exit (1 ); +strList *item =g_new0 (strList,1 ); + + item->value =g_strdup (type); + item->next = mc->allowed_dynamic_sysbus_devices; + mc->allowed_dynamic_sysbus_devices = item; } -static void machine_init_notify (Notifier *notifier,void *data) +static void validate_sysbus_device (SysBusDevice *sbdev,void *opaque) { -Object *machine =qdev_get_machine (); -ObjectClass *oc =object_get_class (machine); -MachineClass *mc =MACHINE_CLASS (oc); +MachineState *machine = opaque; +MachineClass *mc =MACHINE_GET_CLASS (machine); +bool allowed = false; +strList *wl; -if (mc->has_dynamic_sysbus) { -/* Our machine can handle dynamic sysbus devices, we're all good */ -return ; +for (wl = mc->allowed_dynamic_sysbus_devices; + !allowed && wl; + wl = wl->next) { + allowed |= !!object_dynamic_cast (OBJECT (sbdev), wl->value); } +if (!allowed) { +error_report ("Option '-device %s' cannot be handled by this machine" , +object_class_get_name (object_get_class (OBJECT (sbdev)))); +exit (1 ); + } +} + +static void machine_init_notify (Notifier *notifier,void *data) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +/* -* Loop through all dynamically created devices and check whether there -* are sysbus devices among them. If there are, error out. +* Loop through all dynamically created sysbus devices and check if they are +* all allowed. If a device is not allowed, error out. */ -foreach_dynamic_sysbus_device (error_on_sysbus_device,NULL ); +foreach_dynamic_sysbus_device (validate_sysbus_device, machine); }HotpluggableCPUList *machine_query_hotpluggable_cpus (MachineState *machine)hw/i386/pc_q35.c +2
-1@@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ; m->no_floppy =1 ; - m->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (m,TYPE_SYS_BUS_DEVICE ); m->max_cpus =288 ; }hw/ppc/e500plat.c +3
-1@@ -15,6 +15,7 @@#include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" +#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/ppc/openpic.h" #include "kvm_ppc.h" @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc ="generic paravirt e500 platform" ; mc->init = e500plat_init; mc->max_cpus =32 ; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("e500v2_v30" ); }hw/ppc/spapr.c +2
-1@@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="" ; mc->default_ram_size =512 *M_BYTE ; mc->kvm_type = spapr_kvm_type; - mc->has_dynamic_sysbus = true; +/*TODO: allow only sysbus devices that really work with this machine */ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;hw/xen/xen_backend.c +6
-2@@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void)ObjectClass *oc =object_get_class (machine);MachineClass *mc =MACHINE_CLASS (oc); - mc->has_dynamic_sysbus = true; +/* +* Emulate old mc->has_dynamic_sysbus=true assignment +* +*TODO: add only Xen devices to the list +*/ +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); }int xen_be_register (const char *type,struct XenDevOps *ops) --2.13.6
Signature · 6 lines
Marc-André Lureau _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices
On Tue, Nov 28, 2017 at 05:55:15PM +0100, Marc-André Lureau wrote:
[...]
Quoted 26 lines
Hi
Quoted 11 lines · Eduardo Habkost
The existing
has_dynamic_sysbusflag makes the machine accept every user-creatable sysbus device type on the command-line. Replace it with a list of allowed device types, so machines can easily accept some sysbus devices while rejecting others.To keep exactly the same behavior as before, the existing has_dynamic_sysbus=true assignments are replaced with a
TYPE_SYS_BUS_DEVICEentry on the allowed list. Other patches will replace theTYPE_SYS_BUS_DEVICEentries with more specific lists of devices.Quoted 11 lines
Cc Peter Maydell <[email protected]>Cc Marcel Apfelbaum <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Alexander Graf <[email protected]>Cc David Gibson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Quoted 1 line
Reviewed-by Marc-André Lureau <[email protected]>
Thanks!
[...]
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- mc->has_dynamic_sysbus = true; + /*TODO: allow only sysbus devices that really work with this machine */cosmetic: why do you not leave a space between * and TODO ? (you did that repeatedly)
Good question. :)
For reasons I can't explain, I thought "/*TODO:" was more common than "/* TODO:", but I was mistaken. I will change this to "/* TODO:" when committing the patches.
Signature · 6 lines
Eduardo _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list
In reply to Eduardo HabkostHi,
Quoted 20 lines · Eduardo Habkost
There's no need to make the machine allow every possible sysbus device. We can now just add xen-sysdev to the allowed list.
Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Cc Juergen Gross <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes series v1 -> v2:
* New patch added to series--- hw/xen/xen_backend.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)hw/xen/xen_backend.c +0
-0
hw/xen/xen_backend.c static void xen_set_dynamic_sysbus(void) · line 567
Quoted 10 lines
hw/xen/xen_backend.c +1
-6@@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void)ObjectClass *oc =object_get_class (machine);MachineClass *mc =MACHINE_CLASS (oc); -/* -* Emulate old mc->has_dynamic_sysbus=true assignment -* -*TODO: add only Xen devices to the list -*/ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_XENSYSDEV );
It looks like it's the last patch in the series without review. It would be nice if a Xen maintainer could look at it, or test it, as I dont know how to test it tbh.
Quoted 7 lines
hw/xen/xen_backend.c +0
-1}int xen_be_register (const char *type,struct XenDevOps *ops) --2.13.6
Signature · 6 lines
Marc-André Lureau _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi
Quoted 24 lines · Eduardo Habkost
Changes v1 (RFC) -> v2:
* Patch 1 now just addsTYPE_SYS_BUS_DEVICEto the existing has_dynamic_sysbus=true machines, and other patches make the lists on each machine-type more specific.
* Change the name of the new field toallowed_dynamic_sysbus_devices.
* The q35 allowed list is much shorter because the list of user-creatable sysbus devices in QEMU is shorter.
* Keep thexen_set_dynamic_sysbus()hack, just change it to add 'xen-sysdev" to the allowed list.
* Simplified the arm/virt code.Summary
-------This series replaces the existing
has_dynamic_sysbusflag (that makes the machine accept every user-creatable sysbus device type on the command-line) with a list of allowed devices.This will be helpful when implementing the new query-device-slots command, because each machine type will include only the sysbus devices it really supports, instead of including a catch-all
TYPE_SYS_BUS_DEVICE"slot".
Quoted 7 lines
This will be useful to add support to new sysbus devices on machines like
pc_piix, that don't havehas_dynamic_sysbusset today.This also makes the code safer: just compiling a new sysbus device in the same QEMU binary won't make a machine-type automatically start accepting the device.
Anything left for the series? (besides review of patch 5?) I need this to be solved for the pending TPM CRB device to work with piix. Thanks
Quoted 28 lines
Cc Marc-André Lureau <[email protected]>Cc Marcel Apfelbaum <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Stefan Berger <[email protected]>Cc Alexander Graf <[email protected]>Eduardo Habkost (6):
machine: Replacehas_dynamic_sysbuswith list of allowed devices hw/arm/virt: Allow only supported dynamic sysbus devices
ppc: e500: Allow only supported dynamic sysbus devices
spapr: Allow only supported dynamic sysbus devices
xen: Add only xen-sysdev to dynamic sysbus device list
q35: Allow only supported dynamic sysbus devicesinclude/hw/boards.h | 5 ++++- hw/arm/virt.c | 5 ++++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 5 ++++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 2 +- hw/xen/xen_backend.c | 2 +- 7 files changed, 46 insertions(+), 20 deletions(-)--
2.13.6
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list
In reply to Eduardo HabkostQuoted 8 lines · Eduardo Habkost
There's no need to make the machine allow every possible sysbus device. We can now just add xen-sysdev to the allowed list.
Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Cc Juergen Gross <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
I've tested the patch series with every hotplug things I could think of, and it worked fine.
Quoted 25 lines
---
Changes series v1 -> v2:
* New patch added to series--- hw/xen/xen_backend.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)hw/xen/xen_backend.c +1
-6@@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void)ObjectClass *oc =object_get_class (machine);MachineClass *mc =MACHINE_CLASS (oc); -/* -* Emulate old mc->has_dynamic_sysbus=true assignment -* -*TODO: add only Xen devices to the list -*/ -machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SYS_BUS_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_XENSYSDEV ); }int xen_be_register (const char *type,struct XenDevOps *ops)
Signature · 6 lines
Anthony PERARD _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Eduardo Habkost
AppliedQueued on machine-next.
Signature · 1 line
Eduardo