| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/06/23 17:53 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": [
"MITIGATION_VMSCAPE",
"BPF_JIT"
],
"FocusSymbols": [
"emit_spectre_bhb_barrier",
"cpu_bugs_smt_update"
],
"Reasoning": "The patch introduces a new BHB clearing mitigation for the VMSCAPE vulnerability. It modifies BPF JIT code generation to use a refactored BHB clearing loop and updates KVM VM-exit paths to use a static call for predictor flushing. These are functional changes to core kernel logic that are reachable in virtualized environments.",
"WorthFuzzing": true
} |
| 1/1 | 2026/06/23 17:53 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit a913f6a685ca9b2aa9551253c7868925983b9ddb\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Tue Jun 23 17:53:05 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/admin-guide/hw-vuln/vmscape.rst b/Documentation/admin-guide/hw-vuln/vmscape.rst\nindex d9b9a2b6c114c0..2558a5c3d956c3 100644\n--- a/Documentation/admin-guide/hw-vuln/vmscape.rst\n+++ b/Documentation/admin-guide/hw-vuln/vmscape.rst\n@@ -86,6 +86,10 @@ The possible values in this file are:\n run a potentially malicious guest and issues an IBPB before the first\n exit to userspace after VM-exit.\n \n+ * 'Mitigation: Clear BHB before exit to userspace':\n+\n+ As above, conditional BHB clearing mitigation is enabled.\n+\n * 'Mitigation: IBPB on VMEXIT':\n \n IBPB is issued on every VM-exit. This occurs when other mitigations like\n@@ -102,9 +106,18 @@ The mitigation can be controlled via the ``vmscape=`` command line parameter:\n \n * ``vmscape=ibpb``:\n \n- Enable conditional IBPB mitigation (default when CONFIG_MITIGATION_VMSCAPE=y).\n+ Enable conditional IBPB mitigation.\n \n * ``vmscape=force``:\n \n Force vulnerability detection and mitigation even on processors that are\n not known to be affected.\n+\n+ * ``vmscape=auto``:\n+\n+ Choose the mitigation based on the VMSCAPE variant the CPU is affected by.\n+ (default when CONFIG_MITIGATION_VMSCAPE=y)\n+\n+ * ``vmscape=on``:\n+\n+ Same as ``auto``, except that it overrides attack vector controls.\ndiff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt\nindex 97007f4f69d4e8..1320baf9264c05 100644\n--- a/Documentation/admin-guide/kernel-parameters.txt\n+++ b/Documentation/admin-guide/kernel-parameters.txt\n@@ -8337,9 +8337,13 @@ Kernel parameters\n \n \t\t\toff\t\t- disable the mitigation\n \t\t\tibpb\t\t- use Indirect Branch Prediction Barrier\n-\t\t\t\t\t (IBPB) mitigation (default)\n+\t\t\t\t\t (IBPB) mitigation\n \t\t\tforce\t\t- force vulnerability detection even on\n \t\t\t\t\t unaffected processors\n+\t\t\tauto\t\t- (default) use IBPB or BHB clear\n+\t\t\t\t\t mitigation based on CPU\n+\t\t\ton\t\t- same as \"auto\", but override attack\n+\t\t\t\t\t vector control\n \n \tvsyscall=\t[X86-64,EARLY]\n \t\t\tControls the behavior of vsyscalls (i.e. calls to\ndiff --git a/arch/x86/Kconfig b/arch/x86/Kconfig\nindex f3f7cb01d69d02..c5965bcf14c1f7 100644\n--- a/arch/x86/Kconfig\n+++ b/arch/x86/Kconfig\n@@ -2717,6 +2717,7 @@ config MITIGATION_TSA\n config MITIGATION_VMSCAPE\n \tbool \"Mitigate VMSCAPE\"\n \tdepends on KVM\n+\tdepends on HAVE_STATIC_CALL\n \tdefault y\n \thelp\n \t Enable mitigation for VMSCAPE attacks. VMSCAPE is a hardware security\ndiff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S\nindex 42447b1e1dffa4..1f56d086d312c0 100644\n--- a/arch/x86/entry/entry_64.S\n+++ b/arch/x86/entry/entry_64.S\n@@ -1528,12 +1528,17 @@ SYM_CODE_END(rewind_stack_and_make_dead)\n * refactored in the future if needed. The .skips are for safety, to ensure\n * that all RETs are in the second half of a cacheline to mitigate Indirect\n * Target Selection, rather than taking the slowpath via its_return_thunk.\n+ *\n+ * Note, callers should use a speculation barrier like LFENCE immediately after\n+ * a call to this function to ensure BHB is cleared before indirect branches.\n */\n-SYM_FUNC_START(clear_bhb_loop)\n+SYM_FUNC_START(clear_bhb_loop_nofence)\n \tANNOTATE_NOENDBR\n \tpush\t%rbp\n \tmov\t%rsp, %rbp\n-\tmovl\t$5, %ecx\n+\n+\tmovzbl bhb_seq_outer_loop(%rip), %ecx\n+\n \tANNOTATE_INTRA_FUNCTION_CALL\n \tcall\t1f\n \tjmp\t5f\n@@ -1553,8 +1558,8 @@ SYM_FUNC_START(clear_bhb_loop)\n \t * This should be ideally be: .skip 32 - (.Lret2 - 2f), 0xcc\n \t * but some Clang versions (e.g. 18) don't like this.\n \t */\n-\t.skip 32 - 18, 0xcc\n-2:\tmovl\t$5, %eax\n+\t.skip 32 - 20, 0xcc\n+2:\tmovzbl bhb_seq_inner_loop(%rip), %eax\n 3:\tjmp\t4f\n \tnop\n 4:\tsub\t$1, %eax\n@@ -1562,9 +1567,9 @@ SYM_FUNC_START(clear_bhb_loop)\n \tsub\t$1, %ecx\n \tjnz\t1b\n .Lret2:\tRET\n-5:\tlfence\n+5:\n \tpop\t%rbp\n \tRET\n-SYM_FUNC_END(clear_bhb_loop)\n-EXPORT_SYMBOL_FOR_KVM(clear_bhb_loop)\n-STACK_FRAME_NON_STANDARD(clear_bhb_loop)\n+SYM_FUNC_END(clear_bhb_loop_nofence)\n+EXPORT_SYMBOL_FOR_KVM(clear_bhb_loop_nofence)\n+STACK_FRAME_NON_STANDARD(clear_bhb_loop_nofence)\ndiff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h\nindex 1d506e5d6f46ac..09f956b72637c5 100644\n--- a/arch/x86/include/asm/cpufeatures.h\n+++ b/arch/x86/include/asm/cpufeatures.h\n@@ -504,7 +504,7 @@\n #define X86_FEATURE_TSA_SQ_NO\t\t(21*32+11) /* AMD CPU not vulnerable to TSA-SQ */\n #define X86_FEATURE_TSA_L1_NO\t\t(21*32+12) /* AMD CPU not vulnerable to TSA-L1 */\n #define X86_FEATURE_CLEAR_CPU_BUF_VM\t(21*32+13) /* Clear CPU buffers using VERW before VMRUN */\n-#define X86_FEATURE_IBPB_EXIT_TO_USER\t(21*32+14) /* Use IBPB on exit-to-userspace, see VMSCAPE bug */\n+/* Free */\n #define X86_FEATURE_ABMC\t\t(21*32+15) /* Assignable Bandwidth Monitoring Counters */\n #define X86_FEATURE_MSR_IMM\t\t(21*32+16) /* MSR immediate form instructions */\n #define X86_FEATURE_SGX_EUPDATESVN\t(21*32+17) /* Support for ENCLS[EUPDATESVN] instruction */\ndiff --git a/arch/x86/include/asm/entry-common.h b/arch/x86/include/asm/entry-common.h\nindex eca24b5e07f4c6..befa14a198173e 100644\n--- a/arch/x86/include/asm/entry-common.h\n+++ b/arch/x86/include/asm/entry-common.h\n@@ -4,6 +4,7 @@\n \n #include \u003clinux/randomize_kstack.h\u003e\n #include \u003clinux/user-return-notifier.h\u003e\n+#include \u003clinux/static_call_types.h\u003e\n \n #include \u003casm/nospec-branch.h\u003e\n #include \u003casm/io_bitmap.h\u003e\n@@ -82,11 +83,13 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,\n \tcurrent_thread_info()-\u003estatus \u0026= ~(TS_COMPAT | TS_I386_REGS_POKED);\n #endif\n \n-\t/* Avoid unnecessary reads of 'x86_ibpb_exit_to_user' */\n-\tif (cpu_feature_enabled(X86_FEATURE_IBPB_EXIT_TO_USER) \u0026\u0026\n-\t this_cpu_read(x86_ibpb_exit_to_user)) {\n-\t\tindirect_branch_prediction_barrier();\n-\t\tthis_cpu_write(x86_ibpb_exit_to_user, false);\n+\tif (unlikely(this_cpu_read(x86_predictor_flush_exit_to_user))) {\n+\t\t/*\n+\t\t * Since the mitigation is for userspace, an explicit\n+\t\t * speculation barrier is not required after flush.\n+\t\t */\n+\t\tstatic_call_cond(vmscape_predictor_flush)();\n+\t\tthis_cpu_write(x86_predictor_flush_exit_to_user, false);\n \t}\n }\n #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare\ndiff --git a/arch/x86/include/asm/kvm_types.h b/arch/x86/include/asm/kvm_types.h\nindex d7c704ed1be9a2..bceeaed2940e90 100644\n--- a/arch/x86/include/asm/kvm_types.h\n+++ b/arch/x86/include/asm/kvm_types.h\n@@ -15,6 +15,7 @@\n * at least one vendor module is enabled.\n */\n #define EXPORT_SYMBOL_FOR_KVM(symbol)\n+#define EXPORT_STATIC_CALL_FOR_KVM(symbol)\n #endif\n \n #define KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE 40\ndiff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h\nindex 4f4b5e8a157430..38478383139b65 100644\n--- a/arch/x86/include/asm/nospec-branch.h\n+++ b/arch/x86/include/asm/nospec-branch.h\n@@ -331,11 +331,11 @@\n \n #ifdef CONFIG_X86_64\n .macro CLEAR_BRANCH_HISTORY\n-\tALTERNATIVE \"\", \"call clear_bhb_loop\", X86_FEATURE_CLEAR_BHB_LOOP\n+\tALTERNATIVE \"\", \"call clear_bhb_loop_nofence; lfence\", X86_FEATURE_CLEAR_BHB_LOOP\n .endm\n \n .macro CLEAR_BRANCH_HISTORY_VMEXIT\n-\tALTERNATIVE \"\", \"call clear_bhb_loop\", X86_FEATURE_CLEAR_BHB_VMEXIT\n+\tALTERNATIVE \"\", \"call clear_bhb_loop_nofence; lfence\", X86_FEATURE_CLEAR_BHB_VMEXIT\n .endm\n #else\n #define CLEAR_BRANCH_HISTORY\n@@ -389,7 +389,9 @@ extern void entry_untrain_ret(void);\n extern void write_ibpb(void);\n \n #ifdef CONFIG_X86_64\n-extern void clear_bhb_loop(void);\n+extern void clear_bhb_loop_nofence(void);\n+#else\n+static inline void clear_bhb_loop_nofence(void) {}\n #endif\n \n extern void (*x86_return_thunk)(void);\n@@ -533,7 +535,7 @@ void alternative_msr_write(unsigned int msr, u64 val, unsigned int feature)\n \t\t: \"memory\");\n }\n \n-DECLARE_PER_CPU(bool, x86_ibpb_exit_to_user);\n+DECLARE_PER_CPU(bool, x86_predictor_flush_exit_to_user);\n \n static inline void indirect_branch_prediction_barrier(void)\n {\n@@ -542,12 +544,17 @@ static inline void indirect_branch_prediction_barrier(void)\n \t\t\t :: \"rax\", \"rcx\", \"rdx\", \"memory\");\n }\n \n+#include \u003clinux/static_call_types.h\u003e\n+DECLARE_STATIC_CALL(vmscape_predictor_flush, write_ibpb);\n+\n /* The Intel SPEC CTRL MSR base value cache */\n extern u64 x86_spec_ctrl_base;\n DECLARE_PER_CPU(u64, x86_spec_ctrl_current);\n extern void update_spec_ctrl_cond(u64 val);\n extern u64 spec_ctrl_current(void);\n \n+extern u8 bhb_seq_inner_loop, bhb_seq_outer_loop;\n+\n /*\n * With retpoline, we must use IBRS to restrict branch prediction\n * before calling into firmware.\ndiff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c\nindex 83f51cab0b1e39..4e0b77fb21dd34 100644\n--- a/arch/x86/kernel/cpu/bugs.c\n+++ b/arch/x86/kernel/cpu/bugs.c\n@@ -61,12 +61,11 @@ DEFINE_PER_CPU(u64, x86_spec_ctrl_current);\n EXPORT_PER_CPU_SYMBOL_GPL(x86_spec_ctrl_current);\n \n /*\n- * Set when the CPU has run a potentially malicious guest. An IBPB will\n- * be needed to before running userspace. That IBPB will flush the branch\n- * predictor content.\n+ * Set when the CPU has run a potentially malicious guest. Indicates that a\n+ * branch predictor flush is needed before running userspace.\n */\n-DEFINE_PER_CPU(bool, x86_ibpb_exit_to_user);\n-EXPORT_PER_CPU_SYMBOL_GPL(x86_ibpb_exit_to_user);\n+DEFINE_PER_CPU(bool, x86_predictor_flush_exit_to_user);\n+EXPORT_PER_CPU_SYMBOL_GPL(x86_predictor_flush_exit_to_user);\n \n u64 x86_pred_cmd __ro_after_init = PRED_CMD_IBPB;\n \n@@ -144,6 +143,13 @@ EXPORT_SYMBOL_GPL(cpu_buf_idle_clear);\n */\n DEFINE_STATIC_KEY_FALSE(switch_mm_cond_l1d_flush);\n \n+/*\n+ * Controls how vmscape is mitigated e.g. via IBPB or BHB-clear\n+ * sequence. This defaults to no mitigation.\n+ */\n+DEFINE_STATIC_CALL_NULL(vmscape_predictor_flush, write_ibpb);\n+EXPORT_STATIC_CALL_FOR_KVM(vmscape_predictor_flush);\n+\n #undef pr_fmt\n #define pr_fmt(fmt)\t\"mitigations: \" fmt\n \n@@ -2047,6 +2053,10 @@ enum bhi_mitigations {\n static enum bhi_mitigations bhi_mitigation __ro_after_init =\n \tIS_ENABLED(CONFIG_MITIGATION_SPECTRE_BHI) ? BHI_MITIGATION_AUTO : BHI_MITIGATION_OFF;\n \n+/* Default to short BHB sequence values */\n+u8 bhb_seq_outer_loop __ro_after_init = 5;\n+u8 bhb_seq_inner_loop __ro_after_init = 5;\n+\n static int __init spectre_bhi_parse_cmdline(char *str)\n {\n \tif (!str)\n@@ -3048,15 +3058,19 @@ static void __init srso_apply_mitigation(void)\n enum vmscape_mitigations {\n \tVMSCAPE_MITIGATION_NONE,\n \tVMSCAPE_MITIGATION_AUTO,\n+\tVMSCAPE_MITIGATION_ON,\n \tVMSCAPE_MITIGATION_IBPB_EXIT_TO_USER,\n \tVMSCAPE_MITIGATION_IBPB_ON_VMEXIT,\n+\tVMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER,\n };\n \n static const char * const vmscape_strings[] = {\n-\t[VMSCAPE_MITIGATION_NONE]\t\t= \"Vulnerable\",\n+\t[VMSCAPE_MITIGATION_NONE]\t\t\t= \"Vulnerable\",\n \t/* [VMSCAPE_MITIGATION_AUTO] */\n-\t[VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER]\t= \"Mitigation: IBPB before exit to userspace\",\n-\t[VMSCAPE_MITIGATION_IBPB_ON_VMEXIT]\t= \"Mitigation: IBPB on VMEXIT\",\n+\t/* [VMSCAPE_MITIGATION_ON] */\n+\t[VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER]\t\t= \"Mitigation: IBPB before exit to userspace\",\n+\t[VMSCAPE_MITIGATION_IBPB_ON_VMEXIT]\t\t= \"Mitigation: IBPB on VMEXIT\",\n+\t[VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER]\t= \"Mitigation: Clear BHB before exit to userspace\",\n };\n \n static enum vmscape_mitigations vmscape_mitigation __ro_after_init =\n@@ -3073,6 +3087,10 @@ static int __init vmscape_parse_cmdline(char *str)\n \t\tvmscape_mitigation = VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER;\n \t} else if (!strcmp(str, \"force\")) {\n \t\tsetup_force_cpu_bug(X86_BUG_VMSCAPE);\n+\t\tvmscape_mitigation = VMSCAPE_MITIGATION_ON;\n+\t} else if (!strcmp(str, \"on\")) {\n+\t\tvmscape_mitigation = VMSCAPE_MITIGATION_ON;\n+\t} else if (!strcmp(str, \"auto\")) {\n \t\tvmscape_mitigation = VMSCAPE_MITIGATION_AUTO;\n \t} else {\n \t\tpr_err(\"Ignoring unknown vmscape=%s option.\\n\", str);\n@@ -3084,17 +3102,44 @@ early_param(\"vmscape\", vmscape_parse_cmdline);\n \n static void __init vmscape_select_mitigation(void)\n {\n-\tif (!boot_cpu_has_bug(X86_BUG_VMSCAPE) ||\n-\t !boot_cpu_has(X86_FEATURE_IBPB)) {\n+\tif (!boot_cpu_has_bug(X86_BUG_VMSCAPE)) {\n \t\tvmscape_mitigation = VMSCAPE_MITIGATION_NONE;\n \t\treturn;\n \t}\n \n-\tif (vmscape_mitigation == VMSCAPE_MITIGATION_AUTO) {\n-\t\tif (should_mitigate_vuln(X86_BUG_VMSCAPE))\n+\tif ((vmscape_mitigation == VMSCAPE_MITIGATION_AUTO) \u0026\u0026\n+\t !should_mitigate_vuln(X86_BUG_VMSCAPE))\n+\t\tvmscape_mitigation = VMSCAPE_MITIGATION_NONE;\n+\n+\tswitch (vmscape_mitigation) {\n+\tcase VMSCAPE_MITIGATION_NONE:\n+\t\tbreak;\n+\n+\tcase VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER:\n+\t\tif (!boot_cpu_has(X86_FEATURE_IBPB))\n+\t\t\tvmscape_mitigation = VMSCAPE_MITIGATION_NONE;\n+\t\tbreak;\n+\n+\tcase VMSCAPE_MITIGATION_AUTO:\n+\tcase VMSCAPE_MITIGATION_ON:\n+\t\t/*\n+\t\t * CPUs with BHI_CTRL(ADL and newer) can avoid the IBPB and use\n+\t\t * BHB clear sequence. These CPUs are only vulnerable to the BHI\n+\t\t * variant of the VMSCAPE attack, and thus they do not require a\n+\t\t * full predictor flush.\n+\t\t *\n+\t\t * Note, in 32-bit mode BHB clear sequence is not supported.\n+\t\t */\n+\t\tif (boot_cpu_has(X86_FEATURE_BHI_CTRL) \u0026\u0026 IS_ENABLED(CONFIG_X86_64))\n+\t\t\tvmscape_mitigation = VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER;\n+\t\telse if (boot_cpu_has(X86_FEATURE_IBPB))\n \t\t\tvmscape_mitigation = VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER;\n \t\telse\n \t\t\tvmscape_mitigation = VMSCAPE_MITIGATION_NONE;\n+\t\tbreak;\n+\n+\tdefault:\n+\t\tbreak;\n \t}\n }\n \n@@ -3113,7 +3158,9 @@ static void __init vmscape_update_mitigation(void)\n static void __init vmscape_apply_mitigation(void)\n {\n \tif (vmscape_mitigation == VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER)\n-\t\tsetup_force_cpu_cap(X86_FEATURE_IBPB_EXIT_TO_USER);\n+\t\tstatic_call_update(vmscape_predictor_flush, write_ibpb);\n+\telse if (vmscape_mitigation == VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER)\n+\t\tstatic_call_update(vmscape_predictor_flush, clear_bhb_loop_nofence);\n }\n \n #undef pr_fmt\n@@ -3202,9 +3249,11 @@ void cpu_bugs_smt_update(void)\n \tswitch (vmscape_mitigation) {\n \tcase VMSCAPE_MITIGATION_NONE:\n \tcase VMSCAPE_MITIGATION_AUTO:\n+\tcase VMSCAPE_MITIGATION_ON:\n \t\tbreak;\n \tcase VMSCAPE_MITIGATION_IBPB_ON_VMEXIT:\n \tcase VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER:\n+\tcase VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER:\n \t\t/*\n \t\t * Hypervisors can be attacked across-threads, warn for SMT when\n \t\t * STIBP is not already enabled system-wide.\n@@ -3242,6 +3291,15 @@ void __init cpu_select_mitigations(void)\n \t\tx86_spec_ctrl_base \u0026= ~SPEC_CTRL_MITIGATIONS_MASK;\n \t}\n \n+\t/*\n+\t * Switch to long BHB clear sequence on newer CPUs (with BHI_CTRL\n+\t * support), see Intel's BHI guidance.\n+\t */\n+\tif (cpu_feature_enabled(X86_FEATURE_BHI_CTRL)) {\n+\t\tbhb_seq_outer_loop = 12;\n+\t\tbhb_seq_inner_loop = 7;\n+\t}\n+\n \tx86_arch_cap_msr = x86_read_arch_cap_msr();\n \n \tcpu_print_attack_vectors();\ndiff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c\nindex 0550359ed798fc..fcd61c47653fa3 100644\n--- a/arch/x86/kvm/x86.c\n+++ b/arch/x86/kvm/x86.c\n@@ -11556,8 +11556,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)\n \t * set for the CPU that actually ran the guest, and not the CPU that it\n \t * may migrate to.\n \t */\n-\tif (cpu_feature_enabled(X86_FEATURE_IBPB_EXIT_TO_USER))\n-\t\tthis_cpu_write(x86_ibpb_exit_to_user, true);\n+\tif (static_call_query(vmscape_predictor_flush))\n+\t\tthis_cpu_write(x86_predictor_flush_exit_to_user, true);\n \n \t/*\n \t * Consume any pending interrupts, including the possible source of\ndiff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c\nindex ea9e707e8abffb..e6d17eb4d949f9 100644\n--- a/arch/x86/net/bpf_jit_comp.c\n+++ b/arch/x86/net/bpf_jit_comp.c\n@@ -1619,11 +1619,13 @@ static int emit_spectre_bhb_barrier(u8 **pprog, u8 *ip,\n \t\tEMIT1(0x51); /* push rcx */\n \t\tip += 2;\n \n-\t\tfunc = (u8 *)clear_bhb_loop;\n+\t\tfunc = (u8 *)clear_bhb_loop_nofence;\n \t\tip += x86_call_depth_emit_accounting(\u0026prog, func, ip);\n \n \t\tif (emit_call(\u0026prog, func, ip))\n \t\t\treturn -EINVAL;\n+\t\t/* Don't speculate past this until BHB is cleared */\n+\t\tEMIT_LFENCE();\n \t\tEMIT1(0x59); /* pop rcx */\n \t\tEMIT1(0x58); /* pop rax */\n \t}\ndiff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h\nindex a568d8e6f4e829..be602d3f287e57 100644\n--- a/include/linux/kvm_types.h\n+++ b/include/linux/kvm_types.h\n@@ -13,6 +13,8 @@\n \tEXPORT_SYMBOL_FOR_MODULES(symbol, __stringify(KVM_SUB_MODULES))\n #define EXPORT_SYMBOL_FOR_KVM(symbol) \\\n \tEXPORT_SYMBOL_FOR_MODULES(symbol, \"kvm,\" __stringify(KVM_SUB_MODULES))\n+#define EXPORT_STATIC_CALL_FOR_KVM(symbol) \\\n+\tEXPORT_STATIC_CALL_FOR_MODULES(symbol, \"kvm,\" __stringify(KVM_SUB_MODULES))\n #else\n #define EXPORT_SYMBOL_FOR_KVM_INTERNAL(symbol)\n /*\n@@ -23,11 +25,17 @@\n #ifndef EXPORT_SYMBOL_FOR_KVM\n #if IS_MODULE(CONFIG_KVM)\n #define EXPORT_SYMBOL_FOR_KVM(symbol) EXPORT_SYMBOL_FOR_MODULES(symbol, \"kvm\")\n+#define EXPORT_STATIC_CALL_FOR_KVM(symbol) EXPORT_STATIC_CALL_FOR_MODULES(symbol, \"kvm\")\n #else\n #define EXPORT_SYMBOL_FOR_KVM(symbol)\n+#define EXPORT_STATIC_CALL_FOR_KVM(symbol)\n #endif /* IS_MODULE(CONFIG_KVM) */\n-#endif /* EXPORT_SYMBOL_FOR_KVM */\n+#else\n+#ifndef EXPORT_STATIC_CALL_FOR_KVM\n+#error Must #define EXPORT_STATIC_CALL_FOR_KVM if #defining EXPORT_SYMBOL_FOR_KVM\n #endif\n+#endif /* EXPORT_SYMBOL_FOR_KVM */\n+#endif /* KVM_SUB_MODULES */\n \n #ifndef __ASSEMBLER__\n \ndiff --git a/include/linux/static_call.h b/include/linux/static_call.h\nindex 78a77a4ae0ea87..b610afd1ed5566 100644\n--- a/include/linux/static_call.h\n+++ b/include/linux/static_call.h\n@@ -216,6 +216,9 @@ extern long __static_call_return0(void);\n #define EXPORT_STATIC_CALL_GPL(name)\t\t\t\t\t\\\n \tEXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name));\t\t\t\\\n \tEXPORT_SYMBOL_GPL(STATIC_CALL_TRAMP(name))\n+#define EXPORT_STATIC_CALL_FOR_MODULES(name, mods)\t\t\t\\\n+\tEXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_KEY(name), mods);\t\t\\\n+\tEXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_TRAMP(name), mods)\n \n /* Leave the key unexported, so modules can't change static call targets: */\n #define EXPORT_STATIC_CALL_TRAMP(name)\t\t\t\t\t\\\n@@ -276,6 +279,9 @@ extern long __static_call_return0(void);\n #define EXPORT_STATIC_CALL_GPL(name)\t\t\t\t\t\\\n \tEXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name));\t\t\t\\\n \tEXPORT_SYMBOL_GPL(STATIC_CALL_TRAMP(name))\n+#define EXPORT_STATIC_CALL_FOR_MODULES(name, mods)\t\t\t\\\n+\tEXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_KEY(name), mods);\t\t\\\n+\tEXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_TRAMP(name), mods)\n \n /* Leave the key unexported, so modules can't change static call targets: */\n #define EXPORT_STATIC_CALL_TRAMP(name)\t\t\t\t\t\\\n@@ -346,6 +352,8 @@ static inline int static_call_text_reserved(void *start, void *end)\n \n #define EXPORT_STATIC_CALL(name)\tEXPORT_SYMBOL(STATIC_CALL_KEY(name))\n #define EXPORT_STATIC_CALL_GPL(name)\tEXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name))\n+#define EXPORT_STATIC_CALL_FOR_MODULES(name, mods)\t\t\t\\\n+\tEXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_KEY(name), mods)\n \n #endif /* CONFIG_HAVE_STATIC_CALL */\n \n"
} |
| 2/1 | 2026/06/23 17:53 | agent | patch-evaluator |
1mModel:gemini-3.1-pro-preview Args: null Results: {
"EnableConfigs": [
"MITIGATION_VMSCAPE",
"BPF_JIT"
],
"FocusSymbols": [
"emit_spectre_bhb_barrier",
"cpu_bugs_smt_update"
],
"Reasoning": "The patch introduces a new BHB clearing mitigation for the VMSCAPE vulnerability. It modifies BPF JIT code generation to use a refactored BHB clearing loop and updates KVM VM-exit paths to use a static call for predictor flushing. These are functional changes to core kernel logic that are reachable in virtualized environments.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Do not list too generic configs (we already have them enabled). Only list those that specifically cover the modified code. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit a913f6a685ca9b2aa9551253c7868925983b9ddb
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Jun 23 17:53:05 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/admin-guide/hw-vuln/vmscape.rst b/Documentation/admin-guide/hw-vuln/vmscape.rst
index d9b9a2b6c114c0..2558a5c3d956c3 100644
--- a/Documentation/admin-guide/hw-vuln/vmscape.rst
+++ b/Documentation/admin-guide/hw-vuln/vmscape.rst
@@ -86,6 +86,10 @@ The possible values in this file are:
run a potentially malicious guest and issues an IBPB before the first
exit to userspace after VM-exit.
+ * 'Mitigation: Clear BHB before exit to userspace':
+
+ As above, conditional BHB clearing mitigation is enabled.
+
* 'Mitigation: IBPB on VMEXIT':
IBPB is issued on every VM-exit. This occurs when other mitigations like
@@ -102,9 +106,18 @@ The mitigation can be controlled via the ``vmscape=`` command line parameter:
* ``vmscape=ibpb``:
- Enable conditional IBPB mitigation (default when CONFIG_MITIGATION_VMSCAPE=y).
+ Enable conditional IBPB mitigation.
* ``vmscape=force``:
Force vulnerability detection and mitigation even on processors that are
not known to be affected.
+
+ * ``vmscape=auto``:
+
+ Choose the mitigation based on the VMSCAPE variant the CPU is affected by.
+ (default when CONFIG_MITIGATION_VMSCAPE=y)
+
+ * ``vmscape=on``:
+
+ Same as ``auto``, except that it overrides attack vector controls.
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 97007f4f69d4e8..1320baf9264c05 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -8337,9 +8337,13 @@ Kernel parameters
off - disable the mitigation
ibpb - use Indirect Branch Prediction Barrier
- (IBPB) mitigation (default)
+ (IBPB) mitigation
force - force vulnerability detection even on
unaffected processors
+ auto - (default) use IBPB or BHB clear
+ mitigation based on CPU
+ on - same as "auto", but override attack
+ vector control
vsyscall= [X86-64,EARLY]
Controls the behavior of vsyscalls (i.e. calls to
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f3f7cb01d69d02..c5965bcf14c1f7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2717,6 +2717,7 @@ config MITIGATION_TSA
config MITIGATION_VMSCAPE
bool "Mitigate VMSCAPE"
depends on KVM
+ depends on HAVE_STATIC_CALL
default y
help
Enable mitigation for VMSCAPE attacks. VMSCAPE is a hardware security
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 42447b1e1dffa4..1f56d086d312c0 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1528,12 +1528,17 @@ SYM_CODE_END(rewind_stack_and_make_dead)
* refactored in the future if needed. The .skips are for safety, to ensure
* that all RETs are in the second half of a cacheline to mitigate Indirect
* Target Selection, rather than taking the slowpath via its_return_thunk.
+ *
+ * Note, callers should use a speculation barrier like LFENCE immediately after
+ * a call to this function to ensure BHB is cleared before indirect branches.
*/
-SYM_FUNC_START(clear_bhb_loop)
+SYM_FUNC_START(clear_bhb_loop_nofence)
ANNOTATE_NOENDBR
push %rbp
mov %rsp, %rbp
- movl $5, %ecx
+
+ movzbl bhb_seq_outer_loop(%rip), %ecx
+
ANNOTATE_INTRA_FUNCTION_CALL
call 1f
jmp 5f
@@ -1553,8 +1558,8 @@ SYM_FUNC_START(clear_bhb_loop)
* This should be ideally be: .skip 32 - (.Lret2 - 2f), 0xcc
* but some Clang versions (e.g. 18) don't like this.
*/
- .skip 32 - 18, 0xcc
-2: movl $5, %eax
+ .skip 32 - 20, 0xcc
+2: movzbl bhb_seq_inner_loop(%rip), %eax
3: jmp 4f
nop
4: sub $1, %eax
@@ -1562,9 +1567,9 @@ SYM_FUNC_START(clear_bhb_loop)
sub $1, %ecx
jnz 1b
.Lret2: RET
-5: lfence
+5:
pop %rbp
RET
-SYM_FUNC_END(clear_bhb_loop)
-EXPORT_SYMBOL_FOR_KVM(clear_bhb_loop)
-STACK_FRAME_NON_STANDARD(clear_bhb_loop)
+SYM_FUNC_END(clear_bhb_loop_nofence)
+EXPORT_SYMBOL_FOR_KVM(clear_bhb_loop_nofence)
+STACK_FRAME_NON_STANDARD(clear_bhb_loop_nofence)
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 1d506e5d6f46ac..09f956b72637c5 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -504,7 +504,7 @@
#define X86_FEATURE_TSA_SQ_NO (21*32+11) /* AMD CPU not vulnerable to TSA-SQ */
#define X86_FEATURE_TSA_L1_NO (21*32+12) /* AMD CPU not vulnerable to TSA-L1 */
#define X86_FEATURE_CLEAR_CPU_BUF_VM (21*32+13) /* Clear CPU buffers using VERW before VMRUN */
-#define X86_FEATURE_IBPB_EXIT_TO_USER (21*32+14) /* Use IBPB on exit-to-userspace, see VMSCAPE bug */
+/* Free */
#define X86_FEATURE_ABMC (21*32+15) /* Assignable Bandwidth Monitoring Counters */
#define X86_FEATURE_MSR_IMM (21*32+16) /* MSR immediate form instructions */
#define X86_FEATURE_SGX_EUPDATESVN (21*32+17) /* Support for ENCLS[EUPDATESVN] instruction */
diff --git a/arch/x86/include/asm/entry-common.h b/arch/x86/include/asm/entry-common.h
index eca24b5e07f4c6..befa14a198173e 100644
--- a/arch/x86/include/asm/entry-common.h
+++ b/arch/x86/include/asm/entry-common.h
@@ -4,6 +4,7 @@
#include <linux/randomize_kstack.h>
#include <linux/user-return-notifier.h>
+#include <linux/static_call_types.h>
#include <asm/nospec-branch.h>
#include <asm/io_bitmap.h>
@@ -82,11 +83,13 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
current_thread_info()->status &= ~(TS_COMPAT | TS_I386_REGS_POKED);
#endif
- /* Avoid unnecessary reads of 'x86_ibpb_exit_to_user' */
- if (cpu_feature_enabled(X86_FEATURE_IBPB_EXIT_TO_USER) &&
- this_cpu_read(x86_ibpb_exit_to_user)) {
- indirect_branch_prediction_barrier();
- this_cpu_write(x86_ibpb_exit_to_user, false);
+ if (unlikely(this_cpu_read(x86_predictor_flush_exit_to_user))) {
+ /*
+ * Since the mitigation is for userspace, an explicit
+ * speculation barrier is not required after flush.
+ */
+ static_call_cond(vmscape_predictor_flush)();
+ this_cpu_write(x86_predictor_flush_exit_to_user, false);
}
}
#define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare
diff --git a/arch/x86/include/asm/kvm_types.h b/arch/x86/include/asm/kvm_types.h
index d7c704ed1be9a2..bceeaed2940e90 100644
--- a/arch/x86/include/asm/kvm_types.h
+++ b/arch/x86/include/asm/kvm_types.h
@@ -15,6 +15,7 @@
* at least one vendor module is enabled.
*/
#define EXPORT_SYMBOL_FOR_KVM(symbol)
+#define EXPORT_STATIC_CALL_FOR_KVM(symbol)
#endif
#define KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE 40
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 4f4b5e8a157430..38478383139b65 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -331,11 +331,11 @@
#ifdef CONFIG_X86_64
.macro CLEAR_BRANCH_HISTORY
- ALTERNATIVE "", "call clear_bhb_loop", X86_FEATURE_CLEAR_BHB_LOOP
+ ALTERNATIVE "", "call clear_bhb_loop_nofence; lfence", X86_FEATURE_CLEAR_BHB_LOOP
.endm
.macro CLEAR_BRANCH_HISTORY_VMEXIT
- ALTERNATIVE "", "call clear_bhb_loop", X86_FEATURE_CLEAR_BHB_VMEXIT
+ ALTERNATIVE "", "call clear_bhb_loop_nofence; lfence", X86_FEATURE_CLEAR_BHB_VMEXIT
.endm
#else
#define CLEAR_BRANCH_HISTORY
@@ -389,7 +389,9 @@ extern void entry_untrain_ret(void);
extern void write_ibpb(void);
#ifdef CONFIG_X86_64
-extern void clear_bhb_loop(void);
+extern void clear_bhb_loop_nofence(void);
+#else
+static inline void clear_bhb_loop_nofence(void) {}
#endif
extern void (*x86_return_thunk)(void);
@@ -533,7 +535,7 @@ void alternative_msr_write(unsigned int msr, u64 val, unsigned int feature)
: "memory");
}
-DECLARE_PER_CPU(bool, x86_ibpb_exit_to_user);
+DECLARE_PER_CPU(bool, x86_predictor_flush_exit_to_user);
static inline void indirect_branch_prediction_barrier(void)
{
@@ -542,12 +544,17 @@ static inline void indirect_branch_prediction_barrier(void)
:: "rax", "rcx", "rdx", "memory");
}
+#include <linux/static_call_types.h>
+DECLARE_STATIC_CALL(vmscape_predictor_flush, write_ibpb);
+
/* The Intel SPEC CTRL MSR base value cache */
extern u64 x86_spec_ctrl_base;
DECLARE_PER_CPU(u64, x86_spec_ctrl_current);
extern void update_spec_ctrl_cond(u64 val);
extern u64 spec_ctrl_current(void);
+extern u8 bhb_seq_inner_loop, bhb_seq_outer_loop;
+
/*
* With retpoline, we must use IBRS to restrict branch prediction
* before calling into firmware.
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 83f51cab0b1e39..4e0b77fb21dd34 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -61,12 +61,11 @@ DEFINE_PER_CPU(u64, x86_spec_ctrl_current);
EXPORT_PER_CPU_SYMBOL_GPL(x86_spec_ctrl_current);
/*
- * Set when the CPU has run a potentially malicious guest. An IBPB will
- * be needed to before running userspace. That IBPB will flush the branch
- * predictor content.
+ * Set when the CPU has run a potentially malicious guest. Indicates that a
+ * branch predictor flush is needed before running userspace.
*/
-DEFINE_PER_CPU(bool, x86_ibpb_exit_to_user);
-EXPORT_PER_CPU_SYMBOL_GPL(x86_ibpb_exit_to_user);
+DEFINE_PER_CPU(bool, x86_predictor_flush_exit_to_user);
+EXPORT_PER_CPU_SYMBOL_GPL(x86_predictor_flush_exit_to_user);
u64 x86_pred_cmd __ro_after_init = PRED_CMD_IBPB;
@@ -144,6 +143,13 @@ EXPORT_SYMBOL_GPL(cpu_buf_idle_clear);
*/
DEFINE_STATIC_KEY_FALSE(switch_mm_cond_l1d_flush);
+/*
+ * Controls how vmscape is mitigated e.g. via IBPB or BHB-clear
+ * sequence. This defaults to no mitigation.
+ */
+DEFINE_STATIC_CALL_NULL(vmscape_predictor_flush, write_ibpb);
+EXPORT_STATIC_CALL_FOR_KVM(vmscape_predictor_flush);
+
#undef pr_fmt
#define pr_fmt(fmt) "mitigations: " fmt
@@ -2047,6 +2053,10 @@ enum bhi_mitigations {
static enum bhi_mitigations bhi_mitigation __ro_after_init =
IS_ENABLED(CONFIG_MITIGATION_SPECTRE_BHI) ? BHI_MITIGATION_AUTO : BHI_MITIGATION_OFF;
+/* Default to short BHB sequence values */
+u8 bhb_seq_outer_loop __ro_after_init = 5;
+u8 bhb_seq_inner_loop __ro_after_init = 5;
+
static int __init spectre_bhi_parse_cmdline(char *str)
{
if (!str)
@@ -3048,15 +3058,19 @@ static void __init srso_apply_mitigation(void)
enum vmscape_mitigations {
VMSCAPE_MITIGATION_NONE,
VMSCAPE_MITIGATION_AUTO,
+ VMSCAPE_MITIGATION_ON,
VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER,
VMSCAPE_MITIGATION_IBPB_ON_VMEXIT,
+ VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER,
};
static const char * const vmscape_strings[] = {
- [VMSCAPE_MITIGATION_NONE] = "Vulnerable",
+ [VMSCAPE_MITIGATION_NONE] = "Vulnerable",
/* [VMSCAPE_MITIGATION_AUTO] */
- [VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER] = "Mitigation: IBPB before exit to userspace",
- [VMSCAPE_MITIGATION_IBPB_ON_VMEXIT] = "Mitigation: IBPB on VMEXIT",
+ /* [VMSCAPE_MITIGATION_ON] */
+ [VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER] = "Mitigation: IBPB before exit to userspace",
+ [VMSCAPE_MITIGATION_IBPB_ON_VMEXIT] = "Mitigation: IBPB on VMEXIT",
+ [VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER] = "Mitigation: Clear BHB before exit to userspace",
};
static enum vmscape_mitigations vmscape_mitigation __ro_after_init =
@@ -3073,6 +3087,10 @@ static int __init vmscape_parse_cmdline(char *str)
vmscape_mitigation = VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER;
} else if (!strcmp(str, "force")) {
setup_force_cpu_bug(X86_BUG_VMSCAPE);
+ vmscape_mitigation = VMSCAPE_MITIGATION_ON;
+ } else if (!strcmp(str, "on")) {
+ vmscape_mitigation = VMSCAPE_MITIGATION_ON;
+ } else if (!strcmp(str, "auto")) {
vmscape_mitigation = VMSCAPE_MITIGATION_AUTO;
} else {
pr_err("Ignoring unknown vmscape=%s option.\n", str);
@@ -3084,17 +3102,44 @@ early_param("vmscape", vmscape_parse_cmdline);
static void __init vmscape_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_VMSCAPE) ||
- !boot_cpu_has(X86_FEATURE_IBPB)) {
+ if (!boot_cpu_has_bug(X86_BUG_VMSCAPE)) {
vmscape_mitigation = VMSCAPE_MITIGATION_NONE;
return;
}
- if (vmscape_mitigation == VMSCAPE_MITIGATION_AUTO) {
- if (should_mitigate_vuln(X86_BUG_VMSCAPE))
+ if ((vmscape_mitigation == VMSCAPE_MITIGATION_AUTO) &&
+ !should_mitigate_vuln(X86_BUG_VMSCAPE))
+ vmscape_mitigation = VMSCAPE_MITIGATION_NONE;
+
+ switch (vmscape_mitigation) {
+ case VMSCAPE_MITIGATION_NONE:
+ break;
+
+ case VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER:
+ if (!boot_cpu_has(X86_FEATURE_IBPB))
+ vmscape_mitigation = VMSCAPE_MITIGATION_NONE;
+ break;
+
+ case VMSCAPE_MITIGATION_AUTO:
+ case VMSCAPE_MITIGATION_ON:
+ /*
+ * CPUs with BHI_CTRL(ADL and newer) can avoid the IBPB and use
+ * BHB clear sequence. These CPUs are only vulnerable to the BHI
+ * variant of the VMSCAPE attack, and thus they do not require a
+ * full predictor flush.
+ *
+ * Note, in 32-bit mode BHB clear sequence is not supported.
+ */
+ if (boot_cpu_has(X86_FEATURE_BHI_CTRL) && IS_ENABLED(CONFIG_X86_64))
+ vmscape_mitigation = VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER;
+ else if (boot_cpu_has(X86_FEATURE_IBPB))
vmscape_mitigation = VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER;
else
vmscape_mitigation = VMSCAPE_MITIGATION_NONE;
+ break;
+
+ default:
+ break;
}
}
@@ -3113,7 +3158,9 @@ static void __init vmscape_update_mitigation(void)
static void __init vmscape_apply_mitigation(void)
{
if (vmscape_mitigation == VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER)
- setup_force_cpu_cap(X86_FEATURE_IBPB_EXIT_TO_USER);
+ static_call_update(vmscape_predictor_flush, write_ibpb);
+ else if (vmscape_mitigation == VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER)
+ static_call_update(vmscape_predictor_flush, clear_bhb_loop_nofence);
}
#undef pr_fmt
@@ -3202,9 +3249,11 @@ void cpu_bugs_smt_update(void)
switch (vmscape_mitigation) {
case VMSCAPE_MITIGATION_NONE:
case VMSCAPE_MITIGATION_AUTO:
+ case VMSCAPE_MITIGATION_ON:
break;
case VMSCAPE_MITIGATION_IBPB_ON_VMEXIT:
case VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER:
+ case VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER:
/*
* Hypervisors can be attacked across-threads, warn for SMT when
* STIBP is not already enabled system-wide.
@@ -3242,6 +3291,15 @@ void __init cpu_select_mitigations(void)
x86_spec_ctrl_base &= ~SPEC_CTRL_MITIGATIONS_MASK;
}
+ /*
+ * Switch to long BHB clear sequence on newer CPUs (with BHI_CTRL
+ * support), see Intel's BHI guidance.
+ */
+ if (cpu_feature_enabled(X86_FEATURE_BHI_CTRL)) {
+ bhb_seq_outer_loop = 12;
+ bhb_seq_inner_loop = 7;
+ }
+
x86_arch_cap_msr = x86_read_arch_cap_msr();
cpu_print_attack_vectors();
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0550359ed798fc..fcd61c47653fa3 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -11556,8 +11556,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
* set for the CPU that actually ran the guest, and not the CPU that it
* may migrate to.
*/
- if (cpu_feature_enabled(X86_FEATURE_IBPB_EXIT_TO_USER))
- this_cpu_write(x86_ibpb_exit_to_user, true);
+ if (static_call_query(vmscape_predictor_flush))
+ this_cpu_write(x86_predictor_flush_exit_to_user, true);
/*
* Consume any pending interrupts, including the possible source of
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index ea9e707e8abffb..e6d17eb4d949f9 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1619,11 +1619,13 @@ static int emit_spectre_bhb_barrier(u8 **pprog, u8 *ip,
EMIT1(0x51); /* push rcx */
ip += 2;
- func = (u8 *)clear_bhb_loop;
+ func = (u8 *)clear_bhb_loop_nofence;
ip += x86_call_depth_emit_accounting(&prog, func, ip);
if (emit_call(&prog, func, ip))
return -EINVAL;
+ /* Don't speculate past this until BHB is cleared */
+ EMIT_LFENCE();
EMIT1(0x59); /* pop rcx */
EMIT1(0x58); /* pop rax */
}
diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h
index a568d8e6f4e829..be602d3f287e57 100644
--- a/include/linux/kvm_types.h
+++ b/include/linux/kvm_types.h
@@ -13,6 +13,8 @@
EXPORT_SYMBOL_FOR_MODULES(symbol, __stringify(KVM_SUB_MODULES))
#define EXPORT_SYMBOL_FOR_KVM(symbol) \
EXPORT_SYMBOL_FOR_MODULES(symbol, "kvm," __stringify(KVM_SUB_MODULES))
+#define EXPORT_STATIC_CALL_FOR_KVM(symbol) \
+ EXPORT_STATIC_CALL_FOR_MODULES(symbol, "kvm," __stringify(KVM_SUB_MODULES))
#else
#define EXPORT_SYMBOL_FOR_KVM_INTERNAL(symbol)
/*
@@ -23,11 +25,17 @@
#ifndef EXPORT_SYMBOL_FOR_KVM
#if IS_MODULE(CONFIG_KVM)
#define EXPORT_SYMBOL_FOR_KVM(symbol) EXPORT_SYMBOL_FOR_MODULES(symbol, "kvm")
+#define EXPORT_STATIC_CALL_FOR_KVM(symbol) EXPORT_STATIC_CALL_FOR_MODULES(symbol, "kvm")
#else
#define EXPORT_SYMBOL_FOR_KVM(symbol)
+#define EXPORT_STATIC_CALL_FOR_KVM(symbol)
#endif /* IS_MODULE(CONFIG_KVM) */
-#endif /* EXPORT_SYMBOL_FOR_KVM */
+#else
+#ifndef EXPORT_STATIC_CALL_FOR_KVM
+#error Must #define EXPORT_STATIC_CALL_FOR_KVM if #defining EXPORT_SYMBOL_FOR_KVM
#endif
+#endif /* EXPORT_SYMBOL_FOR_KVM */
+#endif /* KVM_SUB_MODULES */
#ifndef __ASSEMBLER__
diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index 78a77a4ae0ea87..b610afd1ed5566 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -216,6 +216,9 @@ extern long __static_call_return0(void);
#define EXPORT_STATIC_CALL_GPL(name) \
EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name)); \
EXPORT_SYMBOL_GPL(STATIC_CALL_TRAMP(name))
+#define EXPORT_STATIC_CALL_FOR_MODULES(name, mods) \
+ EXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_KEY(name), mods); \
+ EXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_TRAMP(name), mods)
/* Leave the key unexported, so modules can't change static call targets: */
#define EXPORT_STATIC_CALL_TRAMP(name) \
@@ -276,6 +279,9 @@ extern long __static_call_return0(void);
#define EXPORT_STATIC_CALL_GPL(name) \
EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name)); \
EXPORT_SYMBOL_GPL(STATIC_CALL_TRAMP(name))
+#define EXPORT_STATIC_CALL_FOR_MODULES(name, mods) \
+ EXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_KEY(name), mods); \
+ EXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_TRAMP(name), mods)
/* Leave the key unexported, so modules can't change static call targets: */
#define EXPORT_STATIC_CALL_TRAMP(name) \
@@ -346,6 +352,8 @@ static inline int static_call_text_reserved(void *start, void *end)
#define EXPORT_STATIC_CALL(name) EXPORT_SYMBOL(STATIC_CALL_KEY(name))
#define EXPORT_STATIC_CALL_GPL(name) EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name))
+#define EXPORT_STATIC_CALL_FOR_MODULES(name, mods) \
+ EXPORT_SYMBOL_FOR_MODULES(STATIC_CALL_KEY(name), mods)
#endif /* CONFIG_HAVE_STATIC_CALL */
|
| 3/2 | 2026/06/23 17:53 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 9371 output: 20 thoughts: 1471 Thoughts: **Fuzzing Feasibility Assessment** Okay, so this patch series is definitely touching on functional changes within the kernel, specifically targeting the x86 architecture. I need to determine if it introduces any new surface area that's worth fuzzing. My initial read indicates this is about mitigating the VMSCAPE vulnerability. It's introducing a new mitigation strategy involving clearing the BHB before exiting to userspace. They're using static calls for a predictor flush. It looks like the changes span across several crucial areas: documentation updates, Kconfig modifications, and core code in `arch/x86/`, including the entry points, CPU bug handling, KVM code, and BPF JIT compilation. This is a functional modification and not just documentation or logging. The changes are reaching KVM and BPF JIT, and this is happening on exit to user space. It can be controlled by a kernel command line `vmscape=...`. I'm thinking about reachability. KVM is certainly reachable in virtualized environments like QEMU, so that's a yes. BPF JIT is reachable too. The question is whether these changes increase the attack surface. The bulk of the changes appear to be focused on replacing hardcoded IBPB instructions with static calls to either IBPB or BHB clearing and minor adjustments to the BHB clearing loop. The BPF JIT change is a simple emission of an lfence instruction. The KVM code uses `static_call_query` instead of directly checking CPU features. The entry code now uses `static_call_cond` instead of an indirect branch prediction barrier. Given that these are mitigations and the primary changes involve static calls and minor instruction re-arrangement, I'm leaning toward this not adding *significant* new attack surface. I need to look into this more, but it seems that these changes may not introduce *new* vulnerabilities per se but are aimed at improving mitigation for existing ones. I've got to check the configuration requirements. `CONFIG_MITIGATION_VMSCAPE` exists and depends on `HAVE_STATIC_CALL` and `KVM`. `CONFIG_KVM` is definitely required, and so is `CONFIG_BPF_JIT`. Let's use the tools to determine other configs. |
| 4/2 | 2026/06/23 17:53 | tool | grepper |
0mArgs:{
"Expression": "MITIGATION_VMSCAPE"
}Results: {
"Output": "Documentation/admin-guide/hw-vuln/vmscape.rst=101=The mitigation can be controlled via the ``vmscape=`` command line parameter:\n--\nDocumentation/admin-guide/hw-vuln/vmscape.rst-118- Choose the mitigation based on the VMSCAPE variant the CPU is affected by.\nDocumentation/admin-guide/hw-vuln/vmscape.rst:119: (default when CONFIG_MITIGATION_VMSCAPE=y)\nDocumentation/admin-guide/hw-vuln/vmscape.rst-120-\n--\narch/x86/Kconfig=2707=config MITIGATION_TSA\n--\narch/x86/Kconfig-2716-\narch/x86/Kconfig:2717:config MITIGATION_VMSCAPE\narch/x86/Kconfig-2718-\tbool \"Mitigate VMSCAPE\"\n--\narch/x86/kernel/cpu/bugs.c=3076=static enum vmscape_mitigations vmscape_mitigation __ro_after_init =\narch/x86/kernel/cpu/bugs.c:3077:\tIS_ENABLED(CONFIG_MITIGATION_VMSCAPE) ? VMSCAPE_MITIGATION_AUTO : VMSCAPE_MITIGATION_NONE;\narch/x86/kernel/cpu/bugs.c-3078-\n"
} |
| 5/2 | 2026/06/23 17:53 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 11691 output: 23 thoughts: 208 Thoughts: **Fuzzing Focus: Initial Assessment** Okay, so the current configuration is set to `MITIGATION_VMSCAPE`. That's good to know. The question now is, what specific functions offer the best return on investment for fuzzing? Let me see… I have three candidate functions flagged: `emit_spectre_bhb_barrier` from `arch/x86/net/bpf_jit_comp.c`, `vcpu_enter_guest` in `arch/x86/kvm/x86.c`, and `arch_exit_to_user_mode_prepare` in `arch/x86/include/asm/entry-common.h`. Wait a minute, both `vcpu_enter_guest` and `arch_exit_to_user_mode_prepare` are definitely hot-path functions, that makes them a great target. But `emit_spectre_bhb_barrier`... that's used during BPF JIT compilation, which typically happens when a BPF program is loaded, not a particularly hot path. Although, Spectre is interesting. I'm going to set it aside for now. Let's dig deeper into the characteristics of `emit_spectre_bhb_barrier`. |
| 6/2 | 2026/06/23 17:53 | tool | grepper |
0mArgs:{
"Expression": "emit_spectre_bhb_barrier"
}Results: {
"Output": "arch/x86/net/bpf_jit_comp.c=1580=static void emit_priv_frame_ptr(u8 **pprog, void __percpu *priv_frame_ptr)\n--\narch/x86/net/bpf_jit_comp.c-1609-\narch/x86/net/bpf_jit_comp.c:1610:static int emit_spectre_bhb_barrier(u8 **pprog, u8 *ip,\narch/x86/net/bpf_jit_comp.c-1611-\t\t\t\t struct bpf_prog *bpf_prog)\n--\narch/x86/net/bpf_jit_comp.c=2141=st:\t\t\tif (is_imm8(insn-\u003eoff))\n--\narch/x86/net/bpf_jit_comp.c-2737-\t\t\t !ns_capable_noaudit(\u0026init_user_ns, CAP_SYS_ADMIN)) {\narch/x86/net/bpf_jit_comp.c:2738:\t\t\t\tif (emit_spectre_bhb_barrier(\u0026prog, ip, bpf_prog))\narch/x86/net/bpf_jit_comp.c-2739-\t\t\t\t\treturn -EINVAL;\n"
} |
| 7/2 | 2026/06/23 17:53 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 12524 output: 23 thoughts: 430 Thoughts: **Fuzzing Focus for Spectre BHB Mitigation** Okay, so looking at this patch, `emit_spectre_bhb_barrier` seems like the prime candidate for targeted fuzzing, right? But what about the other modifications? Those `__init` functions in `arch/x86/kernel/cpu/bugs.c` – `vmscape_select_mitigation`, `vmscape_apply_mitigation`, and `vmscape_parse_cmdline` – are only executed during boot, so they aren't a priority. The changes in `arch/x86/kvm/x86.c` (specifically `vcpu_enter_guest`) and `arch/x86/include/asm/entry-common.h` (`arch_exit_to_user_mode_prepare`) are in super hot paths, and the guidance is to avoid fuzzing those directly. So, really, it all boils down to `emit_spectre_bhb_barrier`. But is this patch even *worth* fuzzing? It's a hardware vulnerability mitigation, and the core logic seems relatively straightforward: setting up static calls and emitting a few assembly instructions. Fuzzing the BPF JIT might hit `emit_spectre_bhb_barrier`, but it's just emitting a call and an `lfence`. I don't see any obvious sources of complex logic that could hide bugs. Wait, but the patch *does* change `clear_bhb_loop` to `clear_bhb_loop_nofence` and adds an explicit `lfence` in BPF JIT. It also uses a static call for KVM exit mitigation. This is a functional change, so `WorthFuzzing=true` seems appropriate. Let's make sure I'm not missing anything. I need to confirm that `emit_spectre_bhb_barrier` is the only function that needs focused attention. Okay, `bpf_jit_comp.c`, specifically the function `do_jit`, calls `emit_spectre_bhb_barrier`. So I should check `arch/x86/net/bpf_jit_comp.c` as well. |
| 8/2 | 2026/06/23 17:53 | tool | grepper |
0mArgs:{
"Expression": "emit_spectre_bhb_barrier"
}Results: {
"Output": "arch/x86/net/bpf_jit_comp.c=1580=static void emit_priv_frame_ptr(u8 **pprog, void __percpu *priv_frame_ptr)\n--\narch/x86/net/bpf_jit_comp.c-1609-\narch/x86/net/bpf_jit_comp.c:1610:static int emit_spectre_bhb_barrier(u8 **pprog, u8 *ip,\narch/x86/net/bpf_jit_comp.c-1611-\t\t\t\t struct bpf_prog *bpf_prog)\n--\narch/x86/net/bpf_jit_comp.c=2141=st:\t\t\tif (is_imm8(insn-\u003eoff))\n--\narch/x86/net/bpf_jit_comp.c-2737-\t\t\t !ns_capable_noaudit(\u0026init_user_ns, CAP_SYS_ADMIN)) {\narch/x86/net/bpf_jit_comp.c:2738:\t\t\t\tif (emit_spectre_bhb_barrier(\u0026prog, ip, bpf_prog))\narch/x86/net/bpf_jit_comp.c-2739-\t\t\t\t\treturn -EINVAL;\n"
} |
| 9/2 | 2026/06/23 17:53 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 13780 output: 21 thoughts: 104 Thoughts: **Analyzing Potential Attack Surfaces** Okay, let's see what else might be vulnerable. I'm focusing on functions beyond the initial command-line parsing, since `vmscape_parse_cmdline` is handled early and therefore not fuzzed. I'm noting that `vmscape_select_mitigation`, `vmscape_apply_mitigation`, and `vmscape_update_mitigation` are all initialized (`__init`). That's good to keep in mind, but they might not be immediately exploitable. Now, here's an interesting one: `cpu_bugs_smt_update`. The comment indicates it's triggered during CPU hotplug or SMT control changes. Hotplug events and SMT toggling are known potential attack vectors, so I suspect it might be reachable. Time to dig deeper into `cpu_bugs_smt_update`. |
| 10/2 | 2026/06/23 17:54 | tool | grepper |
0mArgs:{
"Expression": "cpu_bugs_smt_update"
}Results: {
"Output": "arch/x86/include/asm/bugs.h=10=static inline int ppro_with_ram_bug(void) { return 0; }\n--\narch/x86/include/asm/bugs.h-12-\narch/x86/include/asm/bugs.h:13:extern void cpu_bugs_smt_update(void);\narch/x86/include/asm/bugs.h-14-\n--\narch/x86/kernel/cpu/bugs.c=3158=static void __init vmscape_apply_mitigation(void)\n--\narch/x86/kernel/cpu/bugs.c-3173-\narch/x86/kernel/cpu/bugs.c:3174:void cpu_bugs_smt_update(void)\narch/x86/kernel/cpu/bugs.c-3175-{\n--\narch/x86/kernel/cpu/common.c=2572=void arch_smt_update(void)\n--\narch/x86/kernel/cpu/common.c-2574-\t/* Handle the speculative execution misfeatures */\narch/x86/kernel/cpu/common.c:2575:\tcpu_bugs_smt_update();\narch/x86/kernel/cpu/common.c-2576-\t/* Check whether IPI broadcasting can be enabled */\n"
} |
| 11/2 | 2026/06/23 17:54 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 14437 output: 21 thoughts: 368 Thoughts: **Analyzing the SMT-Related Code Change** Okay, so I'm looking at this `cpu_bugs_smt_update` function, and it's being called by `arch_smt_update`, which is triggered when SMT (Simultaneous Multi-Threading) is enabled or disabled. It's not in a critical performance path, which is good. But it *is* reachable, so we need to understand what's happening. The code change itself seems incredibly minor. It's just a simple addition of a couple more cases to a `switch` statement within `cpu_bugs_smt_update`. Pretty trivial, actually, just extending the scenarios considered for `vmscape_mitigation`. No significant algorithmic modifications. This isn't where the action is. Therefore, the significant change is really in `emit_spectre_bhb_barrier` which is also a non-hot path function. I should verify this function has the required configurations. Alright, let's look at the config options. The key one is `MITIGATION_VMSCAPE`. That's the primary driver here. Then, to enable VMSCAPE, `KVM` is necessary. And, based on the non-hot-path function, `emit_spectre_bhb_barrier`, we need `BPF_JIT`. It looks like `HAVE_STATIC_CALL` is also a dependency for `MITIGATION_VMSCAPE`. These checks are necessary to ensure the code behaves as intended under different configurations. Just to be thorough, I should quickly double-check the definition of `MITIGATION_VMSCAPE` in `arch/x86/Kconfig` to be sure I'm not missing anything in its dependencies or implications. Gotta dot those i's and cross those t's, especially with security-related changes. |
| 12/2 | 2026/06/23 17:54 | tool | grepper |
0mArgs:{
"Expression": "config MITIGATION_VMSCAPE"
}Results: {
"Output": "arch/x86/Kconfig=2707=config MITIGATION_TSA\n--\narch/x86/Kconfig-2716-\narch/x86/Kconfig:2717:config MITIGATION_VMSCAPE\narch/x86/Kconfig-2718-\tbool \"Mitigate VMSCAPE\"\n"
} |
| 13/2 | 2026/06/23 17:54 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 15313 output: 37 thoughts: 22 Thoughts: Here's my summary, as though I'm thinking through this process: **Diving into the x86 Architecture Configuration** Okay, time to get my hands dirty. I'm going to take a look at the `arch/x86/Kconfig` file. Specifically, I'm aiming for around line 2717. I know that's where I need to focus to get the specific piece of information that I'm looking for. Let's see what gems we can find in this section of the config. |
| 14/2 | 2026/06/23 17:54 | tool | read-file |
0mArgs:{
"File": "arch/x86/Kconfig",
"FirstLine": 2710,
"LineCount": 20
}Results: {
"Contents": "2710:\t\tdefault y\n2711:\t\thelp\n2712:\t\t Enable mitigation for Transient Scheduler Attacks. TSA is a hardware\n2713:\t\t security vulnerability on AMD CPUs which can lead to forwarding of\n2714:\t\t invalid info to subsequent instructions and thus can affect their\n2715:\t\t timing and thereby cause a leakage.\n2716:\t\n2717:\tconfig MITIGATION_VMSCAPE\n2718:\t\tbool \"Mitigate VMSCAPE\"\n2719:\t\tdepends on KVM\n2720:\t\tdepends on HAVE_STATIC_CALL\n2721:\t\tdefault y\n2722:\t\thelp\n2723:\t\t Enable mitigation for VMSCAPE attacks. VMSCAPE is a hardware security\n2724:\t\t vulnerability on Intel and AMD CPUs that may allow a guest to do\n2725:\t\t Spectre v2 style attacks on userspace hypervisor.\n2726:\tendif\n2727:\t\n2728:\tconfig ARCH_HAS_ADD_PAGES\n2729:\t\tdef_bool y\n"
} |
| 15/2 | 2026/06/23 17:54 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 15774 output: 20 thoughts: 663 Thoughts: **My Analysis of this Patch** Okay, so I'm looking at this patch and the first thing that jumps out is `MITIGATION_VMSCAPE`. That's the key, right? And, hold on, it depends on `KVM` and `HAVE_STATIC_CALL`. That confirms that enabling `MITIGATION_VMSCAPE` is essential here, and makes total sense given the vulnerability being addressed. And it seems we need `BPF_JIT` for the BPF part. Now, let me just double-check that `MITIGATION_VMSCAPE` is the *only* significant config change... Nope, that's it. Good. Alright, time to summarize what I've got: * **WorthFuzzing:** True - this is definitely worth our time * **FocusSymbols:** `emit_spectre_bhb_barrier` - this looks like the critical entry point. * **EnableConfigs:** `MITIGATION_VMSCAPE`, `BPF_JIT` - obvious choices based on the description and the dependencies * **Reasoning:** The patch introduces a new BHB clearing mitigation for the VMSCAPE vulnerability, specifically modifying BPF JIT code generation and the KVM VM-exit paths. Now, let me drill down on `emit_spectre_bhb_barrier`. It's a static function in `arch/x86/net/bpf_jit_comp.c`. Is it reachable? Bingo! It's called from `do_jit` when computing `bpf_prog->aux->jited_len` and when emitting instructions, and it looks like a user can trigger it through a BPF program. I need to confirm if it is the only function, which I was able to do! I'm seeing other assembly functions that are related, but likely executed. Also, it looks like `vmscape_predictor_flush` is also reachable by static calls. I also noticed that `cpu_bugs_smt_update` is reachable. Right, back to the instructions... "Return WorthFuzzing=false if..." No, this is *definitely* not documentation, a comment, a constant change, or something impossible in a virtualized environment. This is modifying core kernel logic (BPF JIT, KVM exit handling) and is *absolutely* reachable in virtualized environments like QEMU. Therefore, WorthFuzzing stays `true`. So, final summary: * **WorthFuzzing:** True * **FocusSymbols:** `emit_spectre_bhb_barrier` * **EnableConfigs:** `MITIGATION_VMSCAPE`, `BPF_JIT` * **Reasoning:** The patch modifies BPF JIT compilation and KVM VM-exit handling to implement a new BHB clearing mitigation for the VMSCAPE vulnerability. I think `BPF_JIT` is the right config name. |
| 16/2 | 2026/06/23 17:54 | tool | grepper |
0mArgs:{
"Expression": "config BPF_JIT"
}Results: {
"Output": "kernel/bpf/Kconfig=27=config BPF_SYSCALL\n--\nkernel/bpf/Kconfig-41-\nkernel/bpf/Kconfig:42:config BPF_JIT\nkernel/bpf/Kconfig-43-\tbool \"Enable BPF Just In Time compiler\"\n--\nkernel/bpf/Kconfig-57-\nkernel/bpf/Kconfig:58:config BPF_JIT_ALWAYS_ON\nkernel/bpf/Kconfig-59-\tbool \"Permanently enable BPF JIT and remove BPF interpreter\"\n--\nkernel/bpf/Kconfig-68-\nkernel/bpf/Kconfig:69:config BPF_JIT_DEFAULT_ON\nkernel/bpf/Kconfig-70-\tdef_bool ARCH_WANT_DEFAULT_BPF_JIT || BPF_JIT_ALWAYS_ON\n"
} |
| 17/2 | 2026/06/23 17:54 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 17316 output: 17 thoughts: 29 Thoughts: Here's my thought process, summarized as you requested: **Checking BPF and KVM Configurations** Okay, so I'm pretty sure `BPF_JIT` is the key configuration option we're looking at here. That seems like the right flag for the BPF Just-In-Time compiler. It's the one I remember needing to enable for performance optimizations related to BPF programs. Now, I'm just quickly double-checking my mental map of the kernel configuration space. Just to be absolutely certain, I need to verify that `KVM` is indeed the correct name for the KVM-related configuration. My intuition says it is, but it's always good to be thorough and confirm the exact config name, especially when dealing with such foundational components. I'm recalling the general patterns and naming conventions that are usually used so I can be sure I'm talking about the correct configurations. |
| 18/2 | 2026/06/23 17:54 | tool | grepper |
0mArgs:{
"Expression": "config KVM"
}Results: {
"Output": "arch/arm64/kvm/Kconfig=18=if VIRTUALIZATION\narch/arm64/kvm/Kconfig-19-\narch/arm64/kvm/Kconfig:20:menuconfig KVM\narch/arm64/kvm/Kconfig-21-\tbool \"Kernel-based Virtual Machine (KVM) support\"\n--\narch/loongarch/kvm/Kconfig=18=if VIRTUALIZATION\narch/loongarch/kvm/Kconfig-19-\narch/loongarch/kvm/Kconfig:20:config KVM\narch/loongarch/kvm/Kconfig-21-\ttristate \"Kernel-based Virtual Machine (KVM) support\"\n--\narch/mips/kvm/Kconfig=16=if VIRTUALIZATION\narch/mips/kvm/Kconfig-17-\narch/mips/kvm/Kconfig:18:config KVM\narch/mips/kvm/Kconfig-19-\ttristate \"Kernel-based Virtual Machine (KVM) support\"\n--\narch/mips/kvm/Kconfig-30-\narch/mips/kvm/Kconfig:31:config KVM_MIPS_DEBUG_COP0_COUNTERS\narch/mips/kvm/Kconfig-32-\tbool \"Maintain counters for COP0 accesses\"\n--\narch/powerpc/kvm/Kconfig=18=if VIRTUALIZATION\narch/powerpc/kvm/Kconfig-19-\narch/powerpc/kvm/Kconfig:20:config KVM\narch/powerpc/kvm/Kconfig-21-\tbool\n--\narch/powerpc/kvm/Kconfig-25-\narch/powerpc/kvm/Kconfig:26:config KVM_BOOK3S_HANDLER\narch/powerpc/kvm/Kconfig-27-\tbool\narch/powerpc/kvm/Kconfig-28-\narch/powerpc/kvm/Kconfig:29:config KVM_BOOK3S_32_HANDLER\narch/powerpc/kvm/Kconfig-30-\tbool\n--\narch/powerpc/kvm/Kconfig-33-\narch/powerpc/kvm/Kconfig:34:config KVM_BOOK3S_64_HANDLER\narch/powerpc/kvm/Kconfig-35-\tbool\n--\narch/powerpc/kvm/Kconfig-37-\narch/powerpc/kvm/Kconfig:38:config KVM_BOOK3S_PR_POSSIBLE\narch/powerpc/kvm/Kconfig-39-\tbool\n--\narch/powerpc/kvm/Kconfig-41-\narch/powerpc/kvm/Kconfig:42:config KVM_BOOK3S_HV_POSSIBLE\narch/powerpc/kvm/Kconfig-43-\tbool\narch/powerpc/kvm/Kconfig-44-\narch/powerpc/kvm/Kconfig:45:config KVM_BOOK3S_32\narch/powerpc/kvm/Kconfig-46-\ttristate \"KVM support for PowerPC book3s_32 processors\"\n--\narch/powerpc/kvm/Kconfig-61-\narch/powerpc/kvm/Kconfig:62:config KVM_BOOK3S_64\narch/powerpc/kvm/Kconfig-63-\ttristate \"KVM support for PowerPC book3s_64 processors\"\n--\narch/powerpc/kvm/Kconfig-78-\narch/powerpc/kvm/Kconfig:79:config KVM_BOOK3S_64_HV\narch/powerpc/kvm/Kconfig-80-\ttristate \"KVM for POWER7 and later using hypervisor mode in host\"\n--\narch/powerpc/kvm/Kconfig-99-\narch/powerpc/kvm/Kconfig:100:config KVM_BOOK3S_64_PR\narch/powerpc/kvm/Kconfig-101-\ttristate \"KVM support without using hypervisor mode in host\"\n--\narch/powerpc/kvm/Kconfig-125-\narch/powerpc/kvm/Kconfig:126:config KVM_BOOK3S_HV_EXIT_TIMING\narch/powerpc/kvm/Kconfig-127-\tbool\narch/powerpc/kvm/Kconfig-128-\narch/powerpc/kvm/Kconfig:129:config KVM_BOOK3S_HV_P9_TIMING\narch/powerpc/kvm/Kconfig-130-\tbool \"Detailed timing for the P9 entry point\"\n--\narch/powerpc/kvm/Kconfig-141-\narch/powerpc/kvm/Kconfig:142:config KVM_BOOK3S_HV_P8_TIMING\narch/powerpc/kvm/Kconfig-143-\tbool \"Detailed timing for hypervisor real-mode code (for POWER8)\"\n--\narch/powerpc/kvm/Kconfig-156-\narch/powerpc/kvm/Kconfig:157:config KVM_BOOK3S_HV_NESTED_PMU_WORKAROUND\narch/powerpc/kvm/Kconfig-158-\tbool \"Nested L0 host workaround for L1 KVM host PMU handling bug\" if EXPERT\n--\narch/powerpc/kvm/Kconfig-171-\narch/powerpc/kvm/Kconfig:172:config KVM_BOOK3S_HV_PMU\narch/powerpc/kvm/Kconfig-173-\ttristate \"Hypervisor Perf events for KVM Book3s-HV\"\n--\narch/powerpc/kvm/Kconfig-183-\narch/powerpc/kvm/Kconfig:184:config KVM_BOOKE_HV\narch/powerpc/kvm/Kconfig-185-\tbool\narch/powerpc/kvm/Kconfig-186-\narch/powerpc/kvm/Kconfig:187:config KVM_EXIT_TIMING\narch/powerpc/kvm/Kconfig-188-\tbool \"Detailed exit timing\"\n--\narch/powerpc/kvm/Kconfig-197-\narch/powerpc/kvm/Kconfig:198:config KVM_E500V2\narch/powerpc/kvm/Kconfig-199-\tbool \"KVM support for PowerPC E500v2 processors\"\n--\narch/powerpc/kvm/Kconfig-212-\narch/powerpc/kvm/Kconfig:213:config KVM_E500MC\narch/powerpc/kvm/Kconfig-214-\tbool \"KVM support for PowerPC E500MC/E5500/E6500 processors\"\n--\narch/powerpc/kvm/Kconfig-228-\narch/powerpc/kvm/Kconfig:229:config KVM_MPIC\narch/powerpc/kvm/Kconfig-230-\tbool \"KVM in-kernel MPIC emulation\"\n--\narch/powerpc/kvm/Kconfig-240-\narch/powerpc/kvm/Kconfig:241:config KVM_XICS\narch/powerpc/kvm/Kconfig-242-\tbool \"KVM in-kernel XICS emulation\"\n--\narch/powerpc/kvm/Kconfig-250-\narch/powerpc/kvm/Kconfig:251:config KVM_XIVE\narch/powerpc/kvm/Kconfig-252-\tbool\n--\narch/powerpc/platforms/Kconfig=22=source \"arch/powerpc/platforms/microwatt/Kconfig\"\narch/powerpc/platforms/Kconfig-23-\narch/powerpc/platforms/Kconfig:24:config KVM_GUEST\narch/powerpc/platforms/Kconfig-25-\tbool \"KVM Guest support\"\n--\narch/riscv/kvm/Kconfig=18=if VIRTUALIZATION\narch/riscv/kvm/Kconfig-19-\narch/riscv/kvm/Kconfig:20:config KVM\narch/riscv/kvm/Kconfig-21-\ttristate \"Kernel-based Virtual Machine (KVM) support\"\n--\narch/s390/kvm/Kconfig=17=if VIRTUALIZATION\narch/s390/kvm/Kconfig-18-\narch/s390/kvm/Kconfig:19:config KVM\narch/s390/kvm/Kconfig-20-\tdef_tristate y\n--\narch/s390/kvm/Kconfig-45-\narch/s390/kvm/Kconfig:46:config KVM_S390_UCONTROL\narch/s390/kvm/Kconfig-47-\tbool \"Userspace controlled virtual machines\"\n--\narch/x86/Kconfig=839=source \"arch/x86/xen/Kconfig\"\narch/x86/Kconfig-840-\narch/x86/Kconfig:841:config KVM_GUEST\narch/x86/Kconfig-842-\tbool \"KVM Guest support (including kvmclock)\"\n--\narch/x86/kvm/Kconfig=18=if VIRTUALIZATION\narch/x86/kvm/Kconfig-19-\narch/x86/kvm/Kconfig:20:config KVM_X86\narch/x86/kvm/Kconfig-21-\tdef_tristate KVM if (KVM_INTEL != n || KVM_AMD != n)\n--\narch/x86/kvm/Kconfig-51-\narch/x86/kvm/Kconfig:52:config KVM\narch/x86/kvm/Kconfig-53-\ttristate \"Kernel-based Virtual Machine (KVM) support\"\n--\narch/x86/kvm/Kconfig-68-\narch/x86/kvm/Kconfig:69:config KVM_WERROR\narch/x86/kvm/Kconfig-70-\tbool \"Compile KVM with -Werror\"\n--\narch/x86/kvm/Kconfig-82-\narch/x86/kvm/Kconfig:83:config KVM_SW_PROTECTED_VM\narch/x86/kvm/Kconfig-84-\tbool \"Enable support for KVM software-protected VMs\"\n--\narch/x86/kvm/Kconfig-95-\narch/x86/kvm/Kconfig:96:config KVM_INTEL\narch/x86/kvm/Kconfig-97-\ttristate \"KVM for Intel (and compatible) processors support\"\n--\narch/x86/kvm/Kconfig-106-\narch/x86/kvm/Kconfig:107:config KVM_INTEL_PROVE_VE\narch/x86/kvm/Kconfig-108- bool \"Check that guests do not receive #VE exceptions\"\n--\narch/x86/kvm/Kconfig=122=config X86_SGX_KVM\n--\narch/x86/kvm/Kconfig-133-\narch/x86/kvm/Kconfig:134:config KVM_INTEL_TDX\narch/x86/kvm/Kconfig-135-\tbool \"Intel Trust Domain Extensions (TDX) support\"\n--\narch/x86/kvm/Kconfig-145-\narch/x86/kvm/Kconfig:146:config KVM_AMD\narch/x86/kvm/Kconfig-147-\ttristate \"KVM for AMD processors support\"\n--\narch/x86/kvm/Kconfig-155-\narch/x86/kvm/Kconfig:156:config KVM_AMD_SEV\narch/x86/kvm/Kconfig-157-\tbool \"AMD Secure Encrypted Virtualization (SEV) support\"\n--\narch/x86/kvm/Kconfig-171-\narch/x86/kvm/Kconfig:172:config KVM_IOAPIC\narch/x86/kvm/Kconfig-173-\tbool \"I/O APIC, PIC, and PIT emulation\"\n--\narch/x86/kvm/Kconfig-181-\narch/x86/kvm/Kconfig:182:config KVM_SMM\narch/x86/kvm/Kconfig-183-\tbool \"System Management Mode emulation\"\n--\narch/x86/kvm/Kconfig-192-\narch/x86/kvm/Kconfig:193:config KVM_HYPERV\narch/x86/kvm/Kconfig-194-\tbool \"Support for Microsoft Hyper-V emulation\"\n--\narch/x86/kvm/Kconfig-206-\narch/x86/kvm/Kconfig:207:config KVM_XEN\narch/x86/kvm/Kconfig-208-\tbool \"Support for Xen hypercall interface\"\n--\narch/x86/kvm/Kconfig-215-\narch/x86/kvm/Kconfig:216:config KVM_PROVE_MMU\narch/x86/kvm/Kconfig-217-\tbool \"Prove KVM MMU correctness\"\n--\narch/x86/kvm/Kconfig-228-\narch/x86/kvm/Kconfig:229:config KVM_EXTERNAL_WRITE_TRACKING\narch/x86/kvm/Kconfig-230-\tbool\narch/x86/kvm/Kconfig-231-\narch/x86/kvm/Kconfig:232:config KVM_MAX_NR_VCPUS\narch/x86/kvm/Kconfig-233-\tint \"Maximum number of vCPUs per KVM guest\"\n--\nvirt/kvm/Kconfig-3-\nvirt/kvm/Kconfig:4:config KVM_COMMON\nvirt/kvm/Kconfig-5- bool\n--\nvirt/kvm/Kconfig=39=config NEED_KVM_DIRTY_RING_WITH_BITMAP\n--\nvirt/kvm/Kconfig-42-\nvirt/kvm/Kconfig:43:config KVM_MMIO\nvirt/kvm/Kconfig-44- bool\nvirt/kvm/Kconfig-45-\nvirt/kvm/Kconfig:46:config KVM_ASYNC_PF\nvirt/kvm/Kconfig-47- bool\n--\nvirt/kvm/Kconfig-49-# Toggle to switch between direct notification and batch job\nvirt/kvm/Kconfig:50:config KVM_ASYNC_PF_SYNC\nvirt/kvm/Kconfig-51- bool\n--\nvirt/kvm/Kconfig=59=config HAVE_KVM_CPU_RELAX_INTERCEPT\n--\nvirt/kvm/Kconfig-61-\nvirt/kvm/Kconfig:62:config KVM_VFIO\nvirt/kvm/Kconfig-63- bool\n--\nvirt/kvm/Kconfig=65=config HAVE_KVM_INVALID_WAKEUPS\n--\nvirt/kvm/Kconfig-67-\nvirt/kvm/Kconfig:68:config KVM_GENERIC_DIRTYLOG_READ_PROTECT\nvirt/kvm/Kconfig-69- bool\nvirt/kvm/Kconfig-70-\nvirt/kvm/Kconfig:71:config KVM_GENERIC_PRE_FAULT_MEMORY\nvirt/kvm/Kconfig-72- bool\nvirt/kvm/Kconfig-73-\nvirt/kvm/Kconfig:74:config KVM_COMPAT\nvirt/kvm/Kconfig-75- def_bool y\n--\nvirt/kvm/Kconfig=91=config HAVE_KVM_PM_NOTIFIER\n--\nvirt/kvm/Kconfig-93-\nvirt/kvm/Kconfig:94:config KVM_GENERIC_HARDWARE_ENABLING\nvirt/kvm/Kconfig-95- bool\nvirt/kvm/Kconfig-96-\nvirt/kvm/Kconfig:97:config KVM_ELIDE_TLB_FLUSH_IF_YOUNG\nvirt/kvm/Kconfig-98- bool\nvirt/kvm/Kconfig-99-\nvirt/kvm/Kconfig:100:config KVM_MMU_LOCKLESS_AGING\nvirt/kvm/Kconfig-101- bool\nvirt/kvm/Kconfig-102-\nvirt/kvm/Kconfig:103:config KVM_GENERIC_MEMORY_ATTRIBUTES\nvirt/kvm/Kconfig-104- bool\nvirt/kvm/Kconfig-105-\nvirt/kvm/Kconfig:106:config KVM_GUEST_MEMFD\nvirt/kvm/Kconfig-107- select XARRAY_MULTI\n"
} |
| 19/2 | 2026/06/23 17:54 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21843 output: 45 thoughts: 248 Thoughts: **My Configuration Check** Okay, so I'm finalizing this config. I know that `KVM` is the base, but `MITIGATION_VMSCAPE` builds on that dependency. So, really, specifying `MITIGATION_VMSCAPE` and `BPF_JIT` should cover everything we need. Let me do a final sweep through the FocusSymbols. I'm noting that `emit_spectre_bhb_barrier` is static, which is fine, we can still list it. Any other functions I need to address? Let's see... I have `vmscape_select_mitigation`, `vmscape_apply_mitigation`, `vmscape_update_mitigation`, `vmscape_parse_cmdline`, and `cpu_bugs_smt_update`. Alright, I'll include `emit_spectre_bhb_barrier` and `cpu_bugs_smt_update`. Wait a second… wasn't `emit_spectre_bhb_barrier` dependent on `CONFIG_BPF_JIT`? Does `CONFIG_MITIGATION_VMSCAPE` also influence its availability? I should check `arch/x86/net/bpf_jit_comp.c` to confirm that dependency. |
| 20/2 | 2026/06/23 17:54 | tool | read-file |
0mArgs:{
"File": "arch/x86/net/bpf_jit_comp.c",
"FirstLine": 1600,
"LineCount": 30
}Results: {
"Contents": "1600:\t#define __LOAD_TCC_PTR(off)\t\t\t\\\n1601:\t\tEMIT3_off32(0x48, 0x8B, 0x85, off)\n1602:\t/* mov rax, qword ptr [rbp - rounded_stack_depth - 16] */\n1603:\t#define LOAD_TAIL_CALL_CNT_PTR(stack)\t\t\t\t\\\n1604:\t\t__LOAD_TCC_PTR(BPF_TAIL_CALL_CNT_PTR_STACK_OFF(stack))\n1605:\t\n1606:\t/* Memory size/value to protect private stack overflow/underflow */\n1607:\t#define PRIV_STACK_GUARD_SZ 8\n1608:\t#define PRIV_STACK_GUARD_VAL 0xEB9F12345678eb9fULL\n1609:\t\n1610:\tstatic int emit_spectre_bhb_barrier(u8 **pprog, u8 *ip,\n1611:\t\t\t\t\t struct bpf_prog *bpf_prog)\n1612:\t{\n1613:\t\tu8 *prog = *pprog;\n1614:\t\tu8 *func;\n1615:\t\n1616:\t\tif (cpu_feature_enabled(X86_FEATURE_CLEAR_BHB_LOOP)) {\n1617:\t\t\t/* The clearing sequence clobbers eax and ecx. */\n1618:\t\t\tEMIT1(0x50); /* push rax */\n1619:\t\t\tEMIT1(0x51); /* push rcx */\n1620:\t\t\tip += 2;\n1621:\t\n1622:\t\t\tfunc = (u8 *)clear_bhb_loop_nofence;\n1623:\t\t\tip += x86_call_depth_emit_accounting(\u0026prog, func, ip);\n1624:\t\n1625:\t\t\tif (emit_call(\u0026prog, func, ip))\n1626:\t\t\t\treturn -EINVAL;\n1627:\t\t\t/* Don't speculate past this until BHB is cleared */\n1628:\t\t\tEMIT_LFENCE();\n1629:\t\t\tEMIT1(0x59); /* pop rcx */\n"
} |
| 21/2 | 2026/06/23 17:54 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22994 output: 135 thoughts: 353 Thoughts: **Analyzing this Patch: BHI, VMSCAPE, and the BPF JIT** Okay, let's break this down. My initial scan sees a check for `cpu_feature_enabled(X86_FEATURE_CLEAR_BHB_LOOP)`. That rings a bell – `clear_bhb_loop` sounds like it belongs to Branch History Injection (BHI), as set by `bhi_select_mitigation`. But this patch is tagged as VMSCAPE, so something's amiss. Ah, I see it now. The patch isn't directly *about* VMSCAPE, but rather, it alters how the `emit_spectre_bhb_barrier` function handles the BHB clearing for *both* BHI and VMSCAPE. Specifically, it renames `clear_bhb_loop` to `clear_bhb_loop_nofence` and then injects an explicit `lfence` instruction within `emit_spectre_bhb_barrier`. The original `lfence` was removed from `clear_bhb_loop`. So, the underlying `clear_bhb_loop` function is shared by both BHI and VMSCAPE mitigations, meaning this patch has an interesting side effect. The core VMSCAPE mitigation logic itself is in `vmscape_select_mitigation` and `vmscape_apply_mitigation`, which are untouched. This patch is definitely worth fuzzing. It's effectively introducing a *new* BHB clearing strategy that impacts how VMSCAPE is handled. Furthermore, the modifications to `emit_spectre_bhb_barrier` are relevant to the BPF JIT BHB barrier. The key configurations here are `MITIGATION_VMSCAPE` and `BPF_JIT`. The symbols to focus on are `emit_spectre_bhb_barrier` (obviously) and perhaps `cpu_bugs_smt_update` as it could be affected by changes to BHB related mitigations. Let's get these results and get back to this. |
| 22/2 | 2026/06/23 17:54 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"MITIGATION_VMSCAPE",
"BPF_JIT"
],
"FocusSymbols": [
"emit_spectre_bhb_barrier",
"cpu_bugs_smt_update"
],
"Reasoning": "The patch introduces a new BHB clearing mitigation for the VMSCAPE vulnerability. It modifies BPF JIT code generation to use a refactored BHB clearing loop and updates KVM VM-exit paths to use a static call for predictor flushing. These are functional changes to core kernel logic that are reachable in virtualized environments.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"MITIGATION_VMSCAPE",
"BPF_JIT"
],
"FocusSymbols": [
"emit_spectre_bhb_barrier",
"cpu_bugs_smt_update"
],
"Reasoning": "The patch introduces a new BHB clearing mitigation for the VMSCAPE vulnerability. It modifies BPF JIT code generation to use a refactored BHB clearing loop and updates KVM VM-exit paths to use a static call for predictor flushing. These are functional changes to core kernel logic that are reachable in virtualized environments.",
"WorthFuzzing": true
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|