All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/5] Add IPMI firmware tables
@ 2016-05-11 16:38 minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 1/5] pc: Postpone SMBIOS table installation to post machine init minyard
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: minyard @ 2016-05-11 16:38 UTC (permalink / raw)
  To: Igor Mammedov, Michael S . Tsirkin, Paolo Bonzini, qemu-devel, minyard

Now that 2.6 is out, re-post these patches.  No changes since the
previous release.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v2 1/5] pc: Postpone SMBIOS table installation to post machine init
  2016-05-11 16:38 [Qemu-devel] [PATCH v2 0/5] Add IPMI firmware tables minyard
@ 2016-05-11 16:38 ` minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 2/5] smbios: Move table build tools into an include file minyard
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: minyard @ 2016-05-11 16:38 UTC (permalink / raw)
  To: Igor Mammedov, Michael S . Tsirkin, Paolo Bonzini, qemu-devel, minyard
  Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

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 <cminyard@mvista.com>
---
 hw/i386/pc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 99437e0..5e78ef4 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -764,8 +764,6 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms)
                      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)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v2 2/5] smbios: Move table build tools into an include file.
  2016-05-11 16:38 [Qemu-devel] [PATCH v2 0/5] Add IPMI firmware tables minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 1/5] pc: Postpone SMBIOS table installation to post machine init minyard
@ 2016-05-11 16:38 ` minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 3/5] ipmi: Add SMBIOS table entry minyard
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: minyard @ 2016-05-11 16:38 UTC (permalink / raw)
  To: Igor Mammedov, Michael S . Tsirkin, Paolo Bonzini, qemu-devel, minyard
  Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

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

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 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

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index cb8a111..5dc3e43 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -24,6 +24,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 {
@@ -53,10 +54,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;
@@ -429,7 +430,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) */
@@ -443,65 +444,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 */
diff --git a/hw/smbios/smbios_build.h b/hw/smbios/smbios_build.h
new file mode 100644
index 0000000..2257721
--- /dev/null
+++ b/hw/smbios/smbios_build.h
@@ -0,0 +1,77 @@
+/*
+ * SMBIOS Support
+ *
+ * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
+ * Copyright (C) 2013 Red Hat, Inc.
+ */
+
+#ifndef QEMU_SMBIOS_BUILD_H
+#define QEMU_SMBIOS_BUILD_H
+
+bool smbios_skip_table(uint8_t type, bool required_table);
+
+extern uint8_t *smbios_tables;
+extern size_t smbios_tables_len;
+extern unsigned smbios_table_max;
+extern unsigned smbios_table_cnt;
+
+#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)
+
+#endif /* QEMU_SMBIOS_BUILD_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v2 3/5] ipmi: Add SMBIOS table entry
  2016-05-11 16:38 [Qemu-devel] [PATCH v2 0/5] Add IPMI firmware tables minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 1/5] pc: Postpone SMBIOS table installation to post machine init minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 2/5] smbios: Move table build tools into an include file minyard
