From nobody Tue Apr 30 02:17:52 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 1507564444505634.7540346338677; Mon, 9 Oct 2017 08:54:04 -0700 (PDT) Received: from localhost ([::1]:58489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1aNQ-00073Y-MR for importer@patchew.org; Mon, 09 Oct 2017 11:53:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1aJU-0004A7-Bf for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:49:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1aJQ-00036O-DU for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:49:52 -0400 Received: from 10.mo4.mail-out.ovh.net ([188.165.33.109]:35337) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1aJQ-00035n-7Q for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:49:48 -0400 Received: from player746.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id AE443D93D6 for ; Mon, 9 Oct 2017 17:49:46 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player746.ha.ovh.net (Postfix) with ESMTPSA id 78CB2500087; Mon, 9 Oct 2017 17:49:40 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Nikunj A Dadhania , Benjamin Herrenschmidt Date: Mon, 9 Oct 2017 17:49:27 +0200 Message-Id: <20171009154930.29095-2-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171009154930.29095-1-clg@kaod.org> References: <20171009154930.29095-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 11140216630008974163 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrleelgdejkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 188.165.33.109 Subject: [Qemu-devel] [PATCH v2 1/4] target/ppc: export ppc_cpu_pvr_match() helper 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: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It will be used to test the family of a CPU. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/ppc.h | 1 + target/ppc/machine.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h index 4e7fe110d67b..01e32fa03d2e 100644 --- a/include/hw/ppc/ppc.h +++ b/include/hw/ppc/ppc.h @@ -107,4 +107,5 @@ enum { void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags); =20 void ppc_cpu_parse_features(const char *cpu_model); +bool ppc_cpu_pvr_match(PowerPCCPU *cpu, uint32_t pvr); #endif diff --git a/target/ppc/machine.c b/target/ppc/machine.c index 384caee800e6..6085a8c25fd3 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -4,6 +4,7 @@ #include "exec/exec-all.h" #include "hw/hw.h" #include "hw/boards.h" +#include "hw/ppc/ppc.h" #include "sysemu/kvm.h" #include "helper_regs.h" #include "mmu-hash64.h" @@ -210,7 +211,7 @@ static int cpu_pre_save(void *opaque) * between sufficiently similar PVRs, as determined by the CPU class's * pvr_match() hook. */ -static bool pvr_match(PowerPCCPU *cpu, uint32_t pvr) +bool ppc_cpu_pvr_match(PowerPCCPU *cpu, uint32_t pvr) { PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); =20 @@ -247,7 +248,7 @@ static int cpu_post_load(void *opaque, int version_id) } else #endif { - if (!pvr_match(cpu, env->spr[SPR_PVR])) { + if (!ppc_cpu_pvr_match(cpu, env->spr[SPR_PVR])) { return -1; } } --=20 2.13.6 From nobody Tue Apr 30 02:17:52 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 1507564568147764.4267636819574; Mon, 9 Oct 2017 08:56:08 -0700 (PDT) Received: from localhost ([::1]:58504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1aPX-0000PI-DC for importer@patchew.org; Mon, 09 Oct 2017 11:56:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1aJZ-0004D1-Qj for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1aJW-00039x-N7 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:49:57 -0400 Received: from 15.mo4.mail-out.ovh.net ([91.121.62.11]:38280) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1aJW-00039O-Dc for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:49:54 -0400 Received: from player746.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id DCDFED9558 for ; Mon, 9 Oct 2017 17:49:52 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player746.ha.ovh.net (Postfix) with ESMTPSA id A472C500087; Mon, 9 Oct 2017 17:49:46 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Nikunj A Dadhania , Benjamin Herrenschmidt Date: Mon, 9 Oct 2017 17:49:28 +0200 Message-Id: <20171009154930.29095-3-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171009154930.29095-1-clg@kaod.org> References: <20171009154930.29095-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 11141905481627568979 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrleelgdejkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 91.121.62.11 Subject: [Qemu-devel] [PATCH v2 2/4] spapr/rtas: disable the decrementer interrupt when a CPU is unplugged 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: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When a CPU is stopped with the 'stop-self' RTAS call, its state 'halted' is switched to 1 and, in this case, the MSR is not taken into account anymore in the cpu_has_work() routine. Only the pending hardware interrupts are checked with their LPCR:PECE* enablement bit. If the DECR timer fires after 'stop-self' is called and before the CPU 'stop' state is reached, the nearly-dead CPU will have some work to do and the guest will crash. This case happens very frequently with the not yet upstream P9 XIVE exploitation mode. In XICS mode, the DECR is occasionally fired but after 'stop' state, so no work is to be done and the guest survives. I suspect there is a race between the QEMU mainloop triggering the timers and the TCG CPU thread but I could not quite identify the root cause. To be safe, let's disable the decrementer interrupt in the LPCR when the CPU is halted and reenable it when the CPU is restarted. Signed-off-by: C=C3=A9dric Le Goater --- Changes in v2: - used a new routine ppc_cpu_pvr_match() to discriminate CPU versions - removed the LPCR:PECE* enablement bit when the CPU is initialized if it is a secondary hw/ppc/spapr_rtas.c | 20 ++++++++++++++++++++ target/ppc/translate_init.c | 19 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index cdf0b607a0a0..dfdbf1e2c6f8 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -46,6 +46,7 @@ #include "qemu/cutils.h" #include "trace.h" #include "hw/ppc/fdt.h" +#include "target/ppc/cpu-models.h" =20 static void rtas_display_character(PowerPCCPU *cpu, sPAPRMachineState *spa= pr, uint32_t token, uint32_t nargs, @@ -174,6 +175,15 @@ 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 (ppc_cpu_pvr_match(cpu, CPU_POWERPC_LOGICAL_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; @@ -210,6 +220,16 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachi= neState *spapr, * no need to bother with specific bits, we just clear it. */ env->msr =3D 0; + + /* Don't let the decremeter run on a CPU being stopped. This could + * deliver an interrupt on a dying CPU and crash the guest. + */ + if (ppc_cpu_pvr_match(cpu, CPU_POWERPC_LOGICAL_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; + } } =20 static inline int sysparm_st(target_ulong addr, target_ulong len, diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 0d6379fcc5b4..1a62159843e7 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8905,6 +8905,7 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHype= rvisor *vhyp) CPUPPCState *env =3D &cpu->env; ppc_spr_t *lpcr =3D &env->spr_cb[SPR_LPCR]; ppc_spr_t *amor =3D &env->spr_cb[SPR_AMOR]; + CPUState *cs =3D CPU(cpu); =20 cpu->vhyp =3D vhyp; =20 @@ -8946,8 +8947,15 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHyp= ervisor *vhyp) } else { lpcr->default_value &=3D ~(LPCR_UPRT | LPCR_GTSE); } - lpcr->default_value |=3D LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_D= EE | + lpcr->default_value |=3D LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_OEE; + + /* Only let the decremeter wake up the boot CPU. The RTAS + * command start-cpu will enable it on secondaries. + */ + if (cs =3D=3D first_cpu) { + lpcr->default_value |=3D LPCR_DEE; + } break; default: /* P7 and P8 has slightly different PECE bits, mostly because P8 a= dds @@ -8955,7 +8963,14 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHyp= ervisor *vhyp) * will work as expected for both implementations */ lpcr->default_value |=3D LPCR_P8_PECE0 | LPCR_P8_PECE1 | LPCR_P8_P= ECE2 | - LPCR_P8_PECE3 | LPCR_P8_PECE4; + LPCR_P8_PECE4; + + /* Only let the decremeter wake up the boot CPU. The RTAS + * command start-cpu will enable it on secondaries. + */ + if (cs =3D=3D first_cpu) { + lpcr->default_value |=3D LPCR_P8_PECE3; + } } =20 /* We should be followed by a CPU reset but update the active value --=20 2.13.6 From nobody Tue Apr 30 02:17:52 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 1507564444862191.98728486437892; Mon, 9 Oct 2017 08:54:04 -0700 (PDT) Received: from localhost ([::1]:58490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1aNY-00079Y-5U for importer@patchew.org; Mon, 09 Oct 2017 11:54:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1aJf-0004JO-O4 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:50:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1aJc-0003GQ-KA for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:50:03 -0400 Received: from 9.mo4.mail-out.ovh.net ([46.105.40.176]:33814) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1aJc-0003Dz-Di for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:50:00 -0400 Received: from player746.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 0DD22D9648 for ; Mon, 9 Oct 2017 17:49:59 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player746.ha.ovh.net (Postfix) with ESMTPSA id D03975000AC; Mon, 9 Oct 2017 17:49:52 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Nikunj A Dadhania , Benjamin Herrenschmidt Date: Mon, 9 Oct 2017 17:49:29 +0200 Message-Id: <20171009154930.29095-4-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171009154930.29095-1-clg@kaod.org> References: <20171009154930.29095-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 11143594331323796307 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrleelgdejkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.40.176 Subject: [Qemu-devel] [PATCH v2 3/4] spapr/rtas: fix reboot of a SMP TCG guest 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: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Just like for hot unplugged CPUs, when a guest is rebooted, the secondary CPUs can be awaken by the decrementer and start entering SLOF at the same time the boot CPU is. To be safe, let's disable the decrementer interrupt in the LPCR for the secondaries. Based on previous work from Nikunj A Dadhania Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Nikunj A Dadhania --- hw/ppc/spapr_cpu_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 37beb56e8b18..112868dc39d5 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -20,6 +20,7 @@ #include "sysemu/numa.h" #include "sysemu/hw_accel.h" #include "qemu/error-report.h" +#include "target/ppc/cpu-models.h" =20 void spapr_cpu_parse_features(sPAPRMachineState *spapr) { @@ -86,6 +87,17 @@ static void spapr_cpu_reset(void *opaque) cs->halted =3D 1; =20 env->spr[SPR_HIOR] =3D 0; + + /* Don't let the decremeter wake up CPUs other than the boot + * CPUs. this can cause issues when rebooting the guest */ + if (cs !=3D first_cpu) { + if (ppc_cpu_pvr_match(cpu, CPU_POWERPC_LOGICAL_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; + } + } } =20 static void spapr_cpu_destroy(PowerPCCPU *cpu) --=20 2.13.6 From nobody Tue Apr 30 02:17:52 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 1507564344493976.748491500813; Mon, 9 Oct 2017 08:52:24 -0700 (PDT) Received: from localhost ([::1]:58482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1aLq-0005mt-LG for importer@patchew.org; Mon, 09 Oct 2017 11:52:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1aJm-0004Q4-0J for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:50:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1aJi-0003Oz-Sg for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:50:10 -0400 Received: from 2.mo4.mail-out.ovh.net ([46.105.72.36]:43098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1aJi-0003OH-Mj for qemu-devel@nongnu.org; Mon, 09 Oct 2017 11:50:06 -0400 Received: from player746.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 39E8DD968B for ; Mon, 9 Oct 2017 17:50:05 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player746.ha.ovh.net (Postfix) with ESMTPSA id 07BAE500087; Mon, 9 Oct 2017 17:49:59 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Nikunj A Dadhania , Benjamin Herrenschmidt Date: Mon, 9 Oct 2017 17:49:30 +0200 Message-Id: <20171009154930.29095-5-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171009154930.29095-1-clg@kaod.org> References: <20171009154930.29095-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 11145564656128592723 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrleelgdejkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.72.36 Subject: [Qemu-devel] [PATCH v2 4/4] spapr/rtas: do not reset the MSR in stop-self command 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: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When a CPU is stopped with the 'stop-self' RTAS call, its state 'halted' is switched to 1 and, in this case, the MSR is not taken into account anymore in the cpu_has_work() routine. Only the pending hardware interrupts are checked with their LPCR:PECE* enablement bit. The CPU is now also protected from the decrementer interrupt by the LPCR:PECE* bits which are disabled in the 'stop-self' RTAS call. Reseting the MSR is pointless. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson --- hw/ppc/spapr_rtas.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index dfdbf1e2c6f8..dc825bc58263 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -210,16 +210,6 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachi= neState *spapr, =20 cs->halted =3D 1; qemu_cpu_kick(cs); - /* - * While stopping a CPU, the guest calls H_CPPR which - * effectively disables interrupts on XICS level. - * However decrementer interrupts in TCG can still - * wake the CPU up so here we disable interrupts in MSR - * as well. - * As rtas_start_cpu() resets the whole MSR anyway, there is - * no need to bother with specific bits, we just clear it. - */ - env->msr =3D 0; =20 /* Don't let the decremeter run on a CPU being stopped. This could * deliver an interrupt on a dying CPU and crash the guest. --=20 2.13.6