From patchwork Mon Jul 14 20:54:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricky Zhou X-Patchwork-Id: 369764 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 03FFA140170 for ; Tue, 15 Jul 2014 06:55:21 +1000 (EST) Received: from localhost ([::1]:59929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6nHL-0007Mv-7w for incoming@patchwork.ozlabs.org; Mon, 14 Jul 2014 16:55:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6nH0-00070n-Bd for qemu-devel@nongnu.org; Mon, 14 Jul 2014 16:55:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6nGu-0008Iq-UY for qemu-devel@nongnu.org; Mon, 14 Jul 2014 16:54:58 -0400 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:37661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6nGu-0008II-Ms for qemu-devel@nongnu.org; Mon, 14 Jul 2014 16:54:52 -0400 Received: by mail-pa0-f42.google.com with SMTP id lf10so2071040pab.15 for ; Mon, 14 Jul 2014 13:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=FRUeuvF7E6HZVSJPe3Cwsz6+/Kl3Y8OdN3XW4Hjhlb0=; b=0f8IRFoecFS2SmjKfbpOT0HGcj19BLP3fJumiR+f5RBrwqlpKcbCIWAj+ZYG25uZqF bgKNHoUHUDAV5e/HOwmO1xAFDFVXriu6nAYJC3O7GQqh2IByxjmN+Ce/Ubfx3IX2/BAI +skphZu6IVnauUKcQImWz1XZEi3jm5kd3tVJaluwl+8FmCBAG/IYi3KRUi9/sXJEZOEI ubAGxqvjlliFwVThi0sxiPME0B2ImAzx80hTIAtz895GIeoSbKnTAfZRXONTnL691yqa Fc8tALi8M8KKGYwTAdsp983/UcJSnO4gdAhVOMqrdFaKqjzBo0OLYcW6P6y7JyjNQDCl 8hBg== X-Received: by 10.70.96.234 with SMTP id dv10mr18476131pdb.96.1405371291316; Mon, 14 Jul 2014 13:54:51 -0700 (PDT) Received: from gamma.corp.google.com ([216.239.55.198]) by mx.google.com with ESMTPSA id cj17sm15722531pdb.75.2014.07.14.13.54.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jul 2014 13:54:50 -0700 (PDT) From: Ricky Zhou To: qemu-devel@nongnu.org Date: Mon, 14 Jul 2014 13:54:47 -0700 Message-Id: <1405371287-12189-1-git-send-email-ricky@rzhou.org> X-Mailer: git-send-email 1.9.3 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22a Cc: Ricky Zhou Subject: [Qemu-devel] [PATCH] target-i386: Allow execute from user mode when SMEP is enabled. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Previously, execute would be disabled for all pages with SMEP enabled, regardless of what mode the access took place in. Signed-off-by: Ricky Zhou --- target-i386/helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 11ca864..47b982b 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -750,7 +750,8 @@ do_check_protect_pse36: /* the page can be put in the TLB */ prot = PAGE_READ; if (!(ptep & PG_NX_MASK) && - !((env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK))) { + (mmu_idx == MMU_USER_IDX || + !((env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)))) { prot |= PAGE_EXEC; } if (pte & PG_DIRTY_MASK) {