@ 2016-05-11 16:38 ` minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 4/5] acpi: Add IPMI table entries minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 5/5] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard
  4 siblings, 0 replies; 6+ messages in thread
From: minyard @ 2016-05-11 16:38 UTC (permalink / raw)
  To: Igor Mammedov, Michael S . Tsirkin, Paolo Bonzini, qemu-devel, minyard
  Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

Add an IPMI table entry to the SMBIOS.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
---
 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

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index b177e52..c94431d 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -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
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index 6e3b312..256294d 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -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
diff --git a/hw/smbios/Makefile.objs b/hw/smbios/Makefile.objs
index f69a92f..5578f51 100644
--- a/hw/smbios/Makefile.objs
+++ b/hw/smbios/Makefile.objs
@@ -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
diff --git a/hw/smbios/ipmi.c b/hw/smbios/ipmi.c
new file mode 100644
index 0000000..b4b6151
--- /dev/null
+++ b/hw/smbios/ipmi.c
@@ -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;
+
+    /* 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);
+
+    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);
+    }
+}
diff --git a/hw/smbios/noipmi.c b/hw/smbios/noipmi.c
new file mode 100644
index 0000000..ad669a4
--- /dev/null
+++ b/hw/smbios/noipmi.c
@@ -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)
+{
+}
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 5dc3e43..74c7102 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -25,6 +25,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 {
@@ -848,6 +849,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();
diff --git a/include/hw/smbios/ipmi.h b/include/hw/smbios/ipmi.h
new file mode 100644
index 0000000..fd53c96
--- /dev/null
+++ b/include/hw/smbios/ipmi.h
@@ -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 */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v2 4/5] acpi: Add IPMI table entries
  2016-05-11 16:38 [Qemu-devel] [PATCH v2 0/5] Add IPMI firmware tables minyard
                   ` (2 preceding siblings ...)
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 3/5] ipmi: Add SMBIOS table entry minyard
@ 2016-05-11 16:38 ` minyard
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 5/5] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard
  4 siblings, 0 replies; 6+ messages in thread
From: minyard @ 2016-05-11 16:38 UTC (permalink / raw)
  To: Igor Mammedov, Michael S . Tsirkin, Paolo Bonzini, qemu-devel, minyard
  Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

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.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 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 |  17 +++++++
 5 files changed, 154 insertions(+)
 create mode 100644 hw/acpi/ipmi.c
 create mode 100644 hw/acpi/noipmi.c
 create mode 100644 include/hw/acpi/ipmi.h

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index faee86c..b8d5c84 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -6,3 +6,5 @@ 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
diff --git a/hw/acpi/ipmi.c b/hw/acpi/ipmi.c
new file mode 100644
index 0000000..731f4ad
--- /dev/null
+++ b/hw/acpi/ipmi.c
@@ -0,0 +1,117 @@
+/*
+ * 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 "qemu/osdep.h"
+#include "hw/ipmi/ipmi.h"
+#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi.h"
+#include "hw/acpi/ipmi.h"
+
+static Aml *aml_ipmi_crs(IPMIFwInfo *info)
+{
+    Aml *crs = aml_resource_template();
+    uint8_t regspacing = info->register_spacing;
+
+    /*
+     * The base address is fixed and cannot change.  That may be different
+     * if someone does PCI, but we aren't there yet.
+     */
+    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_READ_WRITE,
+                            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,
+                            AML_NON_CACHEABLE, AML_READ_WRITE,
+                            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;
+    default:
+        abort();
+    }
+
+    if (info->interrupt_number) {
+        aml_append(crs, aml_irq_no_flags(info->interrupt_number));
+    }
+
+    return crs;
+}
+
+static void
+ipmi_encode_one_acpi(Aml *table, IPMIFwInfo *info)
+{
+    Aml *scope, *dev, *method;
+    uint16_t version = ((info->ipmi_spec_major_revision << 8)
+                        | (info->ipmi_spec_minor_revision << 4));
+
+    /*
+     * The ACPI parent is a little bit of a pain.  It could be in
+     * different places depending on the device.  It could be an SMBus,
+     * it could be ISA, it could be PCI, etc.  Only the device really
+     * knows, so it has to pass it in.
+     */
+    if (!info->acpi_parent) {
+        ipmi_debug("device %s not compatible with ACPI, no parent given.",
+                   info->interface_name);
+        return;
+    }
+
+    scope = aml_scope("%s", info->acpi_parent);
+
+    dev = aml_device("MI0");
+    aml_append(dev, aml_name_decl("_HID", aml_eisaid("IPI0001")));
+    aml_append(dev, aml_name_decl("_STR", aml_string("ipmi_%s",
+                                                     info->interface_name)));
+    aml_append(dev, aml_name_decl("_UID", aml_int(info->uuid)));
+    aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info)));
+
+    /*
+     * The spec seems to require these to be methods.  All the examples
+     * show them this way and it doesn't seem to work if they are not.
+     */
+    method = aml_method("_IFT", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_return(aml_int(info->interface_type)));
+    aml_append(dev, method);
+    method = aml_method("_SRV", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_return(aml_int(version)));
+    aml_append(dev, method);
+
+    aml_append(scope, dev);
+
+    aml_append(table, scope);
+}
+
+void acpi_add_ipmi(Aml *table)
+{
+    IPMIFwInfo *info = ipmi_first_fwinfo();
+
+    while (info) {
+        ipmi_encode_one_acpi(table, info);
+        info = ipmi_next_fwinfo(info);
+    }
+}
diff --git a/hw/acpi/noipmi.c b/hw/acpi/noipmi.c
new file mode 100644
index 0000000..4aae336
--- /dev/null
+++ b/hw/acpi/noipmi.c
@@ -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)
+{
+}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 6477003..2294e7b 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -59,6 +59,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
@@ -2364,6 +2366,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,
diff --git a/include/hw/acpi/ipmi.h b/include/hw/acpi/ipmi.h
new file mode 100644
index 0000000..4f11a28
--- /dev/null
+++ b/include/hw/acpi/ipmi.h
@@ -0,0 +1,17 @@
+/*
+ * QEMU IPMI ACPI handling
+ *
+ * Copyright (c) 2015 Corey Minyard <cminyard@mvista.com>
+ *
+ * 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 "qemu/osdep.h"
+#include "hw/acpi/aml-build.h"
+
+void acpi_add_ipmi(Aml *ssdt);
+
+#endif /* HW_ACPI_IPMI_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v2 5/5] bios: Add tests for the IPMI ACPI and SMBIOS entries
  2016-05-11 16:38 [Qemu-devel] [PATCH v2 0/5] Add IPMI firmware tables minyard
                   ` (3 preceding siblings ...)
  2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 4/5] acpi: Add IPMI table entries minyard
