arm64: proton-pack: Expose whether the branchy loop k value
authorJames Morse <james.morse@arm.com>
Tue, 29 Apr 2025 12:55:17 +0000 (13:55 +0100)
committerJames Morse <james.morse@arm.com>
Thu, 8 May 2025 14:28:35 +0000 (15:28 +0100)
Add a helper to expose the k value of the branchy loop. This is needed
by the BPF JIT to generate the mitigation sequence in BPF programs.

Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/spectre.h
arch/arm64/kernel/proton-pack.c

index 78fb720987fb4508cce62327443bb915f3989e1c..bca12134245c6a46e96ab5833f3ed159735f4fd2 100644 (file)
@@ -97,6 +97,7 @@ enum mitigation_state arm64_get_meltdown_state(void);
 
 enum mitigation_state arm64_get_spectre_bhb_state(void);
 bool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry, int scope);
+u8 get_spectre_bhb_loop_value(void);
 bool is_spectre_bhb_fw_mitigated(void);
 void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *__unused);
 bool try_emulate_el1_ssbs(struct pt_regs *regs, u32 instr);
index 355f1f3098a24d5e75f35269c13c9298839cbc43..3154094a9e33d447a6461198c595afa6e15e5f9a 100644 (file)
@@ -999,6 +999,11 @@ bool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry,
        return true;
 }
 
+u8 get_spectre_bhb_loop_value(void)
+{
+       return max_bhb_k;
+}
+
 static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot)
 {
        const char *v = arm64_get_bp_hardening_vector(slot);