xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Xiantao Zhang <xiantao.zhang@intel.com>
To: xen-devel@lists.xen.org
Cc: keir@xen.org, jun.nakajima@intel.com, tim@xen.org,
	eddie.dong@intel.com, JBeulich@suse.com,
	Zhang Xiantao <xiantao.zhang@intel.com>
Subject: [PATCH v4 08/10] nEPT: handle invept instruction from L1 VMM
Date: Mon, 24 Dec 2012 22:26:32 +0800	[thread overview]
Message-ID: <1356359194-5321-9-git-send-email-xiantao.zhang@intel.com> (raw)
In-Reply-To: <1356359194-5321-1-git-send-email-xiantao.zhang@intel.com>

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

Add the INVEPT instruction emulation logic.

Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Acked-by: Tim Deegan <tim@xen.org>
---
 xen/arch/x86/hvm/vmx/vmx.c         |    6 +++++-
 xen/arch/x86/hvm/vmx/vvmx.c        |   36 ++++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/hvm/vmx/vvmx.h |    1 +
 3 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index ed8d532..94cac17 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2573,10 +2573,14 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
             update_guest_eip();
         break;
 
+    case EXIT_REASON_INVEPT:
+        if ( nvmx_handle_invept(regs) == X86EMUL_OKAY )
+            update_guest_eip();
+        break;
+
     case EXIT_REASON_MWAIT_INSTRUCTION:
     case EXIT_REASON_MONITOR_INSTRUCTION:
     case EXIT_REASON_GETSEC:
-    case EXIT_REASON_INVEPT:
     case EXIT_REASON_INVVPID:
         /*
          * We should never exit on GETSEC because CR4.SMXE is always 0 when
diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index f1f6af2..c31f7ba 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -1390,6 +1390,42 @@ int nvmx_handle_vmwrite(struct cpu_user_regs *regs)
     return X86EMUL_OKAY;
 }
 
+int nvmx_handle_invept(struct cpu_user_regs *regs)
+{
+    struct vmx_inst_decoded decode;
+    unsigned long eptp;
+    u64 inv_type;
+
+    if ( decode_vmx_inst(regs, &decode, &eptp, 0) != X86EMUL_OKAY )
+        return X86EMUL_EXCEPTION;
+
+    inv_type = reg_read(regs, decode.reg2);
+
+    switch ( inv_type )
+    {
+    case INVEPT_SINGLE_CONTEXT:
+    {
+        struct p2m_domain *p2m = vcpu_nestedhvm(current).nv_p2m;
+        if ( p2m )
+        {
+	        p2m_flush(current, p2m);
+            ept_sync_domain(p2m);
+        }
+        break;
+    }
+    case INVEPT_ALL_CONTEXT:
+        p2m_flush_nestedp2m(current->domain);
+        __invept(INVEPT_ALL_CONTEXT, 0, 0);
+        break;
+    default:
+        vmreturn(regs, VMFAIL_INVALID);
+        return X86EMUL_OKAY;
+    }
+    vmreturn(regs, VMSUCCEED);
+    return X86EMUL_OKAY;
+}
+
+
 #define __emul_value(enable1, default1) \
     ((enable1 | default1) << 32 | (default1))
 
diff --git a/xen/include/asm-x86/hvm/vmx/vvmx.h b/xen/include/asm-x86/hvm/vmx/vvmx.h
index 1da0e77..e671635 100644
--- a/xen/include/asm-x86/hvm/vmx/vvmx.h
+++ b/xen/include/asm-x86/hvm/vmx/vvmx.h
@@ -189,6 +189,7 @@ int nvmx_handle_vmread(struct cpu_user_regs *regs);
 int nvmx_handle_vmwrite(struct cpu_user_regs *regs);
 int nvmx_handle_vmresume(struct cpu_user_regs *regs);
 int nvmx_handle_vmlaunch(struct cpu_user_regs *regs);
+int nvmx_handle_invept(struct cpu_user_regs *regs);
 int nvmx_msr_read_intercept(unsigned int msr,
                                 u64 *msr_content);
 int nvmx_msr_write_intercept(unsigned int msr,
-- 
1.7.1

  parent reply	other threads:[~2012-12-24 14:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-24 14:26 [PATCH v4 00/10] Nested VMX: Add virtual EPT & VPID support to L1 VMM Xiantao Zhang
2012-12-24 14:26 ` [PATCH v4 01/10] nestedhap: Change hostcr3 and p2m->cr3 to meaningful words Xiantao Zhang
2012-12-24 14:26 ` [PATCH v4 02/10] nestedhap: Change nested p2m's walker to vendor-specific Xiantao Zhang
2012-12-24 14:26 ` [PATCH v4 03/10] nested_ept: Implement guest ept's walker Xiantao Zhang
2012-12-24 14:26 ` [PATCH v4 04/10] EPT: Make ept data structure or operations neutral Xiantao Zhang
2012-12-24 14:26 ` [PATCH v4 05/10] nEPT: Try to enable EPT paging for L2 guest Xiantao Zhang
2012-12-24 14:26 ` [PATCH v4 06/10] nEPT: Sync PDPTR fields if L2 guest in PAE paging mode Xiantao Zhang
2012-12-24 14:26 ` [PATCH v4 07/10] nEPT: Use minimal permission for nested p2m Xiantao Zhang
2012-12-24 14:26 ` Xiantao Zhang [this message]
2013-01-03 12:03   ` [PATCH v4 08/10] nEPT: handle invept instruction from L1 VMM Jan Beulich
2013-01-04  0:57     ` Zhang, Xiantao
2013-01-04  8:24       ` Jan Beulich
2013-01-05  3:19         ` Zhang, Xiantao
2012-12-24 14:26 ` [PATCH v4 09/10] nVMX: virutalize VPID capability to nested VMM Xiantao Zhang
2013-01-03 12:05   ` Jan Beulich
2012-12-24 14:26 ` [PATCH v4 10/10] nEPT: Expose EPT & VPID capablities to L1 VMM Xiantao Zhang
2013-02-12 16:22 ` [PATCH v4 00/10] Nested VMX: Add virtual EPT & VPID support " Ian Jackson
2013-02-12 17:54   ` Nakajima, Jun
2013-02-12 17:56     ` Ian Jackson
2013-02-12 18:20       ` Nakajima, Jun

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=1356359194-5321-9-git-send-email-xiantao.zhang@intel.com \
    --to=xiantao.zhang@intel.com \
    --cc=JBeulich@suse.com \
    --cc=eddie.dong@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /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).