Blame SOURCES/kvm-spapr-Add-H-Call-H_HOME_NODE_ASSOCIATIVITY.patch

383d26
From 3e4f22bfb8e4a6a4da948983c96fe60c12c957a3 Mon Sep 17 00:00:00 2001
383d26
From: Laurent Vivier <lvivier@redhat.com>
383d26
Date: Wed, 2 Jan 2019 11:29:48 +0100
383d26
Subject: [PATCH 2/8] spapr: Add H-Call H_HOME_NODE_ASSOCIATIVITY
383d26
383d26
RH-Author: Laurent Vivier <lvivier@redhat.com>
383d26
Message-id: <20190102112948.18536-3-lvivier@redhat.com>
383d26
Patchwork-id: 83821
383d26
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 2/2] spapr: Add H-Call H_HOME_NODE_ASSOCIATIVITY
383d26
Bugzilla: 1626347
383d26
RH-Acked-by: Thomas Huth <thuth@redhat.com>
383d26
RH-Acked-by: Serhii Popovych <spopovyc@redhat.com>
383d26
RH-Acked-by: David Gibson <dgibson@redhat.com>
383d26
383d26
BZ:   https://bugzilla.redhat.com/show_bug.cgi?id=1626347
383d26
383d26
H_HOME_NODE_ASSOCIATIVITY H-Call returns the associativity domain
383d26
designation associated with the identifier input parameter
383d26
383d26
This fixes a crash when we try to hotplug a CPU in memory-less and
383d26
CPU-less numa node. In this case, the kernel tries to online the
383d26
node, but without the information provided by this h-call, the node id,
383d26
it cannot and the CPU is started while the node is not onlined.
383d26
383d26
It also removes the warning message from the kernel:
383d26
  VPHN is not supported. Disabling polling..
383d26
383d26
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
383d26
Reviewed-by: Greg Kurz <groug@kaod.org>
383d26
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
383d26
(cherry picked from commit c24ba3d0a34f68ad2c6bf1a15bc43770005f6cc0)
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 hw/ppc/spapr.c         |  1 +
383d26
 hw/ppc/spapr_hcall.c   | 40 ++++++++++++++++++++++++++++++++++++++++
383d26
 include/hw/ppc/spapr.h |  1 +
383d26
 3 files changed, 42 insertions(+)
383d26
383d26
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
383d26
index b49f377..76676aa 100644
383d26
--- a/hw/ppc/spapr.c
383d26
+++ b/hw/ppc/spapr.c
383d26
@@ -933,6 +933,7 @@ static void spapr_dt_rtas(sPAPRMachineState *spapr, void *fdt)
383d26
     add_str(hypertas, "hcall-sprg0");
383d26
     add_str(hypertas, "hcall-copy");
383d26
     add_str(hypertas, "hcall-debug");
383d26
+    add_str(hypertas, "hcall-vphn");
383d26
     add_str(qemu_hypertas, "hcall-memop1");
383d26
 
383d26
     if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
383d26
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
383d26
index 16bccdd..9dd5cfd 100644
383d26
--- a/hw/ppc/spapr_hcall.c
383d26
+++ b/hw/ppc/spapr_hcall.c
383d26
@@ -1664,6 +1664,42 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
383d26
     return H_SUCCESS;
383d26
 }
383d26
 
383d26
+static target_ulong h_home_node_associativity(PowerPCCPU *cpu,
383d26
+                                              sPAPRMachineState *spapr,
383d26
+                                              target_ulong opcode,
383d26
+                                              target_ulong *args)
383d26
+{
383d26
+    target_ulong flags = args[0];
383d26
+    target_ulong procno = args[1];
383d26
+    PowerPCCPU *tcpu;
383d26
+    int idx;
383d26
+
383d26
+    /* only support procno from H_REGISTER_VPA */
383d26
+    if (flags != 0x1) {
383d26
+        return H_FUNCTION;
383d26
+    }
383d26
+
383d26
+    tcpu = spapr_find_cpu(procno);
383d26
+    if (tcpu == NULL) {
383d26
+        return H_P2;
383d26
+    }
383d26
+
383d26
+    /* sequence is the same as in the "ibm,associativity" property */
383d26
+
383d26
+    idx = 0;
383d26
+#define ASSOCIATIVITY(a, b) (((uint64_t)(a) << 32) | \
383d26
+                             ((uint64_t)(b) & 0xffffffff))
383d26
+    args[idx++] = ASSOCIATIVITY(0, 0);
383d26
+    args[idx++] = ASSOCIATIVITY(0, tcpu->node_id);
383d26
+    args[idx++] = ASSOCIATIVITY(procno, -1);
383d26
+    for ( ; idx < 6; idx++) {
383d26
+        args[idx] = -1;
383d26
+    }
383d26
+#undef ASSOCIATIVITY
383d26
+
383d26
+    return H_SUCCESS;
383d26
+}
383d26
+
383d26
 static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu,
383d26
                                               sPAPRMachineState *spapr,
383d26
                                               target_ulong opcode,
383d26
@@ -1823,6 +1859,10 @@ static void hypercall_register_types(void)
383d26
 
383d26
     /* ibm,client-architecture-support support */
383d26
     spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support);
383d26
+
383d26
+    /* Virtual Processor Home Node */
383d26
+    spapr_register_hypercall(H_HOME_NODE_ASSOCIATIVITY,
383d26
+                             h_home_node_associativity);
383d26
 }
383d26
 
383d26
 type_init(hypercall_register_types)
383d26
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
383d26
index 5118af6..5f1add0 100644
383d26
--- a/include/hw/ppc/spapr.h
383d26
+++ b/include/hw/ppc/spapr.h
383d26
@@ -432,6 +432,7 @@ struct sPAPRMachineState {
383d26
 #define H_GET_EM_PARMS          0x2B8
383d26
 #define H_SET_MPP               0x2D0
383d26
 #define H_GET_MPP               0x2D4
383d26
+#define H_HOME_NODE_ASSOCIATIVITY 0x2EC
383d26
 #define H_XIRR_X                0x2FC
383d26
 #define H_RANDOM                0x300
383d26
 #define H_SET_MODE              0x31C
383d26
-- 
383d26
1.8.3.1
383d26