x86/vvmx: Misc fixes
cover x86/vvmx: Misc fixes
All from code inspection
Andrew Cooper (4):
x86/vvmx: Drop unused CASE_{GET,SET}_REG() macros x86/vvmx: Correct the INVALID_PADDR checks for VMPTRLD/VMCLEAR x86/vvmx: Fixes to VMWRITE emulation
x86/vvmx: Don't call vmsucceed() at the end of virtual_vmexit()
xen/arch/x86/hvm/vmx/vvmx.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/4 x86/vvmx: Drop unused CASE_{GET, SET}_REG() macros
These have been obsolete since c/s 053ae230 "x86/vvmx: Remove enum vmx_regs_enc".
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
--- xen/arch/x86/hvm/vmx/vvmx.c | 5 ----- 1 file changed, 5 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +0 -5
@@ -207,11 +207,6 @@ struct vmx_inst_decoded {unsigned int reg2; }; -#define CASE_SET_REG (REG , reg) \ - case VMX_REG_ ## REG: regs->reg = value; break -#define CASE_GET_REG (REG , reg) \ - case VMX_REG_ ## REG: value = regs->reg; break -static int vvmcs_offset (u32 width,u32 type,u32 index) {int offset;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/4 x86/vvmx: Correct the INVALID_PADDR checks for VMPTRLD/VMCLEAR
In reply to Andrew CooperThe referenced addresses also need checking against MAXPHYSADDR.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
--- xen/arch/x86/hvm/vmx/vvmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +2 -2
@@ -1672,7 +1672,7 @@ static int nvmx_handle_vmptrld(struct cpu_user_regs *regs)if ( rc !=X86EMUL_OKAY )return rc; -if ( gpa &0xfff ) +if ( (gpa & ~PAGE_MASK ) || !gfn_valid (v->domain,gaddr_to_gfn (gpa)) ) {vmfail (regs,VMX_INSN_VMPTRLD_INVALID_PHYADDR ); goto out;
@@ -1780,7 +1780,7 @@ static int nvmx_handle_vmclear(struct cpu_user_regs *regs) goto out; } -if ( gpa &0xfff ) +if ( (gpa & ~PAGE_MASK ) || !gfn_valid (v->domain,gaddr_to_gfn (gpa)) ) {vmfail (regs,VMX_INSN_VMCLEAR_INVALID_PHYADDR ); goto out;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/4 x86/vvmx: Fixes to VMWRITE emulation
In reply to Andrew Cooper * Don't assume that decode_vmx_inst() always returns X86EMUL_EXCEPTION.
* The okay boolean is never written, making the else case dead.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
--- xen/arch/x86/hvm/vmx/vvmx.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +5 -7
@@ -1872,11 +1872,12 @@ static int nvmx_handle_vmwrite(struct cpu_user_regs *regs)struct vmx_inst_decoded decode;unsigned long operand;u64 vmcs_encoding; -bool_t okay =1 ;enum vmx_insn_errno err; +int rc; -if (decode_vmx_inst (regs, &decode, &operand) !=X86EMUL_OKAY ) -return X86EMUL_EXCEPTION ; + rc =decode_vmx_inst (regs, &decode, &operand); +if ( rc !=X86EMUL_OKAY ) +return rc;if ( !vvmcx_valid (v) ) {
@@ -1905,10 +1906,7 @@ static int nvmx_handle_vmwrite(struct cpu_user_regs *regs)break ; } -if ( okay ) -vmsucceed (regs); -else -vmfail_valid (regs,VMX_INSN_UNSUPPORTED_VMCS_COMPONENT ); +vmsucceed (regs);return X86EMUL_OKAY ; }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 4/4 x86/vvmx: Don't call vmsucceed() at the end of virtual_vmexit()
In reply to Andrew CooperThis ends up corrupting L1's view of RFLAGS by setting ZF. The correct value is established earlier in the function.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
--- xen/arch/x86/hvm/vmx/vvmx.c | 1 - 1 file changed, 1 deletion(-)
xen/arch/x86/hvm/vmx/vvmx.c +0 -1
@@ -1371,7 +1371,6 @@ static void virtual_vmexit(struct cpu_user_regs *regs)nvmx_update_apicv (v); nvcpu->nv_vmswitch_in_progress =0 ; -vmsucceed (regs); }static void nvmx_eptp_update (void )
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/4] x86/vvmx: Drop unused CASE_{GET, SET}_REG() macros
In reply to Andrew CooperQuoted 4 lines · Andrew Cooper
These have been obsolete since c/s
053ae230"x86/vvmx: Remove enumvmx_regs_enc".Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/4] x86/vvmx: Correct the INVALID_PADDR checks for VMPTRLD/VMCLEAR
In reply to Andrew CooperQuoted 3 lines · Andrew Cooper
The referenced addresses also need checking against MAXPHYSADDR.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 16 lines
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>--- xen/arch/x86/hvm/vmx/vvmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)xen/arch/x86/hvm/vmx/vvmx.c +0
-0
xen/arch/x86/hvm/vmx/vvmx.c static int nvmx_handle_vmptrld(struct cpu_user_regs *regs) · line 1675
Quoted 5 lines
xen/arch/x86/hvm/vmx/vvmx.c +1
-1@@ -1672,7 +1672,7 @@ static int nvmx_handle_vmptrld(struct cpu_user_regs *regs)if ( rc !=X86EMUL_OKAY )return rc; -if ( gpa &0xfff ) +if ( (gpa & ~PAGE_MASK ) || !gfn_valid (v->domain,gaddr_to_gfn (gpa)) )
Seeing this is repeated in several places, it might be helpful to introduce a helper?
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/4] x86/vvmx: Fixes to VMWRITE emulation
In reply to Andrew CooperQuoted 4 lines · Andrew Cooper
* Don't assume that
decode_vmx_inst()always returnsX86EMUL_EXCEPTION.
* The okay boolean is never written, making the else case dead.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/4] x86/vvmx: Don't call vmsucceed() at the end of virtual_vmexit()
In reply to Andrew CooperQuoted 4 lines · Andrew Cooper
This ends up corrupting L1's view of RFLAGS by setting ZF. The correct value is established earlier in the function.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/4] x86/vvmx: Don't call vmsucceed() at the end of virtual_vmexit()
In reply to Andrew CooperQuoted 2 lines · Andrew Cooper
This ends up corrupting L1's view of RFLAGS by setting ZF. The correct value is established earlier in the function.
vmsucceed() doesn't set any flags, only clears some. And in this function it's just redundant. ZF is set by VMfailValid. So I think the description must be changed.
--
Sergey
Quoted 18 lines
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>--- xen/arch/x86/hvm/vmx/vvmx.c | 1 - 1 file changed, 1 deletion(-)xen/arch/x86/hvm/vmx/vvmx.c +0
-0
xen/arch/x86/hvm/vmx/vvmx.c static void virtual_vmexit(struct cpu_user_regs *regs) · line 1376
Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +0
-1@@ -1371,7 +1371,6 @@ static void virtual_vmexit(struct cpu_user_regs *regs)nvmx_update_apicv (v); nvcpu->nv_vmswitch_in_progress =0 ; -vmsucceed (regs); }static void nvmx_eptp_update (void )
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/4] x86/vvmx: Don't call vmsucceed() at the end of virtual_vmexit()
Quoted 6 lines · Sergey Dyasli
Quoted 2 lines · Andrew Cooper
This ends up corrupting L1's view of RFLAGS by setting ZF. The correct value is established earlier in the function.
vmsucceed()doesn't set any flags, only clears some. And in this function it's just redundant. ZF is set by VMfailValid. So I think the description must be changed.
Oh - so it does. Yes - I was confusing it with the failvalid case. I'll fix the wording to "The correct RFLAGS value is established earlier in the function, and this call has no net effect."
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Andrew Cooper
All from code inspection
Andrew Cooper (4):
x86/vvmx: Drop unused CASE_{GET,SET}_REG() macros x86/vvmx: Correct theINVALID_PADDRchecks for VMPTRLD/VMCLEAR x86/vvmx: Fixes to VMWRITE emulation
x86/vvmx: Don't callvmsucceed()at the end ofvirtual_vmexit()
--
Thanks,
Sergey
Quoted 3 lines
xen/arch/x86/hvm/vmx/vvmx.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Ping VT-x.
Quoted 11 lines · Andrew Cooper
All from code inspection
Andrew Cooper (4):
x86/vvmx: Drop unused CASE_{GET,SET}_REG() macros x86/vvmx: Correct theINVALID_PADDRchecks for VMPTRLD/VMCLEAR x86/vvmx: Fixes to VMWRITE emulation
x86/vvmx: Don't callvmsucceed()at the end ofvirtual_vmexit()xen/arch/x86/hvm/vmx/vvmx.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/4] x86/vvmx: Drop unused CASE_{GET, SET}_REG() macros
In reply to Andrew CooperQuoted 7 lines
From: Andrew Cooper [mailto:[email protected]]
Sent: Thursday, November 15, 2018 9:53 PMThese have been obsolete since c/s
053ae230"x86/vvmx: Remove enumvmx_regs_enc".Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/4] x86/vvmx: Correct the INVALID_PADDR checks for VMPTRLD/VMCLEAR
In reply to Andrew CooperQuoted 6 lines
From: Andrew Cooper [mailto:[email protected]]
Sent: Thursday, November 15, 2018 9:53 PMThe referenced addresses also need checking against MAXPHYSADDR.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/4] x86/vvmx: Fixes to VMWRITE emulation
In reply to Andrew CooperQuoted 8 lines
From: Andrew Cooper [mailto:[email protected]]
Sent: Thursday, November 15, 2018 9:53 PM* Don't assume that
decode_vmx_inst()always returnsX86EMUL_EXCEPTION.
* The okay boolean is never written, making the else case dead.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/4] x86/vvmx: Don't call vmsucceed() at the end of virtual_vmexit()
In reply to Andrew CooperQuoted 8 lines
From: Andrew Cooper [mailto:[email protected]]
Sent: Thursday, November 15, 2018 11:31 PMQuoted 2 lines · Sergey Dyasli
Quoted 1 line · Andrew Cooper
This ends up corrupting L1's view of RFLAGS by setting ZF. The correct
value
Quoted 1 line
Quoted 1 line
is established earlier in the function.
Quoted 9 lines
Quoted 1 line
vmsucceed()doesn't set any flags, only clears some. And in this functionit's
Quoted 2 lines
just redundant. ZF is set by VMfailValid. So I think the description must be changed.
Oh - so it does. Yes - I was confusing it with the failvalid case. I'll fix the wording to "The correct RFLAGS value is established earlier in the function, and this call has no net effect."
with wording fixed, Acked-by: Kevin Tian <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel