Skip to contentSkip to conversation

Add ACPI and SMBIOS table entries for IPMI

PATCH Superseded [email protected] 6 participants 14 messages Feb 24, 2016 – Mar 15, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Add ACPI and SMBIOS table entries for IPMI

Now that Igor has reworked things to remove the SSDT, I've updated IPMI code to work with the new format. This is functionally the same as before, just for ACPI it adds the data to the DSDT now.

This will avoid a lot of "Why doesn't IPMI work when I add it?" questions, which I have already gotten.

-corey

#1 lore raw

PATCH 1/5 smbios: Move table build tools into an include file.

From: Corey Minyard <[email protected]>

This will let things in other files (like IPMI) build SMBIOS tables.

---
 hw/smbios/smbios.c       | 70 ++++---------------------------------------
 hw/smbios/smbios_build.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 64 deletions(-)
 create mode 100644 hw/smbios/smbios_build.h
hw/smbios/smbios.c +6 -64
index 3b5f9bd..e1bc1ea 100644
@@ -23,6 +23,7 @@
 #include "hw/smbios/smbios.h"
 #include "hw/loader.h"
 #include "exec/cpu-common.h"
+#include "smbios_build.h"
 
 /* legacy structures and constants for <= 2.0 machines */
 struct smbios_header {
@@ -52,10 +53,10 @@ static bool smbios_uuid_encoded = true;
 /* end: legacy structures & constants for <= 2.0 machines */
 
 
-static uint8_t *smbios_tables;
-static size_t smbios_tables_len;
-static unsigned smbios_table_max;
-static unsigned smbios_table_cnt;
+uint8_t *smbios_tables;
+size_t smbios_tables_len;
+unsigned smbios_table_max;
+unsigned smbios_table_cnt;
 static SmbiosEntryPointType smbios_ep_type = SMBIOS_ENTRY_POINT_21;
 
 static SmbiosEntryPoint ep;
@@ -428,7 +429,7 @@ uint8_t *smbios_get_table_legacy(size_t *length)
 /* end: legacy setup functions for <= 2.0 machines */
 
 
-static bool smbios_skip_table(uint8_t type, bool required_table)
+bool smbios_skip_table(uint8_t type, bool required_table)
 {
     if (test_bit(type, have_binfile_bitmap)) {
         return true; /* user provided their own binary blob(s) */
@@ -442,65 +443,6 @@ static bool smbios_skip_table(uint8_t type, bool required_table)
     return true;
 }
 
-#define SMBIOS_BUILD_TABLE_PRE(tbl_type, tbl_handle, tbl_required)        \
-    struct smbios_type_##tbl_type *t;                                     \
-    size_t t_off; /* table offset into smbios_tables */                   \
-    int str_index = 0;                                                    \
-    do {                                                                  \
-        /* should we skip building this table ? */                        \
-        if (smbios_skip_table(tbl_type, tbl_required)) {                  \
-            return;                                                       \
-        }                                                                 \
-                                                                          \
-        /* use offset of table t within smbios_tables */                  \
-        /* (pointer must be updated after each realloc) */                \
-        t_off = smbios_tables_len;                                        \
-        smbios_tables_len += sizeof(*t);                                  \
-        smbios_tables = g_realloc(smbios_tables, smbios_tables_len);      \
-        t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off);     \
-                                                                          \
-        t->header.type = tbl_type;                                        \
-        t->header.length = sizeof(*t);                                    \
-        t->header.handle = cpu_to_le16(tbl_handle);                       \
-    } while (0)
-
-#define SMBIOS_TABLE_SET_STR(tbl_type, field, value)                      \
-    do {                                                                  \
-        int len = (value != NULL) ? strlen(value) + 1 : 0;                \
-        if (len > 1) {                                                    \
-            smbios_tables = g_realloc(smbios_tables,                      \
-                                      smbios_tables_len + len);           \
-            memcpy(smbios_tables + smbios_tables_len, value, len);        \
-            smbios_tables_len += len;                                     \
-            /* update pointer post-realloc */                             \
-            t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
-            t->field = ++str_index;                                       \
-        } else {                                                          \
-            t->field = 0;                                                 \
-        }                                                                 \
-    } while (0)
-
-#define SMBIOS_BUILD_TABLE_POST                                           \
-    do {                                                                  \
-        size_t term_cnt, t_size;                                          \
-                                                                          \
-        /* add '\0' terminator (add two if no strings defined) */         \
-        term_cnt = (str_index == 0) ? 2 : 1;                              \
-        smbios_tables = g_realloc(smbios_tables,                          \
-                                  smbios_tables_len + term_cnt);          \
-        memset(smbios_tables + smbios_tables_len, 0, term_cnt);           \
-        smbios_tables_len += term_cnt;                                    \
-                                                                          \
-        /* update smbios max. element size */                             \
-        t_size = smbios_tables_len - t_off;                               \
-        if (t_size > smbios_table_max) {                                  \
-            smbios_table_max = t_size;                                    \
-        }                                                                 \
-                                                                          \
-        /* update smbios element count */                                 \
-        smbios_table_cnt++;                                               \
-    } while (0)
-
 static void smbios_build_type_0_table(void)
 {
     SMBIOS_BUILD_TABLE_PRE(0, 0x000, false); /* optional, leave up to BIOS */
hw/smbios/smbios_build.h new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.5.0
#2 lore raw

PATCH 2/5 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 | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
hw/i386/pc.c +6 -5
index 0aeefd2..da8fc76 100644
@@ -778,8 +778,6 @@ static FWCfgState *bochs_bios_init(AddressSpace *as)
                      acpi_tables, acpi_tables_len);
     fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
 
-    pc_build_smbios(fw_cfg);
-
     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,
@@ -1161,6 +1159,7 @@ void pc_machine_done(Notifier *notifier, void *data)
 {
     PCMachineState *pcms = container_of(notifier,
                                         PCMachineState, machine_done);
+    FWCfgState *fw_cfg = pcms->fw_cfg;
     PCIBus *bus = pcms->bus;
 
     if (bus) {
@@ -1172,15 +1171,17 @@ void pc_machine_done(Notifier *notifier, void *data)
                 extra_hosts++;
             }
         }
-        if (extra_hosts && pcms->fw_cfg) {
+        if (extra_hosts && fw_cfg) {
             uint64_t *val = g_malloc(sizeof(*val));
             *val = cpu_to_le64(extra_hosts);
-            fw_cfg_add_file(pcms->fw_cfg,
-                    "etc/extra-pci-roots", val, sizeof(*val));
+            fw_cfg_add_file(fw_cfg, "etc/extra-pci-roots", val, sizeof(*val));
         }
     }
 
     acpi_setup();
+    if (fw_cfg) {
+        pc_build_smbios(fw_cfg);
+    }
 }
 
 void pc_guest_info_init(PCMachineState *pcms)
