Skip to contentSkip to conversation

x86/spec_ctrl: Extend repoline safey calcuations for eIBRS and Atom parts

PATCH In review Andrew Cooper 2 participants 4 messages Mar 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/spec_ctrl: Extend repoline safey calcuations for eIBRS and Atom parts

All currently-released Atom processors are in practice retpoline-safe, because they don't fall back to a BTB prediction on RSB underflow.

However, an additional meaning of Enhanced IRBS is that the processor may not be retpoline-safe. The Gemini Lake platform, based on the Goldmont+ microarchitecture is the first Atom processor to support eIBRS, even though it is in practice safe.

Until Xen gets full eIBRS support, Gemini Lake will still be safe using regular IBRS.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/spec_ctrl.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
xen/arch/x86/spec_ctrl.c +21 -1
index ad72ecd..d981a1c 100644
@@ -316,8 +316,11 @@ static bool __init retpoline_safe(uint64_t caps)
     /*
      * RSBA may be set by a hypervisor to indicate that we may move to a
      * processor which isn't retpoline-safe.
+     *
+     * Processors offering Enhanced IBRS are not guarenteed to be
+     * repoline-safe.
      */
-    if ( caps & ARCH_CAPS_RSBA )
+    if ( caps & (ARCH_CAPABILITIES_IBRS_ALL | ARCH_CAPS_RSBA) )
         return false;
 
     switch ( boot_cpu_data.x86_model )
@@ -377,6 +380,23 @@ static bool __init retpoline_safe(uint64_t caps)
     case 0x9e:
         return false;
 
+        /*
+         * Atom processors before Goldmont+/Gemini Lake are retpoline-safe.
+         */
+    case 0x1c: /* Pineview */
+    case 0x26: /* Lincroft */
+    case 0x27: /* Penwell */
+    case 0x35: /* Cloverview */
+    case 0x36: /* Cedarview */
+    case 0x37: /* Baytrail / Valleyview (Silvermont) */
+    case 0x4d: /* Avaton / Rangely (Silvermont) */
+    case 0x4c: /* Cherrytrail / Brasswell */
+    case 0x4a: /* Merrifield */
+    case 0x5a: /* Moorefield */
+    case 0x5c: /* Goldmont */
+    case 0x5f: /* Denverton */
+        return true;
+
     default:
         printk("Unrecognised CPU model %#x - assuming not reptpoline safe\n",
                boot_cpu_data.x86_model);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 18.03.19 at 12:27, <[email protected]> wrote:

However, an additional meaning of Enhanced IRBS is that the processor may not be retpoline-safe. The Gemini Lake platform, based on the Goldmont+ microarchitecture is the first Atom processor to support eIBRS, even though it is in practice safe.

But afaict you don't mark them as safe. But then again I don't recall:
Performance-wise, is retpoline considered better or worse than IBRS? Depending on that ...

xen/arch/x86/spec_ctrl.c static bool __init retpoline_safe(uint64_t caps) · line 324

Quoted 13 lines
xen/arch/x86/spec_ctrl.c +4 -1
@@ -316,8 +316,11 @@ static bool __init retpoline_safe(uint64_t caps)
     /*
      * RSBA may be set by a hypervisor to indicate that we may move to a
      * processor which isn't retpoline-safe.
+     *
+     * Processors offering Enhanced IBRS are not guarenteed to be
+     * repoline-safe.
      */
-    if ( caps & ARCH_CAPS_RSBA )
+    if ( caps & (ARCH_CAPABILITIES_IBRS_ALL | ARCH_CAPS_RSBA) )
         return false;

... are there plans to retrofit EIBRS onto any of the models explicitly named in the subsequent switch()? If not, wouldn't you better check for it further down, adding Goldmont Plus into ...

Quoted 10 lines
xen/arch/x86/spec_ctrl.c +6 -0
@@ -377,6 +380,23 @@ static bool __init retpoline_safe(uint64_t caps)
     case 0x9e:
         return false;
 
+        /*
+         * Atom processors before Goldmont+/Gemini Lake are retpoline-safe.
+         */
+    case 0x1c: /* Pineview */
+    case 0x26: /* Lincroft */
+    case 0x27: /* Penwell */

xen/arch/x86/spec_ctrl.c static bool __init retpoline_safe(uint64_t caps) · line 398

Quoted 10 lines
xen/arch/x86/spec_ctrl.c +10 -0
+    case 0x35: /* Cloverview */
+    case 0x36: /* Cedarview */
+    case 0x37: /* Baytrail / Valleyview (Silvermont) */
+    case 0x4d: /* Avaton / Rangely (Silvermont) */
+    case 0x4c: /* Cherrytrail / Brasswell */
+    case 0x4a: /* Merrifield */
+    case 0x5a: /* Moorefield */
+    case 0x5c: /* Goldmont */
+    case 0x5f: /* Denverton */
+        return true;

... this set? Or am I simply misreading the patch description?

As an aside - as mentioned on the other (still unfinished) thread regarding one of my patches, there's no mention of Goldmont+ anywhere in the SDM afaics, it's always Goldmont Plus. I still don't understand why you want us to deliberately diverge.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 6 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 18.03.19 at 12:27, <[email protected]> wrote:

