xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: xiantao.zhang@intel.com
To: xen-devel@lists.xensource.com
Cc: keir@xen.org, JBeulich@suse.com, eddie.dong@intel.com,
	Xu Dongxiao <dongxiao.xu@intel.com>,
	jun.nakajima@intel.com, Zhang Xiantao <xiantao.zhang@intel.com>
Subject: [PATCH 04/11] nEPT: Do further permission check for sucessful translation.
Date: Tue, 11 Dec 2012 01:57:16 +0800	[thread overview]
Message-ID: <1355162243-11857-5-git-send-email-xiantao.zhang@intel.com> (raw)
In-Reply-To: <1355162243-11857-1-git-send-email-xiantao.zhang@intel.com>

From: Zhang Xiantao <xiantao.zhang@intel.com>

If permission check fails, inject EPT violation vmexit to guest. 

Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Xu Dongxiao<dongxiao.xu@intel.com>
---
 xen/arch/x86/mm/hap/nested_ept.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm/hap/nested_ept.c b/xen/arch/x86/mm/hap/nested_ept.c
index da868e7..2d733a8 100644
--- a/xen/arch/x86/mm/hap/nested_ept.c
+++ b/xen/arch/x86/mm/hap/nested_ept.c
@@ -272,6 +272,16 @@ unmap:
     return ret;
 }
 
+static
+bool_t nept_permission_check(uint32_t rwx_acc, uint32_t rwx_bits)
+{
+    if ( ((rwx_acc & 0x1) && !(rwx_bits & 0x1)) ||
+        ((rwx_acc & 0x2) && !(rwx_bits & 0x2 )) ||
+        ((rwx_acc & 0x4) && !(rwx_bits & 0x4 )) )
+        return 0;
+    return 1;
+}
+
 /* Translate a L2 guest address to L1 gpa via L1 EPT paging structure */
 
 int nept_translate_l2ga(struct vcpu *v, paddr_t l2ga, 
@@ -301,11 +311,17 @@ int nept_translate_l2ga(struct vcpu *v, paddr_t l2ga,
                 rwx_bits = gw.l4e.l4 & gw.l3e.l3  & 0x7;
                 *page_order = 18;
             }
-            else
+            else {
                 gdprintk(XENLOG_ERR, "Uncorrect l1 entry!\n");
-
-            *l1gfn = guest_l1e_get_paddr(gw.l1e) >> PAGE_SHIFT;
-            break;
+                BUG();
+            }
+            if ( nept_permission_check(rwx_acc, rwx_bits) )
+            {
+                 *l1gfn = guest_l1e_get_paddr(gw.l1e) >> PAGE_SHIFT;
+                 break;
+            }
+            rc = EPT_TRANSLATE_VIOLATION;
+        /* Fall through to EPT violation if permission check fails. */
         case EPT_TRANSLATE_VIOLATION:
             *exit_qual = (*exit_qual & 0xffffffc0) | (rwx_bits << 3) | rwx_acc;
             *exit_reason = EXIT_REASON_EPT_VIOLATION;
-- 
1.7.1

  parent reply	other threads:[~2012-12-10 17:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-10 17:57 [PATCH 00/11] Add virtual EPT support Xen xiantao.zhang
2012-12-10 17:57 ` [PATCH 01/11] nestedhap: Change hostcr3 and p2m->cr3 to meaningful words xiantao.zhang
2012-12-13 14:52   ` Tim Deegan
2012-12-10 17:57 ` [PATCH 02/11] nestedhap: Change nested p2m's walker to vendor-specific xiantao.zhang
2012-12-13 14:52   ` Tim Deegan
2012-12-10 17:57 ` [PATCH 03/11] nEPT: Implement guest ept's walker xiantao.zhang
2012-12-13 15:41   ` Tim Deegan
2012-12-10 17:57 ` xiantao.zhang [this message]
2012-12-13 15:47   ` [PATCH 04/11] nEPT: Do further permission check for sucessful translation Tim Deegan
2012-12-10 17:57 ` [PATCH 05/11] EPT: Make ept data structure or operations neutral xiantao.zhang
2012-12-13 16:04   ` Tim Deegan
2012-12-17  8:57     ` Zhang, Xiantao
2012-12-17  9:56       ` Jan Beulich
2012-12-10 17:57 ` [PATCH 06/11] nEPT: Try to enable EPT paging for L2 guest xiantao.zhang
2012-12-13 16:16   ` Tim Deegan
2012-12-10 17:57 ` [PATCH 07/11] nEPT: Sync PDPTR fields if L2 guest in PAE paging mode xiantao.zhang
2012-12-13 16:17   ` Tim Deegan
2012-12-10 17:57 ` [PATCH 08/11] nEPT: Use minimal permission for nested p2m xiantao.zhang
2012-12-13 16:43   ` Tim Deegan
2012-12-10 17:57 ` [PATCH 09/11] nEPT: handle invept instruction from L1 VMM xiantao.zhang
2012-12-13 16:56   ` Tim Deegan
2012-12-10 17:57 ` [PATCH 10/11] nEPT: expost EPT capablity to " xiantao.zhang
2012-12-13 17:03   ` Tim Deegan
2012-12-10 17:57 ` [PATCH 11/11] nVMX: Expose VPID capability to nested VMM xiantao.zhang
2012-12-13 17:15   ` Tim Deegan
2012-12-13  0:31 ` [PATCH 00/11] Add virtual EPT support Xen Zhang, Xiantao
2012-12-13 10:25   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355162243-11857-5-git-send-email-xiantao.zhang@intel.com \
    --to=xiantao.zhang@intel.com \
    --cc=JBeulich@suse.com \
    --cc=dongxiao.xu@intel.com \
    --cc=eddie.dong@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).