Signature · 1 line
2.5.0
#3 lore raw

Re: [Qemu-devel] [PATCH 2/5] pc: Postpone SMBIOS table installation to post machine init

Quoted 6 lines · On Wed, Feb 24, 2016 at 12:59:13PM -0600, [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.

This changes the order of fw cfg files, which
is guest visible.
Need to make it depend on either machine type
or the presence of ipmi somehow.

Quoted 48 lines
---
 hw/i386/pc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
hw/i386/pc.c +6 -5
index 0aeefd2..da8fc76 100644
@@ -778,8 +778,6 @@ static FWCfgState *bochs_bios_init(AddressSpace *as)
                      acpi_tables, acpi_tables_len);
     fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
 
-    pc_build_smbios(fw_cfg);
-
     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,
@@ -1161,6 +1159,7 @@ void pc_machine_done(Notifier *notifier, void *data)
 {
     PCMachineState *pcms = container_of(notifier,
                                         PCMachineState, machine_done);
+    FWCfgState *fw_cfg = pcms->fw_cfg;
     PCIBus *bus = pcms->bus;
 
     if (bus) {
@@ -1172,15 +1171,17 @@ void pc_machine_done(Notifier *notifier, void *data)
                 extra_hosts++;
             }
         }
-        if (extra_hosts && pcms->fw_cfg) {
+        if (extra_hosts && fw_cfg) {
             uint64_t *val = g_malloc(sizeof(*val));
             *val = cpu_to_le64(extra_hosts);
-            fw_cfg_add_file(pcms->fw_cfg,
-                    "etc/extra-pci-roots", val, sizeof(*val));
+            fw_cfg_add_file(fw_cfg, "etc/extra-pci-roots", val, sizeof(*val));
         }
     }
 
     acpi_setup();
+    if (fw_cfg) {
+        pc_build_smbios(fw_cfg);
+    }
 }
 
 void pc_guest_info_init(PCMachineState *pcms)
Signature · 1 line
2.5.0
#4 lore raw

