Received: from eggs.gnu.org ([2001:4830:134:3::10]:35794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axcol-0005ky-RI for qemu-devel@nongnu.org; Tue, 03 May 2016 12:05:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axcoa-0007Z7-03 for qemu-devel@nongnu.org; Tue, 03 May 2016 12:04:54 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:44593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axcoZ-0007UX-Nm for qemu-devel@nongnu.org; Tue, 03 May 2016 12:04:47 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 May 2016 17:04:35 +0100 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Tue, 3 May 2016 18:03:27 +0200 Message-Id: <1462291414-8343-6-git-send-email-clg@kaod.org> In-Reply-To: <1462291414-8343-1-git-send-email-clg@kaod.org> References: <1462291414-8343-1-git-send-email-clg@kaod.org> Subject: [Qemu-devel] [PATCH 05/12] ppc: Fix hreg_store_msr() so that non-HV mode cannot alter MSR:HV List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Benjamin Herrenschmidt , Cedric Le Goater From: Benjamin Herrenschmidt This helper is only used by the various instructions that can alter MSR and not interrupts. Add a comment to that effect to the interrupt code as well in case somebody wants to change this Signed-off-by: Benjamin Herrenschmidt Reviewed-by: David Gibson --- target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c index 85f38640bdf4..b48a34bfab8b 100644 --- a/target-ppc/excp_helper.c +++ b/target-ppc/excp_helper.c @@ -708,8 +708,12 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) } } #endif - /* XXX: we don't use hreg_store_msr here as already have treated - * any special case that could occur. Just store MSR and update hflags + /* We don't use hreg_store_msr here as already have treated + * any special case that could occur. Just store MSR and update hflags + * + * Note: We *MUST* not use hreg_store_msr() as-is anyway because it + * will prevent setting of the HV bit which some exceptions might need + * to do. */ env->msr = new_msr & env->msr_mask; hreg_compute_hflags(env); diff --git a/target-ppc/helper_regs.h b/target-ppc/helper_regs.h index 57da931e3c4d..12af61cbf19b 100644 --- a/target-ppc/helper_regs.h +++ b/target-ppc/helper_regs.h @@ -114,8 +114,8 @@ static inline int hreg_store_msr(CPUPPCState *env, target_ulong value, excp = 0; value &= env->msr_mask; #if !defined(CONFIG_USER_ONLY) - if (!alter_hv) { - /* mtmsr cannot alter the hypervisor state */ + /* Neither mtmsr nor guest state can alter HV */ + if (!alter_hv || !(env->msr & MSR_HVB)) { value &= ~MSR_HVB; value |= env->msr & MSR_HVB; } -- 2.1.4