xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Euan Harris <euan.harris@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: andrew.cooper3@citrix.com, kevin.tian@intel.com,
	Euan Harris <euan.harris@citrix.com>,
	jun.nakajima@intel.com, jbeulich@suse.com
Subject: [PATCH 5/9] x86/vvmx: Replace direct calls to reg_read() with operand_read()
Date: Thu, 26 Oct 2017 18:03:15 +0100	[thread overview]
Message-ID: <1509037399-48926-6-git-send-email-euan.harris@citrix.com> (raw)
In-Reply-To: <1509037399-48926-1-git-send-email-euan.harris@citrix.com>

Use operand_read() to read register operands in the following functions:

 * nvmx_handle_vmread()
 * nvmx_handle_vmwrite()
 * nvmx_handle_invept()

Direct reading of memory operands will be replaced in a separate patch.

Signed-off-by: Euan Harris <euan.harris@citrix.com>
---
 xen/arch/x86/hvm/vmx/vvmx.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index 32c07eca3d..7cda37b136 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -1877,6 +1877,7 @@ int nvmx_handle_vmread(struct cpu_user_regs *regs)
     pagefault_info_t pfinfo;
     u64 value = 0;
     int rc;
+    unsigned long vmcs_encoding = 0;
 
     rc = decode_vmx_inst(regs, &decode, NULL, 0);
     if ( rc != X86EMUL_OKAY )
@@ -1888,7 +1889,11 @@ int nvmx_handle_vmread(struct cpu_user_regs *regs)
         return X86EMUL_OKAY;
     }
 
-    rc = get_vvmcs_safe(v, reg_read(regs, decode.op[1].reg_idx), &value);
+    rc = operand_read(&vmcs_encoding, &decode.op[1], regs, decode.op[1].len);
+    if ( rc != X86EMUL_OKAY )
+        return rc;
+
+    rc = get_vvmcs_safe(v, vmcs_encoding, &value);
     if ( rc != VMX_INSN_SUCCEED )
     {
         vmfail(regs, rc);
@@ -1918,9 +1923,10 @@ int nvmx_handle_vmwrite(struct cpu_user_regs *regs)
     struct vcpu *v = current;
     struct vmx_inst_decoded decode;
     unsigned long operand; 
-    u64 vmcs_encoding;
+    unsigned long vmcs_encoding = 0;
     bool_t okay = 1;
     enum vmx_insn_errno err;
+    int rc;
 
     if ( decode_vmx_inst(regs, &decode, &operand, 0)
              != X86EMUL_OKAY )
@@ -1932,7 +1938,10 @@ int nvmx_handle_vmwrite(struct cpu_user_regs *regs)
         return X86EMUL_OKAY;
     }
 
-    vmcs_encoding = reg_read(regs, decode.op[1].reg_idx);
+    rc = operand_read(&vmcs_encoding, &decode.op[1], regs, decode.op[1].len);
+    if ( rc != X86EMUL_OKAY )
+        return rc;
+
     err = set_vvmcs_safe(v, vmcs_encoding, operand);
     if ( err != VMX_INSN_SUCCEED )
     {
@@ -1965,12 +1974,17 @@ int nvmx_handle_invept(struct cpu_user_regs *regs)
 {
     struct vmx_inst_decoded decode;
     unsigned long eptp;
+    unsigned long invept_type = 0;
     int ret;
 
     if ( (ret = decode_vmx_inst(regs, &decode, &eptp, 0)) != X86EMUL_OKAY )
         return ret;
 
-    switch ( reg_read(regs, decode.op[1].reg_idx) )
+    ret = operand_read(&invept_type, &decode.op[1], regs, decode.op[1].len);
+    if ( ret != X86EMUL_OKAY )
+        return ret;
+
+    switch ( invept_type )
     {
     case INVEPT_SINGLE_CONTEXT:
     {
@@ -1992,12 +2006,17 @@ int nvmx_handle_invept(struct cpu_user_regs *regs)
 int nvmx_handle_invvpid(struct cpu_user_regs *regs)
 {
     struct vmx_inst_decoded decode;
+    unsigned long invvpid_type = 0;
     int ret;
 
     if ( (ret = decode_vmx_inst(regs, &decode, NULL, 0)) != X86EMUL_OKAY )
         return ret;
 
-    switch ( reg_read(regs, decode.op[1].reg_idx) )
+    ret = operand_read(&invvpid_type, &decode.op[1], regs, decode.op[1].len);
+    if ( ret != X86EMUL_OKAY )
+        return ret;
+
+    switch ( invvpid_type )
     {
     /* Just invalidate all tlb entries for all types! */
     case INVVPID_INDIVIDUAL_ADDR:
-- 
2.13.6


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-10-26 17:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26 17:03 [PATCH 0/9] x86/vvmx: Read instruction operands correctly on VM exit Euan Harris
2017-10-26 17:03 ` [PATCH 1/9] x86/vvmx: Remove enum vmx_regs_enc Euan Harris
2017-10-26 17:03 ` [PATCH 2/9] x86/vvmx: Unify operands in struct vmx_inst_decoded Euan Harris
2017-10-26 17:03 ` [PATCH 3/9] x86/vvmx: Extract operand reading logic into operand_read() Euan Harris
2017-11-27 17:01   ` Jan Beulich
2017-11-27 18:08     ` Andrew Cooper
2017-11-28  8:40       ` Jan Beulich
2017-11-28  8:14   ` Jan Beulich
2017-10-26 17:03 ` [PATCH 4/9] x86/vvmx: Remove unnecessary VMX operand reads Euan Harris
2017-11-02  7:07   ` Tian, Kevin
2017-11-27 17:03   ` Jan Beulich
2017-10-26 17:03 ` Euan Harris [this message]
2017-10-26 17:03 ` [PATCH 6/9] x86/vvmx: Remove operand reading from decode_vmx_inst() Euan Harris
2017-10-26 17:03 ` [PATCH 7/9] x86/vvmx: Use correct sizes when reading operands Euan Harris
2017-11-28  8:32   ` Jan Beulich
2017-12-01 18:45     ` Andrew Cooper
2017-12-04  8:55       ` Jan Beulich
2017-10-26 17:03 ` [PATCH 8/9] x86/hvm: Add hvm_copy_{to, from}_guest_virt() helpers Euan Harris
2017-11-28  8:38   ` Jan Beulich
2017-10-26 17:03 ` [PATCH 9/9] x86/vvmx: Use hvm_copy_{to, from}_guest_virt() to read operands Euan Harris
2017-11-28  8:49   ` Jan Beulich
2017-10-26 17:59 ` [PATCH 0/9] x86/vvmx: Read instruction operands correctly on VM exit Andrew Cooper
2017-11-02  7:23   ` Tian, Kevin
2017-11-02 18:39     ` Andrew Cooper

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=1509037399-48926-6-git-send-email-euan.harris@citrix.com \
    --to=euan.harris@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xenproject.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).