diff mbox

[v3,1/8] x86/vmx_update_guest_cr: minor optimization

Message ID 1467820195-13302-1-git-send-email-czuzu@bitdefender.com (mailing list archive)
State New, archived
Headers show

Commit Message

Corneliu ZUZU July 6, 2016, 3:49 p.m. UTC
Minor optimization @ vmx_update_guest_cr: checks if v->arch.hvm_vmx.exec_control
was modified before actually calling vmx_update_cpu_exec_control(v).

Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>
---
Changed since v2: <nothing>
---
 xen/arch/x86/hvm/vmx/vmx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Corneliu ZUZU July 8, 2016, 11:39 a.m. UTC | #1
On 7/6/2016 6:49 PM, Corneliu ZUZU wrote:
> Minor optimization @ vmx_update_guest_cr: checks if v->arch.hvm_vmx.exec_control
> was modified before actually calling vmx_update_cpu_exec_control(v).
>
> Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>
> ---
> Changed since v2: <nothing>
> ---
>   xen/arch/x86/hvm/vmx/vmx.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index df19579..8ab074f 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1434,8 +1434,10 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
>           if ( paging_mode_hap(v->domain) )
>           {
>               /* Manage GUEST_CR3 when CR0.PE=0. */
> +            uint32_t old_ctls = v->arch.hvm_vmx.exec_control;
>               uint32_t cr3_ctls = (CPU_BASED_CR3_LOAD_EXITING |
>                                    CPU_BASED_CR3_STORE_EXITING);
> +
>               v->arch.hvm_vmx.exec_control &= ~cr3_ctls;
>               if ( !hvm_paging_enabled(v) && !vmx_unrestricted_guest(v) )
>                   v->arch.hvm_vmx.exec_control |= cr3_ctls;
> @@ -1445,7 +1447,8 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
>                    monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
>                   v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING;
>   
> -            vmx_update_cpu_exec_control(v);
> +            if ( old_ctls != v->arch.hvm_vmx.exec_control )
> +                vmx_update_cpu_exec_control(v);
>           }
>   
>           if ( !nestedhvm_vcpu_in_guestmode(v) )

Jan,

I'm wondering if you could ack this as well (if there's nothing wrong w/ 
it) and push it to be done with it. :-)

Thanks,
Corneliu.
Jan Beulich July 8, 2016, 11:48 a.m. UTC | #2
>>> On 08.07.16 at 13:39, <czuzu@bitdefender.com> wrote:
> On 7/6/2016 6:49 PM, Corneliu ZUZU wrote:
>> Minor optimization @ vmx_update_guest_cr: checks if 
> v->arch.hvm_vmx.exec_control
>> was modified before actually calling vmx_update_cpu_exec_control(v).
>>
>> Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>
>> ---
>> Changed since v2: <nothing>
>> ---
>>   xen/arch/x86/hvm/vmx/vmx.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
>> index df19579..8ab074f 100644
>> --- a/xen/arch/x86/hvm/vmx/vmx.c
>> +++ b/xen/arch/x86/hvm/vmx/vmx.c
>> @@ -1434,8 +1434,10 @@ static void vmx_update_guest_cr(struct vcpu *v, 
> unsigned int cr)
>>           if ( paging_mode_hap(v->domain) )
>>           {
>>               /* Manage GUEST_CR3 when CR0.PE=0. */
>> +            uint32_t old_ctls = v->arch.hvm_vmx.exec_control;
>>               uint32_t cr3_ctls = (CPU_BASED_CR3_LOAD_EXITING |
>>                                    CPU_BASED_CR3_STORE_EXITING);
>> +
>>               v->arch.hvm_vmx.exec_control &= ~cr3_ctls;
>>               if ( !hvm_paging_enabled(v) && !vmx_unrestricted_guest(v) )
>>                   v->arch.hvm_vmx.exec_control |= cr3_ctls;
>> @@ -1445,7 +1447,8 @@ static void vmx_update_guest_cr(struct vcpu *v, 
> unsigned int cr)
>>                    monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
>>                   v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING;
>>   
>> -            vmx_update_cpu_exec_control(v);
>> +            if ( old_ctls != v->arch.hvm_vmx.exec_control )
>> +                vmx_update_cpu_exec_control(v);
>>           }
>>   
>>           if ( !nestedhvm_vcpu_in_guestmode(v) )
> 
> I'm wondering if you could ack this as well (if there's nothing wrong w/ 
> it) and push it to be done with it. :-)

Well, if you had pinged the patch at least once, I probably would.
I don't, however, recall having seen any such ping (only resends).

