Skip to contentSkip to conversation

x86/spec_ctrl: Fix determination of when to use IBRS

PATCH In review Andrew Cooper 2 participants 2 messages Feb 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/spec_ctrl: Fix determination of when to use IBRS

The original version of this logic was:

    /*
     * On Intel hardware, we'd like to use retpoline in preference to
     * IBRS, but only if it is safe on this hardware.
     */
    else if ( boot_cpu_has(X86_FEATURE_IBRSB) )
    {
        if ( retpoline_safe() )
            thunk = THUNK_RETPOLINE;
        else
            ibrs = true;
    }

but it was changed by a request during review. Sadly, the result is buggy as it breaks the later fallback logic by allowing IBRS to appear as available when in fact it isn't.

This in practice means that on repoline-unsafe hardware without IBRS, we select THUNK_JUMP despite intending to select THUNK_RETPOLINE.

---
CC: Jan Beulich <[email protected]>
CC: Zhenzhong Duan <[email protected]>

This wants backporting to everywhere the SP2 series has gone

---
 xen/arch/x86/spec_ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/spec_ctrl.c +1 -1
index f10ffbf..725626b 100644
@@ -223,7 +223,7 @@ void __init init_speculation_mitigations(void)
              */
             else if ( retpoline_safe() )
                 thunk = THUNK_RETPOLINE;
-            else
+            else if ( boot_cpu_has(X86_FEATURE_IBRSB) )
                 ibrs = true;
         }
         /* Without compiler thunk support, use IBRS if available. */
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 06.02.18 at 14:48, <[email protected]> wrote:

The original version of this logic was:

    /*
     * On Intel hardware, we'd like to use retpoline in preference to
     * IBRS, but only if it is safe on this hardware.
     */
    else if ( boot_cpu_has(X86_FEATURE_IBRSB) )
    {
        if ( retpoline_safe() )
            thunk = THUNK_RETPOLINE;
        else
            ibrs = true;
    }

but it was changed by a request during review. Sadly, the result is buggy as it breaks the later fallback logic by allowing IBRS to appear as available when in fact it isn't.

Quoted 5 lines

This in practice means that on repoline-unsafe hardware without IBRS, we select THUNK_JUMP despite intending to select THUNK_RETPOLINE.

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