From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzLzX-0002n5-Tx for qemu-devel@nongnu.org; Thu, 19 Nov 2015 04:59:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzLzE-0006oH-E7 for qemu-devel@nongnu.org; Thu, 19 Nov 2015 04:58:59 -0500 Date: Thu, 19 Nov 2015 17:20:27 +1100 From: David Gibson Message-ID: <20151119062027.GD10667@voom.redhat.com> References: <1447201710-10229-1-git-send-email-benh@kernel.crashing.org> <1447201710-10229-11-git-send-email-benh@kernel.crashing.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wULyF7TL5taEdwHz" Content-Disposition: inline In-Reply-To: <1447201710-10229-11-git-send-email-benh@kernel.crashing.org> Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 10/77] 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: Benjamin Herrenschmidt Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org --wULyF7TL5taEdwHz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 11, 2015 at 11:27:23AM +1100, Benjamin Herrenschmidt wrote: > 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 >=20 > 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(-) >=20 > diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c > index 00fae60..83e6c07 100644 > --- a/target-ppc/excp_helper.c > +++ b/target-ppc/excp_helper.c > @@ -662,8 +662,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 hfla= gs > + * > + * Note: We *MUST* not use hreg_store_msr() as-is anyway because it > + * will prevent setting of the HV bit which some exceptions might ne= ed > + * to do. > */ > env->msr =3D new_msr & env->msr_mask; > hreg_compute_hflags(env); > diff --git a/target-ppc/helper_regs.h b/target-ppc/helper_regs.h > index 57da931..12af61c 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, ta= rget_ulong value, > excp =3D 0; > value &=3D 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 &=3D ~MSR_HVB; > value |=3D env->msr & MSR_HVB; > } --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --wULyF7TL5taEdwHz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWTWorAAoJEGw4ysog2bOSWkcQAMF6pMNI4bfW5DPdsCbarmWT AAAebO0uP3XWzcW2i2nckxCuclbfkI6N3LOTiNrkRivMT9fyxYeRvoImmDGkp/1p AMRsipktl8pSK7ODmr3+FrgMp+NktRKn+RX6C6AaPlJA7qNLupoGDOOS1GO+H4HA OaVP+aEb/BB/Zmr7pj47gpVbGII8n7Sm87+D2SRrxxUwNgBWjYCp6lS47/A0WERc tdU3ydNyos7HrnfS2eRnj0RziLbLQlREJ3RJxs9YupatK/i0QLhJpBrmEvqt0e8T AtxKRImL196422p4q0Xl+s8t1sZrpTcod3IfmvXJhVuORArAIo8J+m6Q7Ee/hScE gOynm8WW0OJ78lD0Tg/6q1CS7xeZPSZl42p3aRyr6Su2YyOSr9eTOJ7n7km0oUdh RjRoI49KugqRVcP6KlhPS66yvRH8z08FiSlffiOGNtOb0uLwOUKYuFgikUXNIGdw b+PZL9IZrZ+1uSMEYm/8zJiDUqv8Oal7VRk/9y9ttVXG19im9dcbH/M8D6mtwRfO 60GEAI/iUsaG4KvgFjtd8PeZt5LhhGmGbQ1upFLSqhHwO0INMJFNE9WyFt8U77Wa KCbVS0ttYlwB4zeExLzLH3h5c/9LmwZWbnkZ/ELEHECPmXbKpQPPSnLAj14Oj7Yx CmWU36nrsP40KNtnYPKB =tzJ/ -----END PGP SIGNATURE----- --wULyF7TL5taEdwHz--