Jan
Corneliu ZUZU July 8, 2016, 11:55 a.m. UTC | #3
On 7/8/2016 2:48 PM, Jan Beulich wrote:
>>>> On 08.07.16 at 13:39, <czuzu@bitdefender.com> wrote:
>> On 7/6/2016 6:49 PM, Corneliu ZUZU wrote:
>>> Minor optimization @ vmx_update_guest_cr: checks if
>> v->arch.hvm_vmx.exec_control
>>> was modified before actually calling vmx_update_cpu_exec_control(v).
>>>
>>> Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>
>>> ---
>>> Changed since v2: <nothing>
>>> ---
>>>    xen/arch/x86/hvm/vmx/vmx.c | 5 ++++-
>>>    1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
>>> index df19579..8ab074f 100644
>>> --- a/xen/arch/x86/hvm/vmx/vmx.c
>>> +++ b/xen/arch/x86/hvm/vmx/vmx.c
>>> @@ -1434,8 +1434,10 @@ static void vmx_update_guest_cr(struct vcpu *v,
>> unsigned int cr)
>>>            if ( paging_mode_hap(v->domain) )
>>>            {
>>>                /* Manage GUEST_CR3 when CR0.PE=0. */
>>> +            uint32_t old_ctls = v->arch.hvm_vmx.exec_control;
>>>                uint32_t cr3_ctls = (CPU_BASED_CR3_LOAD_EXITING |
>>>                                     CPU_BASED_CR3_STORE_EXITING);
>>> +
>>>                v->arch.hvm_vmx.exec_control &= ~cr3_ctls;
>>>                if ( !hvm_paging_enabled(v) && !vmx_unrestricted_guest(v) )
>>>                    v->arch.hvm_vmx.exec_control |= cr3_ctls;
>>> @@ -1445,7 +1447,8 @@ static void vmx_update_guest_cr(struct vcpu *v,
>> unsigned int cr)
>>>                     monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
>>>                    v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING;
>>>    
>>> -            vmx_update_cpu_exec_control(v);
>>> +            if ( old_ctls != v->arch.hvm_vmx.exec_control )
>>> +                vmx_update_cpu_exec_control(v);
>>>            }
>>>    
>>>            if ( !nestedhvm_vcpu_in_guestmode(v) )
>> I'm wondering if you could ack this as well (if there's nothing wrong w/
>> it) and push it to be done with it. :-)
> Well, if you had pinged the patch at least once, I probably would.
> I don't, however, recall having seen any such ping (only resends).
>
> Jan

So is a 'ping' (haven't done that before) still necessary? Is a ping a 
simple 'reply-to-all' including 'Ping: ' in the subject? :-)

Thanks,
Corneliu.
Jan Beulich July 8, 2016, 12:11 p.m. UTC | #4
>>> On 08.07.16 at 13:55, <czuzu@bitdefender.com> wrote:
> On 7/8/2016 2:48 PM, Jan Beulich wrote:
>>>>> On 08.07.16 at 13:39, <czuzu@bitdefender.com> wrote:
>>> On 7/6/2016 6:49 PM, Corneliu ZUZU wrote:
>>>> Minor optimization @ vmx_update_guest_cr: checks if
>>> v->arch.hvm_vmx.exec_control
>>>> was modified before actually calling vmx_update_cpu_exec_control(v).
>>>>
>>>> Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>
>>>> ---
>>>> Changed since v2: <nothing>
>>>> ---
>>>>    xen/arch/x86/hvm/vmx/vmx.c | 5 ++++-
>>>>    1 file changed, 4 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
>>>> index df19579..8ab074f 100644
>>>> --- a/xen/arch/x86/hvm/vmx/vmx.c
>>>> +++ b/xen/arch/x86/hvm/vmx/vmx.c
>>>> @@ -1434,8 +1434,10 @@ static void vmx_update_guest_cr(struct vcpu *v,
>>> unsigned int cr)
>>>>            if ( paging_mode_hap(v->domain) )
>>>>            {
>>>>                /* Manage GUEST_CR3 when CR0.PE=0. */
>>>> +            uint32_t old_ctls = v->arch.hvm_vmx.exec_control;
>>>>                uint32_t cr3_ctls = (CPU_BASED_CR3_LOAD_EXITING |
>>>>                                     CPU_BASED_CR3_STORE_EXITING);
>>>> +
>>>>                v->arch.hvm_vmx.exec_control &= ~cr3_ctls;
>>>>                if ( !hvm_paging_enabled(v) && !vmx_unrestricted_guest(v) )
>>>>                    v->arch.hvm_vmx.exec_control |= cr3_ctls;
>>>> @@ -1445,7 +1447,8 @@ static void vmx_update_guest_cr(struct vcpu *v,
>>> unsigned int cr)
>>>>                     monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
>>>>                    v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING;
>>>>    
>>>> -            vmx_update_cpu_exec_control(v);
>>>> +            if ( old_ctls != v->arch.hvm_vmx.exec_control )
>>>> +                vmx_update_cpu_exec_control(v);
>>>>            }
>>>>    
>>>>            if ( !nestedhvm_vcpu_in_guestmode(v) )
>>> I'm wondering if you could ack this as well (if there's nothing wrong w/
>>> it) and push it to be done with it. :-)
>> Well, if you had pinged the patch at least once, I probably would.
>> I don't, however, recall having seen any such ping (only resends).
> 
> So is a 'ping' (haven't done that before) still necessary? Is a ping a 
> simple 'reply-to-all' including 'Ping: ' in the subject? :-)

