p***@xen.org
2018-11-14 18:55:56 UTC
commit cadebcebfd86036361300d9150f02c51640d4ba5
Author: Sergey Dyasli <***@citrix.com>
AuthorDate: Wed Nov 14 10:23:19 2018 +0000
Commit: Andrew Cooper <***@citrix.com>
CommitDate: Wed Nov 14 18:42:48 2018 +0000
x86/vvmx: correct vmfail() usage for vmptrld and vmclear
Calling vmfail_valid() is correct only if vvmcx is valid. Modify
functions to use vmfail() instead which performs the necessary check.
While at it, add ASSERTs into vmfail_valid/invalid() to quickly catch
an incorrect usage in the future.
Signed-off-by: Sergey Dyasli <***@citrix.com>
Acked-by: Kevin Tian <***@intel.com>
---
xen/arch/x86/hvm/vmx/vvmx.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index a9b92a5b95..206a4a44fb 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -463,14 +463,19 @@ static void vmfail_valid(struct cpu_user_regs *regs, enum vmx_insn_errno errno)
struct vcpu *v = current;
unsigned int eflags = regs->eflags;
+ ASSERT(vvmcx_valid(v));
+
regs->eflags = (eflags & ~X86_EFLAGS_ARITH_MASK) | X86_EFLAGS_ZF;
set_vvmcs(v, VM_INSTRUCTION_ERROR, errno);
}
static void vmfail_invalid(struct cpu_user_regs *regs)
{
+ struct vcpu *v = current;
unsigned int eflags = regs->eflags;
+ ASSERT(!vvmcx_valid(v));
+
regs->eflags = (eflags & ~X86_EFLAGS_ARITH_MASK) | X86_EFLAGS_CF;
}
@@ -1690,7 +1695,7 @@ static int nvmx_handle_vmptrld(struct cpu_user_regs *regs)
!map_io_bitmap_all(v) ||
!_map_msr_bitmap(v) )
{
- vmfail_valid(regs, VMX_INSN_VMPTRLD_INVALID_PHYADDR);
+ vmfail(regs, VMX_INSN_VMPTRLD_INVALID_PHYADDR);
goto out;
}
}
@@ -1774,7 +1779,7 @@ static int nvmx_handle_vmclear(struct cpu_user_regs *regs)
if ( rc == VMSUCCEED )
vmsucceed(regs);
else if ( rc == VMFAIL_VALID )
- vmfail_valid(regs, VMX_INSN_VMCLEAR_INVALID_PHYADDR);
+ vmfail(regs, VMX_INSN_VMCLEAR_INVALID_PHYADDR);
else
vmfail_invalid(regs);
--
generated by git-patchbot for /home/xen/git/xen.git#staging
Author: Sergey Dyasli <***@citrix.com>
AuthorDate: Wed Nov 14 10:23:19 2018 +0000
Commit: Andrew Cooper <***@citrix.com>
CommitDate: Wed Nov 14 18:42:48 2018 +0000
x86/vvmx: correct vmfail() usage for vmptrld and vmclear
Calling vmfail_valid() is correct only if vvmcx is valid. Modify
functions to use vmfail() instead which performs the necessary check.
While at it, add ASSERTs into vmfail_valid/invalid() to quickly catch
an incorrect usage in the future.
Signed-off-by: Sergey Dyasli <***@citrix.com>
Acked-by: Kevin Tian <***@intel.com>
---
xen/arch/x86/hvm/vmx/vvmx.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index a9b92a5b95..206a4a44fb 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -463,14 +463,19 @@ static void vmfail_valid(struct cpu_user_regs *regs, enum vmx_insn_errno errno)
struct vcpu *v = current;
unsigned int eflags = regs->eflags;
+ ASSERT(vvmcx_valid(v));
+
regs->eflags = (eflags & ~X86_EFLAGS_ARITH_MASK) | X86_EFLAGS_ZF;
set_vvmcs(v, VM_INSTRUCTION_ERROR, errno);
}
static void vmfail_invalid(struct cpu_user_regs *regs)
{
+ struct vcpu *v = current;
unsigned int eflags = regs->eflags;
+ ASSERT(!vvmcx_valid(v));
+
regs->eflags = (eflags & ~X86_EFLAGS_ARITH_MASK) | X86_EFLAGS_CF;
}
@@ -1690,7 +1695,7 @@ static int nvmx_handle_vmptrld(struct cpu_user_regs *regs)
!map_io_bitmap_all(v) ||
!_map_msr_bitmap(v) )
{
- vmfail_valid(regs, VMX_INSN_VMPTRLD_INVALID_PHYADDR);
+ vmfail(regs, VMX_INSN_VMPTRLD_INVALID_PHYADDR);
goto out;
}
}
@@ -1774,7 +1779,7 @@ static int nvmx_handle_vmclear(struct cpu_user_regs *regs)
if ( rc == VMSUCCEED )
vmsucceed(regs);
else if ( rc == VMFAIL_VALID )
- vmfail_valid(regs, VMX_INSN_VMCLEAR_INVALID_PHYADDR);
+ vmfail(regs, VMX_INSN_VMCLEAR_INVALID_PHYADDR);
else
vmfail_invalid(regs);
--
generated by git-patchbot for /home/xen/git/xen.git#staging