Received: from eggs.gnu.org ([140.186.70.92]:53998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM7nj-0006T4-1V for qemu-devel@nongnu.org; Thu, 03 Nov 2011 20:38:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RM7nh-0008VH-Rr for qemu-devel@nongnu.org; Thu, 03 Nov 2011 20:38:31 -0400 Received: from mx1.w4a.fr ([178.33.204.49]:46580 helo=zose-store12.web4all.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM7nh-0008Ss-Jq for qemu-devel@nongnu.org; Thu, 03 Nov 2011 20:38:29 -0400 Message-ID: <4EB33402.50302@tribudubois.net> Date: Fri, 04 Nov 2011 01:38:26 +0100 From: Jean-Christophe DUBOIS MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH][ARM] Fix C15 FSR (C5) domain setting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: xvisor-devel@googlegroups.com During Xvisor development, it was noted that qemu did not return the correct domain value in the C15 [Data] FSR register (C5). This patch is a proposal to fix it. Signed-off-by: Jean-Christophe DUBOIS --- --- qemu-0.15.1.org/target-arm/helper.c 2011-10-12 18:41:43.000000000 +0200 +++ qemu-0.15.1/target-arm/helper.c 2011-11-04 00:49:03.247062518 +0100 @@ -924,12 +924,12 @@ /* Check section/page access permissions. Returns the page protection flags, or zero if the access is not permitted. */ -static inline int check_ap(CPUState *env, int ap, int domain, int access_type, +static inline int check_ap(CPUState *env, int ap, int domain_prot, int access_type, int is_user) { int prot_ro; - if (domain == 3) + if (domain_prot == 3) return PAGE_READ | PAGE_WRITE; if (access_type == 1) @@ -996,6 +996,7 @@ int type; int ap; int domain; + int domain_prot; uint32_t phys_addr; /* Pagetable walk. */ @@ -1003,13 +1004,14 @@ table = get_level1_table_address(env, address); desc = ldl_phys(table); type = (desc & 3); - domain = (env->cp15.c3 >> ((desc >> 4) & 0x1e)) & 3; + domain = (desc >> 5) & 0x0f; + domain_prot = (env->cp15.c3 >> (domain * 2)) & 3; if (type == 0) { /* Section translation fault. */ code = 5; goto do_fault; } - if (domain == 0 || domain == 2) { + if (domain_prot == 0 || domain_prot == 2) { if (type == 2) code = 9; /* Section domain fault. */ else @@ -1067,7 +1069,7 @@ } code = 15; } - *prot = check_ap(env, ap, domain, access_type, is_user); + *prot = check_ap(env, ap, domain_prot, access_type, is_user); if (!*prot) { /* Access permission fault. */ goto do_fault; @@ -1090,6 +1092,7 @@ int type; int ap; int domain; + int domain_prot; uint32_t phys_addr; /* Pagetable walk. */ @@ -1107,10 +1110,10 @@ domain = 0; } else { /* Section or page. */ - domain = (desc >> 4) & 0x1e; + domain = (desc >> 5) & 0x0f; } - domain = (env->cp15.c3 >> domain) & 3; - if (domain == 0 || domain == 2) { + domain_prot = (env->cp15.c3 >> (domain * 2)) & 3; + if (domain_prot == 0 || domain_prot == 2) { if (type == 2) code = 9; /* Section domain fault. */ else @@ -1155,7 +1158,7 @@ } code = 15; } - if (domain == 3) { + if (domain_prot == 3) { *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; } else { if (xn && access_type == 2) @@ -1167,7 +1170,7 @@ code = (code == 15) ? 6 : 3; goto do_fault; } - *prot = check_ap(env, ap, domain, access_type, is_user); + *prot = check_ap(env, ap, domain_prot, access_type, is_user); if (!*prot) { /* Access permission fault. */ goto do_fault;