From nobody Tue Nov 26 04:36:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1710183256; cv=none; d=zohomail.com; s=zohoarc; b=KR2/0/SZ653qovaj4YtojPKlKqK8mPP2/cJwIC+aiNcdSMIFImaFs9QaGQ1cJCbH+66Sk3n5ClYqc/UnNa4G1SIX3qZY2vzrSZQapqOkKDCoSHHmzjnrEsXohwu76mB+vpXfnmwMqkN8GYCSE/fH2hWLLUnXI5lN3uKQ2QS9ulo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710183256; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z09svf28Z0llAd2gDy+oDdnr0RjElQioiML8sz0N9IA=; b=dUnff4zd06ITsOukidf6dfcmGHTa7FOVV7ElOR+ZcI+ptRXYfZrpmuUESzqR0NgwdK+kX3gFbrKiV2ZMLw7bBVWYApoXG3R73++uP63i7B+NYpz6xxraw00TcRj+nDWHmeA/t5xfbqaYibZwfSckEOSSz12QEcQXBvSlD04coL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710183256320456.1480359551075; Mon, 11 Mar 2024 11:54:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjklT-0005NP-5j; Mon, 11 Mar 2024 14:52:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjklP-0005MS-J5; Mon, 11 Mar 2024 14:52:44 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rjklO-00056Q-1j; Mon, 11 Mar 2024 14:52:43 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1dc09556599so39013825ad.1; Mon, 11 Mar 2024 11:52:41 -0700 (PDT) Received: from wheely.local0.net ([118.208.155.46]) by smtp.gmail.com with ESMTPSA id z2-20020a170903018200b001dd7d00f7afsm4843887plg.18.2024.03.11.11.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 11:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710183160; x=1710787960; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z09svf28Z0llAd2gDy+oDdnr0RjElQioiML8sz0N9IA=; b=HQNsrq8ZsXskl/t5jZEHtq2a/M9V3FWUI91YUPk6m7gAIdm2usDrki+pGJMoDP6xP9 KEaAR4UfKHSYcJjWGsub+Y7brUxE4lMSiy7a0l+k4IlAYuGRhWcTl7uJVS00Hd/6/R2P 7ugbXDLwmLqC0T3UkYz0zLvuj5SiLRCHDYMubQfc6v1ckjTRuYShEHPrQJq4j6GdCu1x 5V7pWOC+UsGaI3cA8W8qzvoGMTmftfvKlfF1O/mmHFp+yF/xt0UNtuJRKLEyCdKxpToK ehItwPpjPxgDYbQNwVVtBcQfqAMn7sgPp96VS5yyhqmMBg5m2UfybzLxMkUsKna7VB3t Cm2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710183160; x=1710787960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z09svf28Z0llAd2gDy+oDdnr0RjElQioiML8sz0N9IA=; b=QGenPgYa78QIMK1HuVBSR+1J6jfBc3MR5vM00l0T4QdSGlZhS4DQ9J8ZQiFfyqT293 yYqAK7mTK2WYbhEGxfIB1+4nA7QXEuIUYpA3605xWL5b5JgdG0JuMKaWhF33Q1beUc78 Z/EhXrMYs+4M1LvEXKiY51Pj0xuCQAm1AQXZxjSNjawxhO9PAruZmA7hxY6PBzMxxnju OU+QEv0pNUETypQO+SlZNhgx1k2GURK0DdQ9OXxupMOujo7Ddyq/9mfX91L9vtj4u+5R Lhooe4w5nS10NHaXoPadCMbeEYC+5P8IsoaWN+L/2i0WpShCXlV8EBZ97FH2o2Ctj8qU OahQ== X-Forwarded-Encrypted: i=1; AJvYcCUloLvzCcwIIcw0I8NFPEIiVMpF/YuvinbVHSuViuHriom4EoZmNaJE5BcbykN37esmhGSXUZG9EAbTi+U5wVOUcG9fWvw= X-Gm-Message-State: AOJu0YzvoWXy0DR1RIxWnnis8sguq9A2IoZrsUCOF0mlH3BMIuUoN9IK UdVOCOUaeX/uC7ghiG9wWWqwip332GHBD1TpPLpaia+Q7u2hF3cBBOnzcHBdklU= X-Google-Smtp-Source: AGHT+IGEGHMotarG6JJ8S3FrE+dcI4Naq359Pf2ibu6LQ+R9gnAB5gxHW0K9xDkCUywi+Bx+pq8Xqg== X-Received: by 2002:a17:903:24d:b0:1dc:affb:1f50 with SMTP id j13-20020a170903024d00b001dcaffb1f50mr10497345plh.47.1710183160060; Mon, 11 Mar 2024 11:52:40 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora Subject: [PATCH 09/13] target/ppc: Prevent supervisor from modifying MSR[ME] Date: Tue, 12 Mar 2024 04:51:51 +1000 Message-ID: <20240311185200.2185753-10-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240311185200.2185753-1-npiggin@gmail.com> References: <20240311185200.2185753-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=npiggin@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1710183258039100005 Content-Type: text/plain; charset="utf-8" Prevent guest state modifying the MSR[ME] bit. Per ISA: An attempt to modify MSRME in privileged but non-hypervisor state is ignored (i.e., the bit is not changed). Signed-off-by: Nicholas Piggin Reviewed-by: Harsh Prateek Bora --- target/ppc/helper_regs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index 410b39c231..25258986e3 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 valu= e, int alter_hv) value &=3D ~MSR_HVB; value |=3D env->msr & MSR_HVB; } + /* Attempt to modify MSR[ME] in guest state is ignored */ + if (is_book3s_arch2x(env) && !(env->msr & MSR_HVB)) { + value &=3D ~(1 << MSR_ME); + value |=3D env->msr & (1 << MSR_ME); + } if ((value ^ env->msr) & (R_MSR_IR_MASK | R_MSR_DR_MASK)) { cpu_interrupt_exittb(cs); } --=20 2.42.0