Skip to content

Commit 139c0b8

Browse files
pa1guptagregkh
authored andcommitted
x86/its: Add "vmexit" option to skip mitigation on some CPUs
commit 2665281a07e19550944e8354a2024635a7b2714a 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 b1701fe commit 139c0b8

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
@@ -2033,6 +2033,8 @@
20332033
off: Disable mitigation.
20342034
force: Force the ITS bug and deploy default
20352035
mitigation.
2036+
vmexit: Only deploy mitigation if CPU is affected by
2037+
guest/host isolation part of ITS.
20362038

20372039
For details see:
20382040
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
@@ -497,4 +497,5 @@
497497
#define X86_BUG_BHI X86_BUG(1*32 + 3) /* CPU is affected by Branch History Injection */
498498
#define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */
499499
#define X86_BUG_ITS X86_BUG(1*32 + 5) /* CPU is affected by Indirect Target Selection */
500+
#define X86_BUG_ITS_NATIVE_ONLY X86_BUG(1*32 + 6) /* CPU is affected by ITS, VMX is not affected */
500501
#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
@@ -1158,15 +1158,18 @@ static void __init retbleed_select_mitigation(void)
11581158
enum its_mitigation_cmd {
11591159
ITS_CMD_OFF,
11601160
ITS_CMD_ON,
1161+
ITS_CMD_VMEXIT,
11611162
};
11621163

11631164
enum its_mitigation {
11641165
ITS_MITIGATION_OFF,
1166+
ITS_MITIGATION_VMEXIT_ONLY,
11651167
ITS_MITIGATION_ALIGNED_THUNKS,
11661168
};
11671169

11681170
static const char * const its_strings[] = {
11691171
[ITS_MITIGATION_OFF] = "Vulnerable",
1172+
[ITS_MITIGATION_VMEXIT_ONLY] = "Mitigation: Vulnerable, KVM: Not affected",
11701173
[ITS_MITIGATION_ALIGNED_THUNKS] = "Mitigation: Aligned branch/return thunks",
11711174
};
11721175

@@ -1192,6 +1195,8 @@ static int __init its_parse_cmdline(char *str)
11921195
} else if (!strcmp(str, "force")) {
11931196
its_cmd = ITS_CMD_ON;
11941197
setup_force_cpu_bug(X86_BUG_ITS);
1198+
} else if (!strcmp(str, "vmexit")) {
1199+
its_cmd = ITS_CMD_VMEXIT;
11951200
} else {
11961201
pr_err("Ignoring unknown indirect_target_selection option (%s).", str);
11971202
}
@@ -1239,6 +1244,12 @@ static void __init its_select_mitigation(void)
12391244
case ITS_CMD_OFF:
12401245
its_mitigation = ITS_MITIGATION_OFF;
12411246
break;
1247+
case ITS_CMD_VMEXIT:
1248+
if (boot_cpu_has_bug(X86_BUG_ITS_NATIVE_ONLY)) {
1249+
its_mitigation = ITS_MITIGATION_VMEXIT_ONLY;
1250+
goto out;
1251+
}
1252+
fallthrough;
12421253
case ITS_CMD_ON:
12431254
its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
12441255
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
@@ -1253,6 +1253,8 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
12531253
#define RFDS BIT(7)
12541254
/* CPU is affected by Indirect Target Selection */
12551255
#define ITS BIT(8)
1256+
/* CPU is affected by Indirect Target Selection, but guest-host isolation is not affected */
1257+
#define ITS_NATIVE_ONLY BIT(9)
12561258

