From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHQSk-0007fM-R8 for qemu-devel@nongnu.org; Mon, 27 Jun 2016 02:56:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHQSf-0005T5-RJ for qemu-devel@nongnu.org; Mon, 27 Jun 2016 02:56:05 -0400 Received: from 2.mo177.mail-out.ovh.net ([178.33.109.80]:58677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHQSf-0005Si-LR for qemu-devel@nongnu.org; Mon, 27 Jun 2016 02:56:01 -0400 Received: from player699.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id AB01BFF915C for ; Mon, 27 Jun 2016 08:56:00 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Mon, 27 Jun 2016 08:55:17 +0200 Message-Id: <1467010521-6106-5-git-send-email-clg@kaod.org> In-Reply-To: <1467010521-6106-1-git-send-email-clg@kaod.org> References: <1467010521-6106-1-git-send-email-clg@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 4/8] ppc: Fix conditions for delivering external interrupts to a guest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org Cc: David Gibson , Alexander Graf , qemu-devel@nongnu.org, Benjamin Herrenschmidt , Cedric Le Goater From: Benjamin Herrenschmidt External interrupts can bypass the MSR_EE test if they occur in guest mode and LPES0 is clear. In that case they are directed to the hypervisor Signed-off-by: Benjamin Herrenschmidt Signed-off-by: C=C3=A9dric Le Goater --- target-ppc/excp_helper.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c index 533866b87b60..26adda49b248 100644 --- a/target-ppc/excp_helper.c +++ b/target-ppc/excp_helper.c @@ -794,6 +794,14 @@ static void ppc_hw_interrupt(CPUPPCState *env) return; } } + /* Extermal interrupt can ignore MSR:EE under some circumstances */ + if (env->pending_interrupts & (1 << PPC_INTERRUPT_EXT)) { + bool lpes0 =3D !!(env->spr[SPR_LPCR] & LPCR_LPES0); + if (msr_ee !=3D 0 || (env->has_hv_mode && msr_hv =3D=3D 0 && !lp= es0)) { + powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_EXTERNAL); + return; + } + } if (msr_ce !=3D 0) { /* External critical interrupt */ if (env->pending_interrupts & (1 << PPC_INTERRUPT_CEXT)) { @@ -839,17 +847,6 @@ static void ppc_hw_interrupt(CPUPPCState *env) powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DECR); return; } - /* External interrupt */ - if (env->pending_interrupts & (1 << PPC_INTERRUPT_EXT)) { - /* Taking an external interrupt does not clear the external - * interrupt status - */ -#if 0 - env->pending_interrupts &=3D ~(1 << PPC_INTERRUPT_EXT); -#endif - powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_EXTERNAL); - return; - } if (env->pending_interrupts & (1 << PPC_INTERRUPT_DOORBELL)) { env->pending_interrupts &=3D ~(1 << PPC_INTERRUPT_DOORBELL); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DOORI); --=20 2.1.4