From nobody Sat May 4 16:03:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500265091684601.5777262838695; Sun, 16 Jul 2017 21:18:11 -0700 (PDT) Received: from localhost ([::1]:47860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWxU2-0006iq-4e for importer@patchew.org; Mon, 17 Jul 2017 00:18:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWxTB-0006Mj-NB for qemu-devel@nongnu.org; Mon, 17 Jul 2017 00:17:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWxT7-0004Bf-6k for qemu-devel@nongnu.org; Mon, 17 Jul 2017 00:17:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46529) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dWxT6-000488-TM for qemu-devel@nongnu.org; Mon, 17 Jul 2017 00:17:13 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6H4DckZ088293 for ; Mon, 17 Jul 2017 00:17:10 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bqdcrbx22-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 17 Jul 2017 00:17:10 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jul 2017 14:17:08 +1000 Received: from d23relay08.au.ibm.com (202.81.31.227) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Jul 2017 14:17:05 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6H4H4VW27263208; Mon, 17 Jul 2017 14:17:04 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v6H4Gtws009872; Mon, 17 Jul 2017 14:16:55 +1000 Received: from abhimanyu.ibmmodules.com ([9.85.69.224]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v6H4GcO1009454; Mon, 17 Jul 2017 14:16:40 +1000 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Mon, 17 Jul 2017 09:46:39 +0530 X-Mailer: git-send-email 2.9.3 X-TM-AS-MML: disable x-cbid: 17071704-0040-0000-0000-000003494D1E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071704-0041-0000-0000-00000CC506DF Message-Id: <20170717041639.16137-1-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-17_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707170063 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v3] spapr: disable decrementer during reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bharata@linux.vnet.ibm.com, qemu-devel@nongnu.org, Nikunj A Dadhania , clg@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Rebooting a SMP TCG guest is broken for both single/multi threaded TCG. When reset happens, all the CPUs are in halted state. First CPU is brought = out of reset and secondary CPUs would be initialized by the guest kernel using a rtas call start-cpu. However, in case of TCG, decrementer interrupts keep on coming and waking t= he secondary CPUs up. These secondary CPUs would see the decrementer interrupt pending, which mak= es cpu::has_work() to bring them out of wait loop and start executing tcg_exec_cpu(). The problem with this is all the CPUs wake up and start booting SLOF image, causing the following exception(4 CPUs TCG VM): [ 81.440850] reboot: Restarting system SLOF S SLOF SLOFLOF[0[0m **************************************************************= ******** QEMU Starting Build Date =3D Mar 3 2017 13:29:19 FW Version =3D git-66d250ef0fd06bb8 [0m ********************************************************************** QEMU Starting Build Date =3D Mar 3 2017 13:29:19 FW Version =3D git-66d250ef0fd06bb8 [0m *************************************m**********[?25l *****************= ***************************************************** QEMU Starting Build Date =3D Mar 3 2017 13:29:19 FW Version =3D git-66d250ef0fd06bb8 *********************** QEMU Starting Build Date =3D Mar 3 2017 13:29:19 FW Version =3D git-66d250ef0fd06bb8 ERROR: Flatten device tree not available! exception 300 SRR0 =3D 00000000000060e4 SRR1 =3D 800000008000000000000000 SPRG2 =3D 0000000000400000 SPRG3 =3D 0000000000004bd8 ERROR: Flatten device tree not available! exception 300 SRR0 =3D 00000000000060e4 SRR1 =3D 800000008000000000000000 SPRG2 =3D 0000000000400000 SPRG3 =3D 0000000000004bd8 During reset, disable decrementer interrupt for secondary CPUs and enable t= hem when the secondary CPUs are brought online by rtas start-cpu call. Reported-by: Bharata B Rao Signed-off-by: Nikunj A Dadhania --- hw/ppc/spapr_cpu_core.c | 9 +++++++++ hw/ppc/spapr_rtas.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index ea278ce..bbfe8c2 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -87,6 +87,15 @@ static void spapr_cpu_reset(void *opaque) =20 env->spr[SPR_HIOR] =3D 0; =20 + /* Disable DECR for secondary cpus */ + if (cs !=3D first_cpu) { + if (env->mmu_model =3D=3D POWERPC_MMU_3_00) { + env->spr[SPR_LPCR] &=3D ~LPCR_DEE; + } else { + /* P7 and P8 both have same bit for DECR */ + env->spr[SPR_LPCR] &=3D ~LPCR_P8_PECE3; + } + } /* * This is a hack for the benefit of KVM PR - it abuses the SDR1 * slot in kvm_sregs to communicate the userspace address of the diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 94a2799..4623d1d 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -174,6 +174,14 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMach= ineState *spapr, kvm_cpu_synchronize_state(cs); =20 env->msr =3D (1ULL << MSR_SF) | (1ULL << MSR_ME); + + /* Enable DECR interrupt */ + if (env->mmu_model =3D=3D POWERPC_MMU_3_00) { + env->spr[SPR_LPCR] |=3D LPCR_DEE; + } else { + /* P7 and P8 both have same bit for DECR */ + env->spr[SPR_LPCR] |=3D LPCR_P8_PECE3; + } env->nip =3D start; env->gpr[3] =3D r3; cs->halted =3D 0; --=20 2.9.3