Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1713545

Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when "unrestricted guest" is supported.

From Lan Tianyu <tianyu.lan@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when "unrestricted guest" is supported.
Date 2017-08-17 07:20 +0200
Message-ID <uflnP-es-9@gated-at.bofh.it> (permalink)
References <uf1yN-4Ab-13@gated-at.bofh.it> <uf2Oe-5hi-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2017年08月16日 17:25, Paolo Bonzini wrote:
> On 16/08/2017 03:58, Lan Tianyu wrote:
>> These CR3 VMEXITs was introduced for platform without "unrestricted guest"
>> support. This is to set ept identity table to guest CR3 in guest real
>> mode because these platforms don't support ept real mode(CR0.PE and CR0.PG
>> must be set to 1). But these VMEXITs is redundant for platforms with
>> "unrestricted guest" support.
> 
> This is true, but I'm not sure it's a good idea to make things more
> complex...  It is working code and is not a bottleneck anywhere.

Yes, this is just code clear up and will not affect function.
I thought this change was missed when introduced unrestricted guest support.

-- 
Best regards
Tianyu Lan
> 
> Paolo
> 
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>> ---
>>  arch/x86/kvm/vmx.c | 22 +++++++++++++---------
>>  1 file changed, 13 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>> index 9b21b12..46dcf50 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -4221,18 +4221,20 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0,
>>  		vmx_decache_cr3(vcpu);
>>  	if (!(cr0 & X86_CR0_PG)) {
>>  		/* From paging/starting to nonpaging */
>> -		vmcs_write32(CPU_BASED_VM_EXEC_CONTROL,
>> -			     vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) |
>> -			     (CPU_BASED_CR3_LOAD_EXITING |
>> -			      CPU_BASED_CR3_STORE_EXITING));
>> +		if (!enable_unrestricted_guest)
>> +			vmcs_write32(CPU_BASED_VM_EXEC_CONTROL,
>> +				     vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) |
>> +				     (CPU_BASED_CR3_LOAD_EXITING |
>> +				      CPU_BASED_CR3_STORE_EXITING));
>>  		vcpu->arch.cr0 = cr0;
>>  		vmx_set_cr4(vcpu, kvm_read_cr4(vcpu));
>>  	} else if (!is_paging(vcpu)) {
>>  		/* From nonpaging to paging */
>> -		vmcs_write32(CPU_BASED_VM_EXEC_CONTROL,
>> -			     vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) &
>> -			     ~(CPU_BASED_CR3_LOAD_EXITING |
>> -			       CPU_BASED_CR3_STORE_EXITING));
>> +		if (!enable_unrestricted_guest)
>> +			vmcs_write32(CPU_BASED_VM_EXEC_CONTROL,
>> +				     vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) &
>> +				     ~(CPU_BASED_CR3_LOAD_EXITING |
>> +				       CPU_BASED_CR3_STORE_EXITING));
>>  		vcpu->arch.cr0 = cr0;
>>  		vmx_set_cr4(vcpu, kvm_read_cr4(vcpu));
>>  	}
>> @@ -4311,7 +4313,9 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
>>  	}
>>  
>>  	vmx_flush_tlb(vcpu);
>> -	vmcs_writel(GUEST_CR3, guest_cr3);
>> +
>> +	if (!enable_unrestricted_guest || !enable_ept)
>> +		vmcs_writel(GUEST_CR3, guest_cr3);
>>  }
>>  
>>  static int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
>>
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when "unrestricted guest" is supported. Lan Tianyu <tianyu.lan@intel.com> - 2017-08-16 10:10 +0200
  Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when  "unrestricted guest" is supported. Paolo Bonzini <pbonzini@redhat.com> - 2017-08-16 11:30 +0200
    Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when  "unrestricted guest" is supported. Lan Tianyu <tianyu.lan@intel.com> - 2017-08-17 07:20 +0200
    Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when  "unrestricted guest" is supported. Wanpeng Li <kernellwp@gmail.com> - 2017-08-17 08:00 +0200
      Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when  "unrestricted guest" is supported. Wanpeng Li <kernellwp@gmail.com> - 2017-08-17 08:10 +0200
  Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when  "unrestricted guest" is supported. Radim Krčmář <rkrcmar@redhat.com> - 2017-08-16 15:30 +0200
    Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when  "unrestricted guest" is supported. Lan Tianyu <tianyu.lan@intel.com> - 2017-08-17 07:10 +0200
      Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when  "unrestricted guest" is supported. Radim Krčmář <rkrcmar@redhat.com> - 2017-08-17 16:20 +0200

csiph-web