However, an additional meaning of Enhanced IRBS is that the processor may not be retpoline-safe. The Gemini Lake platform, based on the Goldmont+ microarchitecture is the first Atom processor to support eIBRS, even though it is in practice safe.

But afaict you don't mark them as safe.

Correct.  That is deliberate.

Quoted 3 lines

But then again I don't recall:
Performance-wise, is retpoline considered better or worse than IBRS? Depending on that ...

Retpoline is more performant than IRBS as implemented in microcode, but that is not what we are comparing to here.

Goldmont+ is the first processor with hardware fixes for Spectre v2 issues.  This means that IBRS isn't implemented behind the scenes with "turn off the BTB" or "flush via convoluted means".  There is a proper O(1) flush of the BTB for IBPB, and the BTB now tracks the privilege at which a prediction was learnt.

Cascade Lake will (AFAIA) be the first Big-Core processor with eIBRS.

I honestly don't know whether retpoline or legacy-IBRS with new hardware will be faster, but it doesn't really matter - using repotline on Goldmont+ is not spec compliant.

Teaching Xen about eIBRS is moderately high on my priority list, after which eIBRS will be the most performant option without a shadow of a doubt.

Quoted 17 lines
Quoted 4 lines

xen/arch/x86/spec_ctrl.c static bool __init retpoline_safe(uint64_t caps) · line 324

Quoted 10 lines
xen/arch/x86/spec_ctrl.c +4 -1
@@ -316,8 +316,11 @@ static bool __init retpoline_safe(uint64_t caps)
     /*
      * RSBA may be set by a hypervisor to indicate that we may move to a
      * processor which isn't retpoline-safe.
+     *
+     * Processors offering Enhanced IBRS are not guarenteed to be
+     * repoline-safe.
      */
-    if ( caps & ARCH_CAPS_RSBA )
+    if ( caps & (ARCH_CAPABILITIES_IBRS_ALL | ARCH_CAPS_RSBA) )
         return false;

... are there plans to retrofit EIBRS onto any of the models explicitly named in the subsequent switch()? If not, wouldn't you better check for it further down, adding Goldmont Plus into ...

EIBRS requires new silicon.  It can't be retrofitted in microcode.

Quoted 14 lines
Quoted 14 lines
xen/arch/x86/spec_ctrl.c +9 -0
@@ -377,6 +380,23 @@ static bool __init retpoline_safe(uint64_t caps)
     case 0x9e:
         return false;
 
+        /*
+         * Atom processors before Goldmont+/Gemini Lake are retpoline-safe.
+         */
+    case 0x1c: /* Pineview */
+    case 0x26: /* Lincroft */
+    case 0x27: /* Penwell */
+    case 0x35: /* Cloverview */
+    case 0x36: /* Cedarview */
+    case 0x37: /* Baytrail / Valleyview (Silvermont) */
Quoted 8 lines

xen/arch/x86/spec_ctrl.c static bool __init retpoline_safe(uint64_t caps) · line 398

Quoted 7 lines
xen/arch/x86/spec_ctrl.c +7 -0
+    case 0x4d: /* Avaton / Rangely (Silvermont) */
+    case 0x4c: /* Cherrytrail / Brasswell */
+    case 0x4a: /* Merrifield */
+    case 0x5a: /* Moorefield */
+    case 0x5c: /* Goldmont */
+    case 0x5f: /* Denverton */
+        return true;

... this set? Or am I simply misreading the patch description?

The switch statement is only intended for "legacy" processors which don't enumerate explicit information, specifically to prevent it needing to grow with future fixed silicon.

Quoted 4 lines

As an aside - as mentioned on the other (still unfinished) thread regarding one of my patches, there's no mention of Goldmont+ anywhere in the SDM afaics, it's always Goldmont Plus. I still don't understand why you want us to deliberately diverge.

Probably a side effect of shorthands.  If Goldmont+ really doesn't exist anywhere, I'll switch.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by
#3 lore raw
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 18.03.19 at 14:04, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 18.03.19 at 12:27, <[email protected]> wrote:

However, an additional meaning of Enhanced IRBS is that the processor may not be retpoline-safe. The Gemini Lake platform, based on the Goldmont+ microarchitecture is the first Atom processor to support eIBRS, even though it is in practice safe.

But afaict you don't mark them as safe.

Correct. That is deliberate.

Quoted 3 lines

But then again I don't recall:
Performance-wise, is retpoline considered better or worse than IBRS? Depending on that ...

Retpoline is more performant than IRBS as implemented in microcode, but that is not what we are comparing to here.

Quoted 7 lines

Goldmont+ is the first processor with hardware fixes for Spectre v2 issues. This means that IBRS isn't implemented behind the scenes with "turn off the BTB" or "flush via convoluted means". There is a proper O(1) flush of the BTB for IBPB, and the BTB now tracks the privilege at which a prediction was learnt.

Cascade Lake will (AFAIA) be the first Big-Core processor with eIBRS.

In which case

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel