From nobody Tue Feb 10 03:39:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1622708926; cv=none; d=zohomail.com; s=zohoarc; b=jYVLR9sGwMZgiVi+AigYkIDQndU5kqiA0KCIm7KsofuB7N+07uekUso15KQZW9HBLiR5x3P62j327shD54a5mZlBgDpnnpfjQ4XCh5fwl3uP3cT7AmCslpeYEO0Fg7alDyImdPbpN2XPjlCd/Js2jlaynR9og64jkriVvP8ogoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622708926; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BeDU440ckwrnd37iWzG0P6rZT6BDvehsEOM5ewMX2+I=; b=R5pSK3Ool3oMSI7ynQcT5et+N/gczJIQmfLFFjAWlO3XCbqroXfERUunrXmocd7szYrBpCN2A4c9pV2tNChF7NTjpBBu3BGuYPD7Ze6nrmM86quhCFgoCQFxSXtwxCViSTBaYFJvd+rrdPu6z/eNU7KaYlJH7e1LUSxU6SAPQ9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622708926876476.387098562476; Thu, 3 Jun 2021 01:28:46 -0700 (PDT) Received: from localhost ([::1]:35132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loiib-0004MH-Mw for importer@patchew.org; Thu, 03 Jun 2021 04:28:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loicz-0006An-S8; Thu, 03 Jun 2021 04:22:57 -0400 Received: from ozlabs.org ([203.11.71.1]:47775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loicx-0008Tl-OC; Thu, 03 Jun 2021 04:22:57 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4Fwf5l6yT2z9sfG; Thu, 3 Jun 2021 18:22:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1622708555; bh=ocOgRPM3in48qWZnlawAo5g/f8fvj27brpP0cKJM8hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XJziEISTFenYxLPNDIcagORJ5u+e6GJ6bk1AsUf/npAkBAy4kTRafA8Jg+Lu+JgFI RJ/nhVnZ2/zJZsyKiXBeJmpVWBrvIyHdsOEKPDNCiyinu09FYNH0IK9xqutcmYTG46 KfONZAx6DQjaaZN8/bUJe4tNUWCyuYeZDsGO1Aw0= From: David Gibson To: peter.maydell@linaro.org, groug@kaod.org Subject: [PULL 11/42] spapr: Set LPCR to current AIL mode when starting a new CPU Date: Thu, 3 Jun 2021 18:22:00 +1000 Message-Id: <20210603082231.601214-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603082231.601214-1-david@gibson.dropbear.id.au> References: <20210603082231.601214-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nicholas Piggin TCG does not keep track of AIL mode in a central place, it's based on the current LPCR[AIL] bits. Synchronize the new CPU's LPCR to the current LPCR in rtas_start_cpu(), similarly to the way the ILE bit is synchronized. Open-code the ILE setting as well now that the caller's LPCR is available directly, there is no need for the indirection. Without this, under both TCG and KVM, adding a POWER8/9/10 class CPU with a new core ID after a modern Linux has booted results in the new CPU's LPCR missing the LPCR[AIL]=3D0b11 setting that the other CPUs have. This can cause crashes and unexpected behaviour. Signed-off-by: Nicholas Piggin Message-Id: <20210526091626.3388262-3-npiggin@gmail.com> Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr_rtas.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 63d96955c0..b476382ae6 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -132,8 +132,8 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, SpaprMa= chineState *spapr, target_ulong id, start, r3; PowerPCCPU *newcpu; CPUPPCState *env; - PowerPCCPUClass *pcc; target_ulong lpcr; + target_ulong caller_lpcr; =20 if (nargs !=3D 3 || nret !=3D 1) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); @@ -152,7 +152,6 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, SpaprMa= chineState *spapr, } =20 env =3D &newcpu->env; - pcc =3D POWERPC_CPU_GET_CLASS(newcpu); =20 if (!CPU(newcpu)->halted) { rtas_st(rets, 0, RTAS_OUT_HW_ERROR); @@ -164,10 +163,15 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, Spapr= MachineState *spapr, env->msr =3D (1ULL << MSR_SF) | (1ULL << MSR_ME); hreg_compute_hflags(env); =20 + caller_lpcr =3D callcpu->env.spr[SPR_LPCR]; lpcr =3D env->spr[SPR_LPCR]; - if (!pcc->interrupts_big_endian(callcpu)) { - lpcr |=3D LPCR_ILE; - } + + /* Set ILE the same way */ + lpcr =3D (lpcr & ~LPCR_ILE) | (caller_lpcr & LPCR_ILE); + + /* Set AIL the same way */ + lpcr =3D (lpcr & ~LPCR_AIL) | (caller_lpcr & LPCR_AIL); + if (env->mmu_model =3D=3D POWERPC_MMU_3_00) { /* * New cpus are expected to start in the same radix/hash mode --=20 2.31.1