Comment 1 for bug 2051184

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Here is my investigation when discussing this issue with Jesse:

This warning is triggered in spectre_bhb_enable_mitigation() from arch/arm64/kernel/cpu_errata.c, inside this if statement:
    } else if (spectre_bhb_loop_affected(SCOPE_LOCAL_CPU)) {
            switch (spectre_bhb_loop_affected(SCOPE_SYSTEM)) {
            case 8:
                    /*
                     * A57/A72-r0 will already have selected the
                     * spectre-indirect vector, which is sufficient
                     * for BHB too.
                     */
                    if (!__this_cpu_read(bp_hardening_data.fn))
                            kvm_setup_bhb_slot(__spectre_bhb_loop_k8_start);
                    break;
            case 24:
                    kvm_setup_bhb_slot(__spectre_bhb_loop_k24_start);
                    break;
            case 32:
                    kvm_setup_bhb_slot(__spectre_bhb_loop_k32_start);
                    break;
            default:
                    WARN_ON_ONCE(1);
            }
            this_cpu_set_vectors(EL1_VECTOR_BHB_LOOP);

This is because the case value (spectre_bhb_loop_affected(SCOPE_SYSTEM)) does not match, and falls into the "default" case.

This piece of code came from a SAUCE patch 14d45ef5 (UBUNTU: SAUCE: arm64: Mitigate spectre style branch history side channels), in which it moves the code that exist in arch/arm64/kernel/proton-pack.c to cpu_errata.c as mentioned in the commit message:
    [ modified for stable, moved code to cpu_errata.c removed bitmap of
      mitigations, use kvm template infrastructure ]

This issue does not exist in 5.15 kernel, and there is a new commit that added a new "case 11" to the switch-case, 0e5d5ae8 (arm64: Add AMPERE1 to the Spectre-BHB affected list).

According to Google [1]:
> C3A powered by AmpereOne processors
So I think this 0e5d5ae8 is very likely the fix we need for 5.4.

[1] https://cloud.google.com/blog/products/compute/whats-new-in-googles-workload-optimized-computing