yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-spapr-Set-LPCR-to-current-AIL-mode-when-starting-a-n.patch

6e7d01
From 28794dca79a94d01c8732b84fe6ac6ba2986ce45 Mon Sep 17 00:00:00 2001
6e7d01
From: Laurent Vivier <lvivier@redhat.com>
6e7d01
Date: Wed, 9 Jun 2021 10:05:01 -0400
6e7d01
Subject: [PATCH 4/4] spapr: Set LPCR to current AIL mode when starting a new
6e7d01
 CPU
6e7d01
MIME-Version: 1.0
6e7d01
Content-Type: text/plain; charset=UTF-8
6e7d01
Content-Transfer-Encoding: 8bit
6e7d01
6e7d01
RH-Author: Laurent Vivier <lvivier@redhat.com>
6e7d01
Message-id: <20210609100501.427096-3-lvivier@redhat.com>
6e7d01
Patchwork-id: 101683
6e7d01
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 2/2] spapr: Set LPCR to current AIL mode when starting a new CPU
6e7d01
Bugzilla: 1969768
6e7d01
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
6e7d01
RH-Acked-by: David Gibson <dgibson@redhat.com>
6e7d01
RH-Acked-by: Greg Kurz <gkurz@redhat.com>
6e7d01
6e7d01
From: Nicholas Piggin <npiggin@gmail.com>
6e7d01
6e7d01
TCG does not keep track of AIL mode in a central place, it's based on
6e7d01
the current LPCR[AIL] bits. Synchronize the new CPU's LPCR to the
6e7d01
current LPCR in rtas_start_cpu(), similarly to the way the ILE bit is
6e7d01
synchronized.
6e7d01
6e7d01
Open-code the ILE setting as well now that the caller's LPCR is
6e7d01
available directly, there is no need for the indirection.
6e7d01
6e7d01
Without this, under both TCG and KVM, adding a POWER8/9/10 class CPU
6e7d01
with a new core ID after a modern Linux has booted results in the new
6e7d01
CPU's LPCR missing the LPCR[AIL]=0b11 setting that the other CPUs have.
6e7d01
This can cause crashes and unexpected behaviour.
6e7d01
6e7d01
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
6e7d01
Message-Id: <20210526091626.3388262-3-npiggin@gmail.com>
6e7d01
Reviewed-by: Cédric Le Goater <clg@kaod.org>
6e7d01
Reviewed-by: Greg Kurz <groug@kaod.org>
6e7d01
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6e7d01
(cherry picked from commit ac559ecbea2649819e7b3fdd09f4e0243e0128db)
6e7d01
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
6e7d01
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
6e7d01
---
6e7d01
 hw/ppc/spapr_rtas.c | 14 +++++++++-----
6e7d01
 1 file changed, 9 insertions(+), 5 deletions(-)
6e7d01
6e7d01
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
6e7d01
index 295eac986e..5acb7c1f10 100644
6e7d01
--- a/hw/ppc/spapr_rtas.c
6e7d01
+++ b/hw/ppc/spapr_rtas.c
6e7d01
@@ -132,8 +132,8 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, SpaprMachineState *spapr,
6e7d01
     target_ulong id, start, r3;
6e7d01
     PowerPCCPU *newcpu;
6e7d01
     CPUPPCState *env;
6e7d01
-    PowerPCCPUClass *pcc;
6e7d01
     target_ulong lpcr;
6e7d01
+    target_ulong caller_lpcr;
6e7d01
 
6e7d01
     if (nargs != 3 || nret != 1) {
6e7d01
         rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
6e7d01
@@ -152,7 +152,6 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, SpaprMachineState *spapr,
6e7d01
     }
6e7d01
 
6e7d01
     env = &newcpu->env;
6e7d01
-    pcc = POWERPC_CPU_GET_CLASS(newcpu);
6e7d01
 
6e7d01
     if (!CPU(newcpu)->halted) {
6e7d01
         rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
6e7d01
@@ -163,10 +162,15 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, SpaprMachineState *spapr,
6e7d01
 
6e7d01
     env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);
6e7d01
 
6e7d01
+    caller_lpcr = callcpu->env.spr[SPR_LPCR];
6e7d01
     lpcr = env->spr[SPR_LPCR];
6e7d01
-    if (!pcc->interrupts_big_endian(callcpu)) {
6e7d01
-        lpcr |= LPCR_ILE;
6e7d01
-    }
6e7d01
+
6e7d01
+    /* Set ILE the same way */
6e7d01
+    lpcr = (lpcr & ~LPCR_ILE) | (caller_lpcr & LPCR_ILE);
6e7d01
+
6e7d01
+    /* Set AIL the same way */
6e7d01
+    lpcr = (lpcr & ~LPCR_AIL) | (caller_lpcr & LPCR_AIL);
6e7d01
+
6e7d01
     if (env->mmu_model == POWERPC_MMU_3_00) {
6e7d01
         /*
6e7d01
          * New cpus are expected to start in the same radix/hash mode
6e7d01
-- 
6e7d01
2.27.0
6e7d01