Thread (7 messages) 7 messages, 3 authors, 2025-01-06

Re: [PATCH v3 1/3] arm64: errata: Assume that unknown CPUs _are_ vulnerable to Spectre BHB

From: Doug Anderson <dianders@chromium.org>
Date: 2025-01-06 22:33:10
Also in: linux-arm-msm, lkml, stable

Hi,

On Thu, Dec 19, 2024 at 12:54 PM Douglas Anderson [off-list ref] wrote:
quoted hunk ↗ jump to hunk
@@ -916,9 +932,8 @@ static enum mitigation_state spectre_bhb_get_cpu_fw_mitigation_state(void)
        }
 }

-static bool is_spectre_bhb_fw_affected(int scope)
+static bool is_spectre_bhb_fw_affected(void)
 {
-       static bool system_affected;
        enum mitigation_state fw_state;
        bool has_smccc = arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_NONE;
        static const struct midr_range spectre_bhb_firmware_mitigated_list[] = {
@@ -929,16 +944,8 @@ static bool is_spectre_bhb_fw_affected(int scope)
        bool cpu_in_list = is_midr_in_range_list(read_cpuid_id(),
                                         spectre_bhb_firmware_mitigated_list);

-       if (scope != SCOPE_LOCAL_CPU)
-               return system_affected;
-
        fw_state = spectre_bhb_get_cpu_fw_mitigation_state();
-       if (cpu_in_list || (has_smccc && fw_state == SPECTRE_MITIGATED)) {
-               system_affected = true;
-               return true;
-       }
-
-       return false;
+       return cpu_in_list || (has_smccc && fw_state == SPECTRE_MITIGATED);
Upon looking at this again, I realized that I can fully get rid of
`cpu_in_list` here and the whole `spectre_bhb_firmware_mitigated_list`
variable. After my patch there's only one caller to this function and
it only cares whether the firmware call can be used to mitigate, so I
can rename this function to has_spectre_bhb_fw_mitigation() and
simplify it and the caller.

I'll plan to spin this in the next day or two and also include the
proper loop value for Kryo-400 cores, since I've got that now.

I'll plan to keep Julius's review tag unless told not to.

-Doug
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help