From e8977414a2148c75d2ecf69da8860a7e334cb814 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 17 May 2016 16:42:54 +0200 Subject: acpi: add aml_debug() Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- include/hw/acpi/aml-build.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 7eb51c7885..70a4b14919 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -252,6 +252,7 @@ void aml_append(Aml *parent_ctx, Aml *child); /* non block AML object primitives */ Aml *aml_name(const char *name_format, ...) GCC_FMT_ATTR(1, 2); Aml *aml_name_decl(const char *name, Aml *val); +Aml *aml_debug(void); Aml *aml_return(Aml *val); Aml *aml_int(const uint64_t val); Aml *aml_arg(int pos); -- cgit v1.2.3 From 7bc6fd24646fc0c2927c3ab255b8b09ed42e67ee Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 17 May 2016 16:42:55 +0200 Subject: acpi: add aml_refof() Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- include/hw/acpi/aml-build.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 70a4b14919..dd432d2450 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -359,6 +359,7 @@ Aml *aml_create_qword_field(Aml *srcbuf, Aml *index, const char *name); Aml *aml_varpackage(uint32_t num_elements); Aml *aml_touuid(const char *uuid); Aml *aml_unicode(const char *str); +Aml *aml_refof(Aml *arg); Aml *aml_derefof(Aml *arg); Aml *aml_sizeof(Aml *arg); Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target); -- cgit v1.2.3 From 7c2991fa115eae8d54e544d6231ee81844d6c8e3 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 17 May 2016 16:42:57 +0200 Subject: pc: acpi: consolidate CPU hotplug AML move the former SSDT part of CPU hoplug close to DSDT part. AML is only moved but there isn't any functional change. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/cpu_hotplug.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index f22640e389..9b1d0cf785 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -34,5 +34,6 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, #define CPU_STATUS_MAP "PRS" #define CPU_SCAN_METHOD "PRSC" -void build_cpu_hotplug_aml(Aml *ctx); +void build_cpu_hotplug_aml(Aml *ctx, MachineState *machine, + uint16_t io_base, uint16_t io_len); #endif -- cgit v1.2.3 From a630bb314c1f3108f391d19e1a20e07ea3c9edd2 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 17 May 2016 16:42:59 +0200 Subject: pc: acpi: cpu-hotplug: make AML CPU_foo defines local to cpu_hotplug_acpi_table.c now as those defines are used only locally inside of cpu_hotplug_acpi_table.c, move them out of header file. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- include/hw/acpi/cpu_hotplug.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index 9b1d0cf785..565f96c951 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -27,13 +27,6 @@ void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq, void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, AcpiCpuHotplug *gpe_cpu, uint16_t base); -#define CPU_EJECT_METHOD "CPEJ" -#define CPU_MAT_METHOD "CPMA" -#define CPU_ON_BITMAP "CPON" -#define CPU_STATUS_METHOD "CPST" -#define CPU_STATUS_MAP "PRS" -#define CPU_SCAN_METHOD "PRSC" - void build_cpu_hotplug_aml(Aml *ctx, MachineState *machine, uint16_t io_base, uint16_t io_len); #endif -- cgit v1.2.3 From 96e3e12bff14a16e27072619f571bc7b400145c3 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 17 May 2016 16:43:00 +0200 Subject: pc: acpi: mark current CPU hotplug functions as legacy Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- include/hw/acpi/cpu_hotplug.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index 565f96c951..241b50f8f7 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -21,12 +21,12 @@ typedef struct AcpiCpuHotplug { uint8_t sts[ACPI_GPE_PROC_LEN]; } AcpiCpuHotplug; -void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq, - AcpiCpuHotplug *g, DeviceState *dev, Error **errp); +void legacy_acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq, + AcpiCpuHotplug *g, DeviceState *dev, Error **errp); -void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, - AcpiCpuHotplug *gpe_cpu, uint16_t base); +void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, + AcpiCpuHotplug *gpe_cpu, uint16_t base); -void build_cpu_hotplug_aml(Aml *ctx, MachineState *machine, - uint16_t io_base, uint16_t io_len); +void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine, + uint16_t io_base, uint16_t io_len); #endif -- cgit v1.2.3 From ebd8ea82441020f2781928b17f37ed9a0d2e4250 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 17 May 2016 16:43:02 +0200 Subject: pc: acpi: simplify build_legacy_cpu_hotplug_aml() signature since IO block used by CPU hotplug is fixed size and initialized it the same file as build_legacy_cpu_hotplug_aml() just use ACPI_GPE_PROC_LEN directly instead of passing it around in several files. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- include/hw/acpi/cpu_hotplug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index 241b50f8f7..6d729d8108 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -28,5 +28,5 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, AcpiCpuHotplug *gpe_cpu, uint16_t base); void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine, - uint16_t io_base, uint16_t io_len); + uint16_t io_base); #endif -- cgit v1.2.3 From 15139b8ef0ea3d9dd35965bdd5d4f564ffa6e9e1 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Tue, 24 May 2016 12:37:17 -0500 Subject: ipmi: rework the fwinfo to be fetched from the interface Instead of scanning IPMI devices from a fwinfo list, allow the fwinfo to be fetched from the IPMI interface class. Then the code looking for IPMI fwinfo can scan devices on a bus and look for ones that implement the IPMI class. This will let the ACPI scope be defined by the calling code so the IPMI code doesn't have to know the scope. Signed-off-by: Corey Minyard Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/ipmi/ipmi.h | 74 ++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 35 deletions(-) (limited to 'include') diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h index 74a2b5af96..91b83b5bb0 100644 --- a/include/hw/ipmi/ipmi.h +++ b/include/hw/ipmi/ipmi.h @@ -65,6 +65,40 @@ enum ipmi_op { #define IPMI_SMBIOS_BT 0x03 #define IPMI_SMBIOS_SSIF 0x04 +/* + * Used for transferring information to interfaces that add + * entries to firmware tables. + */ +typedef struct IPMIFwInfo { + const char *interface_name; + int interface_type; + uint8_t ipmi_spec_major_revision; + uint8_t ipmi_spec_minor_revision; + uint8_t i2c_slave_address; + uint32_t uuid; + + uint64_t base_address; + uint64_t register_length; + uint8_t register_spacing; + enum { + IPMI_MEMSPACE_IO, + IPMI_MEMSPACE_MEM32, + IPMI_MEMSPACE_MEM64, + IPMI_MEMSPACE_SMBUS + } memspace; + + int interrupt_number; + enum { + IPMI_LEVEL_IRQ, + IPMI_EDGE_IRQ + } irq_type; +} IPMIFwInfo; + +/* + * Called by each instantiated IPMI interface device to get it's uuid. + */ +uint32_t ipmi_next_uuid(void); + /* IPMI Interface types (KCS, SMIC, BT) are prefixed with this */ #define TYPE_IPMI_INTERFACE_PREFIX "ipmi-interface-" @@ -127,6 +161,11 @@ typedef struct IPMIInterfaceClass { * Set by the owner to hold the backend data for the interface. */ void *(*get_backend_data)(struct IPMIInterface *s); + + /* + * Return the firmware info for a device. + */ + void (*get_fwinfo)(struct IPMIInterface *s, IPMIFwInfo *info); } IPMIInterfaceClass; /* @@ -168,41 +207,6 @@ typedef struct IPMIBmcClass { */ void ipmi_bmc_find_and_link(Object *obj, Object **bmc); -/* - * Used for transferring information to interfaces that add - * entries to firmware tables. - */ -typedef struct IPMIFwInfo { - const char *interface_name; - int interface_type; - uint8_t ipmi_spec_major_revision; - uint8_t ipmi_spec_minor_revision; - uint8_t i2c_slave_address; - uint32_t uuid; - - uint64_t base_address; - uint64_t register_length; - uint8_t register_spacing; - enum { - IPMI_MEMSPACE_IO, - IPMI_MEMSPACE_MEM32, - IPMI_MEMSPACE_MEM64, - IPMI_MEMSPACE_SMBUS - } memspace; - - int interrupt_number; - enum { - IPMI_LEVEL_IRQ, - IPMI_EDGE_IRQ - } irq_type; - - const char *acpi_parent; -} IPMIFwInfo; - -void ipmi_add_fwinfo(IPMIFwInfo *info, Error **errp); -IPMIFwInfo *ipmi_first_fwinfo(void); -IPMIFwInfo *ipmi_next_fwinfo(IPMIFwInfo *current); - #ifdef IPMI_DEBUG #define ipmi_debug(fs, ...) \ fprintf(stderr, "IPMI (%s): " fs, __func__, ##__VA_ARGS__) -- cgit v1.2.3 From eaf23bf794c749c621a5605c1076a16e3d81e12b Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 31 May 2016 11:57:57 +0200 Subject: acpi: extend ACPI interface to provide send_event hook send_event() hook will allow to send ACPI event in a target specific way (GPE or GPIO based impl.) it will also simplify proxy wrappers in piix4pm/ich9 that access ACPI regs and SCI which are part of piix4pm/lcp_ich9 devices and call acpi_foo() API directly. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- include/hw/acpi/acpi.h | 10 ++-------- include/hw/acpi/acpi_dev_interface.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index dc6ee00885..c717f157fe 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -23,6 +23,7 @@ #include "qemu/option.h" #include "exec/memory.h" #include "hw/irq.h" +#include "hw/acpi/acpi_dev_interface.h" /* * current device naming scheme supports up to 256 memory devices @@ -89,13 +90,6 @@ /* PM2_CNT */ #define ACPI_BITMASK_ARB_DISABLE 0x0001 -/* These values are part of guest ABI, and can not be changed */ -typedef enum { - ACPI_PCI_HOTPLUG_STATUS = 2, - ACPI_CPU_HOTPLUG_STATUS = 4, - ACPI_MEMORY_HOTPLUG_STATUS = 8, -} AcpiGPEStatusBits; - /* structs */ typedef struct ACPIPMTimer ACPIPMTimer; typedef struct ACPIPM1EVT ACPIPM1EVT; @@ -172,7 +166,7 @@ void acpi_gpe_ioport_writeb(ACPIREGS *ar, uint32_t addr, uint32_t val); uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr); void acpi_send_gpe_event(ACPIREGS *ar, qemu_irq irq, - AcpiGPEStatusBits status); + AcpiEventStatusBits status); void acpi_update_sci(ACPIREGS *acpi_regs, qemu_irq irq); diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h index f245f8d236..a0c4a336f2 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -4,6 +4,13 @@ #include "qom/object.h" #include "qapi-types.h" +/* These values are part of guest ABI, and can not be changed */ +typedef enum { + ACPI_PCI_HOTPLUG_STATUS = 2, + ACPI_CPU_HOTPLUG_STATUS = 4, + ACPI_MEMORY_HOTPLUG_STATUS = 8, +} AcpiEventStatusBits; + #define TYPE_ACPI_DEVICE_IF "acpi-device-interface" #define ACPI_DEVICE_IF_CLASS(klass) \ @@ -22,11 +29,14 @@ typedef struct AcpiDeviceIf { Object Parent; } AcpiDeviceIf; +void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event); + /** * AcpiDeviceIfClass: * * ospm_status: returns status of ACPI device objects, reported * via _OST method if device supports it. + * send_event: inject a specified event into guest * * Interface is designed for providing unified interface * to generic ACPI functionality that could be used without @@ -39,5 +49,6 @@ typedef struct AcpiDeviceIfClass { /* */ void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); + void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev); } AcpiDeviceIfClass; #endif -- cgit v1.2.3 From 0058c0823815d33c96f4f26106dbd713c76280e1 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 31 May 2016 12:01:17 +0200 Subject: pc: use AcpiDeviceIfClass.send_event to issue GPE events it reduces number of args passed in handlers by 1 and a number of used proxy wrappers saving ~20LOC. Also it allows to make cpu/mem hotplug code more universal as it would allow ARM to reuse it without rewrite by providing its own send_event callback to trigger events usiong GPIO instead of GPE as fixed hadrware ACPI model doen't have GPE at all. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/cpu_hotplug.h | 3 ++- include/hw/acpi/ich9.h | 9 +++++---- include/hw/acpi/memory_hotplug.h | 4 ++-- include/hw/acpi/pcihp.h | 5 +++-- 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index 6d729d8108..6fef67ec14 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -15,13 +15,14 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/pc-hotplug.h" #include "hw/acpi/aml-build.h" +#include "hw/hotplug.h" typedef struct AcpiCpuHotplug { MemoryRegion io; uint8_t sts[ACPI_GPE_PROC_LEN]; } AcpiCpuHotplug; -void legacy_acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq, +void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, AcpiCpuHotplug *g, DeviceState *dev, Error **errp); void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 63fa198145..bbd657c59b 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -69,10 +69,11 @@ extern const VMStateDescription vmstate_ich9_pm; void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp); -void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp); -void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev, - Error **errp); -void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, +void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp); +void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp); +void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h index 3a646b12e0..d2c7452397 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -32,9 +32,9 @@ typedef struct MemHotplugState { void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, MemHotplugState *state); -void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st, +void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp); -void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq, +void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp); void acpi_memory_unplug_cb(MemHotplugState *mem_st, diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h index 79a43923e8..04528b78d9 100644 --- a/include/hw/acpi/pcihp.h +++ b/include/hw/acpi/pcihp.h @@ -29,6 +29,7 @@ #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/hotplug.h" #define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base" #define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len" @@ -56,9 +57,9 @@ typedef struct AcpiPciHpState { void acpi_pcihp_init(Object *owner, AcpiPciHpState *, PCIBus *root, MemoryRegion *address_space_io, bool bridges_enabled); -void acpi_pcihp_device_plug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, +void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp); -void acpi_pcihp_device_unplug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, +void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp); /* Called on reset */ -- cgit v1.2.3 From 0e9b9edae7bebfd31fdbead4ccbbce03876a7edd Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Thu, 19 May 2016 15:19:25 +0200 Subject: acpi: convert linker from GArray to BIOSLinker structure Patch just changes type of of linker variables to a structure, there aren't any functional changes. Converting linker to a structure will allow to extend it functionality in follow up patch adding sanity blob checks. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/aml-build.h | 7 ++++--- include/hw/acpi/bios-linker-loader.h | 14 +++++++++----- include/hw/mem/nvdimm.h | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index dd432d2450..3952f85eeb 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -3,6 +3,7 @@ #include #include "hw/acpi/acpi-defs.h" +#include "hw/acpi/bios-linker-loader.h" /* Reserve RAM space for tables: add another order of magnitude. */ #define ACPI_BUILD_TABLE_MAX_SIZE 0x200000 @@ -210,7 +211,7 @@ struct AcpiBuildTables { GArray *table_data; GArray *rsdp; GArray *tcpalog; - GArray *linker; + BIOSLinker *linker; } AcpiBuildTables; /** @@ -365,7 +366,7 @@ Aml *aml_sizeof(Aml *arg); Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target); void -build_header(GArray *linker, GArray *table_data, +build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev, const char *oem_id, const char *oem_table_id); void *acpi_data_push(GArray *table_data, unsigned size); @@ -374,7 +375,7 @@ void acpi_add_table(GArray *table_offsets, GArray *table_data); void acpi_build_tables_init(AcpiBuildTables *tables); void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre); void -build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets, +build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, const char *oem_id, const char *oem_table_id); int diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h index 82f1af6433..4145c56921 100644 --- a/include/hw/acpi/bios-linker-loader.h +++ b/include/hw/acpi/bios-linker-loader.h @@ -3,23 +3,27 @@ #include -GArray *bios_linker_loader_init(void); +typedef struct BIOSLinker { + GArray *cmd_blob; +} BIOSLinker; -void bios_linker_loader_alloc(GArray *linker, +BIOSLinker *bios_linker_loader_init(void); + +void bios_linker_loader_alloc(BIOSLinker *linker, const char *file, uint32_t alloc_align, bool alloc_fseg); -void bios_linker_loader_add_checksum(GArray *linker, const char *file, +void bios_linker_loader_add_checksum(BIOSLinker *linker, const char *file, GArray *table, void *start, unsigned size, uint8_t *checksum); -void bios_linker_loader_add_pointer(GArray *linker, +void bios_linker_loader_add_pointer(BIOSLinker *linker, const char *dest_file, const char *src_file, GArray *table, void *pointer, uint8_t pointer_size); -void *bios_linker_loader_cleanup(GArray *linker); +void *bios_linker_loader_cleanup(BIOSLinker *linker); #endif diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index 517de9c366..32e1445a37 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -24,6 +24,7 @@ #define QEMU_NVDIMM_H #include "hw/mem/pc-dimm.h" +#include "hw/acpi/bios-linker-loader.h" #define NVDIMM_DEBUG 0 #define nvdimm_debug(fmt, ...) \ @@ -58,5 +59,5 @@ typedef struct AcpiNVDIMMState AcpiNVDIMMState; void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *io, FWCfgState *fw_cfg, Object *owner); void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, - GArray *linker); + BIOSLinker *linker); #endif -- cgit v1.2.3 From ad9671b8700ac491564d964f79ee9d1f106756ae Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Thu, 19 May 2016 15:19:26 +0200 Subject: acpi: simplify bios_linker API by removing redundant 'table' argument 'table' argument in bios_linker_add_foo() commands is a data blob of one of files also passed to the same API. So instead of passing blob in every API call, add and keep file name association with related blob at bios_linker_loader_alloc() time. And find blob by name looking up allocated file entries inside of bios_linker_add_foo() commands. It will: - make API less confusing, - enforce calling bios_linker_loader_alloc() before calling any bios_linker_add_foo() - make sure that blob is the correct one, i.e. associated with the right file name Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/bios-linker-loader.h | 7 ++++--- include/hw/mem/nvdimm.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h index 4145c56921..bee6deee02 100644 --- a/include/hw/acpi/bios-linker-loader.h +++ b/include/hw/acpi/bios-linker-loader.h @@ -5,24 +5,25 @@ typedef struct BIOSLinker { GArray *cmd_blob; + GArray *file_list; } BIOSLinker; BIOSLinker *bios_linker_loader_init(void); void bios_linker_loader_alloc(BIOSLinker *linker, - const char *file, + const char *file_name, + GArray *file_blob, uint32_t alloc_align, bool alloc_fseg); void bios_linker_loader_add_checksum(BIOSLinker *linker, const char *file, - GArray *table, void *start, unsigned size, uint8_t *checksum); void bios_linker_loader_add_pointer(BIOSLinker *linker, const char *dest_file, const char *src_file, - GArray *table, void *pointer, + void *pointer, uint8_t pointer_size); void *bios_linker_loader_cleanup(BIOSLinker *linker); diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index 32e1445a37..60ee92b85a 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -59,5 +59,5 @@ typedef struct AcpiNVDIMMState AcpiNVDIMMState; void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *io, FWCfgState *fw_cfg, Object *owner); void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, - BIOSLinker *linker); + BIOSLinker *linker, GArray *dsm_dma_arrea); #endif -- cgit v1.2.3 From 8cc87c3179f3988cf870ae4e637123770bdf82f1 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Thu, 19 May 2016 15:19:27 +0200 Subject: acpi: cleanup bios_linker_loader_cleanup() bios_linker_loader_cleanup() is called only from one place and returned value is immediately freed wich makes returning pointer from bios_linker_loader_cleanup() useless. Cleanup bios_linker_loader_cleanup() by freeing data there so that caller won't have to free it. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/bios-linker-loader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h index bee6deee02..564e192c16 100644 --- a/include/hw/acpi/bios-linker-loader.h +++ b/include/hw/acpi/bios-linker-loader.h @@ -26,5 +26,5 @@ void bios_linker_loader_add_pointer(BIOSLinker *linker, void *pointer, uint8_t pointer_size); -void *bios_linker_loader_cleanup(BIOSLinker *linker); +void bios_linker_loader_cleanup(BIOSLinker *linker); #endif -- cgit v1.2.3 From 4678124bb9bfb49e93b83f95c4d2feeb443ea38b Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Thu, 19 May 2016 15:19:29 +0200 Subject: acpi: make bios_linker_loader_add_pointer() API offset based cleanup bios_linker_loader_add_pointer() API by switching arguments to taking offsets relative to corresponding files instead of doing pointer arithmetic on behalf of user which were confusing. Also make offset inside of source file explicit in API so that user won't have to manually set it in destination file blob and while at it add additional boundary checks. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/bios-linker-loader.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h index 564e192c16..f666b7c81c 100644 --- a/include/hw/acpi/bios-linker-loader.h +++ b/include/hw/acpi/bios-linker-loader.h @@ -22,9 +22,10 @@ void bios_linker_loader_add_checksum(BIOSLinker *linker, const char *file, void bios_linker_loader_add_pointer(BIOSLinker *linker, const char *dest_file, + uint32_t dst_patched_offset, + uint8_t dst_patched_size, const char *src_file, - void *pointer, - uint8_t pointer_size); + uint32_t src_offset); void bios_linker_loader_cleanup(BIOSLinker *linker); #endif -- cgit v1.2.3 From 28213cb6a61a724e2cb1e3a76d2bb17aa0ce9b36 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Thu, 19 May 2016 15:19:30 +0200 Subject: acpi: make bios_linker_loader_add_checksum() API offset based It should help to make clear that bios_linker works in terms of offsets within a file. Also it should prevent mistakes where user passes as arguments pointers to unrelated to file blobs. While at it, considering that it's a ACPI checksum and it's initial value must be 0, move checksum field zeroing into bios_linker_loader_add_checksum() instead of doing it at every call site manually before bios_linker_loader_add_checksum() is called. In addition add extra boundary checks. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/bios-linker-loader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h index f666b7c81c..a05227eb30 100644 --- a/include/hw/acpi/bios-linker-loader.h +++ b/include/hw/acpi/bios-linker-loader.h @@ -17,8 +17,8 @@ void bios_linker_loader_alloc(BIOSLinker *linker, bool alloc_fseg); void bios_linker_loader_add_checksum(BIOSLinker *linker, const char *file, - void *start, unsigned size, - uint8_t *checksum); + unsigned start_offset, unsigned size, + unsigned checksum_offset); void bios_linker_loader_add_pointer(BIOSLinker *linker, const char *dest_file, -- cgit v1.2.3 From 3c3e88a814ef4eb8b2f8bf81863baec24838d998 Mon Sep 17 00:00:00 2001 From: Xiao Guangrong Date: Fri, 20 May 2016 16:19:58 +0800 Subject: pc-dimm: get memory region from ->get_memory_region() Curretly, the memory region of backed memory is all directly mapped to guest's address space, however, it will be not true for nvdimm device if we introduce nvdimm label which only can be indirectly accessed by ACPI DSM method Also it improves the comments a bit to reflect this fact Signed-off-by: Xiao Guangrong Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- include/hw/mem/pc-dimm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 8cdc3266b3..6024627167 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -58,7 +58,8 @@ typedef struct PCDIMMDevice { /** * PCDIMMDeviceClass: - * @get_memory_region: returns #MemoryRegion associated with @dimm + * @get_memory_region: returns #MemoryRegion associated with @dimm which + * is directly mapped into the physical address space of guest */ typedef struct PCDIMMDeviceClass { /* private */ -- cgit v1.2.3 From 9f318f8f7e689b9653b42bac73047f9719a1f34e Mon Sep 17 00:00:00 2001 From: Xiao Guangrong Date: Fri, 20 May 2016 16:19:59 +0800 Subject: pc-dimm: introduce realize callback nvdimm needs to check if the backend memory is large enough to contain label data and init its memory region when the device is realized, so introduce realize callback which is called after common dimm has been realize Signed-off-by: Xiao Guangrong Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- include/hw/mem/pc-dimm.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 6024627167..67e92d8f7b 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -58,6 +58,8 @@ typedef struct PCDIMMDevice { /** * PCDIMMDeviceClass: + * @realize: called after common dimm is realized so that the dimm based + * devices get the chance to do specified operations. * @get_memory_region: returns #MemoryRegion associated with @dimm which * is directly mapped into the physical address space of guest */ @@ -66,6 +68,7 @@ typedef struct PCDIMMDeviceClass { DeviceClass parent_class; /* public */ + void (*realize)(PCDIMMDevice *dimm, Error **errp); MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm); } PCDIMMDeviceClass; -- cgit v1.2.3 From c02d7030c3c538312c7f464cb79b72c29a20df74 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Tue, 31 May 2016 10:09:54 +0200 Subject: virtio: move bi-endian target support to a single location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Paolo's recent cpu.h cleanups broke legacy virtio for ppc64 LE guests (and arm BE guests as well, even if I have not verified that). Especially, commit "33c11879fd42 qemu-common: push cpu.h inclusion out of qemu-common.h" has the side-effect of silently hiding the TARGET_IS_BIENDIAN macro from the virtio memory accessors, and thus fully disabling support of endian changing targets. To be sure this cannot happen again, let's gather all the bi-endian bits where they belong in include/hw/virtio/virtio-access.h. The changes in hw/virtio/vhost.c are safe because vhost_needs_vring_endian() is not called on a hot path and non bi-endian targets will return false anyway. While here, also rename TARGET_IS_BIENDIAN to be more precise: it is only for legacy virtio and bi-endian guests. Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Cédric Le Goater Reviewed-by: Paolo Bonzini --- include/hw/virtio/virtio-access.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h index 8dc84f5203..4b28038146 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -17,9 +17,13 @@ #include "hw/virtio/virtio.h" #include "exec/address-spaces.h" +#if defined(TARGET_PPC64) || defined(TARGET_ARM) +#define LEGACY_VIRTIO_IS_BIENDIAN 1 +#endif + static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) { -#if defined(TARGET_IS_BIENDIAN) +#if defined(LEGACY_VIRTIO_IS_BIENDIAN) return virtio_is_big_endian(vdev); #elif defined(TARGET_WORDS_BIGENDIAN) if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { -- cgit v1.2.3