Received: from eggs.gnu.org ([2001:4830:134:3::10]:58329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLho6-00015O-UQ for qemu-devel@nongnu.org; Thu, 06 Mar 2014 18:35:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLhnv-0003FS-Tw for qemu-devel@nongnu.org; Thu, 06 Mar 2014 18:34:30 -0500 From: Alexander Graf Date: Fri, 7 Mar 2014 00:32:18 +0100 Message-Id: <1394148857-19607-12-git-send-email-agraf@suse.de> In-Reply-To: <1394148857-19607-1-git-send-email-agraf@suse.de> References: <1394148857-19607-1-git-send-email-agraf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 011/130] mmu-hash64: fix Virtual Page Class Key Protection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , blauwirbel@gmail.com, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, aliguori@amazon.com, aurelien@aurel32.net From: C=C3=A9dric Le Goater commit f80872e21c07edd06eb343eeeefc8af404b518a6 (mmu-hash64: Implement Virtual Page Class Key Protection) added a new page protection mechanism based on page keys and the AMR register to control access. The AMR register allows or prohibits reads and/or writes on a page depending on the control bits associated to the key. A store or a load is only permitted if the associate bit is 0 (Power ISA), and not 1 as the code is currently doing. This patch modifies ppc_hash64_amr_prot() to correct the protection check. This issue was unvailed by commit ccfb53ed6360cac0d5f6f7915ca9ae7eed86641= 2 (target-ppc: fix Authority Mask Register init value) which changed the initialisation value of the AMR register to 0. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Alexander Graf --- target-ppc/mmu-hash64.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c index 67fc1b5..c1c33b0 100644 --- a/target-ppc/mmu-hash64.c +++ b/target-ppc/mmu-hash64.c @@ -278,12 +278,12 @@ static int ppc_hash64_pte_prot(CPUPPCState *env, static int ppc_hash64_amr_prot(CPUPPCState *env, ppc_hash_pte64_t pte) { int key, amrbits; - int prot =3D PAGE_EXEC; + int prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; =20 =20 /* Only recent MMUs implement Virtual Page Class Key Protection */ if (!(env->mmu_model & POWERPC_MMU_AMR)) { - return PAGE_READ | PAGE_WRITE | PAGE_EXEC; + return prot; } =20 key =3D HPTE64_R_KEY(pte.pte1); @@ -292,11 +292,19 @@ static int ppc_hash64_amr_prot(CPUPPCState *env, pp= c_hash_pte64_t pte) /* fprintf(stderr, "AMR protection: key=3D%d AMR=3D0x%" PRIx64 "\n",= key, */ /* env->spr[SPR_AMR]); */ =20 + /* + * A store is permitted if the AMR bit is 0. Remove write + * protection if it is set. + */ if (amrbits & 0x2) { - prot |=3D PAGE_WRITE; + prot &=3D ~PAGE_WRITE; } + /* + * A load is permitted if the AMR bit is 0. Remove read + * protection if it is set. + */ if (amrbits & 0x1) { - prot |=3D PAGE_READ; + prot &=3D ~PAGE_READ; } =20 return prot; --=20 1.8.1.4