|
|
1bdc94 |
From 7d5a7d6926805c069903bef845d43912cf718410 Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
1bdc94 |
Date: Tue, 3 Jul 2018 17:23:54 +0200
|
|
|
1bdc94 |
Subject: [PATCH 09/89] i386: Fix up the Node id for CPUID_8000_001E
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
1bdc94 |
Message-id: <20180703172356.21038-9-ehabkost@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 81218
|
|
|
1bdc94 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH v3 08/10] i386: Fix up the Node id for CPUID_8000_001E
|
|
|
1bdc94 |
Bugzilla: 1481253
|
|
|
1bdc94 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
From: Babu Moger <babu.moger@amd.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
This is part of topoext support. To keep the compatibility, it is better
|
|
|
1bdc94 |
we support all the combination of nr_cores and nr_threads currently
|
|
|
1bdc94 |
supported. By allowing more nr_cores and nr_threads, we might end up with
|
|
|
1bdc94 |
more nodes than we can actually support with the real hardware. We need to
|
|
|
1bdc94 |
fix up the node id to make this work. We can achieve this by shifting the
|
|
|
1bdc94 |
socket_id bits left to address more nodes.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Signed-off-by: Babu Moger <babu.moger@amd.com>
|
|
|
1bdc94 |
Message-Id: <1529443919-67509-2-git-send-email-babu.moger@amd.com>
|
|
|
1bdc94 |
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit 631be32155dbafa1fe886f2488127956c9120ba6)
|
|
|
1bdc94 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
---
|
|
|
1bdc94 |
target/i386/cpu.c | 26 +++++++++++++++++++++++++-
|
|
|
1bdc94 |
1 file changed, 25 insertions(+), 1 deletion(-)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
1bdc94 |
index 643d3b1..ef43ea0 100644
|
|
|
1bdc94 |
--- a/target/i386/cpu.c
|
|
|
1bdc94 |
+++ b/target/i386/cpu.c
|
|
|
1bdc94 |
@@ -19,6 +19,7 @@
|
|
|
1bdc94 |
|
|
|
1bdc94 |
#include "qemu/osdep.h"
|
|
|
1bdc94 |
#include "qemu/cutils.h"
|
|
|
1bdc94 |
+#include "qemu/bitops.h"
|
|
|
1bdc94 |
|
|
|
1bdc94 |
#include "cpu.h"
|
|
|
1bdc94 |
#include "exec/exec-all.h"
|
|
|
1bdc94 |
@@ -474,6 +475,8 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu,
|
|
|
1bdc94 |
uint32_t *ecx, uint32_t *edx)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
struct core_topology topo = {0};
|
|
|
1bdc94 |
+ unsigned long nodes;
|
|
|
1bdc94 |
+ int shift;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
build_core_topology(cs->nr_cores, cpu->core_id, &topo;;
|
|
|
1bdc94 |
*eax = cpu->apic_id;
|
|
|
1bdc94 |
@@ -506,7 +509,28 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu,
|
|
|
1bdc94 |
* 2 Socket id
|
|
|
1bdc94 |
* 1:0 Node id
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
- *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << 2) | topo.node_id;
|
|
|
1bdc94 |
+ if (topo.num_nodes <= 4) {
|
|
|
1bdc94 |
+ *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << 2) |
|
|
|
1bdc94 |
+ topo.node_id;
|
|
|
1bdc94 |
+ } else {
|
|
|
1bdc94 |
+ /*
|
|
|
1bdc94 |
+ * Node id fix up. Actual hardware supports up to 4 nodes. But with
|
|
|
1bdc94 |
+ * more than 32 cores, we may end up with more than 4 nodes.
|
|
|
1bdc94 |
+ * Node id is a combination of socket id and node id. Only requirement
|
|
|
1bdc94 |
+ * here is that this number should be unique accross the system.
|
|
|
1bdc94 |
+ * Shift the socket id to accommodate more nodes. We dont expect both
|
|
|
1bdc94 |
+ * socket id and node id to be big number at the same time. This is not
|
|
|
1bdc94 |
+ * an ideal config but we need to to support it. Max nodes we can have
|
|
|
1bdc94 |
+ * is 32 (255/8) with 8 cores per node and 255 max cores. We only need
|
|
|
1bdc94 |
+ * 5 bits for nodes. Find the left most set bit to represent the total
|
|
|
1bdc94 |
+ * number of nodes. find_last_bit returns last set bit(0 based). Left
|
|
|
1bdc94 |
+ * shift(+1) the socket id to represent all the nodes.
|
|
|
1bdc94 |
+ */
|
|
|
1bdc94 |
+ nodes = topo.num_nodes - 1;
|
|
|
1bdc94 |
+ shift = find_last_bit(&nodes, 8);
|
|
|
1bdc94 |
+ *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << (shift + 1)) |
|
|
|
1bdc94 |
+ topo.node_id;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
*edx = 0;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|