KVM: nVMX: Rename prepare_vmcs02_*_full to prepare_vmcs02_*_extra
diff mbox series

Message ID 1559834652-105872-1-git-send-email-pbonzini@redhat.com
State New
Headers show
Series
  • KVM: nVMX: Rename prepare_vmcs02_*_full to prepare_vmcs02_*_extra
Related show

Commit Message

Paolo Bonzini June 6, 2019, 3:24 p.m. UTC
These function do not prepare the entire state of the vmcs02, only the
rarely needed parts.  Rename them to make this clearer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/vmx/nested.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Sean Christopherson June 6, 2019, 6:41 p.m. UTC | #1
On Thu, Jun 06, 2019 at 05:24:12PM +0200, Paolo Bonzini wrote:
> These function do not prepare the entire state of the vmcs02, only the
> rarely needed parts.  Rename them to make this clearer.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/vmx/nested.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 84438cf23d37..fd8150ef6cce 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -1955,7 +1955,7 @@ static void prepare_vmcs02_constant_state(struct vcpu_vmx *vmx)
>  	vmx_set_constant_host_state(vmx);
>  }
>  
> -static void prepare_vmcs02_early_full(struct vcpu_vmx *vmx,
> +static void prepare_vmcs02_early_extra(struct vcpu_vmx *vmx,

Or maybe 'uncommon', 'rare' or 'ext'?  I don't I particularly love any of
the names, but they're all better than 'full'.

Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

>  				      struct vmcs12 *vmcs12)
>  {
>  	prepare_vmcs02_constant_state(vmx);
> @@ -1976,7 +1976,7 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
>  	u64 guest_efer = nested_vmx_calc_efer(vmx, vmcs12);
>  
>  	if (vmx->nested.dirty_vmcs12 || vmx->nested.hv_evmcs)
> -		prepare_vmcs02_early_full(vmx, vmcs12);
> +		prepare_vmcs02_early_extra(vmx, vmcs12);
>  
>  	/*
>  	 * PIN CONTROLS
> @@ -2130,7 +2130,7 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
>  	}
>  }
>  
> -static void prepare_vmcs02_full(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
> +static void prepare_vmcs02_extra(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
>  {
>  	struct hv_enlightened_vmcs *hv_evmcs = vmx->nested.hv_evmcs;
>  
> @@ -2254,7 +2254,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
>  	struct vcpu_vmx *vmx = to_vmx(vcpu);
>  
>  	if (vmx->nested.dirty_vmcs12 || vmx->nested.hv_evmcs) {
> -		prepare_vmcs02_full(vmx, vmcs12);
> +		prepare_vmcs02_extra(vmx, vmcs12);
>  		vmx->nested.dirty_vmcs12 = false;
>  	}
>  
> -- 
> 1.8.3.1
>
Krish Sadhukhan June 6, 2019, 7:19 p.m. UTC | #2
On 06/06/2019 11:41 AM, Sean Christopherson wrote:
> On Thu, Jun 06, 2019 at 05:24:12PM +0200, Paolo Bonzini wrote:
>> These function do not prepare the entire state of the vmcs02, only the
>> rarely needed parts.  Rename them to make this clearer.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   arch/x86/kvm/vmx/nested.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
>> index 84438cf23d37..fd8150ef6cce 100644
>> --- a/arch/x86/kvm/vmx/nested.c
>> +++ b/arch/x86/kvm/vmx/nested.c
>> @@ -1955,7 +1955,7 @@ static void prepare_vmcs02_constant_state(struct vcpu_vmx *vmx)
>>   	vmx_set_constant_host_state(vmx);
>>   }
>>   
>> -static void prepare_vmcs02_early_full(struct vcpu_vmx *vmx,
>> +static void prepare_vmcs02_early_extra(struct vcpu_vmx *vmx,
> Or maybe 'uncommon', 'rare' or 'ext'?  I don't I particularly love any of
> the names, but they're all better than 'full'.

The big chunk of the work in this function is done via 
prepare_vmcs02_constant_state(). It seems cleaner to get rid of 
prepare_vmcs02_early_full(), call prepare_vmcs02_constant_state() 
directly from prepare_vmcs02_early() and move the three vmcs_write16() 
calls to prepare_vmcs02_early().

>
> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>
>
>>   				      struct vmcs12 *vmcs12)
>>   {
>>   	prepare_vmcs02_constant_state(vmx);
>> @@ -1976,7 +1976,7 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
>>   	u64 guest_efer = nested_vmx_calc_efer(vmx, vmcs12);
>>   
>>   	if (vmx->nested.dirty_vmcs12 || vmx->nested.hv_evmcs)
>> -		prepare_vmcs02_early_full(vmx, vmcs12);
>> +		prepare_vmcs02_early_extra(vmx, vmcs12);
>>   
>>   	/*
>>   	 * PIN CONTROLS
>> @@ -2130,7 +2130,7 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
>>   	}
>>   }
>>   
>> -static void prepare_vmcs02_full(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
>> +static void prepare_vmcs02_extra(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
>>   {
>>   	struct hv_enlightened_vmcs *hv_evmcs = vmx->nested.hv_evmcs;
>>   
>> @@ -2254,7 +2254,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
>>   	struct vcpu_vmx *vmx = to_vmx(vcpu);
>>   
>>   	if (vmx->nested.dirty_vmcs12 || vmx->nested.hv_evmcs) {
>> -		prepare_vmcs02_full(vmx, vmcs12);
>> +		prepare_vmcs02_extra(vmx, vmcs12);
>>   		vmx->nested.dirty_vmcs12 = false;
>>   	}
>>   
>> -- 
>> 1.8.3.1
>>
Paolo Bonzini June 6, 2019, 8:19 p.m. UTC | #3
On 06/06/19 21:19, Krish Sadhukhan wrote:
> 
> The big chunk of the work in this function is done via
> prepare_vmcs02_constant_state(). It seems cleaner to get rid of
> prepare_vmcs02_early_full(), call prepare_vmcs02_constant_state()
> directly from prepare_vmcs02_early() and move the three vmcs_write16()
> calls to prepare_vmcs02_early().
> 

This is just a mechanical search and replace, you can send a patch on
top to inline it in the caller.

Paolo
Paolo Bonzini June 7, 2019, 12:19 p.m. UTC | #4
On 06/06/19 20:41, Sean Christopherson wrote:
>> +static void prepare_vmcs02_early_extra(struct vcpu_vmx *vmx,
> Or maybe 'uncommon', 'rare' or 'ext'?  I don't I particularly love any of
> the names, but they're all better than 'full'.

I thought 'ext' was short for 'extra'? :)

Paolo
Sean Christopherson June 7, 2019, 2:18 p.m. UTC | #5
On Fri, Jun 07, 2019 at 02:19:20PM +0200, Paolo Bonzini wrote:
> On 06/06/19 20:41, Sean Christopherson wrote:
> >> +static void prepare_vmcs02_early_extra(struct vcpu_vmx *vmx,
> > Or maybe 'uncommon', 'rare' or 'ext'?  I don't I particularly love any of
> > the names, but they're all better than 'full'.
> 
> I thought 'ext' was short for 'extra'? :)

Ha, I (obviously) didn't make that connection.  ext == extended in my mind.
Paolo Bonzini June 7, 2019, 3:17 p.m. UTC | #6
On 07/06/19 16:18, Sean Christopherson wrote:
> On Fri, Jun 07, 2019 at 02:19:20PM +0200, Paolo Bonzini wrote:
>> On 06/06/19 20:41, Sean Christopherson wrote:
>>>> +static void prepare_vmcs02_early_extra(struct vcpu_vmx *vmx,
>>> Or maybe 'uncommon', 'rare' or 'ext'?  I don't I particularly love any of
>>> the names, but they're all better than 'full'.
>>
>> I thought 'ext' was short for 'extra'? :)
> 
> Ha, I (obviously) didn't make that connection.  ext == extended in my mind.

That's what came to mind first, but then "extended" had the same issue
as "full" (i.e. encompassing the "basic" set as well) so I decided you
knew better!

Paolo
Sean Christopherson June 7, 2019, 4:04 p.m. UTC | #7
On Fri, Jun 07, 2019 at 05:17:09PM +0200, Paolo Bonzini wrote:
> On 07/06/19 16:18, Sean Christopherson wrote:
> > On Fri, Jun 07, 2019 at 02:19:20PM +0200, Paolo Bonzini wrote:
> >> On 06/06/19 20:41, Sean Christopherson wrote:
> >>>> +static void prepare_vmcs02_early_extra(struct vcpu_vmx *vmx,
> >>> Or maybe 'uncommon', 'rare' or 'ext'?  I don't I particularly love any of
> >>> the names, but they're all better than 'full'.
> >>
> >> I thought 'ext' was short for 'extra'? :)
> > 
> > Ha, I (obviously) didn't make that connection.  ext == extended in my mind.
> 
> That's what came to mind first, but then "extended" had the same issue
> as "full" (i.e. encompassing the "basic" set as well) so I decided you
> knew better!

Ah, I was thinking of "basic" and "extended" as separate states, but your
interpretation is correct.

I probably have a slight preference for 'uncommon' over 'extra'?  I feel
like they have equal odds of being misinterpreted, so pick your poison :-)
Paolo Bonzini June 7, 2019, 4:24 p.m. UTC | #8
On 07/06/19 18:04, Sean Christopherson wrote:
>> That's what came to mind first, but then "extended" had the same issue
>> as "full" (i.e. encompassing the "basic" set as well) so I decided you
>> knew better!
> Ah, I was thinking of "basic" and "extended" as separate states, but your
> interpretation is correct.
> 
> I probably have a slight preference for 'uncommon' over 'extra'?  I feel
> like they have equal odds of being misinterpreted, so pick your poison :-)

Among your proposals, in fact, I also thought of "uncommon" and "rare".
 Uncommon is a bit long so I'll go with "rare", knowing that the meat
reference will give me a chuckle every now and then.

Paolo

Patch
diff mbox series

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 84438cf23d37..fd8150ef6cce 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -1955,7 +1955,7 @@  static void prepare_vmcs02_constant_state(struct vcpu_vmx *vmx)
 	vmx_set_constant_host_state(vmx);
 }
 
-static void prepare_vmcs02_early_full(struct vcpu_vmx *vmx,
+static void prepare_vmcs02_early_extra(struct vcpu_vmx *vmx,
 				      struct vmcs12 *vmcs12)
 {
 	prepare_vmcs02_constant_state(vmx);
@@ -1976,7 +1976,7 @@  static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
 	u64 guest_efer = nested_vmx_calc_efer(vmx, vmcs12);
 
 	if (vmx->nested.dirty_vmcs12 || vmx->nested.hv_evmcs)
-		prepare_vmcs02_early_full(vmx, vmcs12);
+		prepare_vmcs02_early_extra(vmx, vmcs12);
 
 	/*
 	 * PIN CONTROLS
@@ -2130,7 +2130,7 @@  static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
 	}
 }
 
-static void prepare_vmcs02_full(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
+static void prepare_vmcs02_extra(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
 {
 	struct hv_enlightened_vmcs *hv_evmcs = vmx->nested.hv_evmcs;
 
@@ -2254,7 +2254,7 @@  static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
 	struct vcpu_vmx *vmx = to_vmx(vcpu);
 
 	if (vmx->nested.dirty_vmcs12 || vmx->nested.hv_evmcs) {
-		prepare_vmcs02_full(vmx, vmcs12);
+		prepare_vmcs02_extra(vmx, vmcs12);
 		vmx->nested.dirty_vmcs12 = false;
 	}