[3/9] x86/mm: honor opt_pcid also for 32-bit PV domains
diff mbox series

Message ID f58f9215-4005-9c1d-0701-1e7fe705b786@suse.com
State Superseded
Headers show
Series
  • XSA-292 follow-up
Related show

Commit Message

Jan Beulich Sept. 11, 2019, 3:22 p.m. UTC
I can't see any technical or performance reason why we should treat
32-bit PV different from 64-bit PV in this regard.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Roger Pau Monné Sept. 12, 2019, 10:34 a.m. UTC | #1
On Wed, Sep 11, 2019 at 05:22:51PM +0200, Jan Beulich wrote:
> I can't see any technical or performance reason why we should treat
> 32-bit PV different from 64-bit PV in this regard.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

The original commit mentions that PCID doesn't improve performance for
non-XPTI domains, but it doesn't mention whether it makes performance
worse. The change LGTM, if you are fine performance wise:

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

> 
> --- a/xen/arch/x86/pv/domain.c
> +++ b/xen/arch/x86/pv/domain.c
> @@ -180,7 +180,24 @@ int switch_compat(struct domain *d)
>      d->arch.x87_fip_width = 4;
>  
>      d->arch.pv.xpti = false;
> -    d->arch.pv.pcid = false;
> +
> +    if ( use_invpcid && cpu_has_pcid )
> +        switch ( ACCESS_ONCE(opt_pcid) )
> +        {
> +        case PCID_OFF:
> +        case PCID_XPTI:
> +            d->arch.pv.pcid = false;
> +            break;
> +
> +        case PCID_ALL:
> +        case PCID_NOXPTI:
> +            d->arch.pv.pcid = true;
> +            break;
> +
> +        default:
> +            ASSERT_UNREACHABLE();
> +            break;
> +        }

This chunk is (functionality wise) exactly the same as the one in
pv_domain_initialise, it might be good to put this in a separate
helper?

>  
>      return 0;
>  
> @@ -312,7 +329,7 @@ int pv_domain_initialise(struct domain *
>  
>      d->arch.pv.xpti = is_hardware_domain(d) ? opt_xpti_hwdom : opt_xpti_domu;
>  
> -    if ( !is_pv_32bit_domain(d) && use_invpcid && cpu_has_pcid )

This is_pv_32bit_domain is already pointless, is_32bit_pv gets
unconditionally set to 0 just two lines above.

Thanks, Roger.
Jan Beulich Sept. 12, 2019, 10:45 a.m. UTC | #2
On 12.09.2019 12:34, Roger Pau Monné  wrote:
> On Wed, Sep 11, 2019 at 05:22:51PM +0200, Jan Beulich wrote:
>> I can't see any technical or performance reason why we should treat
>> 32-bit PV different from 64-bit PV in this regard.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> The original commit mentions that PCID doesn't improve performance for
> non-XPTI domains, but it doesn't mention whether it makes performance
> worse.

Well, yes - it's not like we're defaulting to using PCID now for
32-bit guests. But we allow people to turn on its use. After all
the original measurements were done on a limited set of hardware,
and hardware also changes/advances all the time.

> The change LGTM, if you are fine performance wise:
> 
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks.

>> --- a/xen/arch/x86/pv/domain.c
>> +++ b/xen/arch/x86/pv/domain.c
>> @@ -180,7 +180,24 @@ int switch_compat(struct domain *d)
>>      d->arch.x87_fip_width = 4;
>>  
>>      d->arch.pv.xpti = false;
>> -    d->arch.pv.pcid = false;
>> +
>> +    if ( use_invpcid && cpu_has_pcid )
>> +        switch ( ACCESS_ONCE(opt_pcid) )
>> +        {
>> +        case PCID_OFF:
>> +        case PCID_XPTI:
>> +            d->arch.pv.pcid = false;
>> +            break;
>> +
>> +        case PCID_ALL:
>> +        case PCID_NOXPTI:
>> +            d->arch.pv.pcid = true;
>> +            break;
>> +
>> +        default:
>> +            ASSERT_UNREACHABLE();
>> +            break;
>> +        }
> 
> This chunk is (functionality wise) exactly the same as the one in
> pv_domain_initialise, it might be good to put this in a separate
> helper?

Could be, indeed, but would at least double the size of this patch.
I wasn't convinced that's worth it. I'll see what Andrew thinks,
since I'll need his ack anyway (at least in my understanding of the
still un-refined, un-written rules of what is necessary for
committing a maintainer's patch).

Jan

Patch
diff mbox series

--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -180,7 +180,24 @@  int switch_compat(struct domain *d)
     d->arch.x87_fip_width = 4;
 
     d->arch.pv.xpti = false;
-    d->arch.pv.pcid = false;
+
+    if ( use_invpcid && cpu_has_pcid )
+        switch ( ACCESS_ONCE(opt_pcid) )
+        {
+        case PCID_OFF:
+        case PCID_XPTI:
+            d->arch.pv.pcid = false;
+            break;
+
+        case PCID_ALL:
+        case PCID_NOXPTI:
+            d->arch.pv.pcid = true;
+            break;
+
+        default:
+            ASSERT_UNREACHABLE();
+            break;
+        }
 
     return 0;
 
@@ -312,7 +329,7 @@  int pv_domain_initialise(struct domain *
 
     d->arch.pv.xpti = is_hardware_domain(d) ? opt_xpti_hwdom : opt_xpti_domu;
 
-    if ( !is_pv_32bit_domain(d) && use_invpcid && cpu_has_pcid )
+    if ( use_invpcid && cpu_has_pcid )
         switch ( ACCESS_ONCE(opt_pcid) )
         {
         case PCID_OFF: