Add an IPMI device to QEMU
PATCH v3 7/16 ipmi: Add documentation
In reply to [email protected]From: Corey Minyard <[email protected]>
Add some basic documentation for the IPMI device.
--- qemu-options.hx | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
qemu-options.hx +52 -0
@@ -373,6 +373,58 @@ Add device @var{driver}. @var{prop}=@var{value} sets driver properties. Valid properties depend on the driver. To get help on possible drivers and properties, use @code{-device help} and @code{-device @var{driver},help}. + +Some drivers are: +@item -device ipmi-bmc-sim,id=@var{id}[,slave_addr=@var{val}] + +Add an IPMI BMC. This is a simulation of a hardware management +interface processor that normally sits on a system. It provides +a watchdog and the ability to reset and power control the system. +You need to connect this to an IPMI interface to make it useful + +The IPMI slave address to use for the BMC. The default is 0x20. +This address is the BMC's address on the I2C network of management +controllers. If you don't know what this means, it is safe to ignore +it. + +@item -device ipmi-bmc-extern,id=@var{id},chardev=@var{id}[,slave_addr=@var{val}] + +Add a connection to an external IPMI BMC simulator. Instead of +locally emulating the BMC like the above item, instead connect +to an external entity that provides the IPMI services. + +A connection is made to an external BMC simulator. If you do this, it +is strongly recommended that you use the "reconnect=" chardev option +to reconnect to the simulator if the connection is lost. Note that if +this is not used carefully, it can be a security issue, as the +interface has the ability to send resets, NMIs, and power off the VM. +It's best if QEMU makes a connection to an external simulator running +on a secure port on localhost, so neither the simulator nor QEMU is +exposed to any outside network. + +See the "lanserv/README.vm" file in the OpenIPMI library for more +details on the external interface. + +@item -device isa-ipmi-kcs,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}] + +Add a KCS IPMI interafce on the ISA bus. This also adds a +corresponding ACPI and SMBIOS entries, if appropriate. + +@table @option +@item bmc=@var{id} +The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above. +@item ioport=@var{val} +Define the I/O address of the interface. The default is 0xca0 for KCS. +@item irq=@var{val} +Define the interrupt to use. The default is 5. To disable interrupts, +set this to 0. +@end table + +@item -device isa-ipmi-bt,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}] + +Like the KCS interface, but defines a BT interface. The default port is +0xe4 and the default interrupt is 5. + ETEXI DEF("name", HAS_ARG, QEMU_OPTION_name,
Signature · 1 line
1.8.3.1
PATCH v3 9/16 ipmi: Add a firmware configuration repository
In reply to [email protected]From: Corey Minyard <[email protected]>
Add a way for IPMI devices to register their firmware information with the IPMI subsystem so that various firmware entities can pull that information later for adding to firmware tables.
--- hw/ipmi/ipmi.c | 25 +++++++++++++++++++++++++ include/hw/ipmi/ipmi.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)
hw/ipmi/ipmi.c +25 -0
@@ -123,3 +123,28 @@ static void ipmi_register_types(void) }type_init (ipmi_register_types) + +struct fw_entry_handlers { +IPMIFwHandler handler; +void *opaque; +QSLIST_ENTRY (fw_entry_handlers) next; +}; +static QSLIST_HEAD(, fw_entry_handlers) fw_entries; + +void ipmi_add_fwinfo (IPMIFwInfo *info) +{ +struct fw_entry_handlers *e; + + QSLIST_FOREACH(e, &fw_entries, next) { + e->handler (info, e->opaque); + } +} + +void ipmi_register_fwinfo_handler (IPMIFwHandler handler,void *opaque) +{ +struct fw_entry_handlers *e =g_malloc (sizeof (*e)); + + e->handler = handler; + e->opaque = opaque; +QSLIST_INSERT_HEAD (&fw_entries, e, next); +}
include/hw/ipmi/ipmi.h +35 -0
@@ -168,6 +168,41 @@ 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; + +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 ; + +typedef void (*IPMIFwHandler )(IPMIFwInfo *info,void *opaque); + +void ipmi_add_fwinfo (IPMIFwInfo *info); +void ipmi_register_fwinfo_handler (IPMIFwHandler handler,void *opaque); +#ifdef IPMI_DEBUG #define ipmi_debug (fs, ...) \ fprintf(stderr, "IPMI (%s): " fs, __func__, ##__VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH v3 10/16 ipmi: Add firmware registration to the ISA interface
In reply to [email protected]From: Corey Minyard <[email protected]>
--- hw/ipmi/isa_ipmi_bt.c | 15 +++++++++++++++ hw/ipmi/isa_ipmi_kcs.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+)
hw/ipmi/isa_ipmi_bt.c +15 -0
@@ -407,6 +407,7 @@ typedef struct ISAIPMIBTDevice {ISADevice dev;int32 isairq;IPMIBT bt; +IPMIFwInfo fwinfo; } ISAIPMIBTDevice;static void isa_ipmi_bt_realize (DeviceState *dev,Error **errp)
@@ -435,6 +436,20 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)qdev_set_legacy_instance_id (dev, iib->bt.io_base, iib->bt.io_length);isa_register_ioport (isadev, &iib->bt.io, iib->bt.io_base); + + iib->fwinfo.interface_name ="bt" ; + iib->fwinfo.interface_type =IPMI_SMBIOS_BT ; + iib->fwinfo.ipmi_spec_major_revision =2 ; + iib->fwinfo.ipmi_spec_minor_revision =0 ; + iib->fwinfo.base_address = iib->bt.io_base; + iib->fwinfo.register_length = iib->bt.io_length; + iib->fwinfo.register_spacing =1 ; + iib->fwinfo.memspace =IPMI_MEMSPACE_IO ; + iib->fwinfo.irq_type =IPMI_LEVEL_IRQ ; + iib->fwinfo.interrupt_number = iib->isairq; + iib->fwinfo.acpi_parent ="\\_SB.PCI0.ISA" ; + iib->fwinfo.i2c_slave_address = iib->bt.bmc->slave_addr; +ipmi_add_fwinfo (&iib->fwinfo); }static const VMStateDescription vmstate_ISAIPMIBTDevice = {
hw/ipmi/isa_ipmi_kcs.c +15 -0
@@ -370,6 +370,7 @@ typedef struct ISAIPMIKCSDevice {ISADevice dev;int32 isairq;IPMIKCS kcs; +IPMIFwInfo fwinfo; } ISAIPMIKCSDevice;static void ipmi_isa_realize (DeviceState *dev,Error **errp)
@@ -398,6 +399,20 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp)qdev_set_legacy_instance_id (dev, iik->kcs.io_base, iik->kcs.io_length);isa_register_ioport (isadev, &iik->kcs.io, iik->kcs.io_base); + + iik->fwinfo.interface_name ="kcs" ; + iik->fwinfo.interface_type =IPMI_SMBIOS_KCS ; + iik->fwinfo.ipmi_spec_major_revision =2 ; + iik->fwinfo.ipmi_spec_minor_revision =0 ; + iik->fwinfo.base_address = iik->kcs.io_base; + iik->fwinfo.i2c_slave_address = iik->kcs.bmc->slave_addr; + iik->fwinfo.register_length = iik->kcs.io_length; + iik->fwinfo.register_spacing =1 ; + iik->fwinfo.memspace =IPMI_MEMSPACE_IO ; + iik->fwinfo.irq_type =IPMI_LEVEL_IRQ ; + iik->fwinfo.interrupt_number = iik->isairq; + iik->fwinfo.acpi_parent ="\\_SB.PCI0.ISA" ; +ipmi_add_fwinfo (&iik->fwinfo); }const VMStateDescription vmstate_ISAIPMIKCSDevice = {
Signature · 1 line
1.8.3.1
PATCH v3 12/16 pc: Postpone SMBIOS table installation to post machine init
In reply to [email protected]From: Corey Minyard <[email protected]>
This is the same place that the ACPI SSDT table gets added, so that devices can add themselves to the SMBIOS table.
--- hw/i386/pc.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
hw/i386/pc.c +18 -17
@@ -680,8 +680,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_tables, *smbios_anchor; -size_t smbios_tables_len, smbios_anchor_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);
@@ -707,21 +705,6 @@ static FWCfgState *bochs_bios_init(void) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_tables =smbios_get_table_legacy (&smbios_tables_len); -if (smbios_tables) { -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_tables, smbios_tables_len); - } - -smbios_get_tables (&smbios_tables, &smbios_tables_len, - &smbios_anchor, &smbios_anchor_len); -if (smbios_anchor) { -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , - smbios_tables, smbios_tables_len); -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , - smbios_anchor, smbios_anchor_len); - } -fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_reserve,sizeof (e820_reserve)); fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
@@ -1119,7 +1102,25 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)PcGuestInfoState *guest_info_state =container_of (notifier, PcGuestInfoState, machine_done); +uint8_t *smbios_tables, *smbios_anchor; +size_t smbios_tables_len, smbios_anchor_len; +FWCfgState *fw_cfg = guest_info_state->info.fw_cfg; +acpi_setup (&guest_info_state->info); + + smbios_tables =smbios_get_table_legacy (&smbios_tables_len); +if (smbios_tables) { +fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_tables, smbios_tables_len); + } +smbios_get_tables (&smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len); +if (smbios_anchor) { +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , + smbios_tables, smbios_tables_len); +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , + smbios_anchor, smbios_anchor_len); + } } PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
Signature · 1 line
1.8.3.1
PATCH v3 8/16 ipmi: Add migration capability to the IPMI devices.
In reply to [email protected]From: Corey Minyard <[email protected]>
--- hw/ipmi/ipmi_bmc_extern.c | 34 ++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 30 ++++++++++++++++++++++++++++++ hw/ipmi/isa_ipmi_bt.c | 24 ++++++++++++++++++++++++ hw/ipmi/isa_ipmi_kcs.c | 26 ++++++++++++++++++++++++++ 4 files changed, 114 insertions(+)
hw/ipmi/ipmi_bmc_extern.c +34 -0
@@ -439,11 +439,45 @@ static void ipmi_bmc_extern_realize(DeviceState *dev, Error **errp)qemu_chr_add_handlers (ibe->chr, can_receive, receive, chr_event, ibe); } +static int ipmi_bmc_extern_post_migrate (void *opaque,int version_id) +{ +IPMIBmcExtern *ibe = opaque; + +/* +* We don't directly restore waiting_rsp, Instead, we return an +* error on the interface if a response was being waited for. +*/ +if (ibe->waiting_rsp) { +IPMIInterface *ii = ibe->parent.intf; +IPMIInterfaceClass *iic =IPMI_INTERFACE_GET_CLASS (ii); + + ibe->waiting_rsp = false; + ibe->inbuf[1 ] = ibe->outbuf[1 ] |0x04 ; + ibe->inbuf[2 ] = ibe->outbuf[2 ]; + ibe->inbuf[3 ] =IPMI_CC_BMC_INIT_IN_PROGRESS ; + iic->handle_rsp (ii, ibe->outbuf[0 ], ibe->inbuf +1 ,3 ); + } +return 0 ; +} + +static const VMStateDescription vmstate_ipmi_bmc_extern = { + .name =TYPE_IPMI_BMC_EXTERN , + .version_id =1 , + .minimum_version_id =1 , + .post_load = ipmi_bmc_extern_post_migrate, + .fields = (VMStateField []) { +VMSTATE_BOOL (send_reset, IPMIBmcExtern), +VMSTATE_BOOL (waiting_rsp, IPMIBmcExtern), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_bmc_extern_init (Object *obj) {IPMIBmcExtern *ibe =IPMI_BMC_EXTERN (obj); ibe->extern_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , extern_timeout, ibe); +vmstate_register (NULL ,0 , &vmstate_ipmi_bmc_extern, ibe); }static Property ipmi_bmc_extern_properties[] = {
hw/ipmi/ipmi_bmc_sim.c +30 -0
@@ -1658,6 +1658,34 @@ static const uint8_t init_sdrs[] = {0xff ,0xff ,0x00 ,0x00 ,0x00 }; +static const VMStateDescription vmstate_ipmi_sim = { + .name =TYPE_IPMI_BMC_SIMULATOR , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (bmc_global_enables, IPMIBmcSim), +VMSTATE_UINT8 (msg_flags, IPMIBmcSim), +VMSTATE_BOOL (watchdog_initialized, IPMIBmcSim), +VMSTATE_UINT8 (watchdog_use, IPMIBmcSim), +VMSTATE_UINT8 (watchdog_action, IPMIBmcSim), +VMSTATE_UINT8 (watchdog_pretimeout, IPMIBmcSim), +VMSTATE_BOOL (watchdog_expired, IPMIBmcSim), +VMSTATE_UINT16 (watchdog_timeout, IPMIBmcSim), +VMSTATE_BOOL (watchdog_running, IPMIBmcSim), +VMSTATE_BOOL (watchdog_preaction_ran, IPMIBmcSim), +VMSTATE_INT64 (watchdog_expiry, IPMIBmcSim), +VMSTATE_UINT8_ARRAY (evtbuf, IPMIBmcSim,16 ), +VMSTATE_UINT8 (sensors[IPMI_WATCHDOG_SENSOR ].status, IPMIBmcSim), +VMSTATE_UINT8 (sensors[IPMI_WATCHDOG_SENSOR ].reading, IPMIBmcSim), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].states, IPMIBmcSim), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].assert_states, IPMIBmcSim), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].deassert_states, + IPMIBmcSim), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].assert_enable, IPMIBmcSim), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_sim_init (Object *obj) {IPMIBmc *b =IPMI_BMC (obj);
@@ -1706,6 +1734,8 @@ static void ipmi_sim_init(Object *obj)register_cmds (ibs); ibs->timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , ipmi_timeout, ibs); + +vmstate_register (NULL ,0 , &vmstate_ipmi_sim, ibs); }static void ipmi_sim_class_init (ObjectClass *oc,void *data)
hw/ipmi/isa_ipmi_bt.c +24 -0
@@ -437,11 +437,35 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)isa_register_ioport (isadev, &iib->bt.io, iib->bt.io_base); } +static const VMStateDescription vmstate_ISAIPMIBTDevice = { + .name =TYPE_IPMI_INTERFACE , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_BOOL (bt.obf_irq_set, ISAIPMIBTDevice), +VMSTATE_BOOL (bt.atn_irq_set, ISAIPMIBTDevice), +VMSTATE_BOOL (bt.use_irq, ISAIPMIBTDevice), +VMSTATE_BOOL (bt.irqs_enabled, ISAIPMIBTDevice), +VMSTATE_UINT32 (bt.outpos, ISAIPMIBTDevice), +VMSTATE_VBUFFER_UINT32 (bt.outmsg, ISAIPMIBTDevice,1 ,NULL ,0 , + bt.outlen), +VMSTATE_VBUFFER_UINT32 (bt.inmsg, ISAIPMIBTDevice,1 ,NULL ,0 , + bt.inlen), +VMSTATE_UINT8 (bt.control_reg, ISAIPMIBTDevice), +VMSTATE_UINT8 (bt.mask_reg, ISAIPMIBTDevice), +VMSTATE_UINT8 (bt.waiting_rsp, ISAIPMIBTDevice), +VMSTATE_UINT8 (bt.waiting_seq, ISAIPMIBTDevice), +VMSTATE_END_OF_LIST () + } +}; +static void isa_ipmi_bt_init (Object *obj) {ISAIPMIBTDevice *iib =ISA_IPMI_BT (obj);ipmi_bmc_find_and_link (obj, (Object **) &iib->bt.bmc); + +vmstate_register (NULL ,0 , &vmstate_ISAIPMIBTDevice, iib); }static void *isa_ipmi_bt_get_backend_data (IPMIInterface *ii)
hw/ipmi/isa_ipmi_kcs.c +26 -0
@@ -400,11 +400,37 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp)isa_register_ioport (isadev, &iik->kcs.io, iik->kcs.io_base); } +const VMStateDescription vmstate_ISAIPMIKCSDevice = { + .name =TYPE_IPMI_INTERFACE , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_BOOL (kcs.obf_irq_set, ISAIPMIKCSDevice), +VMSTATE_BOOL (kcs.atn_irq_set, ISAIPMIKCSDevice), +VMSTATE_BOOL (kcs.use_irq, ISAIPMIKCSDevice), +VMSTATE_BOOL (kcs.irqs_enabled, ISAIPMIKCSDevice), +VMSTATE_UINT32 (kcs.outpos, ISAIPMIKCSDevice), +VMSTATE_VBUFFER_UINT32 (kcs.outmsg, ISAIPMIKCSDevice,1 ,NULL ,0 , + kcs.outlen), +VMSTATE_VBUFFER_UINT32 (kcs.inmsg, ISAIPMIKCSDevice,1 ,NULL ,0 , + kcs.inlen), +VMSTATE_BOOL (kcs.write_end, ISAIPMIKCSDevice), +VMSTATE_UINT8 (kcs.status_reg, ISAIPMIKCSDevice), +VMSTATE_UINT8 (kcs.data_out_reg, ISAIPMIKCSDevice), +VMSTATE_INT16 (kcs.data_in_reg, ISAIPMIKCSDevice), +VMSTATE_INT16 (kcs.cmd_reg, ISAIPMIKCSDevice), +VMSTATE_UINT8 (kcs.waiting_rsp, ISAIPMIKCSDevice), +VMSTATE_END_OF_LIST () + } +}; +static void isa_ipmi_kcs_init (Object *obj) {ISAIPMIKCSDevice *iik =ISA_IPMI_KCS (obj);ipmi_bmc_find_and_link (obj, (Object **) &iik->kcs.bmc); + +vmstate_register (NULL ,0 , &vmstate_ISAIPMIKCSDevice, iik); }static void *isa_ipmi_kcs_get_backend_data (IPMIInterface *ii)
Signature · 1 line
1.8.3.1
PATCH v3 11/16 smbios: Add a function to directly add an entry
In reply to [email protected]From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
--- hw/i386/smbios.c | 153 +++++++++++++++++++++++++++++++---------------- include/hw/i386/smbios.h | 8 +++ 2 files changed, 109 insertions(+), 52 deletions(-)
hw/i386/smbios.c +101 -52
@@ -831,6 +831,92 @@ static void smbios_entry_point_setup(void) ep.structure_table_address =cpu_to_le32 (0 ); } +struct smbios_table_entry { +void *data; +int size; +bool append_zeros; +QSLIST_ENTRY (smbios_table_entry) next; +}; + +static QSLIST_HEAD(, smbios_table_entry) table_entries; + +void smbios_add_table_entry (void *data,int size,bool append_zeros) +{ +struct smbios_table_entry *e =g_malloc (sizeof (*e)); + + e->data =g_malloc (size); +memcpy (e->data, data, size); + e->size = size; + e->append_zeros = append_zeros; +QSLIST_INSERT_HEAD (&table_entries, e, next); +} + +static void smbios_table_entry_append (void *data,int size,bool append_zeros) +{ +struct smbios_structure_header *header; +struct smbios_table *table;/* legacy mode only */ + +/* +* NOTE: standard double '\0' terminator expected, per smbios spec. +* (except in legacy mode, where the second '\0' is implicit and +* will be inserted by the BIOS). +*/ +if (append_zeros) { + size +=2 ; + } + smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); + header = (struct smbios_structure_header *)(smbios_tables + + smbios_tables_len); + +memcpy (header, data, size); +if (append_zeros) { +memset (smbios_tables + smbios_tables_len + size -2 ,0 ,2 ); + } + +if (test_bit (header->type, have_fields_bitmap)) { +error_report ("can't load type %d struct, fields already specified!" , + header->type); +exit (1 ); + } +set_bit (header->type, have_binfile_bitmap); + +if (header->type ==4 ) { + smbios_type4_count++; + } + + smbios_tables_len += size; +if (size > smbios_table_max) { + smbios_table_max = size; + } + smbios_table_cnt++; + +/* add a copy of the newly loaded blob to legacy smbios_entries */ +/* NOTE: This code runs before smbios_set_defaults(), so we don't +* yet know which mode (legacy vs. aggregate-table) will be +* required. We therefore add the binary blob to both legacy +* (smbios_entries) and aggregate (smbios_tables) tables, and +* delete the one we don't need from smbios_set_defaults(), +* once we know which machine version has been requested. +*/ +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } +if (append_zeros) { + size -=1 ;/* The BIOS adds the second zero in legacy mode. */ + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + + size +sizeof (*table)); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); +memcpy (table->data, header, size); + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +/* end: add a copy of the newly loaded blob to legacy smbios_entries */ +} +void smbios_get_tables (uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len) {
@@ -875,6 +961,16 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, }smbios_build_type_32_table (); + +while (!QSLIST_EMPTY (&table_entries)) { +struct smbios_table_entry *e =QSLIST_FIRST (&table_entries); + +QSLIST_REMOVE_HEAD (&table_entries, next); +smbios_table_entry_append (e->data, e->size, e->append_zeros); +g_free (e->data); +g_free (e); + } +smbios_build_type_127_table ();smbios_validate_table ();
@@ -907,9 +1003,8 @@ void smbios_entry_add(QemuOpts *opts) val =qemu_opt_get (opts,"file" );if (val) { -struct smbios_structure_header *header;int size; -struct smbios_table *table;/* legacy mode only */ +uint8_t *data;qemu_opts_validate (opts, qemu_smbios_file_opts, &local_err);if (local_err) {
@@ -923,60 +1018,14 @@ void smbios_entry_add(QemuOpts *opts)exit (1 ); } -/* -* NOTE: standard double '\0' terminator expected, per smbios spec. -* (except in legacy mode, where the second '\0' is implicit and -* will be inserted by the BIOS). -*/ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); - header = (struct smbios_structure_header *)(smbios_tables + - smbios_tables_len); - -if (load_image (val, (uint8_t *)header) != size) { + data =g_malloc (size); +if (load_image (val, data) != size) {error_report ("Failed to load SMBIOS file %s" , val);exit (1 ); } -if (test_bit (header->type, have_fields_bitmap)) { -error_report ("can't load type %d struct, fields already specified!" , - header->type); -exit (1 ); - } -set_bit (header->type, have_binfile_bitmap); - -if (header->type ==4 ) { - smbios_type4_count++; - } - - smbios_tables_len += size; -if (size > smbios_table_max) { - smbios_table_max = size; - } - smbios_table_cnt++; - -/* add a copy of the newly loaded blob to legacy smbios_entries */ -/* NOTE: This code runs before smbios_set_defaults(), so we don't -* yet know which mode (legacy vs. aggregate-table) will be -* required. We therefore add the binary blob to both legacy -* (smbios_entries) and aggregate (smbios_tables) tables, and -* delete the one we don't need from smbios_set_defaults(), -* once we know which machine version has been requested. -*/ -if (!smbios_entries) { - smbios_entries_len =sizeof (uint16_t ); - smbios_entries =g_malloc0 (smbios_entries_len); - } - smbios_entries =g_realloc (smbios_entries, smbios_entries_len + - size +sizeof (*table)); - table = (struct smbios_table *)(smbios_entries + smbios_entries_len); - table->header.type =SMBIOS_TABLE_ENTRY ; - table->header.length =cpu_to_le16 (sizeof (*table) + size); -memcpy (table->data, header, size); - smbios_entries_len +=sizeof (*table) + size; - (*(uint16_t *)smbios_entries) = -cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); -/* end: add a copy of the newly loaded blob to legacy smbios_entries */ - +smbios_table_entry_append (data, size, false); +g_free (data);return ; }
include/hw/i386/smbios.h +8 -0
@@ -27,6 +27,14 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len);/* +* Add an external entry to the SMBIOS table. Can only be called +* from a registered device table handler. This will store the +* given data in a queue and append it when the SMBIOS table is +* built. +*/ +void smbios_add_table_entry (void *data,int size,bool append_zeros); + +/* * SMBIOS spec defined tables */
Signature · 1 line
1.8.3.1
PATCH v3 13/16 ipmi: Add SMBIOS table entry
In reply to [email protected]From: Corey Minyard <[email protected]>
Add an IPMI table entry to the SMBIOS.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_smbios.c | 89 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 hw/ipmi/ipmi_smbios.c
default-configs/i386-softmmu.mak +1 -0
@@ -19,6 +19,7 @@ CONFIG_I8254=y CONFIG_PCSPK=y CONFIG_PCKBD=y CONFIG_FDC=y +CONFIG_SMBIOS=y CONFIG_ACPI=y CONFIG_APM=y CONFIG_I8257=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -19,6 +19,7 @@ CONFIG_I8254=y CONFIG_PCSPK=y CONFIG_PCKBD=y CONFIG_FDC=y +CONFIG_SMBIOS=y CONFIG_ACPI=y CONFIG_APM=y CONFIG_I8257=y
hw/ipmi/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o +common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_SMBIOS)) += ipmi_smbios.o
hw/ipmi/ipmi_smbios.c new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 15/16 ipmi: Add ACPI table entries
In reply to [email protected]From: Corey Minyard <[email protected]>
Use the new ACPI table construction tools to create an ACPI entry for IPMI.
--- hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_acpi.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 hw/ipmi/ipmi_acpi.c
hw/ipmi/Makefile.objs +1 -0
@@ -4,3 +4,4 @@ common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_SMBIOS)) += ipmi_smbios.o +common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_ACPI)) += ipmi_acpi.o
hw/ipmi/ipmi_acpi.c new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 14/16 acpi: Add a way for devices to add ACPI tables
In reply to [email protected]From: Corey Minyard <[email protected]>
Some devices, like IPMI, need to add ACPI table entries to report their presence. Add a method for adding these entries.
--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-dev-tables.c | 80 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 17 +++++++++ include/hw/acpi/acpi-dev-tables.h | 38 +++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 hw/acpi/acpi-dev-tables.c create mode 100644 include/hw/acpi/acpi-dev-tables.h
hw/acpi/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.o +common-obj-$(CONFIG_ACPI) += acpi-dev-tables.o
hw/acpi/acpi-dev-tables.c new file +80 -0
80 lines not on this page · raw message
hw/i386/acpi-build.c +17 -0
@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-dev-tables.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h"
@@ -1377,6 +1378,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)AcpiMcfgInfo mcfg;PcPciInfo pci;uint8_t *u; +struct acpi_dev_table *dt;size_t aml_len =0 ;GArray *tables_blob = tables->table_data;
@@ -1448,6 +1450,21 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)build_dmar_q35 (tables_blob, tables->linker); } +/* Add tables from devices. */ +for (dt =acpi_dev_table_first (); dt; dt =acpi_dev_table_next (dt)) { +unsigned len =acpi_dev_table_len (dt); +void *data =acpi_dev_table_data (dt); + +acpi_add_table (table_offsets, tables_blob); +acpi_data_push (tables_blob,sizeof (AcpiTableHeader)); +g_array_append_vals (tables_blob, data, len); +build_header (tables->linker, tables_blob, + (void *)(tables_blob->data + tables_blob->len - + len -sizeof (AcpiTableHeader)), +acpi_dev_table_sig (dt), len +sizeof (AcpiTableHeader), +acpi_dev_table_rev (dt)); + } +/* Add tables supplied by user (if any) */ for (u =acpi_table_first (); u; u =acpi_table_next (u)) {unsigned len =acpi_table_len (u);
include/hw/acpi/acpi-dev-tables.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Add and get ACPI tables registered by devices. +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_acpi_dev_table (void *data,int size,const char *sig,uint8_t rev); + +struct acpi_dev_table ; + +struct acpi_dev_table *acpi_dev_table_first (void ); +struct acpi_dev_table *acpi_dev_table_next (struct acpi_dev_table *current); +uint8_t *acpi_dev_table_data (struct acpi_dev_table *); +unsigned acpi_dev_table_len (struct acpi_dev_table *); +const char *acpi_dev_table_sig (struct acpi_dev_table *); +uint8_t acpi_dev_table_rev (struct acpi_dev_table *); + +#endif /* QEMU_HW_ACPI_HOOKS_H */
Signature · 1 line
1.8.3.1
PATCH v3 16/16 bios: Add tests for the IPMI ACPI and SMBIOS entries
In reply to [email protected]From: Corey Minyard <[email protected]>
--- tests/bios-tables-test.c | 114 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 109 insertions(+), 5 deletions(-)
tests/bios-tables-test.c +109 -5
@@ -51,6 +51,10 @@ typedef struct {GArray *tables;uint32_t smbios_ep_addr;struct smbios_entry_point smbios_ep_table; +uint8_t *ssdt_compare; +int ssdt_compare_len; +uint8_t *required_struct_types; +int required_struct_types_len; } test_data;#define LOW (x) ((x) & 0xff)
@@ -105,6 +109,12 @@ typedef struct {ACPI_READ_FIELD ((table)->asl_compiler_revision, addr); \ }while (0 ); +static bool acpi_cmp32 (uint32_t actual,const char *expected) +{ + actual =cpu_to_le32 (actual); +return memcmp (&actual, expected,4 ) ==0 ; +} +#define ACPI_ASSERT_CMP (actual, expected) do { \ uint32_t ACPI_ASSERT_CMP_le = cpu_to_le32(actual); \ char ACPI_ASSERT_CMP_str[5] = {}; \
@@ -376,15 +386,28 @@ static void test_acpi_tables(test_data *data) {int tables_nr = data->rsdt_tables_nr -1 ;/* fadt is first */ int i; +bool match_found = !data->ssdt_compare;for (i =0 ; i < tables_nr; i++) {AcpiSdtTable ssdt_table; -memset (&ssdt_table,0 ,sizeof (ssdt_table)); +memset (&ssdt_table,0 ,sizeof (ssdt_table));uint32_t addr = data->rsdt_tables_addr[i +1 ];/* fadt is first */ test_dst_table (&ssdt_table, addr); -g_array_append_val (data->tables, ssdt_table); + +if (data->ssdt_compare && +acpi_cmp32 (ssdt_table.header.signature,"SSDT" ) && + data->ssdt_compare_len == ssdt_table.aml_len && +memcmp (data->ssdt_compare, ssdt_table.aml, + ssdt_table.aml_len) ==0 ) { + match_found = true; +g_free (ssdt_table.aml); + }else { +g_array_append_val (data->tables, ssdt_table); + } } + +g_assert (match_found); }static void dump_aml_files (test_data *data,bool rebuild)
@@ -672,7 +695,6 @@ static void test_smbios_structs(test_data *data)uint32_t addr = ep_table->structure_table_address;int i, len, max_len =0 ;uint8_t type, prv, crt; -uint8_t required_struct_types[] = {0 ,1 ,3 ,4 ,16 ,17 ,19 ,32 ,127 };/* walk the smbios tables */ for (i =0 ; i < ep_table->number_of_structures; i++) {
@@ -712,8 +734,8 @@ static void test_smbios_structs(test_data *data) g_assert_cmpuint(ep_table->max_structure_size, ==, max_len);/* required struct types must all be present */ -for (i =0 ; i <ARRAY_SIZE (required_struct_types); i++) { -g_assert (test_bit (required_struct_types[i], struct_bitmap)); +for (i =0 ; i < data->required_struct_types_len; i++) { +g_assert (test_bit (data->required_struct_types[i], struct_bitmap)); } }
@@ -775,6 +797,9 @@ static void test_acpi_one(const char *params, test_data *data)g_free (args); } +static uint8_t base_required_struct_types[] = + {0 ,1 ,3 ,4 ,16 ,17 ,19 ,32 ,127 }; +static void test_acpi_piix4_tcg (void ) {test_data data;
@@ -784,6 +809,8 @@ static void test_acpi_piix4_tcg(void)*/ memset (&data,0 ,sizeof (data)); data.machine =MACHINE_PC ; + data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-machine accel=tcg" , &data);free_test_data (&data); }
@@ -795,6 +822,8 @@ static void test_acpi_piix4_tcg_bridge(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_PC ; data.variant =".bridge" ; + data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-machine accel=tcg -device pci-bridge,chassis_nr=1" , &data);free_test_data (&data); }
@@ -805,6 +834,8 @@ static void test_acpi_q35_tcg(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_Q35 ; + data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-machine q35,accel=tcg" , &data);free_test_data (&data); }
@@ -816,11 +847,82 @@ static void test_acpi_q35_tcg_bridge(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_Q35 ; data.variant =".bridge" ; + data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1" , &data);free_test_data (&data); } +static uint8_t ipmi_ssdt_bt_irq5[] = { +0x10 ,0x42 ,0x06 ,0x5c ,0x2f ,0x03 ,0x5f ,0x53 , +0x42 ,0x5f ,0x50 ,0x43 ,0x49 ,0x30 ,0x49 ,0x53 , +0x41 ,0x5f ,0x5b ,0x82 ,0x4f ,0x04 ,0x4d ,0x49 , +0x30 ,0x5f ,0x08 ,0x5f ,0x48 ,0x49 ,0x44 ,0x0c , +0x26 ,0x09 ,0x00 ,0x01 ,0x08 ,0x5f ,0x53 ,0x54 , +0x52 ,0x0d ,0x69 ,0x70 ,0x6d ,0x69 ,0x5f ,0x62 , +0x74 ,0x00 ,0x08 ,0x5f ,0x55 ,0x49 ,0x44 ,0x00 , +0x08 ,0x5f ,0x43 ,0x52 ,0x53 ,0x11 ,0x10 ,0x0a , +0x0d ,0x47 ,0x01 ,0xe4 ,0x00 ,0xe6 ,0x00 ,0x00 , +0x03 ,0x22 ,0x20 ,0x00 ,0x79 ,0x00 ,0x14 ,0x09 , +0x5f ,0x49 ,0x46 ,0x54 ,0x00 ,0xa4 ,0x0a ,0x03 , +0x14 ,0x0a ,0x5f ,0x53 ,0x52 ,0x56 ,0x00 ,0xa4 , +0x0b ,0x00 ,0x02 +}; + +static uint8_t ipmi_ssdt_kcs_irq0[] = { +0x10 ,0x4f ,0x05 ,0x5c ,0x2f ,0x03 ,0x5f ,0x53 , +0x42 ,0x5f ,0x50 ,0x43 ,0x49 ,0x30 ,0x49 ,0x53 , +0x41 ,0x5f ,0x5b ,0x82 ,0x4c ,0x04 ,0x4d ,0x49 , +0x30 ,0x5f ,0x08 ,0x5f ,0x48 ,0x49 ,0x44 ,0x0c , +0x26 ,0x09 ,0x00 ,0x01 ,0x08 ,0x5f ,0x53 ,0x54 , +0x52 ,0x0d ,0x69 ,0x70 ,0x6d ,0x69 ,0x5f ,0x6b , +0x63 ,0x73 ,0x00 ,0x08 ,0x5f ,0x55 ,0x49 ,0x44 , +0x00 ,0x08 ,0x5f ,0x43 ,0x52 ,0x53 ,0x11 ,0x0d , +0x0a ,0x0a ,0x47 ,0x01 ,0xa2 ,0x0c ,0xa3 ,0x0c , +0x00 ,0x02 ,0x79 ,0x00 ,0x14 ,0x08 ,0x5f ,0x49 , +0x46 ,0x54 ,0x00 ,0xa4 ,0x01 ,0x14 ,0x0a ,0x5f , +0x53 ,0x52 ,0x56 ,0x00 ,0xa4 ,0x0b ,0x00 ,0x02 +}; + +static uint8_t ipmi_required_struct_types[] = + {0 ,1 ,3 ,4 ,16 ,17 ,19 ,32 ,38 ,127 }; + +static void test_acpi_q35_tcg_ipmi (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.ssdt_compare = ipmi_ssdt_bt_irq5; + data.ssdt_compare_len =sizeof (ipmi_ssdt_bt_irq5); + data.required_struct_types = ipmi_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (ipmi_required_struct_types); +test_acpi_one ("-machine q35,accel=tcg -device ipmi-bmc-sim,id=bmc0" +" -device isa-ipmi-bt,bmc=bmc0" , + &data); +free_test_data (&data); +} + +static void test_acpi_piix4_tcg_ipmi (void ) +{ +test_data data; + +/* Supplying -machine accel argument overrides the default (qtest). +* This is to make guest actually run. +*/ +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ; + data.ssdt_compare = ipmi_ssdt_kcs_irq0; + data.ssdt_compare_len =sizeof (ipmi_ssdt_kcs_irq0); + data.required_struct_types = ipmi_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (ipmi_required_struct_types); +test_acpi_one ("-machine accel=tcg -device ipmi-bmc-sim,id=bmc0" +" -device isa-ipmi-kcs,irq=0,bmc=bmc0" , + &data); +free_test_data (&data); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();
@@ -841,6 +943,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/piix4/tcg/bridge" , test_acpi_piix4_tcg_bridge);qtest_add_func ("acpi/q35/tcg" , test_acpi_q35_tcg);qtest_add_func ("acpi/q35/tcg/bridge" , test_acpi_q35_tcg_bridge); +qtest_add_func ("acpi/piix4/tcg/ipmi" , test_acpi_piix4_tcg_ipmi); +qtest_add_func ("acpi/q35/tcg/ipmi" , test_acpi_q35_tcg_ipmi); } ret =g_test_run ();unlink (disk);
Signature · 1 line
1.8.3.1
PATCH v3 6/16 ipmi: Add tests
In reply to [email protected]From: Corey Minyard <[email protected]>
Test the KCS interface with a local BMC and a BT interface with an external BMC.
--- tests/Makefile | 4 + tests/ipmi-bt-test.c | 441 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ipmi-kcs-test.c | 295 +++++++++++++++++++++++++++++++++ 3 files changed, 740 insertions(+) create mode 100644 tests/ipmi-bt-test.c create mode 100644 tests/ipmi-kcs-test.c
tests/Makefile +4 -0
@@ -146,6 +146,8 @@ gcov-files-i386-y += hw/block/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/bios-tables-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-i386-y += tests/drive_del-test$(EXESUF)
@@ -326,6 +328,8 @@ tests/spapr-phb-test$(EXESUF): tests/spapr-phb-test.o $(libqos-obj-y) tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y) +tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o +tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o $(libqos-obj-y)
tests/ipmi-bt-test.c new file +441 -0
441 lines not on this page · raw message
tests/ipmi-kcs-test.c new file +295 -0
295 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 1/16 Add a base IPMI interface
In reply to [email protected]From: Corey Minyard <[email protected]>
Add the basic IPMI types and infrastructure to QEMU. Low-level interfaces and simulation interfaces will register with this; it's kind of the go-between to tie them together.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi.c | 125 ++++++++++++++++++++++++++ include/hw/ipmi/ipmi.h | 178 +++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 2 + 7 files changed, 309 insertions(+) create mode 100644 hw/ipmi/Makefile.objs create mode 100644 hw/ipmi/ipmi.c create mode 100644 include/hw/ipmi/ipmi.h
default-configs/i386-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_VGA_ISA=y CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y +CONFIG_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_VGA_ISA=y CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y +CONFIG_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += ide/ devices-dirs-$(CONFIG_SOFTMMU) += input/ devices-dirs-$(CONFIG_SOFTMMU) += intc/ devices-dirs-$(CONFIG_IPACK) += ipack/ +devices-dirs-$(CONFIG_IPMI) += ipmi/ devices-dirs-$(CONFIG_SOFTMMU) += isa/ devices-dirs-$(CONFIG_SOFTMMU) += misc/ devices-dirs-$(CONFIG_SOFTMMU) += net/
hw/ipmi/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +common-obj-$(CONFIG_IPMI) += ipmi.o
hw/ipmi/ipmi.c new file +125 -0
125 lines not on this page · raw message
include/hw/ipmi/ipmi.h new file +178 -0
178 lines not on this page · raw message
qemu-doc.texi +2 -0
@@ -195,6 +195,8 @@ PCI and ISA network adapters @item Serial ports @item +IPMI BMC, either and internal or external one +@item Creative SoundBlaster 16 sound card @item ENSONIQ AudioPCI ES1370 sound card
Signature · 1 line
1.8.3.1
PATCH v3 5/16 ipmi: Add a BT low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the BT hardware interface for IPMI.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi_bt.c | 489 +++++++++++++++++++++++++++++++++++++ 4 files changed, 492 insertions(+) create mode 100644 hw/ipmi/isa_ipmi_bt.c
default-configs/i386-softmmu.mak +1 -0
@@ -12,6 +12,7 @@ CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y CONFIG_ISA_IPMI_KCS=y +CONFIG_ISA_IPMI_BT=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -12,6 +12,7 @@ CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y CONFIG_ISA_IPMI_KCS=y +CONFIG_ISA_IPMI_BT=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -2,3 +2,4 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o +common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o
hw/ipmi/isa_ipmi_bt.c new file +489 -0
489 lines not on this page · raw message
Signature · 1 line
1.8.3.1
v3 cover Add an IPMI device to QEMU
I have reworked the QEMU IPMI patches, and I believe this design improves greatly on the previous one. The suggestions made all resulted in better design. To start an IPMI interface with this, you would use:
-device ipmi-bmc-sim,id=bmc0 -device isa-ipmi-bt,bmc=bmc0
Note that I did not make the BMCs objects. I started this way, but adding properties was ending up duplicating a lot of code already in the device core, especially for the chardev link.
I'm not sure of the importance of having a BMC be an object instead of a device, but it seems to me that if we do that, it would be best to add helper functions to the object core for the chardev and integer properties.
Thanks,
-corey
PATCH v3 3/16 ipmi: Add an external connection simulation interface
From: Corey Minyard <[email protected]>
This adds an interface for IPMI that connects to a remote BMC over a chardev (generally a TCP socket). The OpenIPMI lanserv simulator describes this interface, see that for interface details.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_bmc_extern.c | 478 +++++++++++++++++++++++++++++++++++++ 4 files changed, 481 insertions(+) create mode 100644 hw/ipmi/ipmi_bmc_extern.c
default-configs/i386-softmmu.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y +CONFIG_IPMI_EXTERN=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y +CONFIG_IPMI_EXTERN=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o +common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o
hw/ipmi/ipmi_bmc_extern.c new file +478 -0
478 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 4/16 ipmi: Add an ISA KCS low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the KCS hardware interface.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi_kcs.c | 452 +++++++++++++++++++++++++++++++++++++ 4 files changed, 455 insertions(+) create mode 100644 hw/ipmi/isa_ipmi_kcs.c
default-configs/i386-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y +CONFIG_ISA_IPMI_KCS=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y +CONFIG_ISA_IPMI_KCS=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -1,3 +1,4 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o +common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o
hw/ipmi/isa_ipmi_kcs.c new file +452 -0
452 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 2/16 ipmi: Add a local BMC simulation
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides a minimal local BMC, basically enough to comply with the spec and provide a complete watchdog timer (including a sensor, SDR, and event).
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_bmc_sim.c | 1731 ++++++++++++++++++++++++++++++++++++ 4 files changed, 1734 insertions(+) create mode 100644 hw/ipmi/ipmi_bmc_sim.c
default-configs/i386-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_IPMI_LOCAL=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_IPMI_LOCAL=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -1 +1,2 @@ common-obj-$(CONFIG_IPMI) += ipmi.o +common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o
hw/ipmi/ipmi_bmc_sim.c new file +1731 -0
1,731 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 7 lines · On Mon, 2015-06-08 at 20:11 -0500, [email protected] wrote:
I have reworked the QEMU IPMI patches, and I believe this design improves greatly on the previous one. The suggestions made all resulted in better design. To start an IPMI interface with this, you would use:
-device ipmi-bmc-sim,id=bmc0 -device isa-ipmi-bt,bmc=bmc0
Quoted 8 lines
Note that I did not make the BMCs objects. I started this way, but adding properties was ending up duplicating a lot of code already in the device core, especially for the chardev link.
I'm not sure of the importance of having a BMC be an object instead of a device, but it seems to me that if we do that, it would be best to add helper functions to the object core for the chardev and integer properties.
Out of curiosity, what's the outlook to have this merged ? I'm working on a "native" OpenPower (POWER8 based) model which could definitely make good use of that !
Cheers,
Ben.
Quoted 7 lines · On 09/06/2015 03:11, [email protected] wrote:
I have reworked the QEMU IPMI patches, and I believe this design improves greatly on the previous one. The suggestions made all resulted in better design. To start an IPMI interface with this, you would use:
-device ipmi-bmc-sim,id=bmc0 -device isa-ipmi-bt,bmc=bmc0
Quoted 8 lines
Note that I did not make the BMCs objects. I started this way, but adding properties was ending up duplicating a lot of code already in the device core, especially for the chardev link.
I'm not sure of the importance of having a BMC be an object instead of a device, but it seems to me that if we do that, it would be best to add helper functions to the object core for the chardev and integer properties.
Hi, sorry for the delay. I missed this because I left for vacation exactly on the day it was posted. I think it's okay to have it as a device.
Michael, are you going to merge it? Otherwise, just ack the patches and I will take care of it. Time is ticking fast...
Paolo
Re: [Qemu-devel] [PATCH v3 12/16] pc: Postpone SMBIOS table installation to post machine init
In reply to [email protected]Quoted 6 lines · On Mon, Jun 08, 2015 at 08:12:07PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
This is the same place that the ACPI SSDT table gets added, so that devices can add themselves to the SMBIOS table.
Signed-off-by Corey Minyard <[email protected]>
This will change the order of fwcfg files, problematic for cross version migrations.
That's exactly the type of problem I pointed out. Should be made conditional on the new machine type? Cc Gerd for an opinion.
Quoted 68 lines
--- hw/i386/pc.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)hw/i386/pc.c +18
-17@@ -680,8 +680,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_tables, *smbios_anchor; -size_t smbios_tables_len, smbios_anchor_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);@@ -707,21 +705,6 @@ static FWCfgState *bochs_bios_init(void) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_tables =smbios_get_table_legacy (&smbios_tables_len); -if (smbios_tables) { -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_tables, smbios_tables_len); - } - -smbios_get_tables (&smbios_tables, &smbios_tables_len, - &smbios_anchor, &smbios_anchor_len); -if (smbios_anchor) { -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , - smbios_tables, smbios_tables_len); -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , - smbios_anchor, smbios_anchor_len); - } -fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_reserve,sizeof (e820_reserve)); fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,@@ -1119,7 +1102,25 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)PcGuestInfoState *guest_info_state =container_of (notifier, PcGuestInfoState, machine_done); +uint8_t *smbios_tables, *smbios_anchor; +size_t smbios_tables_len, smbios_anchor_len; +FWCfgState *fw_cfg = guest_info_state->info.fw_cfg; +acpi_setup (&guest_info_state->info); + + smbios_tables =smbios_get_table_legacy (&smbios_tables_len); +if (smbios_tables) { +fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_tables, smbios_tables_len); + } +smbios_get_tables (&smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len); +if (smbios_anchor) { +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , + smbios_tables, smbios_tables_len); +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , + smbios_anchor, smbios_anchor_len); + } } PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
In reply to [email protected]Quoted 173 lines · On Mon, Jun 08, 2015 at 08:12:09PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
Some devices, like IPMI, need to add ACPI table entries to report their presence. Add a method for adding these entries.
Signed-off-by Corey Minyard <[email protected]>--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-dev-tables.c | 80 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 17 +++++++++ include/hw/acpi/acpi-dev-tables.h | 38 +++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 hw/acpi/acpi-dev-tables.c create mode 100644 include/hw/acpi/acpi-dev-tables.hhw/acpi/Makefile.objs +1
-0@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.o +common-obj-$(CONFIG_ACPI) += acpi-dev-tables.ohw/acpi/acpi-dev-tables.c new file +80
-0@@ -0,0 +1,80 @@ +/* +* Add and get ACPI tables registered by devices. +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <string.h> +#include <hw/acpi/acpi-dev-tables.h> +#include <qemu/queue.h> + +struct acpi_dev_table { +void *data; +int size; +const char *sig; +uint8_t rev; +QSLIST_ENTRY (acpi_dev_table) next; +}; + +static QSLIST_HEAD(, acpi_dev_table) acpi_table_entries; + +void +add_acpi_dev_table (void *data,int size,const char *sig,uint8_t rev) +{ +struct acpi_dev_table *e =g_malloc (sizeof (*e)); + + e->data =g_malloc (size); +memcpy (e->data, data, size); + e->size = size; + e->sig = sig; + e->rev = rev; +QSLIST_INSERT_HEAD (&acpi_table_entries, e, next); +} + +struct acpi_dev_table *acpi_dev_table_first (void ) +{ +return QSLIST_FIRST (&acpi_table_entries); +} + +struct acpi_dev_table *acpi_dev_table_next (struct acpi_dev_table *current) +{ +return QSLIST_NEXT (current, next); +} + +uint8_t *acpi_dev_table_data (struct acpi_dev_table *e) +{ +return e->data; +} + +unsigned acpi_dev_table_len (struct acpi_dev_table *e) +{ +return e->size; +} + +const char *acpi_dev_table_sig (struct acpi_dev_table *e) +{ +return e->sig; +} + +uint8_t acpi_dev_table_rev (struct acpi_dev_table *e) +{ +return e->rev; +}hw/i386/acpi-build.c +17
-0@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-dev-tables.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h" @@ -1377,6 +1378,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)AcpiMcfgInfo mcfg;PcPciInfo pci;uint8_t *u; +struct acpi_dev_table *dt;size_t aml_len =0 ;GArray *tables_blob = tables->table_data;@@ -1448,6 +1450,21 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)build_dmar_q35 (tables_blob, tables->linker); } +/* Add tables from devices. */ +for (dt =acpi_dev_table_first (); dt; dt =acpi_dev_table_next (dt)) { +unsigned len =acpi_dev_table_len (dt); +void *data =acpi_dev_table_data (dt); + +acpi_add_table (table_offsets, tables_blob); +acpi_data_push (tables_blob,sizeof (AcpiTableHeader)); +g_array_append_vals (tables_blob, data, len); +build_header (tables->linker, tables_blob, + (void *)(tables_blob->data + tables_blob->len - + len -sizeof (AcpiTableHeader)), +acpi_dev_table_sig (dt), len +sizeof (AcpiTableHeader), +acpi_dev_table_rev (dt)); + } +/* Add tables supplied by user (if any) */ for (u =acpi_table_first (); u; u =acpi_table_next (u)) {unsigned len =acpi_table_len (u);include/hw/acpi/acpi-dev-tables.h new file +15
-0@@ -0,0 +1,38 @@ +/* +* Add and get ACPI tables registered by devices. +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public
include/hw/acpi/acpi-dev-tables.h line 25
Quoted 10 lines
include/hw/acpi/acpi-dev-tables.h new file +10
-0+* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h>
you don't seem to do anything with this header.
why include it?
include/hw/acpi/acpi-dev-tables.h line 29
Quoted 4 lines
include/hw/acpi/acpi-dev-tables.h new file +4
-0+ +void add_acpi_dev_table (void *data,int size,const char *sig,uint8_t rev); + +struct acpi_dev_table ;
Any particular reason to violate the coding style with the name of this structure.
include/hw/acpi/acpi-dev-tables.h line 36
Quoted 7 lines
include/hw/acpi/acpi-dev-tables.h new file +7
-0+ +struct acpi_dev_table *acpi_dev_table_first (void ); +struct acpi_dev_table *acpi_dev_table_next (struct acpi_dev_table *current); +uint8_t *acpi_dev_table_data (struct acpi_dev_table *); +unsigned acpi_dev_table_len (struct acpi_dev_table *); +const char *acpi_dev_table_sig (struct acpi_dev_table *); +uint8_t acpi_dev_table_rev (struct acpi_dev_table *);
Pls add documentation for the APIs.
Quoted 5 lines
include/hw/acpi/acpi-dev-tables.h new file +2
-0+ +#endif /* QEMU_HW_ACPI_HOOKS_H */ Signature · 1 line
1.8.3.1
Quoted 11 lines · On Mon, Jun 08, 2015 at 08:11:55PM -0500, [email protected] wrote:
I have reworked the QEMU IPMI patches, and I believe this design improves greatly on the previous one. The suggestions made all resulted in better design. To start an IPMI interface with this, you would use:
-device ipmi-bmc-sim,id=bmc0 -device isa-ipmi-bt,bmc=bmc0
Note that I did not make the BMCs objects. I started this way, but adding properties was ending up duplicating a lot of code already in the device core, especially for the chardev link.
Quoted 8 lines
I'm not sure of the importance of having a BMC be an object instead of a device, but it seems to me that if we do that, it would be best to add helper functions to the object core for the chardev and integer properties.
Thanks,
-corey
In the future pls remember to copy maintainers on patches you post.
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
In reply to [email protected]Quoted 100 lines · On Mon, Jun 08, 2015 at 08:12:09PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
Some devices, like IPMI, need to add ACPI table entries to report their presence. Add a method for adding these entries.
Signed-off-by Corey Minyard <[email protected]>--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-dev-tables.c | 80 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 17 +++++++++ include/hw/acpi/acpi-dev-tables.h | 38 +++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 hw/acpi/acpi-dev-tables.c create mode 100644 include/hw/acpi/acpi-dev-tables.hhw/acpi/Makefile.objs +1
-0@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.o +common-obj-$(CONFIG_ACPI) += acpi-dev-tables.ohw/acpi/acpi-dev-tables.c new file +70
-0@@ -0,0 +1,80 @@ +/* +* Add and get ACPI tables registered by devices. +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <string.h> +#include <hw/acpi/acpi-dev-tables.h> +#include <qemu/queue.h> + +struct acpi_dev_table { +void *data; +int size; +const char *sig; +uint8_t rev; +QSLIST_ENTRY (acpi_dev_table) next; +}; + +static QSLIST_HEAD(, acpi_dev_table) acpi_table_entries; + +void +add_acpi_dev_table (void *data,int size,const char *sig,uint8_t rev) +{ +struct acpi_dev_table *e =g_malloc (sizeof (*e)); + + e->data =g_malloc (size); +memcpy (e->data, data, size); + e->size = size; + e->sig = sig; + e->rev = rev; +QSLIST_INSERT_HEAD (&acpi_table_entries, e, next); +} + +struct acpi_dev_table *acpi_dev_table_first (void ) +{ +return QSLIST_FIRST (&acpi_table_entries); +} + +struct acpi_dev_table *acpi_dev_table_next (struct acpi_dev_table *current) +{ +return QSLIST_NEXT (current, next); +} + +uint8_t *acpi_dev_table_data (struct acpi_dev_table *e) +{ +return e->data; +} + +unsigned acpi_dev_table_len (struct acpi_dev_table *e) +{ +return e->size; +}
hw/acpi/acpi-dev-tables.c line 80
Quoted 10 lines
hw/acpi/acpi-dev-tables.c new file +10
-0+ +const char *acpi_dev_table_sig (struct acpi_dev_table *e) +{ +return e->sig; +} + +uint8_t acpi_dev_table_rev (struct acpi_dev_table *e) +{ +return e->rev; +}
First, I think at this point we should limit this to SSDTs. Second, I think it's a good idea to make OEM table IDs unique. Cc Igor for an opinion.
Quoted 89 lines
hw/i386/acpi-build.c +17
-0@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-dev-tables.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h" @@ -1377,6 +1378,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)AcpiMcfgInfo mcfg;PcPciInfo pci;uint8_t *u; +struct acpi_dev_table *dt;size_t aml_len =0 ;GArray *tables_blob = tables->table_data;@@ -1448,6 +1450,21 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)build_dmar_q35 (tables_blob, tables->linker); } +/* Add tables from devices. */ +for (dt =acpi_dev_table_first (); dt; dt =acpi_dev_table_next (dt)) { +unsigned len =acpi_dev_table_len (dt); +void *data =acpi_dev_table_data (dt); + +acpi_add_table (table_offsets, tables_blob); +acpi_data_push (tables_blob,sizeof (AcpiTableHeader)); +g_array_append_vals (tables_blob, data, len); +build_header (tables->linker, tables_blob, + (void *)(tables_blob->data + tables_blob->len - + len -sizeof (AcpiTableHeader)), +acpi_dev_table_sig (dt), len +sizeof (AcpiTableHeader), +acpi_dev_table_rev (dt)); + } +/* Add tables supplied by user (if any) */ for (u =acpi_table_first (); u; u =acpi_table_next (u)) {unsigned len =acpi_table_len (u);include/hw/acpi/acpi-dev-tables.h new file +38
-0@@ -0,0 +1,38 @@ +/* +* Add and get ACPI tables registered by devices. +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_acpi_dev_table (void *data,int size,const char *sig,uint8_t rev); + +struct acpi_dev_table ; + +struct acpi_dev_table *acpi_dev_table_first (void ); +struct acpi_dev_table *acpi_dev_table_next (struct acpi_dev_table *current); +uint8_t *acpi_dev_table_data (struct acpi_dev_table *); +unsigned acpi_dev_table_len (struct acpi_dev_table *); +const char *acpi_dev_table_sig (struct acpi_dev_table *); +uint8_t acpi_dev_table_rev (struct acpi_dev_table *); + +#endif /* QEMU_HW_ACPI_HOOKS_H */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
In reply to [email protected]Quoted 4 lines · On Mon, 8 Jun 2015 20:12:09 -0500 [email protected] wrote:
From: Corey Minyard <[email protected]>
Some devices, like IPMI, need to add ACPI table entries to report their presence. Add a method for adding these entries.
I think that it's not up to device to define in which table/scope it's entries should be but rather upto a board/platform to decide.
I'd prefer the old way of adding device's ACPI AML into existing SSDT, like we do for every other device that needs it (for example: pvpanic).
That allows to keep ACPI code in one place and for each platform to decide to which table put a device description and where exactly it should be.
So I'd drop this patch and add function that returns non NULL "IPMIFwInfo *" if IPMI device is present and use slightly modified 15/16 to add device entry into the existing SSDT.
Quoted 191 lines
Signed-off-by Corey Minyard <[email protected]>--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-dev-tables.c | 80 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 17 +++++++++ include/hw/acpi/acpi-dev-tables.h | 38 +++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 hw/acpi/acpi-dev-tables.c create mode 100644 include/hw/acpi/acpi-dev-tables.hhw/acpi/Makefile.objs +1
-0@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.o +common-obj-$(CONFIG_ACPI) += acpi-dev-tables.ohw/acpi/acpi-dev-tables.c new file +80
-0@@ -0,0 +1,80 @@ +/* +* Add and get ACPI tables registered by devices. +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <string.h> +#include <hw/acpi/acpi-dev-tables.h> +#include <qemu/queue.h> + +struct acpi_dev_table { +void *data; +int size; +const char *sig; +uint8_t rev; +QSLIST_ENTRY (acpi_dev_table) next; +}; + +static QSLIST_HEAD(, acpi_dev_table) acpi_table_entries; + +void +add_acpi_dev_table (void *data,int size,const char *sig,uint8_t rev) +{ +struct acpi_dev_table *e =g_malloc (sizeof (*e)); + + e->data =g_malloc (size); +memcpy (e->data, data, size); + e->size = size; + e->sig = sig; + e->rev = rev; +QSLIST_INSERT_HEAD (&acpi_table_entries, e, next); +} + +struct acpi_dev_table *acpi_dev_table_first (void ) +{ +return QSLIST_FIRST (&acpi_table_entries); +} + +struct acpi_dev_table *acpi_dev_table_next (struct acpi_dev_table *current) +{ +return QSLIST_NEXT (current, next); +} + +uint8_t *acpi_dev_table_data (struct acpi_dev_table *e) +{ +return e->data; +} + +unsigned acpi_dev_table_len (struct acpi_dev_table *e) +{ +return e->size; +} + +const char *acpi_dev_table_sig (struct acpi_dev_table *e) +{ +return e->sig; +} + +uint8_t acpi_dev_table_rev (struct acpi_dev_table *e) +{ +return e->rev; +}hw/i386/acpi-build.c +17
-0@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-dev-tables.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h" @@ -1377,6 +1378,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)AcpiMcfgInfo mcfg;PcPciInfo pci;uint8_t *u; +struct acpi_dev_table *dt;size_t aml_len =0 ;GArray *tables_blob = tables->table_data;@@ -1448,6 +1450,21 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)build_dmar_q35 (tables_blob, tables->linker); } +/* Add tables from devices. */ +for (dt =acpi_dev_table_first (); dt; dt =acpi_dev_table_next (dt)) { +unsigned len =acpi_dev_table_len (dt); +void *data =acpi_dev_table_data (dt); + +acpi_add_table (table_offsets, tables_blob); +acpi_data_push (tables_blob,sizeof (AcpiTableHeader)); +g_array_append_vals (tables_blob, data, len); +build_header (tables->linker, tables_blob, + (void *)(tables_blob->data + tables_blob->len - + len -sizeof (AcpiTableHeader)), +acpi_dev_table_sig (dt), len +sizeof (AcpiTableHeader), +acpi_dev_table_rev (dt)); + } +/* Add tables supplied by user (if any) */ for (u =acpi_table_first (); u; u =acpi_table_next (u)) {unsigned len =acpi_table_len (u);include/hw/acpi/acpi-dev-tables.h new file +38
-0@@ -0,0 +1,38 @@ +/* +* Add and get ACPI tables registered by devices. +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_acpi_dev_table (void *data,int size,const char *sig,uint8_t rev); + +struct acpi_dev_table ; + +struct acpi_dev_table *acpi_dev_table_first (void ); +struct acpi_dev_table *acpi_dev_table_next (struct acpi_dev_table *current); +uint8_t *acpi_dev_table_data (struct acpi_dev_table *); +unsigned acpi_dev_table_len (struct acpi_dev_table *); +const char *acpi_dev_table_sig (struct acpi_dev_table *); +uint8_t acpi_dev_table_rev (struct acpi_dev_table *); + +#endif /* QEMU_HW_ACPI_HOOKS_H */
Re: [Qemu-devel] [PATCH v3 15/16] ipmi: Add ACPI table entries
In reply to [email protected]Quoted 4 lines · On Mon, 8 Jun 2015 20:12:10 -0500 [email protected] wrote:
From: Corey Minyard <[email protected]>
Use the new ACPI table construction tools to create an ACPI entry for IPMI.
Above doesn't tell what is purpose of patch.
It would be nice for commit message to describe what the patch actually does with references to relevant specs.
Quoted 13 lines
Signed-off-by Corey Minyard <[email protected]>--- hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_acpi.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 hw/ipmi/ipmi_acpi.chw/ipmi/Makefile.objs +0
-0
hw/ipmi/Makefile.objs common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o · line 7
Quoted 4 lines
hw/ipmi/Makefile.objs +1
-0@@ -4,3 +4,4 @@ common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_SMBIOS)) += ipmi_smbios.o +common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_ACPI)) += ipmi_acpi.o
if device is planned to be used only with PC machine I'd suggest to put below functions into hw/i386/acpi-build.c
but if there is plans to make it work with ARM target as well then a more generic hw/acpi/ipmi_acpi.c would be more suitable.
Quoted 34 lines
hw/ipmi/ipmi_acpi.c new file +28
-0@@ -0,0 +1,122 @@ +/* +* IPMI ACPI firmware handling +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "hw/ipmi/ipmi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-dev-tables.h"
hw/ipmi/ipmi_acpi.c line 38
Quoted 10 lines
hw/ipmi/ipmi_acpi.c new file +10
-0+#include <qemu/error-report.h> + +static Aml *aml_ipmi_crs (IPMIFwInfo *info) +{ +Aml *crs =aml_resource_template (); +uint8_t regspacing = info->register_spacing; + +if (regspacing ==1 ) { + regspacing =0 ; + }
what's is purpose of ^^^ ???
Is it used but other code than ACPI, if not then just drop it and hardcode it here naming it according to field it's used for (i.e. alignment)
Quoted 21 lines
hw/ipmi/ipmi_acpi.c new file +21
-0+ +switch (info->memspace) { +case IPMI_MEMSPACE_IO : +aml_append (crs,aml_io (aml_decode16, info->base_address, + info->base_address + info->register_length - 1 + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_MEM32 : +aml_append (crs, +aml_dword_memory (aml_pos_decode, + aml_min_fixed, aml_max_fixed, + aml_non_cacheable, aml_ReadWrite, +0xffffffff , + info->base_address, + info->base_address + info->register_length -1 , + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_MEM64 : + aml_append(crs, + aml_qword_memory(aml_pos_decode, + aml_min_fixed, aml_max_fixed,
hw/ipmi/ipmi_acpi.c line 69
Quoted 10 lines
hw/ipmi/ipmi_acpi.c new file +10
-0+ aml_non_cacheable, aml_ReadWrite, +0xffffffffffffffffULL , + info->base_address, + info->base_address + info->register_length -1 , + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_SMBUS : +aml_append (crs,aml_return (aml_int (info->base_address))); +break ; + }
does device support reprogramming of "base_address" or is it fixed?
+ case for default with abort()
Quoted 4 lines
hw/ipmi/ipmi_acpi.c new file +4
-0+ +if (info->interrupt_number) { +aml_append (crs,aml_irq_no_flags (info->interrupt_number)); + }
hw/ipmi/ipmi_acpi.c line 83
Quoted 10 lines
hw/ipmi/ipmi_acpi.c new file +10
-0+ +return crs; +} + +static void +ipmi_encode_one_acpi (IPMIFwInfo *info,void *opaque) +{ +Aml *ssdt, *scope, *dev, *method; +char *name; + int version = ((info->ipmi_spec_major_revision << 8)
s/int/uint16_t/
hw/ipmi/ipmi_acpi.c line 86
Quoted 3 lines
hw/ipmi/ipmi_acpi.c new file +3
-0+ | (info->ipmi_spec_minor_revision << 4)); + +if (!info->acpi_parent) {
point of attaching should be defined here and not by device, hence I'd drop this hunk
hw/ipmi/ipmi_acpi.c line 92
Quoted 6 lines
hw/ipmi/ipmi_acpi.c new file +6
-0+ipmi_debug ("device %s not compatible with ACPI, no parent given." , + info->interface_name); +return ; + } + + ssdt =init_aml_allocator ();
drop this and just call this function directly from build_ssdt()
hw/ipmi/ipmi_acpi.c line 95
Quoted 3 lines
hw/ipmi/ipmi_acpi.c new file +3
-0+ + scope =aml_scope ("%s" , info->acpi_parent); + name =g_strdup_printf ("ipmi_%s" , info->interface_name);
I don't see 'name' being reused neither freed, just do below
..."_STR", aml_string("ipmi_%s", info->interface_name)...
hw/ipmi/ipmi_acpi.c line 100
Quoted 5 lines
hw/ipmi/ipmi_acpi.c new file +5
-0+ + dev =aml_device ("MI0" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("IPI0001" ))); +aml_append (dev,aml_name_decl ("_STR" ,aml_string ("%s" , name))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 )));
since it's the only device there is no need to provide UUID, if there could be more than one BMCs than this part is wrong.
hw/ipmi/ipmi_acpi.c line 106
Quoted 6 lines
hw/ipmi/ipmi_acpi.c new file +6
-0+aml_append (dev,aml_name_decl ("_CRS" ,aml_ipmi_crs (info))); + method =aml_method ("_IFT" ,0 ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ); +aml_append (method,aml_return (aml_int (version)));
Is there a specific need to use methods for _IFT/SRV objects, since they just return a value and don't do anything else, I'd suggest to use named variables (i.e. aml_name_decl())
Quoted 16 lines
hw/ipmi/ipmi_acpi.c new file +16
-0+aml_append (dev, method); + +aml_append (scope, dev); + +aml_append (ssdt, scope); + +add_acpi_dev_table (ssdt->buf->data, ssdt->buf->len,"SSDT" ,1 ); +free_aml_allocator (); +} + +static void ipmi_acpi_init (void ) +{ +ipmi_register_fwinfo_handler (ipmi_encode_one_acpi,NULL ); +} + +type_init (ipmi_acpi_init);
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
In reply to Igor MammedovQuoted 8 lines · Igor Mammedov
Quoted 2 lines
Some devices, like IPMI, need to add ACPI table entries to report their presence. Add a method for adding these entries.
I think that it's not up to device to define in which table/scope it's entries should be but rather upto a board/platform to decide.
I'd prefer the old way of adding device's ACPI AML into existing SSDT
This was suggested by Michael, so I think you should read the reviews of earlier versions first.
Paolo
, like we do for every other device that needs it
Quoted 8 lines
(for example: pvpanic).
That allows to keep ACPI code in one place and for each platform to decide to which table put a device description and where exactly it should be.So I'd drop this patch and add function that returns non NULL "IPMIFwInfo *" if IPMI device is present and use slightly modified 15/16 to add device entry into the existing SSDT.
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
Quoted 6 lines · On Wed, 8 Jul 2015 19:44:16 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 3 lines · Igor Mammedov
Quoted 2 lines
Some devices, like IPMI, need to add ACPI table entries to report their presence. Add a method for adding these entries.
Quoted 8 lines
Quoted 5 lines
I think that it's not up to device to define in which table/scope it's entries should be but rather upto a board/platform to decide.
I'd prefer the old way of adding device's ACPI AML into existing SSDT
This was suggested by Michael, so I think you should read the reviews of earlier versions first.
That is basically the same as hooks in v1 only the other way around with all drawbacks attached.
Just dropping this universal way to scatter ACPI code all over QEMU and calling ipmi_encode_one_acpi() "[15/16] ipmi: Add ACPI table entries" directly from build_ssdt() would simplify series quite a bit.
I'd do the same for SMBIOS entries as well, i.e. drop similar universal way for devices to supply SMBIOS info (it's not their business) and just call ipmi_encode_one_smbios() to add ipmi specific entry if device is present. Again simplifying series even more.
that roughly would save us 300 lines of not really necessary code and keep things consistent with a way we are managing ssdt now.
Quoted 13 lines
Paolo
, like we do for every other device that needs it
Quoted 8 lines
(for example: pvpanic).
That allows to keep ACPI code in one place and for each platform to decide to which table put a device description and where exactly it should be.So I'd drop this patch and add function that returns non NULL "IPMIFwInfo *" if IPMI device is present and use slightly modified 15/16 to add device entry into the existing SSDT.
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
Quoted 9 lines · Igor Mammedov
Quoted 2 lines
This was suggested by Michael, so I think you should read the reviews of earlier versions first.
That is basically the same as hooks in v1 only the other way around with all drawbacks attached.
Just dropping this universal way to scatter ACPI code all over QEMU and calling
ipmi_encode_one_acpi()"[15/16] ipmi: Add ACPI table entries" directly frombuild_ssdt()would simplify series quite a bit.
On the other hand, it would be much harder to make IPMI optional unless you want to add a bunch of ugly stubs. Same for SMBIOS. Especially when you can have the same ACPI and SMBIOS tables in both x86 and ARM virtual machines, it becomes a little more the device business to provide ACPI and SMBIOS information.
So overall I'm happy with the way it was done here. I and Michael disagreed on several details, but not enough to fight over it...
Paolo
Quoted 7 lines
I'd do the same for SMBIOS entries as well, i.e. drop similar universal way for devices to supply SMBIOS info (it's not their business) and just call
ipmi_encode_one_smbios()to add ipmi specific entry if device is present. Again simplifying series even more.that roughly would save us 300 lines of not really necessary code and keep things consistent with a way we are managing ssdt now.
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
Quoted 9 lines · On Wed, 8 Jul 2015 22:39:24 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 6 lines · Igor Mammedov
Quoted 2 lines
This was suggested by Michael, so I think you should read the reviews of earlier versions first.
That is basically the same as hooks in v1 only the other way around with all drawbacks attached.
Quoted 6 lines
Quoted 3 lines
Just dropping this universal way to scatter ACPI code all over QEMU and calling
ipmi_encode_one_acpi()"[15/16] ipmi: Add ACPI table entries" directly frombuild_ssdt()would simplify series quite a bit.On the other hand, it would be much harder to make IPMI optional unless you want to add a bunch of ugly stubs. Same for SMBIOS. Especially
it's no the case if one uses QOM properties to fetch info. it's a bit verbose but works well without need for ugly stubs.
Quoted 3 lines
when you can have the same ACPI and SMBIOS tables in both x86 and ARM virtual machines, it becomes a little more the device business to provide ACPI and SMBIOS information.
For a generic way for device to supply information to ACPI, I was thinking about introducing interface that device might implement for example if it should have _CRS in its ACPI description. Then APCI core could query for devices that implement interface and build AML code based on resource values (i.e. base address, size, irq #, e.t.c) it gets from device.
Quoted 2 lines
So overall I'm happy with the way it was done here. I and Michael disagreed on several details, but not enough to fight over it...
I won't fight over it either, but it's my opinion how it should be done.
Quoted 11 lines
Paolo
Quoted 7 lines
I'd do the same for SMBIOS entries as well, i.e. drop similar universal way for devices to supply SMBIOS info (it's not their business) and just call
ipmi_encode_one_smbios()to add ipmi specific entry if device is present. Again simplifying series even more.that roughly would save us 300 lines of not really necessary code and keep things consistent with a way we are managing ssdt now.
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
Quoted 21 lines · Igor Mammedov
Quoted 4 lines · On Wed, 8 Jul 2015 22:39:24 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 2 lines · Igor Mammedov
Quoted 2 lines
This was suggested by Michael, so I think you should read the reviews of earlier versions first.
Quoted 8 lines
Quoted 6 lines
That is basically the same as hooks in v1 only the other way around with all drawbacks attached.
Just dropping this universal way to scatter ACPI code all over QEMU and calling
ipmi_encode_one_acpi()"[15/16] ipmi: Add ACPI table entries" directly frombuild_ssdt()would simplify series quite a bit.On the other hand, it would be much harder to make IPMI optional unless you want to add a bunch of ugly stubs. Same for SMBIOS. Especially
it's no the case if one uses QOM properties to fetch info. it's a bit verbose but works well without need for ugly stubs.
Quoted 3 lines
when you can have the same ACPI and SMBIOS tables in both x86 and ARM virtual machines, it becomes a little more the device business to provide ACPI and SMBIOS information.
Quoted 6 lines
For a generic way for device to supply information to ACPI, I was thinking about introducing interface that device might implement for example if it should have
_CRSin its ACPI description. Then APCI core could query for devices that implement interface and build AML code based on resource values (i.e. base address, size, irq #,e.t.c) it gets from device.
I'm just getting back from vacation and catching up.
I would agree that implementing an interface is a more consistent way to do this than the way it's done now. If it's ok with everyone, I'll work on implementing this.
I'm not sure that resource values are enough to do this, though. IPMI has some custom fields (_IFT, _SRV, _STR) and lots of optional fields (_ADR, _UID, _STA), how would you do these fields?
-corey
Quoted 15 lines
Quoted 3 lines
So overall I'm happy with the way it was done here. I and Michael disagreed on several details, but not enough to fight over it...
I won't fight over it either, but it's my opinion how it should be done.
Quoted 9 lines
Paolo
Quoted 7 lines
I'd do the same for SMBIOS entries as well, i.e. drop similar universal way for devices to supply SMBIOS info (it's not their business) and just call
ipmi_encode_one_smbios()to add ipmi specific entry if device is present. Again simplifying series even more.that roughly would save us 300 lines of not really necessary code and keep things consistent with a way we are managing ssdt now.
Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
Quoted 29 lines · On Mon, 13 Jul 2015 16:55:29 -0500 Corey Minyard <[email protected]> wrote:
Quoted 21 lines · Igor Mammedov
Quoted 4 lines · On Wed, 8 Jul 2015 22:39:24 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 2 lines · Igor Mammedov
Quoted 2 lines
This was suggested by Michael, so I think you should read the reviews of earlier versions first.
Quoted 8 lines
Quoted 6 lines
That is basically the same as hooks in v1 only the other way around with all drawbacks attached.
Just dropping this universal way to scatter ACPI code all over QEMU and calling
ipmi_encode_one_acpi()"[15/16] ipmi: Add ACPI table entries" directly frombuild_ssdt()would simplify series quite a bit.On the other hand, it would be much harder to make IPMI optional unless you want to add a bunch of ugly stubs. Same for SMBIOS. Especially
it's no the case if one uses QOM properties to fetch info. it's a bit verbose but works well without need for ugly stubs.
Quoted 3 lines
when you can have the same ACPI and SMBIOS tables in both x86 and ARM virtual machines, it becomes a little more the device business to provide ACPI and SMBIOS information.
Quoted 6 lines
For a generic way for device to supply information to ACPI, I was thinking about introducing interface that device might implement for example if it should have
_CRSin its ACPI description. Then APCI core could query for devices that implement interface and build AML code based on resource values (i.e. base address, size, irq #,e.t.c) it gets from device.
Quoted 5 lines
I'm just getting back from vacation and catching up.
I would agree that implementing an interface is a more consistent way to do this than the way it's done now. If it's ok with everyone, I'll work on implementing this.
Implementing interface shouldn't block this series.
I'm ok with this series ACPI wise if you drop 14/16 and do as suggested above + address comment on 15/16.
It would require minimal changes and get us an interesting device to play with without significant delays.
I would do the same with SMBIOS side as well.
Implementing interface could be made on top along with conversion of current code that fetches resource info from devices manually.
Quoted 4 lines
I'm not sure that resource values are enough to do this, though. IPMI has some custom fields (
_IFT,_SRV,_STR) and lots of optional fields (_ADR,_UID,_STA), how would you do these fields?
fields names are part of ACPI spec,
maybe interface should have methods for returning these fields.
_ADR - for example for PCI devices should address of device on bus _SRV - return packed revision number_IFT - return interface number_STR, _UID, _STA - I'd leave them to board/firmware to decide how to name/enumerate/detect presence (i.e. in acpi-build.c)
Quoted 19 lines
-corey
Quoted 15 lines
Quoted 3 lines
So overall I'm happy with the way it was done here. I and Michael disagreed on several details, but not enough to fight over it...
I won't fight over it either, but it's my opinion how it should be done.
Quoted 9 lines
Paolo
Quoted 7 lines
I'd do the same for SMBIOS entries as well, i.e. drop similar universal way for devices to supply SMBIOS info (it's not their business) and just call
ipmi_encode_one_smbios()to add ipmi specific entry if device is present. Again simplifying series even more.that roughly would save us 300 lines of not really necessary code and keep things consistent with a way we are managing ssdt now.