qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: aliguori@us.ibm.com
Cc: Andre Przywara <andre.przywara@amd.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/4] sending NUMA topology to BIOS
Date: Tue, 21 Apr 2009 13:02:48 +0200	[thread overview]
Message-ID: <1240311769-8590-4-git-send-email-andre.przywara@amd.com> (raw)
In-Reply-To: <1240311769-8590-1-git-send-email-andre.przywara@amd.com>

uses the QEMU firmware configuration interfacce to send the NUMA
topology to the BIOS, which has to setup the tables. Only one firmware
configuration channel is used.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 hw/fw_cfg.h |    1 +
 hw/pc.c     |   24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
index 41a3dd0..f616ed2 100644
--- a/hw/fw_cfg.h
+++ b/hw/fw_cfg.h
@@ -14,6 +14,7 @@
 #define FW_CFG_INITRD_ADDR      0x0a
 #define FW_CFG_INITRD_SIZE      0x0b
 #define FW_CFG_BOOT_DEVICE      0x0c
+#define FW_CFG_NUMA             0x0d
 #define FW_CFG_MAX_ENTRY        0x10
 
 #define FW_CFG_WRITE_CHANNEL    0x4000
diff --git a/hw/pc.c b/hw/pc.c
index cac6fb1..07b75f3 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -424,11 +424,15 @@ static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val)
     }
 }
 
+extern uint64_t node_cpumask[MAX_NODES];
+
 static void bochs_bios_init(void)
 {
     void *fw_cfg;
     uint8_t *smbios_table;
     size_t smbios_len;
+    uint64_t *numa_fw_cfg;
+    int i, j;
 
     register_ioport_write(0x400, 1, 2, bochs_bios_write, NULL);
     register_ioport_write(0x401, 1, 2, bochs_bios_write, NULL);
@@ -451,6 +455,26 @@ static void bochs_bios_init(void)
     if (smbios_table)
         fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
                          smbios_table, smbios_len);
+
+    /* allocate memory for the NUMA channel: one (64bit) word for the number
+     * of nodes, one word for each VCPU->node and one word for each node to
+     * hold the amount of memory.
+     */
+    numa_fw_cfg = qemu_mallocz((1 + smp_cpus + nb_numa_nodes) * 8);
+    numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes);
+    for (i = 0; i < smp_cpus; i++) {
+        for (j = 0; j < nb_numa_nodes; j++) {
+            if (node_cpumask[j] & (1 << i)) {
+                numa_fw_cfg[i + 1] = cpu_to_le64(j);
+                break;
+            }
+        }
+    }
+    for (i = 0; i < nb_numa_nodes; i++) {
+        numa_fw_cfg[smp_cpus + 1 + i] = cpu_to_le64(node_mem[i]);
+    }
+    fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, (uint8_t *)numa_fw_cfg,
+                     (1 + smp_cpus + nb_numa_nodes) * 8);
 }
 
 /* Generate an initial boot sector which sets state and jump to
-- 
1.6.1.3

  parent reply	other threads:[~2009-04-21 11:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-21 11:02 [Qemu-devel] [PATCH 0/4] v3: add NUMA emulation Andre Przywara
2009-04-21 11:02 ` [Qemu-devel] [PATCH 1/4] added -numa cmdline parameter parser Andre Przywara
2009-04-21 22:32   ` [Qemu-devel] " Anthony Liguori
2009-04-21 11:02 ` [Qemu-devel] [PATCH 2/4] add info numa command to monitor Andre Przywara
2009-04-21 11:02 ` Andre Przywara [this message]
2009-04-21 11:02 ` [Qemu-devel] [PATCH 4/4] add SRAT ACPI table support Andre Przywara
  -- strict thread matches above, loose matches on Subject: below --
2009-04-08 14:50 [Qemu-devel] [PATCH 0/4] v2: add NUMA emulation Andre Przywara
2009-04-08 14:50 ` [Qemu-devel] [PATCH 3/4] sending NUMA topology to BIOS Andre Przywara
2009-03-31 13:28 [Qemu-devel] [PATCH 0/4] add NUMA emulation Andre Przywara
2009-03-31 13:28 ` [Qemu-devel] [PATCH 1/4] added -numa cmdline parameter parser Andre Przywara
2009-03-31 13:28   ` [Qemu-devel] [PATCH 2/4] add info numa command to monitor Andre Przywara
2009-03-31 13:28     ` [Qemu-devel] [PATCH 3/4] sending NUMA topology to BIOS Andre Przywara
2009-03-31 16:00       ` Blue Swirl
2009-03-31 21:33         ` Andre Przywara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1240311769-8590-4-git-send-email-andre.przywara@amd.com \
    --to=andre.przywara@amd.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).