From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsYZK-0007GD-8x for qemu-devel@nongnu.org; Thu, 05 Jun 2014 10:23:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsYZB-00006l-8T for qemu-devel@nongnu.org; Thu, 05 Jun 2014 10:23:02 -0400 Received: from mail-wg0-x22b.google.com ([2a00:1450:400c:c00::22b]:42298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsYZB-00006T-2B for qemu-devel@nongnu.org; Thu, 05 Jun 2014 10:22:53 -0400 Received: by mail-wg0-f43.google.com with SMTP id l18so1164472wgh.26 for ; Thu, 05 Jun 2014 07:22:52 -0700 (PDT) Received: from playground.station (net-37-117-132-7.cust.vodafonedsl.it. [37.117.132.7]) by mx.google.com with ESMTPSA id p9sm14884136eeg.32.2014.06.05.07.22.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jun 2014 07:22:51 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 5 Jun 2014 16:22:07 +0200 Message-Id: <1401978143-11896-18-git-send-email-pbonzini@redhat.com> In-Reply-To: <1401978143-11896-1-git-send-email-pbonzini@redhat.com> References: <1401978143-11896-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 17/33] target-i386: simplify SMAP handling in MMU_KSMAP_IDX List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Do not use this MMU index at all if CR4.SMAP is false, and drop the SMAP check from x86_cpu_handle_mmu_fault. Signed-off-by: Paolo Bonzini --- target-i386/cpu.h | 2 +- target-i386/helper.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index b80df66..f2d5b19 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -1162,7 +1162,7 @@ static inline CPUX86State *cpu_init(const char *cpu_model) static inline int cpu_mmu_index(CPUX86State *env) { return (env->hflags & HF_CPL_MASK) == 3 ? MMU_USER_IDX : - ((env->hflags & HF_SMAP_MASK) && (env->eflags & AC_MASK)) + (!(env->hflags & HF_SMAP_MASK) || (env->eflags & AC_MASK)) ? MMU_KNOSMAP_IDX : MMU_KSMAP_IDX; } diff --git a/target-i386/helper.c b/target-i386/helper.c index 6d8e350..d10de26 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -649,8 +649,7 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, break; case MMU_KSMAP_IDX: - if (is_write1 != 2 && (env->cr[4] & CR4_SMAP_MASK) && - (ptep & PG_USER_MASK)) { + if (is_write1 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } /* fall through */ @@ -711,8 +710,7 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, break; case MMU_KSMAP_IDX: - if (is_write1 != 2 && (env->cr[4] & CR4_SMAP_MASK) && - (ptep & PG_USER_MASK)) { + if (is_write1 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } /* fall through */ @@ -766,8 +764,7 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, break; case MMU_KSMAP_IDX: - if (is_write1 != 2 && (env->cr[4] & CR4_SMAP_MASK) && - (pde & PG_USER_MASK)) { + if (is_write1 != 2 && (pde & PG_USER_MASK)) { goto do_fault_protect; } /* fall through */ @@ -823,8 +820,7 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, break; case MMU_KSMAP_IDX: - if (is_write1 != 2 && (env->cr[4] & CR4_SMAP_MASK) && - (ptep & PG_USER_MASK)) { + if (is_write1 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } /* fall through */ -- 1.8.3.1