kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5/5] KVM: nVMX: VMWRITE emulation: remove unnecessary check for compatibility mode
@ 2015-08-20 19:38 Eugene Korenevsky
  2015-09-07 11:43 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Eugene Korenevsky @ 2015-08-20 19:38 UTC (permalink / raw)
  To: kvm; +Cc: Paolo Bonzini

VMWRITE instruction is not valid in compatibility mode. This is
checked by nested_vmx_check_permission() function which throws #UD if CS.L=0.
The additional check in is_64_bit_mode() for CS.L=0 is useless.
We should check only EFER.LMA=1 which is done by is_long_mode().

Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com>
---
 arch/x86/kvm/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f39e24f..12bdaae 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -7034,7 +7034,7 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
 		field_value = kvm_register_readl(vcpu,
 			(((vmx_instruction_info) >> 3) & 0xf));
 	else {
-		mem_op_size = is_64_bit_mode(vcpu) ? 8 : 4;
+		mem_op_size = is_long_mode(vcpu) ? 8 : 4;
 		if (get_vmx_mem_address(vcpu, exit_qualification,
 		    vmx_instruction_info, false, mem_op_size, &gva))
 			return 1;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5/5] KVM: nVMX: VMWRITE emulation: remove unnecessary check for compatibility mode
  2015-08-20 19:38 [PATCH 5/5] KVM: nVMX: VMWRITE emulation: remove unnecessary check for compatibility mode Eugene Korenevsky
@ 2015-09-07 11:43 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-09-07 11:43 UTC (permalink / raw)
  To: Eugene Korenevsky, kvm



On 20/08/2015 21:38, Eugene Korenevsky wrote:
> VMWRITE instruction is not valid in compatibility mode. This is
> checked by nested_vmx_check_permission() function which throws #UD if CS.L=0.
> The additional check in is_64_bit_mode() for CS.L=0 is useless.

This is true, and it matches what handle_vmread does, on the other hand
is_long_mode is generally used to test page table type.

I think it's clearer if you change handle_vmread to use is_64_bit_mode
instead.

Paolo

> We should check only EFER.LMA=1 which is done by is_long_mode().
> 
> Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com>
> ---
>  arch/x86/kvm/vmx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index f39e24f..12bdaae 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -7034,7 +7034,7 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
>  		field_value = kvm_register_readl(vcpu,
>  			(((vmx_instruction_info) >> 3) & 0xf));
>  	else {
> -		mem_op_size = is_64_bit_mode(vcpu) ? 8 : 4;
> +		mem_op_size = is_long_mode(vcpu) ? 8 : 4;
>  		if (get_vmx_mem_address(vcpu, exit_qualification,
>  		    vmx_instruction_info, false, mem_op_size, &gva))
>  			return 1;
> -- 2.1.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-07 11:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 19:38 [PATCH 5/5] KVM: nVMX: VMWRITE emulation: remove unnecessary check for compatibility mode Eugene Korenevsky
2015-09-07 11:43 ` Paolo Bonzini

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).