Re: [Qemu-devel] [PATCH 2/5] pc: Postpone SMBIOS table installation to post machine init

Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · On Wed, Feb 24, 2016 at 12:59:13PM -0600, [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.

This changes the order of fw cfg files, which
is guest visible.
Need to make it depend on either machine type

Do you mean add a new machine type, like adding a 2.7 version of pc-i440fx and pc-q35?

Quoted 1 line

or the presence of ipmi somehow.

You could pre-scan for ipmi options from early in the pc code. Kind of hackish.

One other option would be to just have ACPI support for IPMI. Older OSes might not work; I'm not sure how important that is.

Does anyone have a preference here? To me, adding a new machine type looks easiest, but I'm not sure of the effects on users.

-corey

Quoted 48 lines
Quoted 48 lines
---
  hw/i386/pc.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
hw/i386/pc.c +6 -5
index 0aeefd2..da8fc76 100644
@@ -778,8 +778,6 @@ static FWCfgState *bochs_bios_init(AddressSpace *as)
                       acpi_tables, acpi_tables_len);
      fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
 
-    pc_build_smbios(fw_cfg);
-
      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,
@@ -1161,6 +1159,7 @@ void pc_machine_done(Notifier *notifier, void *data)
  {
      PCMachineState *pcms = container_of(notifier,
                                          PCMachineState, machine_done);
+    FWCfgState *fw_cfg = pcms->fw_cfg;
      PCIBus *bus = pcms->bus;
 
      if (bus) {
@@ -1172,15 +1171,17 @@ void pc_machine_done(Notifier *notifier, void *data)
                  extra_hosts++;
              }
          }
-        if (extra_hosts && pcms->fw_cfg) {
+        if (extra_hosts && fw_cfg) {
              uint64_t *val = g_malloc(sizeof(*val));
              *val = cpu_to_le64(extra_hosts);
-            fw_cfg_add_file(pcms->fw_cfg,
-                    "etc/extra-pci-roots", val, sizeof(*val));
+            fw_cfg_add_file(fw_cfg, "etc/extra-pci-roots", val, sizeof(*val));
          }
      }
 
      acpi_setup();
+    if (fw_cfg) {
+        pc_build_smbios(fw_cfg);
+    }
  }
 
  void pc_guest_info_init(PCMachineState *pcms)
Signature · 1 line
2.5.0
#5 lore raw

Re: [Qemu-devel] [PATCH 2/5] pc: Postpone SMBIOS table installation to post machine init

