From: Nicholas Piggin Date: Tue, 13 Jun 2023 14:16:23 +0000 (+1000) Subject: target/ppc: Prevent supervisor from modifying MSR[ME] X-Git-Tag: v9.0.0-rc0~10^2~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=678b6f1af75ef42f510495a81fe8562e872e9daf;p=thirdparty%2Fqemu.git target/ppc: Prevent supervisor from modifying MSR[ME] Prevent guest state modifying the MSR[ME] bit. Per ISA: An attempt to modify MSR[ME] in privileged but non-hypervisor state is ignored (i.e., the bit is not changed). Reviewed-by: Harsh Prateek Bora Signed-off-by: Nicholas Piggin --- diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index 410b39c231b..25258986e36 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -264,6 +264,11 @@ int hreg_store_msr(CPUPPCState *env, target_ulong value, int alter_hv) value &= ~MSR_HVB; value |= env->msr & MSR_HVB; } + /* Attempt to modify MSR[ME] in guest state is ignored */ + if (is_book3s_arch2x(env) && !(env->msr & MSR_HVB)) { + value &= ~(1 << MSR_ME); + value |= env->msr & (1 << MSR_ME); + } if ((value ^ env->msr) & (R_MSR_IR_MASK | R_MSR_DR_MASK)) { cpu_interrupt_exittb(cs); }