Remove VirtGuestInfo
v2 cover Remove VirtGuestInfo
v2:
- all Igor's suggestions
- added four mach-virt acpi cleanup patches
- added the remaining two acpi patches needed to bring equivalence to Peter's DT changes
This series is based on Peter's qemu-arm gicv3-virt branch. It's main goal (patches 07-13), which was suggested by Eduardo, is to remove an unnecessary structure, VirtGuestInfo, which is a maintenance burden, as it requires duplicating Virt machine state. Additionally patches 05-06 do some mach-virt cleanups and patches 14-16 add the ACPI equivalents of the DT patches in Peter's gicv3-virt branch. The first four patches are cleanups to mach-virt's acpi code.
Patches available here
https://github.com/rhdrjones/qemu/commits/virt/remove-guest-info-v2
Andrew Jones (16):
hw/arm/virt-acpi-build: add all missing cpu_to_le's hw/arm/virt-acpi-build: name GIC CPU Interface Structure appropriately hw/arm/virt-acpi-build: gtdt: improve flag naming hw/arm/virt-acpi-build: fadt: improve flag naming hw/arm/virt: parameter passing cleanups
hw/arm/virt: use VirtMachineState.gic_version
hw/arm/virt: eliminate struct VirtGuestInfoState hw/arm/virt: remove include/hw/arm/virt-acpi-build.h hw/arm/virt: move VirtMachineState/Class to virt.h hw/arm/virt: pass VirtMachineState instead of VirtGuestInfo hw/arm/virt-acpi-build: remove redundant members from VirtGuestInfo hw/arm/virt-acpi-build: don't save VirtGuestInfo on AcpiBuildState hw/arm/virt: remove VirtGuestInfo
hw/arm/virt-acpi-build: Don't incorrectly claim architectural timer to
be edge-triggered
hw/arm/virt-acpi-build: use SMC if booting in EL2 hw/arm/virt-acpi-build: madt: add vgic maint irq
MAINTAINERS | 2 - hw/arm/virt-acpi-build.c | 145 +++++++++++++++++++++------------------ hw/arm/virt.c | 141 +++++++++++++------------------------ include/hw/acpi/acpi-defs.h | 33 +++------ include/hw/arm/virt-acpi-build.h | 47 ------------- include/hw/arm/virt.h | 43 +++++++++++- 6 files changed, 178 insertions(+), 233 deletions(-) delete mode 100644 include/hw/arm/virt-acpi-build.h
Signature · 1 line
2.9.3
PATCH v2 1/16 hw/arm/virt-acpi-build: add all missing cpu_to_le's
--- hw/arm/virt-acpi-build.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
hw/arm/virt-acpi-build.c +14 -13
@@ -542,17 +542,18 @@ build_gtdt(GArray *table_data, BIOSLinker *linker) gtdt =acpi_data_push (table_data,sizeof *gtdt);/* The interrupt values are the same with the device tree when adding 16 */ - gtdt->secure_el1_interrupt =ARCH_TIMER_S_EL1_IRQ +16 ; - gtdt->secure_el1_flags =ACPI_EDGE_SENSITIVE ; + gtdt->secure_el1_interrupt =cpu_to_le32 (ARCH_TIMER_S_EL1_IRQ +16 ); + gtdt->secure_el1_flags =cpu_to_le32 (ACPI_EDGE_SENSITIVE ); - gtdt->non_secure_el1_interrupt =ARCH_TIMER_NS_EL1_IRQ +16 ; - gtdt->non_secure_el1_flags =ACPI_EDGE_SENSITIVE |ACPI_GTDT_ALWAYS_ON ; + gtdt->non_secure_el1_interrupt =cpu_to_le32 (ARCH_TIMER_NS_EL1_IRQ +16 ); + gtdt->non_secure_el1_flags =cpu_to_le32 (ACPI_EDGE_SENSITIVE | +ACPI_GTDT_ALWAYS_ON ); - gtdt->virtual_timer_interrupt =ARCH_TIMER_VIRT_IRQ +16 ; - gtdt->virtual_timer_flags =ACPI_EDGE_SENSITIVE ; + gtdt->virtual_timer_interrupt =cpu_to_le32 (ARCH_TIMER_VIRT_IRQ +16 ); + gtdt->virtual_timer_flags =cpu_to_le32 (ACPI_EDGE_SENSITIVE ); - gtdt->non_secure_el2_interrupt =ARCH_TIMER_NS_EL2_IRQ +16 ; - gtdt->non_secure_el2_flags =ACPI_EDGE_SENSITIVE ; + gtdt->non_secure_el2_interrupt =cpu_to_le32 (ARCH_TIMER_NS_EL2_IRQ +16 ); + gtdt->non_secure_el2_flags =cpu_to_le32 (ACPI_EDGE_SENSITIVE ); build_header(linker, table_data, (void *)(table_data->data + gtdt_start), "GTDT",
@@ -576,7 +577,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicd =acpi_data_push (table_data,sizeof *gicd); gicd->type =ACPI_APIC_GENERIC_DISTRIBUTOR ; gicd->length =sizeof (*gicd); - gicd->base_address = memmap[VIRT_GIC_DIST ].base; + gicd->base_address =cpu_to_le64 (memmap[VIRT_GIC_DIST ].base); gicd->version = guest_info->gic_version;for (i =0 ; i < guest_info->smp_cpus; i++) {
@@ -587,11 +588,11 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicc->type =ACPI_APIC_GENERIC_INTERRUPT ; gicc->length =sizeof (*gicc);if (guest_info->gic_version ==2 ) { - gicc->base_address = memmap[VIRT_GIC_CPU ].base; + gicc->base_address =cpu_to_le64 (memmap[VIRT_GIC_CPU ].base); } - gicc->cpu_interface_number = i; - gicc->arm_mpidr = armcpu->mp_affinity; - gicc->uid = i; + gicc->cpu_interface_number =cpu_to_le32 (i); + gicc->arm_mpidr =cpu_to_le64 (armcpu->mp_affinity); + gicc->uid =cpu_to_le32 (i); gicc->flags =cpu_to_le32 (ACPI_GICC_ENABLED );if (arm_feature (&armcpu->env,ARM_FEATURE_PMU )) {
Signature · 1 line
2.9.3
PATCH v2 2/16 hw/arm/virt-acpi-build: name GIC CPU Interface Structure appropriately
In reply to Andrew JonesAlso move the enabled flag definition from mach-virt code to acpi common.
--- hw/arm/virt-acpi-build.c | 8 ++++---- include/hw/acpi/acpi-defs.h | 9 ++++++--- include/hw/arm/virt-acpi-build.h | 2 -- 3 files changed, 10 insertions(+), 9 deletions(-)
hw/arm/virt-acpi-build.c +4 -4
@@ -581,11 +581,11 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicd->version = guest_info->gic_version;for (i =0 ; i < guest_info->smp_cpus; i++) { -AcpiMadtGenericInterrupt *gicc =acpi_data_push (table_data, -sizeof *gicc); +AcpiMadtGenericCpuInterface *gicc =acpi_data_push (table_data, +sizeof (*gicc));ARMCPU *armcpu =ARM_CPU (qemu_get_cpu (i)); - gicc->type =ACPI_APIC_GENERIC_INTERRUPT ; + gicc->type =ACPI_APIC_GENERIC_CPU_INTERFACE ; gicc->length =sizeof (*gicc);if (guest_info->gic_version ==2 ) { gicc->base_address =cpu_to_le64 (memmap[VIRT_GIC_CPU ].base);
@@ -593,7 +593,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicc->cpu_interface_number =cpu_to_le32 (i); gicc->arm_mpidr =cpu_to_le64 (armcpu->mp_affinity); gicc->uid =cpu_to_le32 (i); - gicc->flags =cpu_to_le32 (ACPI_GICC_ENABLED ); + gicc->flags =cpu_to_le32 (ACPI_MADT_GICC_ENABLED );if (arm_feature (&armcpu->env,ARM_FEATURE_PMU )) { gicc->performance_interrupt =cpu_to_le32 (PPI (VIRTUAL_PMU_IRQ ));
include/hw/acpi/acpi-defs.h +6 -3
@@ -290,7 +290,7 @@ typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;#define ACPI_APIC_XRUPT_SOURCE 8#define ACPI_APIC_LOCAL_X2APIC 9#define ACPI_APIC_LOCAL_X2APIC_NMI 10 -#define ACPI_APIC_GENERIC_INTERRUPT 11 +#define ACPI_APIC_GENERIC_CPU_INTERFACE 11#define ACPI_APIC_GENERIC_DISTRIBUTOR 12#define ACPI_APIC_GENERIC_MSI_FRAME 13#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14
@@ -361,7 +361,7 @@ struct AcpiMadtLocalX2ApicNmi { }QEMU_PACKED ;typedef struct AcpiMadtLocalX2ApicNmi AcpiMadtLocalX2ApicNmi ; -struct AcpiMadtGenericInterrupt { +struct AcpiMadtGenericCpuInterface {ACPI_SUB_HEADER_DEF uint16_t reserved;uint32_t cpu_interface_number;
@@ -378,7 +378,10 @@ struct AcpiMadtGenericInterrupt {uint64_t arm_mpidr; }QEMU_PACKED ; -typedef struct AcpiMadtGenericInterrupt AcpiMadtGenericInterrupt ; +typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface ; + +/* GICC CPU Interface Flags */ +#define ACPI_MADT_GICC_ENABLED 1struct AcpiMadtGenericDistributor {ACPI_SUB_HEADER_DEF
include/hw/arm/virt-acpi-build.h +0 -2
@@ -24,8 +24,6 @@#include "hw/arm/virt.h" #include "qemu/notify.h" -#define ACPI_GICC_ENABLED 1 - typedef struct VirtGuestInfo { int smp_cpus; FWCfgState *fw_cfg;
Signature · 1 line
2.9.3
PATCH v2 3/16 hw/arm/virt-acpi-build: gtdt: improve flag naming
In reply to Andrew JonesAlso remove all unused flags.
--- hw/arm/virt-acpi-build.c | 10 +++++----- include/hw/acpi/acpi-defs.h | 17 ++--------------- 2 files changed, 7 insertions(+), 20 deletions(-)
hw/arm/virt-acpi-build.c +5 -5
@@ -543,17 +543,17 @@ build_gtdt(GArray *table_data, BIOSLinker *linker) gtdt =acpi_data_push (table_data,sizeof *gtdt);/* The interrupt values are the same with the device tree when adding 16 */ gtdt->secure_el1_interrupt =cpu_to_le32 (ARCH_TIMER_S_EL1_IRQ +16 ); - gtdt->secure_el1_flags =cpu_to_le32 (ACPI_EDGE_SENSITIVE ); + gtdt->secure_el1_flags =cpu_to_le32 (ACPI_GTDT_INTERRUPT_MODE_EDGE ); gtdt->non_secure_el1_interrupt =cpu_to_le32 (ARCH_TIMER_NS_EL1_IRQ +16 ); - gtdt->non_secure_el1_flags =cpu_to_le32 (ACPI_EDGE_SENSITIVE | -ACPI_GTDT_ALWAYS_ON ); + gtdt->non_secure_el1_flags =cpu_to_le32 (ACPI_GTDT_INTERRUPT_MODE_EDGE | +ACPI_GTDT_CAP_ALWAYS_ON ); gtdt->virtual_timer_interrupt =cpu_to_le32 (ARCH_TIMER_VIRT_IRQ +16 ); - gtdt->virtual_timer_flags =cpu_to_le32 (ACPI_EDGE_SENSITIVE ); + gtdt->virtual_timer_flags =cpu_to_le32 (ACPI_GTDT_INTERRUPT_MODE_EDGE ); gtdt->non_secure_el2_interrupt =cpu_to_le32 (ARCH_TIMER_NS_EL2_IRQ +16 ); - gtdt->non_secure_el2_flags =cpu_to_le32 (ACPI_EDGE_SENSITIVE ); + gtdt->non_secure_el2_flags =cpu_to_le32 (ACPI_GTDT_INTERRUPT_MODE_EDGE ); build_header(linker, table_data, (void *)(table_data->data + gtdt_start), "GTDT",
include/hw/acpi/acpi-defs.h +2 -15
@@ -430,21 +430,8 @@ typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator;/* * Generic Timer Description Table (GTDT) */ - -#define ACPI_GTDT_INTERRUPT_MODE (1 << 0) -#define ACPI_GTDT_INTERRUPT_POLARITY (1 << 1) -#define ACPI_GTDT_ALWAYS_ON (1 << 2) - -/* Triggering */ - -#define ACPI_LEVEL_SENSITIVE ((uint8_t) 0x00) -#define ACPI_EDGE_SENSITIVE ((uint8_t) 0x01) - -/* Polarity */ - -#define ACPI_ACTIVE_HIGH ((uint8_t) 0x00) -#define ACPI_ACTIVE_LOW ((uint8_t) 0x01) -#define ACPI_ACTIVE_BOTH ((uint8_t) 0x02) +#define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0) +#define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2)struct AcpiGenericTimerTable {ACPI_TABLE_HEADER_DEF
Signature · 1 line
2.9.3
PATCH v2 4/16 hw/arm/virt-acpi-build: fadt: improve flag naming
In reply to Andrew Jones--- hw/arm/virt-acpi-build.c | 4 ++-- include/hw/acpi/acpi-defs.h | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-)
hw/arm/virt-acpi-build.c +2 -2
@@ -642,8 +642,8 @@ build_fadt(GArray *table_data, BIOSLinker *linker, unsigned dsdt_tbl_offset)/* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */ fadt->flags =cpu_to_le32 (1 <<ACPI_FADT_F_HW_REDUCED_ACPI ); - fadt->arm_boot_flags =cpu_to_le16 ((1 <<ACPI_FADT_ARM_USE_PSCI_G_0_2 ) | - (1 <<ACPI_FADT_ARM_PSCI_USE_HVC )); + fadt->arm_boot_flags =cpu_to_le16 (ACPI_FADT_ARM_PSCI_COMPLIANT | +ACPI_FADT_ARM_PSCI_USE_HVC );/* ACPI v5.1 (fadt->revision.fadt->minor_revision) */ fadt->minor_revision =0x1 ;
include/hw/acpi/acpi-defs.h +2 -4
@@ -191,10 +191,8 @@ struct AcpiFadtDescriptorRev5_1 {typedef struct AcpiFadtDescriptorRev5_1 AcpiFadtDescriptorRev5_1 ; -enum { -ACPI_FADT_ARM_USE_PSCI_G_0_2 =0 , -ACPI_FADT_ARM_PSCI_USE_HVC =1 , -}; +#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) +#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1)/* * Serial Port Console Redirection Table (SPCR), Rev. 1.02
Signature · 1 line
2.9.3
PATCH v2 5/16 hw/arm/virt: parameter passing cleanups
In reply to Andrew JonesSome simple cleanups made possible by "hw/arm/virt: Merge VirtBoardInfo and VirtMachineState"
--- hw/arm/virt.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
hw/arm/virt.c +9 -10
@@ -570,10 +570,10 @@ static void create_v2m(VirtMachineState *vms, qemu_irq *pic)fdt_add_v2m_gic_node (vms); } -static void create_gic (VirtMachineState *vms,qemu_irq *pic,int type, -bool secure,bool no_its) +static void create_gic (VirtMachineState *vms,qemu_irq *pic,int type) {/* We create a standalone GIC */ +VirtMachineClass *vmc =VIRT_MACHINE_GET_CLASS (vms);DeviceState *gicdev;SysBusDevice *gicbusdev;const char *gictype;
@@ -589,7 +589,7 @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic, int type,*/ qdev_prop_set_uint32 (gicdev,"num-irq" ,NUM_IRQS +32 );if (!kvm_irqchip_in_kernel ()) { -qdev_prop_set_bit (gicdev,"has-security-extensions" , secure); +qdev_prop_set_bit (gicdev,"has-security-extensions" , vms->secure); }qdev_init_nofail (gicdev); gicbusdev =SYS_BUS_DEVICE (gicdev);
@@ -643,7 +643,7 @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic, int type,fdt_add_gic_node (vms, type); -if (type ==3 && !no_its) { +if (type ==3 && !vmc->no_its) {create_its (vms, gicdev); }else if (type ==2 ) {create_v2m (vms, pic);
@@ -1005,8 +1005,7 @@ static void create_pcie_irq_map(const VirtMachineState *vms, 0x7 /* PCI irq */); } -static void create_pcie (const VirtMachineState *vms,qemu_irq *pic, -bool use_highmem) +static void create_pcie (const VirtMachineState *vms,qemu_irq *pic) {hwaddr base_mmio = vms->memmap[VIRT_PCIE_MMIO ].base;hwaddr size_mmio = vms->memmap[VIRT_PCIE_MMIO ].size;
@@ -1049,7 +1048,7 @@ static void create_pcie(const VirtMachineState *vms, qemu_irq *pic, mmio_reg, base_mmio, size_mmio);memory_region_add_subregion (get_system_memory (), base_mmio, mmio_alias); -if (use_highmem) { +if (vms->highmem) {/* Map high MMIO space */ MemoryRegion *high_mmio_alias =g_new0 (MemoryRegion,1 );
@@ -1098,7 +1097,7 @@ static void create_pcie(const VirtMachineState *vms, qemu_irq *pic,qemu_fdt_setprop_sized_cells (vms->fdt, nodename,"reg" ,2 , base_ecam,2 , size_ecam); -if (use_highmem) { +if (vms->highmem) { qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "ranges", 1, FDT_PCI_RANGE_IOPORT, 2, 0, 2, base_pio, 2, size_pio,
@@ -1428,7 +1427,7 @@ static void machvirt_init(MachineState *machine)create_flash (vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); -create_gic (vms, pic, gic_version, vms->secure, vmc->no_its); +create_gic (vms, pic, gic_version);fdt_add_pmu_nodes (vms, gic_version);
@@ -1441,7 +1440,7 @@ static void machvirt_init(MachineState *machine)create_rtc (vms, pic); -create_pcie (vms, pic, vms->highmem); +create_pcie (vms, pic);create_gpio (vms, pic);
Signature · 1 line
2.9.3
PATCH v2 6/16 hw/arm/virt: use VirtMachineState.gic_version
In reply to Andrew Jonesmachvirt_init may need to probe for the gic version. If so, then make sure the result is written to VirtMachineState. With the state up to date, use it instead of a local variable. This is a cleanup that prepares for VirtMachineState to be passed to functions even outside hw/arm/virt.c
--- hw/arm/virt.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
hw/arm/virt.c +17 -18
@@ -319,7 +319,7 @@ static void fdt_add_psci_node(const VirtMachineState *vms)qemu_fdt_setprop_cell (fdt,"/psci" ,"migrate" , migrate_fn); } -static void fdt_add_timer_nodes (const VirtMachineState *vms,int gictype) +static void fdt_add_timer_nodes (const VirtMachineState *vms) {/* On real hardware these interrupts are level-triggered. * On KVM they were edge-triggered before host kernel version 4.4,
@@ -347,7 +347,7 @@ static void fdt_add_timer_nodes(const VirtMachineState *vms, int gictype) irqflags =GIC_FDT_IRQ_FLAGS_EDGE_LO_HI ; } -if (gictype ==2 ) { +if (vms->gic_version ==2 ) { irqflags =deposit32 (irqflags,GIC_FDT_IRQ_PPI_CPU_START ,GIC_FDT_IRQ_PPI_CPU_WIDTH , (1 << vms->smp_cpus) -1 );
@@ -462,7 +462,7 @@ static void fdt_add_v2m_gic_node(VirtMachineState *vms)qemu_fdt_setprop_cell (vms->fdt,"/intc/v2m" ,"phandle" , vms->msi_phandle); } -static void fdt_add_gic_node (VirtMachineState *vms,int type) +static void fdt_add_gic_node (VirtMachineState *vms) { vms->gic_phandle =qemu_fdt_alloc_phandle (vms->fdt);qemu_fdt_setprop_cell (vms->fdt,"/" ,"interrupt-parent" , vms->gic_phandle);
@@ -473,7 +473,7 @@ static void fdt_add_gic_node(VirtMachineState *vms, int type)qemu_fdt_setprop_cell (vms->fdt,"/intc" ,"#address-cells" ,0x2 );qemu_fdt_setprop_cell (vms->fdt,"/intc" ,"#size-cells" ,0x2 );qemu_fdt_setprop (vms->fdt,"/intc" ,"ranges" ,NULL ,0 ); -if (type ==3 ) { +if (vms->gic_version ==3 ) {qemu_fdt_setprop_string (vms->fdt,"/intc" ,"compatible" ,"arm,gic-v3" ); qemu_fdt_setprop_sized_cells(vms->fdt, "/intc", "reg",
@@ -500,7 +500,7 @@ static void fdt_add_gic_node(VirtMachineState *vms, int type)qemu_fdt_setprop_cell (vms->fdt,"/intc" ,"phandle" , vms->gic_phandle); } -static void fdt_add_pmu_nodes (const VirtMachineState *vms,int gictype) +static void fdt_add_pmu_nodes (const VirtMachineState *vms) {CPUState *cpu;ARMCPU *armcpu;
@@ -514,7 +514,7 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms, int gictype) } } -if (gictype ==2 ) { +if (vms->gic_version ==2 ) { irqflags =deposit32 (irqflags,GIC_FDT_IRQ_PPI_CPU_START ,GIC_FDT_IRQ_PPI_CPU_WIDTH , (1 << vms->smp_cpus) -1 );
@@ -570,14 +570,14 @@ static void create_v2m(VirtMachineState *vms, qemu_irq *pic)fdt_add_v2m_gic_node (vms); } -static void create_gic (VirtMachineState *vms,qemu_irq *pic,int type) +static void create_gic (VirtMachineState *vms,qemu_irq *pic) {/* We create a standalone GIC */ VirtMachineClass *vmc =VIRT_MACHINE_GET_CLASS (vms);DeviceState *gicdev;SysBusDevice *gicbusdev;const char *gictype; -int i; +int type = vms->gic_version, i; gictype = (type ==3 ) ?gicv3_class_name () :gic_class_name ();
@@ -641,7 +641,7 @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic, int type) pic[i] =qdev_get_gpio_in (gicdev, i); } -fdt_add_gic_node (vms, type); +fdt_add_gic_node (vms);if (type ==3 && !vmc->no_its) {create_its (vms, gicdev);
@@ -1237,7 +1237,6 @@ static void machvirt_init(MachineState *machine)qemu_irq pic[NUM_IRQS ];MemoryRegion *sysmem =get_system_memory ();MemoryRegion *secure_sysmem =NULL ; -int gic_version = vms->gic_version;int n, virt_max_cpus;MemoryRegion *ram =g_new (MemoryRegion,1 );const char *cpu_model = machine->cpu_model;
@@ -1258,14 +1257,14 @@ static void machvirt_init(MachineState *machine)/* We can probe only here because during property set * KVM is not available yet */ -if (!gic_version) { +if (!vms->gic_version) {if (!kvm_enabled ()) {error_report ("gic-version=host requires KVM" );exit (1 ); } - gic_version =kvm_arm_vgic_probe (); -if (!gic_version) { + vms->gic_version =kvm_arm_vgic_probe (); +if (!vms->gic_version) {error_report ("Unable to determine GIC version supported by host" );exit (1 ); }
@@ -1300,7 +1299,7 @@ static void machvirt_init(MachineState *machine)/* The maximum number of CPUs depends on the GIC version, or on how * many redistributors we can fit into the memory map. */ -if (gic_version ==3 ) { +if (vms->gic_version ==3 ) { virt_max_cpus = vms->memmap[VIRT_GIC_REDIST ].size /0x20000 ; clustersz =GICV3_TARGETLIST_BITS ; }else {
@@ -1417,7 +1416,7 @@ static void machvirt_init(MachineState *machine)object_property_set_bool (cpuobj, true,"realized" ,NULL ); } -fdt_add_timer_nodes (vms, gic_version); +fdt_add_timer_nodes (vms);fdt_add_cpu_nodes (vms);fdt_add_psci_node (vms);
@@ -1427,9 +1426,9 @@ static void machvirt_init(MachineState *machine)create_flash (vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); -create_gic (vms, pic, gic_version); +create_gic (vms, pic); -fdt_add_pmu_nodes (vms, gic_version); +fdt_add_pmu_nodes (vms);create_uart (vms, pic,VIRT_UART , sysmem, serial_hds[0 ]);
@@ -1458,7 +1457,7 @@ static void machvirt_init(MachineState *machine) guest_info->memmap = vms->memmap; guest_info->irqmap = vms->irqmap; guest_info->use_highmem = vms->highmem; - guest_info->gic_version = gic_version; + guest_info->gic_version = vms->gic_version; guest_info->no_its = vmc->no_its; guest_info_state->machine_done.notify = virt_guest_info_machine_done;qemu_add_machine_init_done_notifier (&guest_info_state->machine_done);
Signature · 1 line
2.9.3
PATCH v2 7/16 hw/arm/virt: eliminate struct VirtGuestInfoState
In reply to Andrew JonesInstead of allocating a new struct just for VirtGuestInfo and the machine_done Notifier, place them inside VirtMachineState. This is the mach-virt equivalent of "pc: Eliminate struct PcGuestInfoState"
--- hw/arm/virt.c | 20 +++++++++++--------- include/hw/arm/virt-acpi-build.h | 6 ------ 2 files changed, 11 insertions(+), 15 deletions(-)
hw/arm/virt.c +11 -9
@@ -76,6 +76,8 @@ typedef struct { typedef struct { MachineState parent; + VirtGuestInfo acpi_guest_info; + Notifier machine_done; bool secure; bool highmem; bool virt;
@@ -1222,12 +1224,13 @@ static void virt_build_smbios(VirtGuestInfo *guest_info) }static -void virt_guest_info_machine_done (Notifier *notifier,void *data) +void virt_machine_done (Notifier *notifier,void *data) { -VirtGuestInfoState *guest_info_state =container_of (notifier, - VirtGuestInfoState, machine_done); -virt_acpi_setup (&guest_info_state->info); -virt_build_smbios (&guest_info_state->info); +VirtMachineState *vms =container_of (notifier, VirtMachineState, + machine_done); + +virt_acpi_setup (&vms->acpi_guest_info); +virt_build_smbios (&vms->acpi_guest_info); }static void machvirt_init (MachineState *machine)
@@ -1240,8 +1243,7 @@ static void machvirt_init(MachineState *machine)int n, virt_max_cpus;MemoryRegion *ram =g_new (MemoryRegion,1 );const char *cpu_model = machine->cpu_model; -VirtGuestInfoState *guest_info_state =g_malloc0 (sizeof *guest_info_state); -VirtGuestInfo *guest_info = &guest_info_state->info; +VirtGuestInfo *guest_info = &vms->acpi_guest_info;char **cpustr;ObjectClass *oc;const char *typename;
@@ -1459,8 +1461,8 @@ static void machvirt_init(MachineState *machine) guest_info->use_highmem = vms->highmem; guest_info->gic_version = vms->gic_version; guest_info->no_its = vmc->no_its; - guest_info_state->machine_done.notify = virt_guest_info_machine_done; -qemu_add_machine_init_done_notifier (&guest_info_state->machine_done); + vms->machine_done.notify = virt_machine_done; +qemu_add_machine_init_done_notifier (&vms->machine_done); vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.kernel_filename = machine->kernel_filename;
include/hw/arm/virt-acpi-build.h +0 -6
@@ -34,12 +34,6 @@ typedef struct VirtGuestInfo { bool no_its; } VirtGuestInfo; - -typedef struct VirtGuestInfoState { -VirtGuestInfo info; -Notifier machine_done; -}VirtGuestInfoState ; -void virt_acpi_setup (VirtGuestInfo *guest_info);#endif
Signature · 1 line
2.9.3
PATCH v2 8/16 hw/arm/virt: remove include/hw/arm/virt-acpi-build.h
In reply to Andrew Jonesinclude/hw/arm/virt-acpi-build.h is only used for VirtGuestInfo, which doesn't even necessarily have to be ACPI specific. Move VirtGuestInfo to include/hw/arm/virt.h, allowing us to remove include/hw/arm/virt-acpi-build.h, and to prepare for even more code motion.
--- MAINTAINERS | 2 -- hw/arm/virt-acpi-build.c | 2 +- hw/arm/virt.c | 1 - include/hw/arm/virt-acpi-build.h | 39 --------------------------------------- include/hw/arm/virt.h | 14 +++++++++++++- 5 files changed, 14 insertions(+), 44 deletions(-) delete mode 100644 include/hw/arm/virt-acpi-build.h
MAINTAINERS +0 -2
@@ -508,7 +508,6 @@ M: Shannon Zhao <[email protected]> L: [email protected] S: Maintained F: hw/arm/virt-acpi-build.c -F: include/hw/arm/virt-acpi-build.h STM32F205 M: Alistair Francis <[email protected]>
@@ -885,7 +884,6 @@ F: hw/acpi/* F: hw/smbios/* F: hw/i386/acpi-build.[hc] F: hw/arm/virt-acpi-build.c -F: include/hw/arm/virt-acpi-build.h ppc4xx M: Alexander Graf <[email protected]>
hw/arm/virt-acpi-build.c +1 -1
@@ -29,7 +29,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" -#include "hw/arm/virt-acpi-build.h" #include "qemu/bitmap.h" #include "trace.h" #include "qom/cpu.h"
@@ -43,6 +42,7 @@#include "hw/acpi/aml-build.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" +#include "hw/arm/virt.h" #include "sysemu/numa.h" #include "kvm_arm.h"
hw/arm/virt.c +0 -1
@@ -48,7 +48,6 @@#include "qemu/bitops.h" #include "qemu/error-report.h" #include "hw/pci-host/gpex.h" -#include "hw/arm/virt-acpi-build.h" #include "hw/arm/sysbus-fdt.h" #include "hw/platform-bus.h" #include "hw/arm/fdt.h"
include/hw/arm/virt-acpi-build.h deleted +0 -39
@@ -1,39 +0,0 @@ -/* -* -* Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. -* -* Author: Shannon Zhao <[email protected]> -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2 or later, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef QEMU_VIRT_ACPI_BUILD_H -#define QEMU_VIRT_ACPI_BUILD_H - -#include "qemu-common.h" -#include "hw/arm/virt.h" -#include "qemu/notify.h" - -typedef struct VirtGuestInfo { -int smp_cpus; -FWCfgState *fw_cfg; -const MemMapEntry *memmap; -const int *irqmap; -bool use_highmem; -int gic_version; -bool no_its; -}VirtGuestInfo ; - -void virt_acpi_setup (VirtGuestInfo *guest_info); - -#endif
include/hw/arm/virt.h +13 -1
@@ -32,6 +32,7 @@#include "qemu-common.h" #include "exec/hwaddr.h" +#include "qemu/notify.h" #define NUM_GICV2M_SPIS 64#define NUM_VIRTIO_TRANSPORTS 32
@@ -76,5 +77,16 @@ typedef struct MemMapEntry { hwaddr size; } MemMapEntry; +typedef struct VirtGuestInfo { +int smp_cpus; +FWCfgState *fw_cfg; +const MemMapEntry *memmap; +const int *irqmap; +bool use_highmem; +int gic_version; +bool no_its; +}VirtGuestInfo ; -#endif +void virt_acpi_setup (VirtGuestInfo *guest_info); + +#endif /* QEMU_ARM_VIRT_H */
Signature · 1 line
2.9.3
PATCH v2 9/16 hw/arm/virt: move VirtMachineState/Class to virt.h
In reply to Andrew JonesIn preparation to share more Virt machine state than just guest-info with other mach-virt source files, move the State and Class structures to virt.h
--- hw/arm/virt.c | 52 +++++++-------------------------------------------- include/hw/arm/virt.h | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 45 deletions(-)
hw/arm/virt.c +7 -45
@@ -41,7 +41,6 @@#include "sysemu/numa.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" -#include "hw/boards.h" #include "hw/compat.h" #include "hw/loader.h" #include "exec/address-spaces.h"
@@ -58,50 +57,6 @@#include "qapi/visitor.h" #include "standard-headers/linux/input.h" -/* Number of external interrupt lines to configure the GIC with */ -#define NUM_IRQS 256 - -#define PLATFORM_BUS_NUM_IRQS 64 - -static ARMPlatformBusSystemParams platform_bus_params; - -typedef struct { -MachineClass parent; -bool disallow_affinity_adjustment; -bool no_its; -bool no_pmu; -bool claim_edge_triggered_timers; -}VirtMachineClass ; - -typedef struct { -MachineState parent; -VirtGuestInfo acpi_guest_info; -Notifier machine_done; -bool secure; -bool highmem; -bool virt; -int32_t gic_version; -struct arm_boot_info bootinfo; -const MemMapEntry *memmap; -const int *irqmap; -int smp_cpus; -void *fdt; -int fdt_size; -uint32_t clock_phandle; -uint32_t gic_phandle; -uint32_t msi_phandle; -int psci_conduit; -}VirtMachineState ; - -#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") -#define VIRT_MACHINE (obj) \ - OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE) -#define VIRT_MACHINE_GET_CLASS (obj) \ - OBJECT_GET_CLASS(VirtMachineClass, obj, TYPE_VIRT_MACHINE) -#define VIRT_MACHINE_CLASS (klass) \ - OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) - -#define DEFINE_VIRT_MACHINE_LATEST (major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ void *data) \
@@ -131,6 +86,13 @@ typedef struct {DEFINE_VIRT_MACHINE_LATEST (major, minor, false) +/* Number of external interrupt lines to configure the GIC with */ +#define NUM_IRQS 256 + +#define PLATFORM_BUS_NUM_IRQS 64 + +static ARMPlatformBusSystemParams platform_bus_params; +/* RAM limit in GB. Since VIRT_MEM starts at the 1GB mark, this means * RAM can go up to the 256GB mark, leaving 256GB of the physical * address space unallocated and free for future use between 256G and 512G.
include/hw/arm/virt.h +39 -0
@@ -33,6 +33,8 @@#include "qemu-common.h" #include "exec/hwaddr.h" #include "qemu/notify.h" +#include "hw/boards.h" +#include "hw/arm/arm.h" #define NUM_GICV2M_SPIS 64#define NUM_VIRTIO_TRANSPORTS 32
@@ -87,6 +89,43 @@ typedef struct VirtGuestInfo { bool no_its; } VirtGuestInfo; +typedef struct { +MachineClass parent; +bool disallow_affinity_adjustment; +bool no_its; +bool no_pmu; +bool claim_edge_triggered_timers; +}VirtMachineClass ; + +typedef struct { +MachineState parent; +VirtGuestInfo acpi_guest_info; +Notifier machine_done; +bool secure; +bool highmem; +bool virt; +int32_t gic_version; +struct arm_boot_info bootinfo; +const MemMapEntry *memmap; +const int *irqmap; +int smp_cpus; +void *fdt; +int fdt_size; +uint32_t clock_phandle; +uint32_t gic_phandle; +uint32_t msi_phandle; +int psci_conduit; +}VirtMachineState ; + +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +#define VIRT_MACHINE (obj) \ + OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE) +#define VIRT_MACHINE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(VirtMachineClass, obj, TYPE_VIRT_MACHINE) +#define VIRT_MACHINE_CLASS (klass) \ + OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) + +void virt_acpi_setup (VirtGuestInfo *guest_info);#endif /* QEMU_ARM_VIRT_H */
Signature · 1 line
2.9.3
PATCH v2 10/16 hw/arm/virt: pass VirtMachineState instead of VirtGuestInfo
In reply to Andrew JonesOnly two functions take VirtGuestInfo parameters. Now that guest-info is part of VirtMachineState, and VirtMachineState is defined in the virt header, pass that instead.
--- hw/arm/virt-acpi-build.c | 3 ++- hw/arm/virt.c | 8 ++++---- include/hw/arm/virt.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-)
hw/arm/virt-acpi-build.c +2 -1
@@ -823,8 +823,9 @@ static const VMStateDescription vmstate_virt_acpi_build = { }, }; -void virt_acpi_setup (VirtGuestInfo *guest_info) +void virt_acpi_setup (VirtMachineState *vms) { +VirtGuestInfo *guest_info = &vms->acpi_guest_info;AcpiBuildTables tables;AcpiBuildState *build_state;
hw/arm/virt.c +4 -4
@@ -1155,9 +1155,9 @@ static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)return board->fdt; } -static void virt_build_smbios (VirtGuestInfo *guest_info) +static void virt_build_smbios (VirtMachineState *vms) { -FWCfgState *fw_cfg = guest_info->fw_cfg; +FWCfgState *fw_cfg = vms->acpi_guest_info.fw_cfg;uint8_t *smbios_tables, *smbios_anchor;size_t smbios_tables_len, smbios_anchor_len;const char *product ="QEMU Virtual Machine" ;
@@ -1190,8 +1190,8 @@ void virt_machine_done(Notifier *notifier, void *data)VirtMachineState *vms =container_of (notifier, VirtMachineState, machine_done); -virt_acpi_setup (&vms->acpi_guest_info); -virt_build_smbios (&vms->acpi_guest_info); +virt_acpi_setup (vms); +virt_build_smbios (vms); }static void machvirt_init (MachineState *machine)
include/hw/arm/virt.h +1 -1
@@ -126,6 +126,6 @@ typedef struct { OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) -void virt_acpi_setup (VirtGuestInfo *guest_info); +void virt_acpi_setup (VirtMachineState *vms);#endif /* QEMU_ARM_VIRT_H */
Signature · 1 line
2.9.3
PATCH v2 11/16 hw/arm/virt-acpi-build: remove redundant members from VirtGuestInfo
In reply to Andrew JonesNow that we pass VirtMachineState, and guest-info is just part of that state, we can remove all the redundant members and access the VirtMachineState directly.
--- hw/arm/virt-acpi-build.c | 72 +++++++++++++++++++++++++----------------------- hw/arm/virt.c | 6 ---- include/hw/arm/virt.h | 6 ---- 3 files changed, 37 insertions(+), 47 deletions(-)
hw/arm/virt-acpi-build.c +37 -35
@@ -384,7 +384,7 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset) }static void -build_iort (GArray *table_data,BIOSLinker *linker,VirtGuestInfo *guest_info) +build_iort (GArray *table_data,BIOSLinker *linker) {int iort_start = table_data->len;AcpiIortIdMapping *idmap;
@@ -439,11 +439,11 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }static void -build_spcr (GArray *table_data,BIOSLinker *linker,VirtGuestInfo *guest_info) +build_spcr (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {AcpiSerialPortConsoleRedirection *spcr; -const MemMapEntry *uart_memmap = &guest_info->memmap[VIRT_UART ]; -int irq = guest_info->irqmap[VIRT_UART ] +ARM_SPI_BASE ; +const MemMapEntry *uart_memmap = &vms->memmap[VIRT_UART ]; +int irq = vms->irqmap[VIRT_UART ] +ARM_SPI_BASE ; spcr =acpi_data_push (table_data,sizeof (*spcr));
@@ -472,16 +472,16 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }static void -build_srat (GArray *table_data,BIOSLinker *linker,VirtGuestInfo *guest_info) +build_srat (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {AcpiSystemResourceAffinityTable *srat;AcpiSratProcessorGiccAffinity *core;AcpiSratMemoryAffinity *numamem;int i, j, srat_start;uint64_t mem_base; -uint32_t *cpu_node =g_malloc0 (guest_info->smp_cpus *sizeof (uint32_t )); +uint32_t *cpu_node =g_malloc0 (vms->smp_cpus *sizeof (uint32_t )); -for (i =0 ; i < guest_info->smp_cpus; i++) { +for (i =0 ; i < vms->smp_cpus; i++) { j =numa_get_node_for_cpu (i);if (j < nb_numa_nodes) { cpu_node[i] = j;
@@ -492,7 +492,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) srat =acpi_data_push (table_data,sizeof (*srat)); srat->reserved1 =cpu_to_le32 (1 ); -for (i =0 ; i < guest_info->smp_cpus; ++i) { +for (i =0 ; i < vms->smp_cpus; ++i) { core =acpi_data_push (table_data,sizeof (*core)); core->type =ACPI_SRAT_PROCESSOR_GICC ; core->length =sizeof (*core);
@@ -502,7 +502,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }g_free (cpu_node); - mem_base = guest_info->memmap[VIRT_MEM ].base; + mem_base = vms->memmap[VIRT_MEM ].base;for (i =0 ; i < nb_numa_nodes; ++i) { numamem =acpi_data_push (table_data,sizeof (*numamem)); build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i,
@@ -515,10 +515,10 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }static void -build_mcfg (GArray *table_data,BIOSLinker *linker,VirtGuestInfo *guest_info) +build_mcfg (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {AcpiTableMcfg *mcfg; -const MemMapEntry *memmap = guest_info->memmap; +const MemMapEntry *memmap = vms->memmap;int len =sizeof (*mcfg) +sizeof (mcfg->allocation[0 ]); mcfg =acpi_data_push (table_data, len);
@@ -562,11 +562,12 @@ build_gtdt(GArray *table_data, BIOSLinker *linker)/* MADT */ static void -build_madt (GArray *table_data,BIOSLinker *linker,VirtGuestInfo *guest_info) +build_madt (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) { +VirtMachineClass *vmc =VIRT_MACHINE_GET_CLASS (vms);int madt_start = table_data->len; -const MemMapEntry *memmap = guest_info->memmap; -const int *irqmap = guest_info->irqmap; +const MemMapEntry *memmap = vms->memmap; +const int *irqmap = vms->irqmap;AcpiMultipleApicTable *madt;AcpiMadtGenericDistributor *gicd;AcpiMadtGenericMsiFrame *gic_msi;
@@ -578,16 +579,16 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicd->type =ACPI_APIC_GENERIC_DISTRIBUTOR ; gicd->length =sizeof (*gicd); gicd->base_address =cpu_to_le64 (memmap[VIRT_GIC_DIST ].base); - gicd->version = guest_info->gic_version; + gicd->version = vms->gic_version; -for (i =0 ; i < guest_info->smp_cpus; i++) { +for (i =0 ; i < vms->smp_cpus; i++) {AcpiMadtGenericCpuInterface *gicc =acpi_data_push (table_data,sizeof (*gicc));ARMCPU *armcpu =ARM_CPU (qemu_get_cpu (i)); gicc->type =ACPI_APIC_GENERIC_CPU_INTERFACE ; gicc->length =sizeof (*gicc); -if (guest_info->gic_version ==2 ) { +if (vms->gic_version ==2 ) { gicc->base_address =cpu_to_le64 (memmap[VIRT_GIC_CPU ].base); } gicc->cpu_interface_number =cpu_to_le32 (i);
@@ -600,7 +601,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) } } -if (guest_info->gic_version ==3 ) { +if (vms->gic_version ==3 ) {AcpiMadtGenericTranslator *gic_its;AcpiMadtGenericRedistributor *gicr =acpi_data_push (table_data,sizeof *gicr);
@@ -610,7 +611,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicr->base_address =cpu_to_le64 (memmap[VIRT_GIC_REDIST ].base); gicr->range_length =cpu_to_le32 (memmap[VIRT_GIC_REDIST ].size); -if (its_class_name () && !guest_info->no_its) { +if (its_class_name () && !vmc->no_its) { gic_its =acpi_data_push (table_data,sizeof *gic_its); gic_its->type =ACPI_APIC_GENERIC_TRANSLATOR ; gic_its->length =sizeof (*gic_its);
@@ -659,11 +660,11 @@ build_fadt(GArray *table_data, BIOSLinker *linker, unsigned dsdt_tbl_offset)/* DSDT */ static void -build_dsdt (GArray *table_data,BIOSLinker *linker,VirtGuestInfo *guest_info) +build_dsdt (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {Aml *scope, *dsdt; -const MemMapEntry *memmap = guest_info->memmap; -const int *irqmap = guest_info->irqmap; +const MemMapEntry *memmap = vms->memmap; +const int *irqmap = vms->irqmap; dsdt =init_aml_allocator ();/* Reserve space for header */
@@ -675,7 +676,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)* the RTC ACPI device at all when using UEFI. */ scope =aml_scope ("\\_SB" ); -acpi_dsdt_add_cpus (scope, guest_info->smp_cpus); +acpi_dsdt_add_cpus (scope, vms->smp_cpus);acpi_dsdt_add_uart (scope, &memmap[VIRT_UART ], (irqmap[VIRT_UART ] +ARM_SPI_BASE ));acpi_dsdt_add_flash (scope, &memmap[VIRT_FLASH ]);
@@ -683,7 +684,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)acpi_dsdt_add_virtio (scope, &memmap[VIRT_MMIO ], (irqmap[VIRT_MMIO ] +ARM_SPI_BASE ),NUM_VIRTIO_TRANSPORTS );acpi_dsdt_add_pci (scope, memmap, (irqmap[VIRT_PCIE ] +ARM_SPI_BASE ), - guest_info->use_highmem); + vms->highmem);acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], (irqmap[VIRT_GPIO ] +ARM_SPI_BASE ));acpi_dsdt_add_power_button (scope);
@@ -710,8 +711,9 @@ struct AcpiBuildState { } AcpiBuildState;static -void virt_acpi_build (VirtGuestInfo *guest_info,AcpiBuildTables *tables) +void virt_acpi_build (VirtMachineState *vms,AcpiBuildTables *tables) { +VirtMachineClass *vmc =VIRT_MACHINE_GET_CLASS (vms);GArray *table_offsets;unsigned dsdt, rsdt;GArray *tables_blob = tables->table_data;
@@ -725,32 +727,32 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)/* DSDT is pointed to by FADT */ dsdt = tables_blob->len; -build_dsdt (tables_blob, tables->linker, guest_info); +build_dsdt (tables_blob, tables->linker, vms);/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob);build_fadt (tables_blob, tables->linker, dsdt);acpi_add_table (table_offsets, tables_blob); -build_madt (tables_blob, tables->linker, guest_info); +build_madt (tables_blob, tables->linker, vms);acpi_add_table (table_offsets, tables_blob);build_gtdt (tables_blob, tables->linker);acpi_add_table (table_offsets, tables_blob); -build_mcfg (tables_blob, tables->linker, guest_info); +build_mcfg (tables_blob, tables->linker, vms);acpi_add_table (table_offsets, tables_blob); -build_spcr (tables_blob, tables->linker, guest_info); +build_spcr (tables_blob, tables->linker, vms);if (nb_numa_nodes >0 ) {acpi_add_table (table_offsets, tables_blob); -build_srat (tables_blob, tables->linker, guest_info); +build_srat (tables_blob, tables->linker, vms); } -if (its_class_name () && !guest_info->no_its) { +if (its_class_name () && !vmc->no_its) {acpi_add_table (table_offsets, tables_blob); -build_iort (tables_blob, tables->linker, guest_info); +build_iort (tables_blob, tables->linker); }/* RSDT is pointed to by RSDP */
@@ -789,13 +791,13 @@ static void virt_acpi_build_update(void *build_opaque)acpi_build_tables_init (&tables); -virt_acpi_build (build_state->guest_info, &tables); +virt_acpi_build (container_of (build_state->guest_info, + VirtMachineState, acpi_guest_info), &tables);acpi_ram_update (build_state->table_mr, tables.table_data);acpi_ram_update (build_state->rsdp_mr, tables.rsdp);acpi_ram_update (build_state->linker_mr, tables.linker->cmd_blob); -acpi_build_tables_cleanup (&tables, true); }
@@ -843,7 +845,7 @@ void virt_acpi_setup(VirtMachineState *vms) build_state->guest_info = guest_info;acpi_build_tables_init (&tables); -virt_acpi_build (build_state->guest_info, &tables); +virt_acpi_build (vms, &tables);/* Now expose it all to Guest */ build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data,
hw/arm/virt.c +0 -6
@@ -1415,13 +1415,7 @@ static void machvirt_init(MachineState *machine)create_fw_cfg (vms, &address_space_memory);rom_set_fw (fw_cfg_find ()); - guest_info->smp_cpus = smp_cpus; guest_info->fw_cfg =fw_cfg_find (); - guest_info->memmap = vms->memmap; - guest_info->irqmap = vms->irqmap; - guest_info->use_highmem = vms->highmem; - guest_info->gic_version = vms->gic_version; - guest_info->no_its = vmc->no_its; vms->machine_done.notify = virt_machine_done;qemu_add_machine_init_done_notifier (&vms->machine_done);
include/hw/arm/virt.h +0 -6
@@ -80,13 +80,7 @@ typedef struct MemMapEntry { } MemMapEntry;typedef struct VirtGuestInfo { -int smp_cpus;FWCfgState *fw_cfg; -const MemMapEntry *memmap; -const int *irqmap; -bool use_highmem; -int gic_version; -bool no_its; }VirtGuestInfo ; typedef struct {
Signature · 1 line
2.9.3
PATCH v2 12/16 hw/arm/virt-acpi-build: don't save VirtGuestInfo on AcpiBuildState
In reply to Andrew JonesWe can get to VirtMachineState without the need for saving a pointer on AcpiBuildState. This is the mach-virt equivalent to "acpi: Don't save PcGuestInfo on AcpiBuildState"
--- hw/arm/virt-acpi-build.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/arm/virt-acpi-build.c +1 -4
@@ -707,7 +707,6 @@ struct AcpiBuildState {MemoryRegion *linker_mr;/* Is table patched? */ bool patched; -VirtGuestInfo *guest_info; } AcpiBuildState; static
@@ -791,8 +790,7 @@ static void virt_acpi_build_update(void *build_opaque)acpi_build_tables_init (&tables); -virt_acpi_build (container_of (build_state->guest_info, - VirtMachineState, acpi_guest_info), &tables); +virt_acpi_build (VIRT_MACHINE (qdev_get_machine ()), &tables);acpi_ram_update (build_state->table_mr, tables.table_data);acpi_ram_update (build_state->rsdp_mr, tables.rsdp);
@@ -842,7 +840,6 @@ void virt_acpi_setup(VirtMachineState *vms) } build_state =g_malloc0 (sizeof *build_state); - build_state->guest_info = guest_info;acpi_build_tables_init (&tables);virt_acpi_build (vms, &tables);
Signature · 1 line
2.9.3
PATCH v2 13/16 hw/arm/virt: remove VirtGuestInfo
In reply to Andrew Jonesby moving VirtGuestInfo.fw_cfg to VirtMachineState. This is the mach-virt equivalent of "pc: Move PcGuestInfo.fw_cfg to PCMachineState" and "pc: Eliminate PcGuestInfo struct" combined.
--- hw/arm/virt-acpi-build.c | 7 +++---- hw/arm/virt.c | 16 +++++++--------- include/hw/arm/virt.h | 6 +----- 3 files changed, 11 insertions(+), 18 deletions(-)
hw/arm/virt-acpi-build.c +3 -4
@@ -825,11 +825,10 @@ static const VMStateDescription vmstate_virt_acpi_build = {void virt_acpi_setup (VirtMachineState *vms) { -VirtGuestInfo *guest_info = &vms->acpi_guest_info;AcpiBuildTables tables;AcpiBuildState *build_state; -if (!guest_info->fw_cfg) { +if (!vms->fw_cfg) {trace_virt_acpi_setup ();return ; }
@@ -854,8 +853,8 @@ void virt_acpi_setup(VirtMachineState *vms)acpi_add_rom_blob (build_state, tables.linker->cmd_blob,"etc/table-loader" ,0 ); -fw_cfg_add_file (guest_info->fw_cfg,ACPI_BUILD_TPMLOG_FILE , - tables.tcpalog->data,acpi_data_len (tables.tcpalog)); +fw_cfg_add_file (vms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data, +acpi_data_len (tables.tcpalog)); build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp,ACPI_BUILD_RSDP_FILE ,0 );
hw/arm/virt.c +7 -9
@@ -913,7 +913,7 @@ static void create_flash(const VirtMachineState *vms, } } -static void create_fw_cfg (const VirtMachineState *vms,AddressSpace *as) +static FWCfgState *create_fw_cfg (const VirtMachineState *vms,AddressSpace *as) {hwaddr base = vms->memmap[VIRT_FW_CFG ].base;hwaddr size = vms->memmap[VIRT_FW_CFG ].size;
@@ -930,6 +930,7 @@ static void create_fw_cfg(const VirtMachineState *vms, AddressSpace *as)qemu_fdt_setprop_sized_cells (vms->fdt, nodename,"reg" ,2 , base,2 , size);g_free (nodename); +return fw_cfg; } static void create_pcie_irq_map(const VirtMachineState *vms,
@@ -1157,12 +1158,11 @@ static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)static void virt_build_smbios (VirtMachineState *vms) { -FWCfgState *fw_cfg = vms->acpi_guest_info.fw_cfg;uint8_t *smbios_tables, *smbios_anchor;size_t smbios_tables_len, smbios_anchor_len;const char *product ="QEMU Virtual Machine" ; -if (!fw_cfg) { +if (!vms->fw_cfg) {return ; }
@@ -1177,9 +1177,9 @@ static void virt_build_smbios(VirtMachineState *vms) &smbios_anchor, &smbios_anchor_len);if (smbios_anchor) { -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , +fw_cfg_add_file (vms->fw_cfg,"etc/smbios/smbios-tables" , smbios_tables, smbios_tables_len); -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , +fw_cfg_add_file (vms->fw_cfg,"etc/smbios/smbios-anchor" , smbios_anchor, smbios_anchor_len); } }
@@ -1204,7 +1204,6 @@ static void machvirt_init(MachineState *machine)int n, virt_max_cpus;MemoryRegion *ram =g_new (MemoryRegion,1 );const char *cpu_model = machine->cpu_model; -VirtGuestInfo *guest_info = &vms->acpi_guest_info;char **cpustr;ObjectClass *oc;const char *typename;
@@ -1412,10 +1411,9 @@ static void machvirt_init(MachineState *machine)*/ create_virtio_devices (vms, pic); -create_fw_cfg (vms, &address_space_memory); -rom_set_fw (fw_cfg_find ()); + vms->fw_cfg =create_fw_cfg (vms, &address_space_memory); +rom_set_fw (vms->fw_cfg); - guest_info->fw_cfg =fw_cfg_find (); vms->machine_done.notify = virt_machine_done;qemu_add_machine_init_done_notifier (&vms->machine_done);
include/hw/arm/virt.h +1 -5
@@ -79,10 +79,6 @@ typedef struct MemMapEntry {hwaddr size; } MemMapEntry; -typedef struct VirtGuestInfo { -FWCfgState *fw_cfg; -}VirtGuestInfo ; - typedef struct { MachineClass parent; bool disallow_affinity_adjustment;
@@ -93,8 +89,8 @@ typedef struct { typedef struct { MachineState parent; - VirtGuestInfo acpi_guest_info; Notifier machine_done; + FWCfgState *fw_cfg; bool secure; bool highmem; bool virt;
Signature · 1 line
2.9.3
PATCH v2 14/16 hw/arm/virt-acpi-build: Don't incorrectly claim architectural timer to be edge-triggered
In reply to Andrew JonesThis is the ACPI equivalent to "hw/arm/virt: Don't incorrectly claim architectural timer to be edge-triggered" which fixes the DT for machine types 2.9 and later.
--- hw/arm/virt-acpi-build.c | 20 ++++++++++++++------ include/hw/acpi/acpi-defs.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-)
hw/arm/virt-acpi-build.c +14 -6
@@ -535,25 +535,33 @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)/* GTDT */ static void -build_gtdt (GArray *table_data,BIOSLinker *linker) +build_gtdt (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) { +VirtMachineClass *vmc =VIRT_MACHINE_GET_CLASS (vms);int gtdt_start = table_data->len;AcpiGenericTimerTable *gtdt; +uint32_t irqflags; + +if (vmc->claim_edge_triggered_timers) { + irqflags =ACPI_GTDT_INTERRUPT_MODE_EDGE ; + }else { + irqflags =ACPI_GTDT_INTERRUPT_MODE_LEVEL ; + } gtdt =acpi_data_push (table_data,sizeof *gtdt);/* The interrupt values are the same with the device tree when adding 16 */ gtdt->secure_el1_interrupt =cpu_to_le32 (ARCH_TIMER_S_EL1_IRQ +16 ); - gtdt->secure_el1_flags =cpu_to_le32 (ACPI_GTDT_INTERRUPT_MODE_EDGE ); + gtdt->secure_el1_flags =cpu_to_le32 (irqflags); gtdt->non_secure_el1_interrupt =cpu_to_le32 (ARCH_TIMER_NS_EL1_IRQ +16 ); - gtdt->non_secure_el1_flags =cpu_to_le32 (ACPI_GTDT_INTERRUPT_MODE_EDGE | + gtdt->non_secure_el1_flags =cpu_to_le32 (irqflags |ACPI_GTDT_CAP_ALWAYS_ON ); gtdt->virtual_timer_interrupt =cpu_to_le32 (ARCH_TIMER_VIRT_IRQ +16 ); - gtdt->virtual_timer_flags =cpu_to_le32 (ACPI_GTDT_INTERRUPT_MODE_EDGE ); + gtdt->virtual_timer_flags =cpu_to_le32 (irqflags); gtdt->non_secure_el2_interrupt =cpu_to_le32 (ARCH_TIMER_NS_EL2_IRQ +16 ); - gtdt->non_secure_el2_flags =cpu_to_le32 (ACPI_GTDT_INTERRUPT_MODE_EDGE ); + gtdt->non_secure_el2_flags =cpu_to_le32 (irqflags); build_header(linker, table_data, (void *)(table_data->data + gtdt_start), "GTDT",
@@ -736,7 +744,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)build_madt (tables_blob, tables->linker, vms);acpi_add_table (table_offsets, tables_blob); -build_gtdt (tables_blob, tables->linker); +build_gtdt (tables_blob, tables->linker, vms);acpi_add_table (table_offsets, tables_blob);build_mcfg (tables_blob, tables->linker, vms);
include/hw/acpi/acpi-defs.h +1 -0
@@ -428,6 +428,7 @@ typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator;/* * Generic Timer Description Table (GTDT) */ +#define ACPI_GTDT_INTERRUPT_MODE_LEVEL (0 << 0)#define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0)#define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2)
Signature · 1 line
2.9.3
PATCH v2 15/16 hw/arm/virt-acpi-build: use SMC if booting in EL2
In reply to Andrew Jones--- hw/arm/virt-acpi-build.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/arm/virt-acpi-build.c +6 -6
@@ -643,16 +643,16 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }/* FADT */ -static void -build_fadt (GArray *table_data,BIOSLinker *linker,unsigned dsdt_tbl_offset) +static void build_fadt (GArray *table_data,BIOSLinker *linker, +VirtMachineState *vms,unsigned dsdt_tbl_offset) {AcpiFadtDescriptorRev5_1 *fadt =acpi_data_push (table_data,sizeof (*fadt));unsigned dsdt_entry_offset = (char *)&fadt->dsdt - table_data->data; +uint16_t use_hvc = vms->virt ?0 :ACPI_FADT_ARM_PSCI_USE_HVC ; -/* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */ +/* Hardware Reduced = 1 and use PSCI 0.2+ */ fadt->flags =cpu_to_le32 (1 <<ACPI_FADT_F_HW_REDUCED_ACPI ); - fadt->arm_boot_flags =cpu_to_le16 (ACPI_FADT_ARM_PSCI_COMPLIANT | -ACPI_FADT_ARM_PSCI_USE_HVC ); + fadt->arm_boot_flags =cpu_to_le16 (ACPI_FADT_ARM_PSCI_COMPLIANT | use_hvc);/* ACPI v5.1 (fadt->revision.fadt->minor_revision) */ fadt->minor_revision =0x1 ;
@@ -738,7 +738,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob); -build_fadt (tables_blob, tables->linker, dsdt); +build_fadt (tables_blob, tables->linker, vms, dsdt);acpi_add_table (table_offsets, tables_blob);build_madt (tables_blob, tables->linker, vms);
Signature · 1 line
2.9.3
PATCH v2 16/16 hw/arm/virt-acpi-build: madt: add vgic maint irq
In reply to Andrew JonesWhen virtualization is enabled and we have a v3 gic, then we add the vgic maintenance interrupt to the DT. This patch is the ACPI equivalent.
--- hw/arm/virt-acpi-build.c | 3 +++ 1 file changed, 3 insertions(+)
hw/arm/virt-acpi-build.c +3 -0
@@ -607,6 +607,9 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)if (arm_feature (&armcpu->env,ARM_FEATURE_PMU )) { gicc->performance_interrupt =cpu_to_le32 (PPI (VIRTUAL_PMU_IRQ )); } +if (vms->virt && vms->gic_version ==3 ) { + gicc->vgic_interrupt =cpu_to_le32 (PPI (ARCH_GICV3_MAINT_IRQ )); + } }if (vms->gic_version ==3 ) {
Signature · 1 line
2.9.3
Quoted 15 lines · Andrew Jones
v2:
- all Igor's suggestions
- added four mach-virt acpi cleanup patches
- added the remaining two acpi patches needed to bring equivalence to Peter's DT changesThis series is based on Peter's qemu-arm gicv3-virt branch. It's main goal (patches 07-13), which was suggested by Eduardo, is to remove an unnecessary structure, VirtGuestInfo, which is a maintenance burden, as it requires duplicating Virt machine state. Additionally patches 05-06 do some mach-virt cleanups and patches 14-16 add the ACPI equivalents of the DT patches in Peter's gicv3-virt branch. The first four patches are cleanups to mach-virt's acpi code.
Quoted 2 lines
Patches available here
https://github.com/rhdrjones/qemu/commits/virt/remove-guest-info-v2
Thanks. Apart from the last 2 patches which depend on the gicv3-virt changes, I think this is all OK to go in now.
Since the gicv3-virt code still needs a respin (I haven't looked at the failure to boot smp secondaries into EL2 yet), I have taken the first 3 patches from gicv3-virt and put them into target-arm.next:
hw/arm/virt: Merge VirtBoardInfo and VirtMachineState hw/arm/virt: Rename 'vbi' variables to 'vms'
hw/arm/virt: Don't incorrectly claim architectural timer to be edge-triggered
and then rebased patches 1-14 from this series on top of that, and applied all that to target-arm.next.
I'll put patches 15 and 16 into my gicv3-virt branch for when I send out v2 of that.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v2 15/16] hw/arm/virt-acpi-build: use SMC if booting in EL2
In reply to Andrew JonesQuoted 11 lines · Andrew Jones
Signed-off-by Andrew Jones <[email protected]>--- hw/arm/virt-acpi-build.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)hw/arm/virt-acpi-build.c +0
-0@@ -643,16 +643,16 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }
hw/arm/virt-acpi-build.c build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 651
Quoted 10 lines
hw/arm/virt-acpi-build.c +3
-2/* FADT */ -static void -build_fadt (GArray *table_data,BIOSLinker *linker,unsigned dsdt_tbl_offset) +static void build_fadt (GArray *table_data,BIOSLinker *linker, +VirtMachineState *vms,unsigned dsdt_tbl_offset) {AcpiFadtDescriptorRev5_1 *fadt =acpi_data_push (table_data,sizeof (*fadt));unsigned dsdt_entry_offset = (char *)&fadt->dsdt - table_data->data; +uint16_t use_hvc = vms->virt ?0 :ACPI_FADT_ARM_PSCI_USE_HVC ;
This is the wrong condition -- you should just check whether vms->psci_conduit is QEMU_PSCI_CONDUIT_HVC (vs _SMC or _DISABLED), something like:
switch (vms->psci_conduit) {
case QEMU_PSCI_CONDUIT_DISABLED:
/* XXX should we fail, or boot without the PSCI_COMPLIANT flag? */
use_hvc = 0;
break;
case QEMU_PSCI_CONDUIT_HVC:
use_hvc = ACPI_FADT_ARM_PSCI_USE_HVC;
break;
case QEMU_PSCI_CONDUIT_SMC:
use_hvc = 0;
break;
default:
g_assert_not_reached();
}What should we do in the DISABLED case ?
Quoted 10 lines
hw/arm/virt-acpi-build.c +2
-3-/* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */ +/* Hardware Reduced = 1 and use PSCI 0.2+ */ fadt->flags =cpu_to_le32 (1 <<ACPI_FADT_F_HW_REDUCED_ACPI ); - fadt->arm_boot_flags =cpu_to_le16 (ACPI_FADT_ARM_PSCI_COMPLIANT | -ACPI_FADT_ARM_PSCI_USE_HVC ); + fadt->arm_boot_flags =cpu_to_le16 (ACPI_FADT_ARM_PSCI_COMPLIANT | use_hvc);/* ACPI v5.1 (fadt->revision.fadt->minor_revision) */ fadt->minor_revision =0x1 ;
hw/arm/virt-acpi-build.c void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) · line 744
Quoted 8 lines
hw/arm/virt-acpi-build.c +1
-1@@ -738,7 +738,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob); -build_fadt (tables_blob, tables->linker, dsdt); +build_fadt (tables_blob, tables->linker, vms, dsdt);acpi_add_table (table_offsets, tables_blob);build_madt (tables_blob, tables->linker, vms);
thanks
-- PMM
Re: [Qemu-arm] [PATCH v2 16/16] hw/arm/virt-acpi-build: madt: add vgic maint irq
In reply to Andrew JonesQuoted 14 lines · Andrew Jones
When virtualization is enabled and we have a v3 gic, then we add the vgic maintenance interrupt to the DT. This patch is the ACPI equivalent.
Signed-off-by Andrew Jones <[email protected]>--- hw/arm/virt-acpi-build.c | 3 +++ 1 file changed, 3 insertions(+)hw/arm/virt-acpi-build.c +0
-0
hw/arm/virt-acpi-build.c build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 615
Quoted 9 lines
hw/arm/virt-acpi-build.c +3
-0@@ -607,6 +607,9 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)if (arm_feature (&armcpu->env,ARM_FEATURE_PMU )) { gicc->performance_interrupt =cpu_to_le32 (PPI (VIRTUAL_PMU_IRQ )); } +if (vms->virt && vms->gic_version ==3 ) { + gicc->vgic_interrupt =cpu_to_le32 (PPI (ARCH_GICV3_MAINT_IRQ )); + } }if (vms->gic_version ==3 ) {
I'm going to squash this change into my "target-arm: Enable EL2 feature bit on A53 and A57" patch, since it's a trivial diff and that's the patch which has the "put this into the DTB" change in it.
thanks
-- PMM