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

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