Skip to content

Commit 2665281

Browse files
pa1guptahansendc
authored andcommitted
x86/its: Add "vmexit" option to skip mitigation on some CPUs
Ice Lake generation CPUs are not affected by guest/host isolation part of ITS. If a user is only concerned about KVM guests, they can now choose a new cmdline option "vmexit" that will not deploy the ITS mitigation when CPU is not affected by guest/host isolation. This saves the performance overhead of ITS mitigation on Ice Lake gen CPUs. When "vmexit" option selected, if the CPU is affected by ITS guest/host isolation, the default ITS mitigation is deployed. Signed-off-by: Pawan Gupta <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Reviewed-by: Josh Poimboeuf <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]>
1 parent f481888 commit 2665281

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,8 @@
22102210
off: Disable mitigation.
22112211
force: Force the ITS bug and deploy default
22122212
mitigation.
2213+
vmexit: Only deploy mitigation if CPU is affected by
2214+
guest/host isolation part of ITS.
22132215

22142216
For details see:
22152217
Documentation/admin-guide/hw-vuln/indirect-target-selection.rst

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,4 +535,5 @@
535535
#define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */
536536
#define X86_BUG_SPECTRE_V2_USER X86_BUG(1*32 + 5) /* "spectre_v2_user" CPU is affected by Spectre variant 2 attack between user processes */
537537
#define X86_BUG_ITS X86_BUG(1*32 + 6) /* "its" CPU is affected by Indirect Target Selection */
538+
#define X86_BUG_ITS_NATIVE_ONLY X86_BUG(1*32 + 7) /* "its_native_only" CPU is affected by ITS, VMX is not affected */
538539
#endif /* _ASM_X86_CPUFEATURES_H */

arch/x86/kernel/cpu/bugs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,16 +1203,19 @@ static void __init retbleed_select_mitigation(void)
12031203
enum its_mitigation_cmd {
12041204
ITS_CMD_OFF,
12051205
ITS_CMD_ON,
1206+
ITS_CMD_VMEXIT,
12061207
};
12071208

12081209
enum its_mitigation {
12091210
ITS_MITIGATION_OFF,
1211+
ITS_MITIGATION_VMEXIT_ONLY,
12101212
ITS_MITIGATION_ALIGNED_THUNKS,
12111213
ITS_MITIGATION_RETPOLINE_STUFF,
12121214
};
12131215

12141216
static const char * const its_strings[] = {
12151217
[ITS_MITIGATION_OFF] = "Vulnerable",
1218+
[ITS_MITIGATION_VMEXIT_ONLY] = "Mitigation: Vulnerable, KVM: Not affected",
12161219
[ITS_MITIGATION_ALIGNED_THUNKS] = "Mitigation: Aligned branch/return thunks",
12171220
[ITS_MITIGATION_RETPOLINE_STUFF] = "Mitigation: Retpolines, Stuffing RSB",
12181221
};
@@ -1239,6 +1242,8 @@ static int __init its_parse_cmdline(char *str)
12391242
} else if (!strcmp(str, "force")) {
12401243
its_cmd = ITS_CMD_ON;
12411244
setup_force_cpu_bug(X86_BUG_ITS);
1245+
} else if (!strcmp(str, "vmexit")) {
1246+
its_cmd = ITS_CMD_VMEXIT;
12421247
} else {
12431248
pr_err("Ignoring unknown indirect_target_selection option (%s).", str);
12441249
}
@@ -1294,6 +1299,12 @@ static void __init its_select_mitigation(void)
12941299
case ITS_CMD_OFF:
12951300
its_mitigation = ITS_MITIGATION_OFF;
12961301
break;
1302+
case ITS_CMD_VMEXIT:
1303+
if (boot_cpu_has_bug(X86_BUG_ITS_NATIVE_ONLY)) {
1304+
its_mitigation = ITS_MITIGATION_VMEXIT_ONLY;
1305+
goto out;
1306+
}
1307+
fallthrough;
12971308
case ITS_CMD_ON:
12981309
its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
12991310
if (!boot_cpu_has(X86_FEATURE_RETPOLINE))

arch/x86/kernel/cpu/common.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,8 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
12291229
#define RFDS BIT(7)
12301230
/* CPU is affected by Indirect Target Selection */
12311231
#define ITS BIT(8)
1232+
/* CPU is affected by Indirect Target Selection, but guest-host isolation is not affected */
1233+
#define ITS_NATIVE_ONLY BIT(9)
12321234