@ 2016-05-11 16:38 ` minyard
  4 siblings, 0 replies; 6+ messages in thread
From: minyard @ 2016-05-11 16:38 UTC (permalink / raw)
  To: Igor Mammedov, Michael S . Tsirkin, Paolo Bonzini, qemu-devel, minyard
  Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 tests/acpi-test-data/pc/DSDT.ipmikcs | Bin 0 -> 5683 bytes
 tests/acpi-test-data/q35/DSDT.ipmibt | Bin 0 -> 8456 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

diff --git a/tests/acpi-test-data/pc/DSDT.ipmikcs b/tests/acpi-test-data/pc/DSDT.ipmikcs
new file mode 100644
index 0000000000000000000000000000000000000000..280aeb3059eb9220108b9a2b7f0ac07819023b06
GIT binary patch
literal 5683
zcmb7IUvC@75ud#yrQ?#6j?!6{?Kmc6J8sh2<{w*j(4r7|M~Req)R{-QF3#v3B^jmL
zq&_Gy5Jd<eGpOw3EoEJ_Z?wy|0`^B}AN!b(kbZ>}jr|mL=8j9Tat?3_@OEeBw==W5
zGqZbV*hZ^32f+STUel{~wtU;t4dgKZpgy%~Ep`W-J)^whvZNGa&ckHT$46Pweqxl@
zSJ<CB-k&`0<3}EA`>^p$eX`N^KY#3P0D&HC_?%NmU2yHP>vT_9dM&58)tZqiea&UX
zEg4Nv-1VBlR8t8t6{TubS^~rngkp4~YPC#A0et;^5@OCnmFU@9m4=bEnueRz7G1kl
z0-rdZPptN*9#_47>Z_gyJui81Fo6ElSG_j;v7Lf{{U<(v0iRY}y=iAMd}=>|Ge+eQ
z1K0ue{3Y^++;zGqtlRlw;A=_-hOSuoqAmeHP?zFkFg;eYOKyn6g(cjToGx*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VDuqNZ2jV
z(k`X~L!z<@9W6ukUBZgrfqfc&PoaZjMrQQ7HWtf4wGZm{*xuk3h{HTNRki4L3Y^b7
z56=)GQ<ch6&B8~WdUfn!@}k$L2~dJ19@Jf|3Rum9;!Ss7=i#w%Jl6Uw<uN{NJ*!Pn
z!IxC?KCPruMk$6w($3}ZHG$qSo$h;fen?>KN}%D+<PAJ#s8bM~B6XbZyLSFM4z$-B
z!*^61B7-&)tPNeI$pDE7S|GIq#hU<{LMXnGL_mesxPZo^phck-BO%l}5eXGqCk1pe
z3VKCo#W$=_s}cznS`z}Ah=N`fTDgGoNT|??NgO(mjDju-ttkObMM8zvw1B3gpx1=f
zDFK~|gbJ;A#}9p-j)GnnT2%p6BcVcTMnE%B(D#Mb83CP%gbJ;*0y-N7EeWj{`Qfy*
zNT|?yOhAuCLCZqxoPf?nLWS1j0(v|Ostc|20y-ZF6<SXS=!qz(A+(+p(36o+q4ku2
zo{EB2gx0qN^sPv!(0W=xPe(zQh1RzP^zBHf(0WEd&-@TntDZ7$HCj?XwcEiLjeV+h
z_X0vi0;^d_WQh=xB_yySg_1oYNRr;|B=I}fzKvyNNJ&JEWHF?$I1FWE>*`2G#xTW)
zGP1Tfl94$~)S-;*T_f4_ZU?I?p2+()CY+%0Oh)=pjwkcJjj1E#_$Gz)p<E>zlR(I`
z0evW6A{xV4$oB&JP#(+}15?QHFxj{DF*(f|Lu@3cc^hMLnmGo`NS-BnOumFPZu>~S
zM>NW{GjxZ<kAC#^hPDvTx^*_}7+hA@;$ug0`1P<JGiww<^tIxh1mKqfyVXqJ^FO@j
n{&w>tyq?gf*ReDES?aGTCgBUL;?|b&hQKtAFRQm;kOb+!4tZ%z

literal 0
HcmV?d00001

diff --git a/tests/acpi-test-data/q35/DSDT.ipmibt b/tests/acpi-test-data/q35/DSDT.ipmibt
new file mode 100644
index 0000000000000000000000000000000000000000..6704538dee7dcfade6a1dc74eda5b8b832d7c6a2
GIT binary patch
literal 8456
zcmb7KO>Y~=8J;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Vwd9{pMV$OAzm$9}=3--P3XFJO;
zsQ`DHBk*$2Ia9$5PmQy>vBHgP6s&fISI!#R)bjCKCTvnlT0edY-`eOJv<o+rH*WSf
qZs9WXe+BT{8L!m-OZ;0n>7_+jF;;+^HJogj_9b4?u8Q59Nc|sVisEVj

literal 0
HcmV?d00001

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 0352814..3b7689e 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -50,6 +50,8 @@ typedef struct {
     GArray *tables;
     uint32_t smbios_ep_addr;
     struct smbios_21_entry_point smbios_ep_table;
+    uint8_t *required_struct_types;
+    int required_struct_types_len;
 } test_data;
 
 #define ACPI_READ_FIELD(field, addr)           \
@@ -335,7 +337,7 @@ static void test_acpi_tables(test_data *data)
     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);
@@ -654,7 +656,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++) {
@@ -694,8 +695,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));
     }
 }
 
@@ -735,6 +736,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;
@@ -744,6 +748,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);
 }
@@ -755,6 +761,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);
 }
@@ -765,6 +773,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);
 }
@@ -776,11 +786,49 @@ 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_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.variant = ".ipmibt";
+    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.variant = ".ipmikcs";
+    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();
@@ -797,6 +845,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();
     boot_sector_cleanup(disk);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-11 16:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-11 16:38 [Qemu-devel] [PATCH v2 0/5] Add IPMI firmware tables minyard
2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 1/5] pc: Postpone SMBIOS table installation to post machine init minyard
2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 2/5] smbios: Move table build tools into an include file minyard
2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 3/5] ipmi: Add SMBIOS table entry minyard
2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 4/5] acpi: Add IPMI table entries minyard
2016-05-11 16:38 ` [Qemu-devel] [PATCH v2 5/5] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.