12571259
static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12581260
VULNBL_INTEL_STEPPINGS(IVYBRIDGE, X86_STEPPING_ANY, SRBDS),
@@ -1273,16 +1275,16 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12731275
VULNBL_INTEL_STEPPINGS(KABYLAKE, X86_STEPPINGS(0x0, 0xc), MMIO | RETBLEED | GDS | SRBDS),
12741276
VULNBL_INTEL_STEPPINGS(KABYLAKE, X86_STEPPING_ANY, MMIO | RETBLEED | GDS | SRBDS | ITS),
12751277
VULNBL_INTEL_STEPPINGS(CANNONLAKE_L, X86_STEPPING_ANY, RETBLEED),
1276-
VULNBL_INTEL_STEPPINGS(ICELAKE_L, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
1277-
VULNBL_INTEL_STEPPINGS(ICELAKE_D, X86_STEPPING_ANY, MMIO | GDS | ITS),
1278-
VULNBL_INTEL_STEPPINGS(ICELAKE_X, X86_STEPPING_ANY, MMIO | GDS | ITS),
1278+
VULNBL_INTEL_STEPPINGS(ICELAKE_L, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS | ITS_NATIVE_ONLY),
1279+
VULNBL_INTEL_STEPPINGS(ICELAKE_D, X86_STEPPING_ANY, MMIO | GDS | ITS | ITS_NATIVE_ONLY),
1280+
VULNBL_INTEL_STEPPINGS(ICELAKE_X, X86_STEPPING_ANY, MMIO | GDS | ITS | ITS_NATIVE_ONLY),
12791281
VULNBL_INTEL_STEPPINGS(COMETLAKE, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
12801282
VULNBL_INTEL_STEPPINGS(COMETLAKE_L, X86_STEPPINGS(0x0, 0x0), MMIO | RETBLEED | ITS),
12811283
VULNBL_INTEL_STEPPINGS(COMETLAKE_L, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED | GDS | ITS),
1282-
VULNBL_INTEL_STEPPINGS(TIGERLAKE_L, X86_STEPPING_ANY, GDS | ITS),
1283-
VULNBL_INTEL_STEPPINGS(TIGERLAKE, X86_STEPPING_ANY, GDS | ITS),
1284+
VULNBL_INTEL_STEPPINGS(TIGERLAKE_L, X86_STEPPING_ANY, GDS | ITS | ITS_NATIVE_ONLY),
1285+
VULNBL_INTEL_STEPPINGS(TIGERLAKE, X86_STEPPING_ANY, GDS | ITS | ITS_NATIVE_ONLY),
12841286
VULNBL_INTEL_STEPPINGS(LAKEFIELD, X86_STEPPING_ANY, MMIO | MMIO_SBDS | RETBLEED),
1285-
VULNBL_INTEL_STEPPINGS(ROCKETLAKE, X86_STEPPING_ANY, MMIO | RETBLEED | GDS | ITS),
1287+
VULNBL_INTEL_STEPPINGS(ROCKETLAKE, X86_STEPPING_ANY, MMIO | RETBLEED | GDS | ITS | ITS_NATIVE_ONLY),
12861288
VULNBL_INTEL_STEPPINGS(ALDERLAKE, X86_STEPPING_ANY, RFDS),
12871289
VULNBL_INTEL_STEPPINGS(ALDERLAKE_L, X86_STEPPING_ANY, RFDS),
12881290
VULNBL_INTEL_STEPPINGS(RAPTORLAKE, X86_STEPPING_ANY, RFDS),
@@ -1499,8 +1501,11 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14991501
if (cpu_has(c, X86_FEATURE_AMD_IBPB) && !cpu_has(c, X86_FEATURE_AMD_IBPB_RET))
15001502
setup_force_cpu_bug(X86_BUG_IBPB_NO_RET);
15011503

1502-
if (vulnerable_to_its(x86_arch_cap_msr))
1504+
if (vulnerable_to_its(x86_arch_cap_msr)) {
15031505
setup_force_cpu_bug(X86_BUG_ITS);
1506+
if (cpu_matches(cpu_vuln_blacklist, ITS_NATIVE_ONLY))
1507+
setup_force_cpu_bug(X86_BUG_ITS_NATIVE_ONLY);
1508+
}
15041509

15051510
if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
15061511
return;

0 commit comments

Comments
 (0)