lkml.org 
[lkml]   [2019]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 2/2] arm64: Use firmware to detect CPUs that are not affected by Spectre-v2
    Date
    The SMCCC ARCH_WORKAROUND_1 service can indicate that although the
    firmware knows about the Spectre-v2 mitigation, this particular
    CPU is not vulnerable, and it is thus not necessary to call
    the firmware on this CPU.

    Let's use this information to our benefit.

    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    ---
    arch/arm64/kernel/cpu_errata.c | 30 +++++++++++++++++++++---------
    1 file changed, 21 insertions(+), 9 deletions(-)

    diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
    index 145f8b5d093d..b44f87e7360d 100644
    --- a/arch/arm64/kernel/cpu_errata.c
    +++ b/arch/arm64/kernel/cpu_errata.c
    @@ -231,26 +231,38 @@ static int detect_harden_bp_fw(void)
    case PSCI_CONDUIT_HVC:
    arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
    ARM_SMCCC_ARCH_WORKAROUND_1, &res);
    - if ((int)res.a0 < 0) {
    + switch ((int)res.a0) {
    + case 1:
    + /* Firmware says we're just fine */
    + return 0;
    + case 0:
    + cb = call_hvc_arch_workaround_1;
    + /* This is a guest, no need to patch KVM vectors */
    + smccc_start = NULL;
    + smccc_end = NULL;
    + break;
    + default:
    __hardenbp_enab = false;
    return -1;
    }
    - cb = call_hvc_arch_workaround_1;
    - /* This is a guest, no need to patch KVM vectors */
    - smccc_start = NULL;
    - smccc_end = NULL;
    break;

    case PSCI_CONDUIT_SMC:
    arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
    ARM_SMCCC_ARCH_WORKAROUND_1, &res);
    - if ((int)res.a0 < 0) {
    + switch ((int)res.a0) {
    + case 1:
    + /* Firmware says we're just fine */
    + return 0;
    + case 0:
    + cb = call_smc_arch_workaround_1;
    + smccc_start = __smccc_workaround_1_smc_start;
    + smccc_end = __smccc_workaround_1_smc_end;
    + break;
    + default:
    __hardenbp_enab = false;
    return -1;
    }
    - cb = call_smc_arch_workaround_1;
    - smccc_start = __smccc_workaround_1_smc_start;
    - smccc_end = __smccc_workaround_1_smc_end;
    break;

    default:
    --
    2.20.1
    \
     
     \ /
      Last update: 2019-01-14 11:36    [W:3.210 / U:0.436 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site