Commit 318e8c3
x86/cpu/kvm: SRSO: Fix possible missing IBPB on VM-Exit
In [1] the meaning of the synthetic IBPB flags has been redefined for a
better separation of concerns:
- ENTRY_IBPB -- issue IBPB on entry only
- IBPB_ON_VMEXIT -- issue IBPB on VM-Exit only
and the Retbleed mitigations have been updated to match this new
semantics.
Commit [2] was merged shortly before [1], and their interaction was not
handled properly. This resulted in IBPB not being triggered on VM-Exit
in all SRSO mitigation configs requesting an IBPB there.
Specifically, an IBPB on VM-Exit is triggered only when
X86_FEATURE_IBPB_ON_VMEXIT is set. However:
- X86_FEATURE_IBPB_ON_VMEXIT is not set for "spec_rstack_overflow=ibpb",
because before [1] having X86_FEATURE_ENTRY_IBPB was enough. Hence,
an IBPB is triggered on entry but the expected IBPB on VM-exit is
not.
- X86_FEATURE_IBPB_ON_VMEXIT is not set also when
"spec_rstack_overflow=ibpb-vmexit" if X86_FEATURE_ENTRY_IBPB is
already set.
That's because before [1] this was effectively redundant. Hence, e.g.
a "retbleed=ibpb spec_rstack_overflow=bpb-vmexit" config mistakenly
reports the machine still vulnerable to SRSO, despite an IBPB being
triggered both on entry and VM-Exit, because of the Retbleed selected
mitigation config.
- UNTRAIN_RET_VM won't still actually do anything unless
CONFIG_MITIGATION_IBPB_ENTRY is set.
For "spec_rstack_overflow=ibpb", enable IBPB on both entry and VM-Exit
and clear X86_FEATURE_RSB_VMEXIT which is made superfluous by
X86_FEATURE_IBPB_ON_VMEXIT. This effectively makes this mitigation
option similar to the one for 'retbleed=ibpb', thus re-order the code
for the RETBLEED_MITIGATION_IBPB option to be less confusing by having
all features enabling before the disabling of the not needed ones.
For "spec_rstack_overflow=ibpb-vmexit", guard this mitigation setting
with CONFIG_MITIGATION_IBPB_ENTRY to ensure UNTRAIN_RET_VM sequence is
effectively compiled in. Drop instead the CONFIG_MITIGATION_SRSO guard,
since none of the SRSO compile cruft is required in this configuration.
Also, check only that the required microcode is present to effectively
enabled the IBPB on VM-Exit.
Finally, update the KConfig description for CONFIG_MITIGATION_IBPB_ENTRY
to list also all SRSO config settings enabled by this guard.
Fixes: 864bcaa ("x86/cpu/kvm: Provide UNTRAIN_RET_VM") [1]
Fixes: d893832 ("x86/srso: Add IBPB on VMEXIT") [2]
Reported-by: Yosry Ahmed <[email protected]>
Signed-off-by: Patrick Bellasi <[email protected]>
Reviewed-by: Borislav Petkov (AMD) <[email protected]>
Cc: [email protected]
Signed-off-by: Linus Torvalds <[email protected]>1 parent febbc55 commit 318e8c3
2 files changed
+16
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2599 | 2599 | | |
2600 | 2600 | | |
2601 | 2601 | | |
2602 | | - | |
| 2602 | + | |
| 2603 | + | |
2603 | 2604 | | |
2604 | 2605 | | |
2605 | 2606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1115 | 1115 | | |
1116 | 1116 | | |
1117 | 1117 | | |
| 1118 | + | |
| 1119 | + | |
1118 | 1120 | | |
1119 | 1121 | | |
1120 | 1122 | | |
| |||
1124 | 1126 | | |
1125 | 1127 | | |
1126 | 1128 | | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | 1129 | | |
1131 | 1130 | | |
1132 | 1131 | | |
| |||
2646 | 2645 | | |
2647 | 2646 | | |
2648 | 2647 | | |
| 2648 | + | |
2649 | 2649 | | |
2650 | 2650 | | |
2651 | 2651 | | |
| |||
2655 | 2655 | | |
2656 | 2656 | | |
2657 | 2657 | | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
2658 | 2665 | | |
2659 | 2666 | | |
2660 | 2667 | | |
| |||
2663 | 2670 | | |
2664 | 2671 | | |
2665 | 2672 | | |
2666 | | - | |
2667 | | - | |
| 2673 | + | |
| 2674 | + | |
2668 | 2675 | | |
2669 | 2676 | | |
2670 | 2677 | | |
| |||
2676 | 2683 | | |
2677 | 2684 | | |
2678 | 2685 | | |
2679 | | - | |
2680 | | - | |
| 2686 | + | |
| 2687 | + | |
2681 | 2688 | | |
2682 | 2689 | | |
2683 | 2690 | | |
| |||
0 commit comments