It's not very much formalized. What I do in such a case is, as you
say, prefix the subject with Ping:, but change addressing so that
the people expected to reply end up in To:, while everyone else in
the original To: list (i.e. including xen-devel) would get moved to
Cc:.

And while, with the adjustment to addressees in my earlier reply, I
already tried to do kind of a ping to them, I think it wouldn't hurt if
you did another explicit one.

Jan
Corneliu ZUZU July 8, 2016, 12:18 p.m. UTC | #5
On 7/6/2016 6:49 PM, Corneliu ZUZU wrote:
> Minor optimization @ vmx_update_guest_cr: checks if v->arch.hvm_vmx.exec_control
> was modified before actually calling vmx_update_cpu_exec_control(v).
>
> Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>
> ---
> Changed since v2: <nothing>
> ---
>   xen/arch/x86/hvm/vmx/vmx.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index df19579..8ab074f 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1434,8 +1434,10 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
>           if ( paging_mode_hap(v->domain) )
>           {
>               /* Manage GUEST_CR3 when CR0.PE=0. */
> +            uint32_t old_ctls = v->arch.hvm_vmx.exec_control;
>               uint32_t cr3_ctls = (CPU_BASED_CR3_LOAD_EXITING |
>                                    CPU_BASED_CR3_STORE_EXITING);
> +
>               v->arch.hvm_vmx.exec_control &= ~cr3_ctls;
>               if ( !hvm_paging_enabled(v) && !vmx_unrestricted_guest(v) )
>                   v->arch.hvm_vmx.exec_control |= cr3_ctls;
> @@ -1445,7 +1447,8 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
>                    monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
>                   v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING;
>   
> -            vmx_update_cpu_exec_control(v);
> +            if ( old_ctls != v->arch.hvm_vmx.exec_control )
> +                vmx_update_cpu_exec_control(v);
>           }
>   
>           if ( !nestedhvm_vcpu_in_guestmode(v) )
Tian, Kevin July 11, 2016, 2:37 a.m. UTC | #6
> From: Corneliu ZUZU [mailto:czuzu@bitdefender.com]
> Sent: Wednesday, July 06, 2016 11:50 PM
> 
> Minor optimization @ vmx_update_guest_cr: checks if v->arch.hvm_vmx.exec_control
> was modified before actually calling vmx_update_cpu_exec_control(v).
> 
> Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>

Acked-by: Kevin Tian <kevin.tian@intel.com>
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index df19579..8ab074f 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1434,8 +1434,10 @@  static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
         if ( paging_mode_hap(v->domain) )
         {
             /* Manage GUEST_CR3 when CR0.PE=0. */
+            uint32_t old_ctls = v->arch.hvm_vmx.exec_control;
             uint32_t cr3_ctls = (CPU_BASED_CR3_LOAD_EXITING |
                                  CPU_BASED_CR3_STORE_EXITING);
+
             v->arch.hvm_vmx.exec_control &= ~cr3_ctls;
             if ( !hvm_paging_enabled(v) && !vmx_unrestricted_guest(v) )
                 v->arch.hvm_vmx.exec_control |= cr3_ctls;
@@ -1445,7 +1447,8 @@  static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
                  monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
                 v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING;
 
-            vmx_update_cpu_exec_control(v);
+            if ( old_ctls != v->arch.hvm_vmx.exec_control )
+                vmx_update_cpu_exec_control(v);
         }
 
         if ( !nestedhvm_vcpu_in_guestmode(v) )