12331235
static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12341236
VULNBL_INTEL_STEPS(INTEL_IVYBRIDGE, X86_STEP_MAX, SRBDS),
@@ -1249,16 +1251,16 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12491251
VULNBL_INTEL_STEPS(INTEL_KABYLAKE, 0xc, MMIO | RETBLEED | GDS | SRBDS),
12501252
VULNBL_INTEL_STEPS(INTEL_KABYLAKE, X86_STEP_MAX, MMIO | RETBLEED | GDS | SRBDS | ITS),
12511253
VULNBL_INTEL_STEPS(INTEL_CANNONLAKE_L, X86_STEP_MAX, RETBLEED),
1252-
VULNBL_INTEL_STEPS(INTEL_ICELAKE_L, X86_STEP_MAX, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
1253-
VULNBL_INTEL_STEPS(INTEL_ICELAKE_D, X86_STEP_MAX, MMIO | GDS | ITS),
1254-
VULNBL_INTEL_STEPS(INTEL_ICELAKE_X, X86_STEP_MAX, MMIO | GDS | ITS),
1254+
VULNBL_INTEL_STEPS(INTEL_ICELAKE_L, X86_STEP_MAX, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS | ITS_NATIVE_ONLY),
1255+
VULNBL_INTEL_STEPS(INTEL_ICELAKE_D, X86_STEP_MAX, MMIO | GDS | ITS | ITS_NATIVE_ONLY),
1256+
VULNBL_INTEL_STEPS(INTEL_ICELAKE_X, X86_STEP_MAX, MMIO | GDS | ITS | ITS_NATIVE_ONLY),
12551257
VULNBL_INTEL_STEPS(INTEL_COMETLAKE, X86_STEP_MAX, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
12561258
VULNBL_INTEL_STEPS(INTEL_COMETLAKE_L, 0x0, MMIO | RETBLEED | ITS),
12571259
VULNBL_INTEL_STEPS(INTEL_COMETLAKE_L, X86_STEP_MAX, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
1258-
VULNBL_INTEL_STEPS(INTEL_TIGERLAKE_L, X86_STEP_MAX, GDS | ITS),
1259-
VULNBL_INTEL_STEPS(INTEL_TIGERLAKE, X86_STEP_MAX, GDS | ITS),
1260+
VULNBL_INTEL_STEPS(INTEL_TIGERLAKE_L, X86_STEP_MAX, GDS | ITS | ITS_NATIVE_ONLY),
1261+
VULNBL_INTEL_STEPS(INTEL_TIGERLAKE, X86_STEP_MAX, GDS | ITS | ITS_NATIVE_ONLY),
12601262
VULNBL_INTEL_STEPS(INTEL_LAKEFIELD, X86_STEP_MAX, MMIO | MMIO_SBDS | RETBLEED),
1261-
VULNBL_INTEL_STEPS(INTEL_ROCKETLAKE, X86_STEP_MAX, MMIO | RETBLEED | GDS | ITS),
1263+
VULNBL_INTEL_STEPS(INTEL_ROCKETLAKE, X86_STEP_MAX, MMIO | RETBLEED | GDS | ITS | ITS_NATIVE_ONLY),
12621264
VULNBL_INTEL_TYPE(INTEL_ALDERLAKE, ATOM, RFDS),
12631265
VULNBL_INTEL_STEPS(INTEL_ALDERLAKE_L, X86_STEP_MAX, RFDS),
12641266
VULNBL_INTEL_TYPE(INTEL_RAPTORLAKE, ATOM, RFDS),
@@ -1480,8 +1482,11 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14801482
if (cpu_has(c, X86_FEATURE_AMD_IBPB) && !cpu_has(c, X86_FEATURE_AMD_IBPB_RET))
14811483
setup_force_cpu_bug(X86_BUG_IBPB_NO_RET);
14821484

1483-
if (vulnerable_to_its(x86_arch_cap_msr))
1485+
if (vulnerable_to_its(x86_arch_cap_msr)) {
14841486
setup_force_cpu_bug(X86_BUG_ITS);
1487+
if (cpu_matches(cpu_vuln_blacklist, ITS_NATIVE_ONLY))
1488+
setup_force_cpu_bug(X86_BUG_ITS_NATIVE_ONLY);
1489+
}
14851490

14861491
if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
14871492
return;

0 commit comments

Comments
 (0)