[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 6/9] x86/vvmx: Remove operand reading from decode_vmx_inst()



Use operand_read() to read memory operands instead of using the value
read by decode_vmx_inst() in the following functions:

 * nvmx_handle_invept()
 * nvmx_handle_invvpid()
 * nvmx_handle_vmclear()
 * nvmx_handle_vmptrld()
 * nvmx_handle_vmxon()
 * nvmx_handle_vmwrite()

Signed-off-by: Euan Harris <euan.harris@xxxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vvmx.c | 57 ++++++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index 7cda37b136..fc2123c7c0 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -456,7 +456,7 @@ gp_fault:
 
 static int decode_vmx_inst(struct cpu_user_regs *regs,
                            struct vmx_inst_decoded *decode,
-                           unsigned long *poperandS, int vmxon_check)
+                           int vmxon_check)
 {
     struct vcpu *v = current;
     union vmx_inst_info info;
@@ -473,13 +473,6 @@ static int decode_vmx_inst(struct cpu_user_regs *regs,
     if ( info.fields.memreg ) {
         decode->op[0].type = VMX_INST_MEMREG_TYPE_REG;
         decode->op[0].reg_idx = info.fields.reg1;
-        if ( poperandS != NULL )
-        {
-            int rc = operand_read(poperandS, &decode->op[0], regs,
-                                  decode->op[0].len);
-            if ( rc != X86EMUL_OKAY )
-                return rc;
-        }
     }
     else
     {
@@ -516,14 +509,6 @@ static int decode_vmx_inst(struct cpu_user_regs *regs,
 
         decode->op[0].mem = base;
         decode->op[0].len = size;
-
-        if ( poperandS != NULL )
-        {
-            int rc = operand_read(poperandS, &decode->op[0], regs,
-                                  decode->op[0].len);
-            if ( rc != X86EMUL_OKAY )
-                return rc;
-        }
     }
 
     decode->op[1].type = VMX_INST_MEMREG_TYPE_REG;
@@ -1513,7 +1498,11 @@ int nvmx_handle_vmxon(struct cpu_user_regs *regs)
     uint32_t nvmcs_revid;
     int rc;
 
-    rc = decode_vmx_inst(regs, &decode, &gpa, 1);
+    rc = decode_vmx_inst(regs, &decode, 1);
+    if ( rc != X86EMUL_OKAY )
+        return rc;
+
+    rc = operand_read(&gpa, &decode.op[0], regs, decode.op[0].len);
     if ( rc != X86EMUL_OKAY )
         return rc;
 
@@ -1729,7 +1718,11 @@ int nvmx_handle_vmptrld(struct cpu_user_regs *regs)
     unsigned long gpa = 0;
     int rc;
 
-    rc = decode_vmx_inst(regs, &decode, &gpa, 0);
+    rc = decode_vmx_inst(regs, &decode, 0);
+    if ( rc != X86EMUL_OKAY )
+        return rc;
+
+    rc = operand_read(&gpa, &decode.op[0], regs, decode.op[0].len);
     if ( rc != X86EMUL_OKAY )
         return rc;
 
@@ -1801,7 +1794,7 @@ int nvmx_handle_vmptrst(struct cpu_user_regs *regs)
     unsigned long gpa = 0;
     int rc;
 
-    rc = decode_vmx_inst(regs, &decode, NULL, 0);
+    rc = decode_vmx_inst(regs, &decode, 0);
     if ( rc != X86EMUL_OKAY )
         return rc;
 
@@ -1828,7 +1821,11 @@ int nvmx_handle_vmclear(struct cpu_user_regs *regs)
     void *vvmcs;
     int rc;
 
-    rc = decode_vmx_inst(regs, &decode, &gpa, 0);
+    rc = decode_vmx_inst(regs, &decode, 0);
+    if ( rc != X86EMUL_OKAY )
+        return rc;
+
+    rc = operand_read(&gpa, &decode.op[0], regs, decode.op[0].len);
     if ( rc != X86EMUL_OKAY )
         return rc;
 
@@ -1879,7 +1876,7 @@ int nvmx_handle_vmread(struct cpu_user_regs *regs)
     int rc;
     unsigned long vmcs_encoding = 0;
 
-    rc = decode_vmx_inst(regs, &decode, NULL, 0);
+    rc = decode_vmx_inst(regs, &decode, 0);
     if ( rc != X86EMUL_OKAY )
         return rc;
 
@@ -1928,10 +1925,13 @@ int nvmx_handle_vmwrite(struct cpu_user_regs *regs)
     enum vmx_insn_errno err;
     int rc;
 
-    if ( decode_vmx_inst(regs, &decode, &operand, 0)
-             != X86EMUL_OKAY )
+    if ( decode_vmx_inst(regs, &decode, 0) != X86EMUL_OKAY )
         return X86EMUL_EXCEPTION;
 
+    rc = operand_read(&operand, &decode.op[0], regs, decode.op[0].len);
+    if ( rc != X86EMUL_OKAY )
+        return rc;
+
     if ( vcpu_nestedhvm(v).nv_vvmcxaddr == INVALID_PADDR )
     {
         vmfail_invalid(regs);
@@ -1973,11 +1973,10 @@ int nvmx_handle_vmwrite(struct cpu_user_regs *regs)
 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 )
+    if ( (ret = decode_vmx_inst(regs, &decode, 0)) != X86EMUL_OKAY )
         return ret;
 
     ret = operand_read(&invept_type, &decode.op[1], regs, decode.op[1].len);
@@ -1988,6 +1987,12 @@ int nvmx_handle_invept(struct cpu_user_regs *regs)
     {
     case INVEPT_SINGLE_CONTEXT:
     {
+        unsigned long eptp;
+
+        ret = operand_read(&eptp, &decode.op[0], regs, decode.op[0].len);
+        if ( ret )
+            return ret;
+
         np2m_flush_base(current, eptp);
         break;
     }
@@ -2009,7 +2014,7 @@ int nvmx_handle_invvpid(struct cpu_user_regs *regs)
     unsigned long invvpid_type = 0;
     int ret;
 
-    if ( (ret = decode_vmx_inst(regs, &decode, NULL, 0)) != X86EMUL_OKAY )
+    if ( (ret = decode_vmx_inst(regs, &decode, 0)) != X86EMUL_OKAY )
         return ret;
 
     ret = operand_read(&invvpid_type, &decode.op[1], regs, decode.op[1].len);
-- 
2.13.6


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.