Skip to content

Commit 4dc1902

Browse files
pa1guptagregkh
authored andcommitted
x86/its: Add "vmexit" option to skip mitigation on some CPUs
commit 2665281 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 68d59e9 commit 4dc1902

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
@@ -2157,6 +2157,8 @@
21572157
off: Disable mitigation.
21582158
force: Force the ITS bug and deploy default
21592159
mitigation.
2160+
vmexit: Only deploy mitigation if CPU is affected by
2161+
guest/host isolation part of ITS.
21602162

21612163
For details see:
21622164
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
@@ -528,4 +528,5 @@
528528
#define X86_BUG_BHI X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch History Injection */
529529
#define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */
530530
#define X86_BUG_ITS X86_BUG(1*32 + 5) /* "its" CPU is affected by Indirect Target Selection */
531+
#define X86_BUG_ITS_NATIVE_ONLY X86_BUG(1*32 + 6) /* "its_native_only" CPU is affected by ITS, VMX is not affected */
531532
#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
@@ -1189,16 +1189,19 @@ static void __init retbleed_select_mitigation(void)
11891189
enum its_mitigation_cmd {
11901190
ITS_CMD_OFF,
11911191
ITS_CMD_ON,
1192+
ITS_CMD_VMEXIT,
11921193
};
11931194

11941195
enum its_mitigation {
11951196
ITS_MITIGATION_OFF,
1197+
ITS_MITIGATION_VMEXIT_ONLY,
11961198
ITS_MITIGATION_ALIGNED_THUNKS,
11971199
ITS_MITIGATION_RETPOLINE_STUFF,
11981200
};
11991201

12001202
static const char * const its_strings[] = {
12011203
[ITS_MITIGATION_OFF] = "Vulnerable",
1204+
[ITS_MITIGATION_VMEXIT_ONLY] = "Mitigation: Vulnerable, KVM: Not affected",
12021205
[ITS_MITIGATION_ALIGNED_THUNKS] = "Mitigation: Aligned branch/return thunks",
12031206
[ITS_MITIGATION_RETPOLINE_STUFF] = "Mitigation: Retpolines, Stuffing RSB",
12041207
};
@@ -1225,6 +1228,8 @@ static int __init its_parse_cmdline(char *str)
12251228
} else if (!strcmp(str, "force")) {
12261229
its_cmd = ITS_CMD_ON;
12271230
setup_force_cpu_bug(X86_BUG_ITS);
1231+
} else if (!strcmp(str, "vmexit")) {
1232+
its_cmd = ITS_CMD_VMEXIT;
12281233
} else {
12291234
pr_err("Ignoring unknown indirect_target_selection option (%s).", str);
12301235
}
@@ -1280,6 +1285,12 @@ static void __init its_select_mitigation(void)
12801285
case ITS_CMD_OFF:
12811286
its_mitigation = ITS_MITIGATION_OFF;
12821287
break;
1288+
case ITS_CMD_VMEXIT:
1289+
if (boot_cpu_has_bug(X86_BUG_ITS_NATIVE_ONLY)) {
1290+
its_mitigation = ITS_MITIGATION_VMEXIT_ONLY;
1291+
goto out;
1292+
}
1293+
fallthrough;
12831294
case ITS_CMD_ON:
12841295
its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
12851296
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
@@ -1230,6 +1230,8 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
12301230
#define RFDS BIT(7)
12311231
/* CPU is affected by Indirect Target Selection */
12321232
#define ITS BIT(8)
1233+
/* CPU is affected by Indirect Target Selection, but guest-host isolation is not affected */
1234+
#define ITS_NATIVE_ONLY BIT(9)
12331235

