x86/spec_ctrl: Fix determination of when to use IBRS
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 6 Feb 2018 13:45:17 +0000 (13:45 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 6 Feb 2018 18:32:58 +0000 (18:32 +0000)
commit30cbd0c83ef3d0edac2d5bcc41a9a2b7a843ae58
tree5443f5569ade6af9639b070750c8ebb078e3ff4a
parentbb3b88f894e7e1b3a8be3a2b7ea514a8046b4e67
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.

Reported-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/spec_ctrl.c