Quoted 11 lines · Corey Minyard
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · On Wed, Feb 24, 2016 at 12:59:13PM -0600, [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.

This changes the order of fw cfg files, which
is guest visible.
Need to make it depend on either machine type

Didn't Gerd have a patch to sort fw_cfg files?

... yes, here it is:
https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg05238.html

Paolo

#6 lore raw

Re: [Qemu-devel] [PATCH 2/5] pc: Postpone SMBIOS table installation to post machine init

Quoted 9 lines · Paolo Bonzini
Quoted 7 lines · Corey Minyard
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · On Wed, Feb 24, 2016 at 12:59:13PM -0600, [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.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

This changes the order of fw cfg files, which
is guest visible.
Need to make it depend on either machine type

Didn't Gerd have a patch to sort fw_cfg files?

... yes, here it is:
https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg05238.html

I could take that patch and modify it to add a new machine type...

-corey

Quoted 1 line

Paolo

#7 lore raw

Re: [Qemu-devel] [PATCH 2/5] pc: Postpone SMBIOS table installation to post machine init

Hi,

Quoted 6 lines
Quoted 4 lines

Didn't Gerd have a patch to sort fw_cfg files?

... yes, here it is:
https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg05238.html

I could take that patch and modify it to add a new machine type...

Sure, go ahead. Didn't submit the patch because I wasn't sure it is worth it, especially the compat stuff, do it on new machine types only etc.

But if we now have to change the order _anyway_ for new machine types it is a good opportunity to move to a sorted order at the same time, so we will not have that problem (init order changes reorders fw_cfg file directory) again.

cheers,
Gerd

#8 lore raw

Re: [Qemu-devel] [PATCH 2/5] pc: Postpone SMBIOS table installation to post machine init

In reply to Paolo Bonzini
Quoted 15 lines · Paolo Bonzini
Quoted 11 lines · Corey Minyard
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · On Wed, Feb 24, 2016 at 12:59:13PM -0600, [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.

This changes the order of fw cfg files, which
is guest visible.
Need to make it depend on either machine type

Quoted 6 lines

Didn't Gerd have a patch to sort fw_cfg files?

... yes, here it is:
https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg05238.html

Paolo

Yes but the messy part is the compatibility. Specifically we need to find out the current list of fw cfg files, and their order, and use that existing order with old machine types.

Signature · 1 line
MST
#9 lore raw

PATCH 3/5 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/smbios/Makefile.objs            |  2 +
 hw/smbios/ipmi.c                   | 76 ++++++++++++++++++++++++++++++++++++++
 hw/smbios/noipmi.c                 | 14 +++++++
 hw/smbios/smbios.c                 |  2 +
 include/hw/smbios/ipmi.h           | 15 ++++++++
 7 files changed, 111 insertions(+)
 create mode 100644 hw/smbios/ipmi.c
 create mode 100644 hw/smbios/noipmi.c
 create mode 100644 include/hw/smbios/ipmi.h
default-configs/i386-softmmu.mak +1 -0
index b177e52..c94431d 100644
@@ -20,6 +20,7 @@ CONFIG_I8254=y
 CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
+CONFIG_SMBIOS=y
 CONFIG_ACPI=y
 CONFIG_ACPI_X86=y
 CONFIG_ACPI_X86_ICH=y
default-configs/x86_64-softmmu.mak +1 -0
index 6e3b312..256294d 100644
@@ -20,6 +20,7 @@ CONFIG_I8254=y
 CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
+CONFIG_SMBIOS=y
 CONFIG_ACPI=y
 CONFIG_ACPI_X86=y
 CONFIG_ACPI_X86_ICH=y
hw/smbios/Makefile.objs +2 -0
index f69a92f..5578f51 100644
@@ -1 +1,3 @@
 common-obj-$(CONFIG_SMBIOS) += smbios.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += ipmi.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
hw/smbios/ipmi.c new file +76 -0

76 lines not on this page · raw message

hw/smbios/noipmi.c new file +14 -0
new file mode 100644
index 0000000..ad669a4
@@ -0,0 +1,14 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/smbios/ipmi.h"
+
+void smbios_build_type_38_table(void)
+{
+}
hw/smbios/smbios.c +2 -0
index e1bc1ea..ef8acdd 100644
@@ -24,6 +24,7 @@
 #include "hw/loader.h"
 #include "exec/cpu-common.h"
 #include "smbios_build.h"
+#include "hw/smbios/ipmi.h"
 
 /* legacy structures and constants for <= 2.0 machines */
 struct smbios_header {
@@ -847,6 +848,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
         }
 
         smbios_build_type_32_table();
+        smbios_build_type_38_table();
         smbios_build_type_127_table();
 
         smbios_validate_table();
include/hw/smbios/ipmi.h new file +15 -0
new file mode 100644
index 0000000..fd53c96
@@ -0,0 +1,15 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_SMBIOS_IPMI_H
+#define QEMU_SMBIOS_IPMI_H
+
+void smbios_build_type_38_table(void);
+
+#endif /* QEMU_SMBIOS_IPMI_H */
Signature · 1 line
2.5.0
#10 lore raw

Re: [Qemu-devel] [PATCH 3/5] ipmi: Add SMBIOS table entry

Quoted 96 lines · On Wed, Feb 24, 2016 at 12:59:14PM -0600, [email protected] wrote:

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/smbios/Makefile.objs            |  2 +
 hw/smbios/ipmi.c                   | 76 ++++++++++++++++++++++++++++++++++++++
 hw/smbios/noipmi.c                 | 14 +++++++
 hw/smbios/smbios.c                 |  2 +
 include/hw/smbios/ipmi.h           | 15 ++++++++
 7 files changed, 111 insertions(+)
 create mode 100644 hw/smbios/ipmi.c
 create mode 100644 hw/smbios/noipmi.c
 create mode 100644 include/hw/smbios/ipmi.h
default-configs/i386-softmmu.mak +1 -0
index b177e52..c94431d 100644
@@ -20,6 +20,7 @@ CONFIG_I8254=y
 CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
+CONFIG_SMBIOS=y
 CONFIG_ACPI=y
 CONFIG_ACPI_X86=y
 CONFIG_ACPI_X86_ICH=y
default-configs/x86_64-softmmu.mak +1 -0
index 6e3b312..256294d 100644
@@ -20,6 +20,7 @@ CONFIG_I8254=y
 CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
+CONFIG_SMBIOS=y
 CONFIG_ACPI=y
 CONFIG_ACPI_X86=y
 CONFIG_ACPI_X86_ICH=y
hw/smbios/Makefile.objs +2 -0
index f69a92f..5578f51 100644
@@ -1 +1,3 @@
 common-obj-$(CONFIG_SMBIOS) += smbios.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += ipmi.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
hw/smbios/ipmi.c new file +39 -0
new file mode 100644
index 0000000..3874431
@@ -0,0 +1,76 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/ipmi/ipmi.h"
+#include "hw/smbios/ipmi.h"
+#include "hw/smbios/smbios.h"
+#include "qemu/error-report.h"
+#include "smbios_build.h"
+
+/* SMBIOS type 38 - IPMI */
+struct smbios_type_38 {
+    struct smbios_structure_header header;
+    uint8_t interface_type;
+    uint8_t ipmi_spec_revision;
+    uint8_t i2c_slave_address;
+    uint8_t nv_storage_device_address;
+    uint64_t base_address;
+    uint8_t base_address_modifier;
+    uint8_t interrupt_number;
+} QEMU_PACKED;
+
+static void ipmi_encode_one_smbios(IPMIFwInfo *info)
+{
+    uint64_t baseaddr = info->base_address;
+    SMBIOS_BUILD_TABLE_PRE(38, 0x3000, true);
+
+    t->interface_type = info->interface_type;
+    t->ipmi_spec_revision = ((info->ipmi_spec_major_revision << 4)
+                             | info->ipmi_spec_minor_revision);
+    t->i2c_slave_address = info->i2c_slave_address;
+    t->nv_storage_device_address = 0;
+

hw/smbios/ipmi.c line 49

Quoted 10 lines
hw/smbios/ipmi.c new file +10 -0
+    /* or 1 to set it to I/O space */
+    switch (info->memspace) {
+    case IPMI_MEMSPACE_IO: baseaddr |= 1; break;
+    case IPMI_MEMSPACE_MEM32: break;
+    case IPMI_MEMSPACE_MEM64: break;
+    case IPMI_MEMSPACE_SMBUS: baseaddr <<= 1; break;
+    }
+
+    t->base_address = cpu_to_le64(baseaddr);
+    

trailing whitespace

Quoted 90 lines
hw/smbios/ipmi.c new file +27 -0
+    t->base_address_modifier = 0;
+    if (info->irq_type == IPMI_LEVEL_IRQ) {
+        t->base_address_modifier |= 1;
+    }
+    switch (info->register_spacing) {
+    case 1: break;
+    case 4: t->base_address_modifier |= 1 << 6; break;
+    case 16: t->base_address_modifier |= 2 << 6; break;
+    default:
+        error_report("IPMI register spacing %d is not compatible with"
+                     " SMBIOS, ignoring this entry.", info->register_spacing);
+        return;
+    }
+    t->interrupt_number = info->interrupt_number;
+
+    SMBIOS_BUILD_TABLE_POST;
+}
+
+void smbios_build_type_38_table(void)
+{
+    IPMIFwInfo *info = ipmi_first_fwinfo();
+
+    while (info) {
+        ipmi_encode_one_smbios(info);
+        info = ipmi_next_fwinfo(info);
+    }
+}
hw/smbios/noipmi.c new file +14 -0
new file mode 100644
index 0000000..ad669a4
@@ -0,0 +1,14 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/smbios/ipmi.h"
+
+void smbios_build_type_38_table(void)
+{
+}
hw/smbios/smbios.c +2 -0
index e1bc1ea..ef8acdd 100644
@@ -24,6 +24,7 @@
 #include "hw/loader.h"
 #include "exec/cpu-common.h"
 #include "smbios_build.h"
+#include "hw/smbios/ipmi.h"
 
 /* legacy structures and constants for <= 2.0 machines */
 struct smbios_header {
@@ -847,6 +848,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
         }
 
         smbios_build_type_32_table();
+        smbios_build_type_38_table();
         smbios_build_type_127_table();
 
         smbios_validate_table();
include/hw/smbios/ipmi.h new file +15 -0
new file mode 100644
index 0000000..fd53c96
@@ -0,0 +1,15 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_SMBIOS_IPMI_H
+#define QEMU_SMBIOS_IPMI_H
+
+void smbios_build_type_38_table(void);
+
+#endif /* QEMU_SMBIOS_IPMI_H */
Signature · 1 line
2.5.0
#11 lore raw

PATCH 4/5 acpi: Add IPMI 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. This adds a function called from build_dsdt to add an DSDT entry for IPMI if IPMI is compiled in and has registered firmware. It also adds a dummy function if IPMI is not compiled in.

This conforms to section "C3-2 Locating IPMI System Interfaces in ACPI Name Space" in the IPMI 2.0 specification.

---
 hw/acpi/Makefile.objs  |   2 +
 hw/acpi/ipmi.c         | 117 +++++++++++++++++++++++++++++++++++++++++++++++++
 hw/acpi/noipmi.c       |  14 ++++++
 hw/i386/acpi-build.c   |   4 ++
 include/hw/acpi/ipmi.h |  16 +++++++
 5 files changed, 153 insertions(+)
 create mode 100644 hw/acpi/ipmi.c
 create mode 100644 hw/acpi/noipmi.c
 create mode 100644 include/hw/acpi/ipmi.h
hw/acpi/Makefile.objs +2 -0
index f3ade9a..c44b24e 100644
@@ -6,3 +6,5 @@ common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.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-$(call land,$(CONFIG_ACPI),$(CONFIG_IPMI)) += ipmi.o
+common-obj-$(call land,$(CONFIG_ACPI),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
hw/acpi/ipmi.c new file +117 -0

117 lines not on this page · raw message

hw/acpi/noipmi.c new file +14 -0
new file mode 100644
index 0000000..4aae336
@@ -0,0 +1,14 @@
+/*
+ * IPMI ACPI firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/acpi/ipmi.h"
+
+void acpi_add_ipmi(Aml *ssdt)
+{
+}
hw/i386/acpi-build.c +4 -0
index 4554eb8..ca3d2a0 100644
@@ -58,6 +58,8 @@
 #include "qapi/qmp/qint.h"
 #include "qom/qom-qobject.h"
 
+#include "hw/acpi/ipmi.h"
+
 /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and
  * -M pc-i440fx-2.0.  Even if the actual amount of AML generated grows
  * a little bit, there should be plenty of free space since the DSDT
@@ -2283,6 +2285,8 @@ build_dsdt(GArray *table_data, GArray *linker,
         aml_append(dsdt, sb_scope);
     }
 
+    acpi_add_ipmi(dsdt);
+
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
     build_header(linker, table_data,
include/hw/acpi/ipmi.h new file +16 -0
new file mode 100644
index 0000000..313ce37
@@ -0,0 +1,16 @@
+/*
+ * QEMU IPMI ACPI handling
+ *
+ * Copyright (c) 2015 Corey Minyard <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef HW_ACPI_IPMI_H
+#define HW_ACPI_IPMI_H
+
+#include "hw/acpi/aml-build.h"
+
+void acpi_add_ipmi(Aml *ssdt);
+
+#endif /* HW_ACPI_IPMI_H */
Signature · 1 line
2.5.0
#12 lore raw

PATCH 5/5 bios: Add tests for the IPMI ACPI and SMBIOS entries

In reply to [email protected]

From: Corey Minyard <[email protected]>

---
 tests/acpi-test-data/pc/DSDT.ipmikcs | Bin 0 -> 5574 bytes
 tests/acpi-test-data/q35/DSDT.ipmibt | Bin 0 -> 8420 bytes
 tests/bios-tables-test.c             |  58 ++++++++++++++++++++++++++++++++---
 3 files changed, 54 insertions(+), 4 deletions(-)
 create mode 100644 tests/acpi-test-data/pc/DSDT.ipmikcs
 create mode 100644 tests/acpi-test-data/q35/DSDT.ipmibt
tests/acpi-test-data/pc/DSDT.ipmikcs new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b73ccc0ee985c5d0d3aa9d11715d1e7ea9e1e85a
GIT binary patch
tests/acpi-test-data/q35/DSDT.ipmibt new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..2e8f3e33137888ae7c050d396a42cf613f1656db
GIT binary patch
tests/bios-tables-test.c +54 -4

123 lines not on this page · raw message

Signature · 1 line
2.5.0
#13 lore raw
In reply to [email protected]

I haven't seen any comments on this. Is it ok? I'd like to get this in before the next release so it works automatically.

Quoted 10 lines · On 02/25/2016 01:59 AM, [email protected] wrote:

Now that Igor has reworked things to remove the SSDT, I've updated IPMI code to work with the new format. This is functionally the same as before, just for ACPI it adds the data to the DSDT now.

This will avoid a lot of "Why doesn't IPMI work when I add it?" questions, which I have already gotten.

-corey