12341236
static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12351237
VULNBL_INTEL_STEPPINGS(INTEL_IVYBRIDGE, X86_STEPPING_ANY, SRBDS),
@@ -1250,16 +1252,16 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12501252
VULNBL_INTEL_STEPPINGS(INTEL_KABYLAKE, X86_STEPPINGS(0x0, 0xc), MMIO | RETBLEED | GDS | SRBDS),
12511253
VULNBL_INTEL_STEPPINGS(INTEL_KABYLAKE, X86_STEPPING_ANY, MMIO | RETBLEED | GDS | SRBDS | ITS),
12521254
VULNBL_INTEL_STEPPINGS(INTEL_CANNONLAKE_L, X86_STEPPING_ANY, RETBLEED),
1253-
VULNBL_INTEL_STEPPINGS(INTEL_ICELAKE_L, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
1254-
VULNBL_INTEL_STEPPINGS(INTEL_ICELAKE_D, X86_STEPPING_ANY, MMIO | GDS | ITS),
1255-
VULNBL_INTEL_STEPPINGS(INTEL_ICELAKE_X, X86_STEPPING_ANY, MMIO | GDS | ITS),
1255+
VULNBL_INTEL_STEPPINGS(INTEL_ICELAKE_L, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS | ITS_NATIVE_ONLY),
1256+
VULNBL_INTEL_STEPPINGS(INTEL_ICELAKE_D, X86_STEPPING_ANY, MMIO | GDS | ITS | ITS_NATIVE_ONLY),
1257+
VULNBL_INTEL_STEPPINGS(INTEL_ICELAKE_X, X86_STEPPING_ANY, MMIO | GDS | ITS | ITS_NATIVE_ONLY),
12561258
VULNBL_INTEL_STEPPINGS(INTEL_COMETLAKE, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
12571259
VULNBL_INTEL_STEPPINGS(INTEL_COMETLAKE_L, X86_STEPPINGS(0x0, 0x0), MMIO | RETBLEED | ITS),
12581260
VULNBL_INTEL_STEPPINGS(INTEL_COMETLAKE_L, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
1259-
VULNBL_INTEL_STEPPINGS(INTEL_TIGERLAKE_L, X86_STEPPING_ANY, GDS | ITS),
1260-
VULNBL_INTEL_STEPPINGS(INTEL_TIGERLAKE, X86_STEPPING_ANY, GDS | ITS),
1261+
VULNBL_INTEL_STEPPINGS(INTEL_TIGERLAKE_L, X86_STEPPING_ANY, GDS | ITS | ITS_NATIVE_ONLY),
1262+
VULNBL_INTEL_STEPPINGS(INTEL_TIGERLAKE, X86_STEPPING_ANY, GDS | ITS | ITS_NATIVE_ONLY),
12611263
VULNBL_INTEL_STEPPINGS(INTEL_LAKEFIELD, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED),
1262-
VULNBL_INTEL_STEPPINGS(INTEL_ROCKETLAKE, X86_STEPPING_ANY, MMIO | RETBLEED | GDS | ITS),
1264+
VULNBL_INTEL_STEPPINGS(INTEL_ROCKETLAKE, X86_STEPPING_ANY, MMIO | RETBLEED | GDS | ITS | ITS_NATIVE_ONLY),
12631265
VULNBL_INTEL_STEPPINGS(INTEL_ALDERLAKE, X86_STEPPING_ANY, RFDS),
12641266
VULNBL_INTEL_STEPPINGS(INTEL_ALDERLAKE_L, X86_STEPPING_ANY, RFDS),
12651267
VULNBL_INTEL_STEPPINGS(INTEL_RAPTORLAKE, X86_STEPPING_ANY, RFDS),
@@ -1481,8 +1483,11 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14811483
if (cpu_has(c, X86_FEATURE_AMD_IBPB) && !cpu_has(c, X86_FEATURE_AMD_IBPB_RET))
14821484
setup_force_cpu_bug(X86_BUG_IBPB_NO_RET);
14831485

1484-
if (vulnerable_to_its(x86_arch_cap_msr))
1486+
if (vulnerable_to_its(x86_arch_cap_msr)) {
14851487
setup_force_cpu_bug(X86_BUG_ITS);
1488+
if (cpu_matches(cpu_vuln_blacklist, ITS_NATIVE_ONLY))
1489+
setup_force_cpu_bug(X86_BUG_ITS_NATIVE_ONLY);
1490+
}
14861491

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

0 commit comments

Comments
 (0)