diff options
| author | Josh Poimboeuf <jpoimboe@redhat.com> | 2019-04-12 16:39:32 -0400 |
|---|---|---|
| committer | Will Deacon <will.deacon@arm.com> | 2019-05-01 09:48:07 -0400 |
| commit | a111b7c0f20e13b54df2fa959b3dc0bdf1925ae6 (patch) | |
| tree | fb21c31d9d66a71ece8f4a9b8138002ca5eacb6d | |
| parent | eb337cdfcd5dd3b10522c2f34140a73a4c285c30 (diff) | |
arm64/speculation: Support 'mitigations=' cmdline option
Configure arm64 runtime CPU speculation bug mitigations in accordance
with the 'mitigations=' cmdline option. This affects Meltdown, Spectre
v2, and Speculative Store Bypass.
The default behavior is unchanged.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
[will: reorder checks so KASLR implies KPTI and SSBS is affected by cmdline]
Signed-off-by: Will Deacon <will.deacon@arm.com>
| -rw-r--r-- | Documentation/admin-guide/kernel-parameters.txt | 8 | ||||
| -rw-r--r-- | arch/arm64/kernel/cpu_errata.c | 6 | ||||
| -rw-r--r-- | arch/arm64/kernel/cpufeature.c | 8 |
3 files changed, 17 insertions, 5 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 6a929258faf7..ce226f7ee566 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt | |||
| @@ -2545,8 +2545,8 @@ | |||
| 2545 | http://repo.or.cz/w/linux-2.6/mini2440.git | 2545 | http://repo.or.cz/w/linux-2.6/mini2440.git |
| 2546 | 2546 | ||
| 2547 | mitigations= | 2547 | mitigations= |
| 2548 | [X86,PPC,S390] Control optional mitigations for CPU | 2548 | [X86,PPC,S390,ARM64] Control optional mitigations for |
| 2549 | vulnerabilities. This is a set of curated, | 2549 | CPU vulnerabilities. This is a set of curated, |
| 2550 | arch-independent options, each of which is an | 2550 | arch-independent options, each of which is an |
| 2551 | aggregation of existing arch-specific options. | 2551 | aggregation of existing arch-specific options. |
| 2552 | 2552 | ||
| @@ -2555,11 +2555,13 @@ | |||
| 2555 | improves system performance, but it may also | 2555 | improves system performance, but it may also |
| 2556 | expose users to several CPU vulnerabilities. | 2556 | expose users to several CPU vulnerabilities. |
| 2557 | Equivalent to: nopti [X86,PPC] | 2557 | Equivalent to: nopti [X86,PPC] |
| 2558 | kpti=0 [ARM64] | ||
| 2558 | nospectre_v1 [PPC] | 2559 | nospectre_v1 [PPC] |
| 2559 | nobp=0 [S390] | 2560 | nobp=0 [S390] |
| 2560 | nospectre_v2 [X86,PPC,S390] | 2561 | nospectre_v2 [X86,PPC,S390,ARM64] |
| 2561 | spectre_v2_user=off [X86] | 2562 | spectre_v2_user=off [X86] |
| 2562 | spec_store_bypass_disable=off [X86,PPC] | 2563 | spec_store_bypass_disable=off [X86,PPC] |
| 2564 | ssbd=force-off [ARM64] | ||
| 2563 | l1tf=off [X86] | 2565 | l1tf=off [X86] |
| 2564 | 2566 | ||
| 2565 | auto (default) | 2567 | auto (default) |
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 44ef98be001e..1b9ce0fdd81d 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/arm-smccc.h> | 19 | #include <linux/arm-smccc.h> |
| 20 | #include <linux/psci.h> | 20 | #include <linux/psci.h> |
| 21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
| 22 | #include <linux/cpu.h> | ||
| 22 | #include <asm/cpu.h> | 23 | #include <asm/cpu.h> |
| 23 | #include <asm/cputype.h> | 24 | #include <asm/cputype.h> |
| 24 | #include <asm/cpufeature.h> | 25 | #include <asm/cpufeature.h> |
| @@ -386,6 +387,9 @@ static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry, | |||
| 386 | 387 | ||
| 387 | WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); | 388 | WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); |
| 388 | 389 | ||
| 390 | if (cpu_mitigations_off()) | ||
| 391 | ssbd_state = ARM64_SSBD_FORCE_DISABLE; | ||
| 392 | |||
| 389 | /* delay setting __ssb_safe until we get a firmware response */ | 393 | /* delay setting __ssb_safe until we get a firmware response */ |
| 390 | if (is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list)) | 394 | if (is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list)) |
| 391 | this_cpu_safe = true; | 395 | this_cpu_safe = true; |
| @@ -589,7 +593,7 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope) | |||
| 589 | } | 593 | } |
| 590 | 594 | ||
| 591 | /* forced off */ | 595 | /* forced off */ |
| 592 | if (__nospectre_v2) { | 596 | if (__nospectre_v2 || cpu_mitigations_off()) { |
| 593 | pr_info_once("spectrev2 mitigation disabled by command line option\n"); | 597 | pr_info_once("spectrev2 mitigation disabled by command line option\n"); |
| 594 | __hardenbp_enab = false; | 598 | __hardenbp_enab = false; |
| 595 | return false; | 599 | return false; |
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 703ee8564fbd..f3b32d88f165 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/stop_machine.h> | 25 | #include <linux/stop_machine.h> |
| 26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
| 27 | #include <linux/mm.h> | 27 | #include <linux/mm.h> |
| 28 | #include <linux/cpu.h> | ||
| 28 | #include <asm/cpu.h> | 29 | #include <asm/cpu.h> |
| 29 | #include <asm/cpufeature.h> | 30 | #include <asm/cpufeature.h> |
| 30 | #include <asm/cpu_ops.h> | 31 | #include <asm/cpu_ops.h> |
| @@ -966,7 +967,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, | |||
| 966 | MIDR_ALL_VERSIONS(MIDR_HISI_TSV110), | 967 | MIDR_ALL_VERSIONS(MIDR_HISI_TSV110), |
| 967 | { /* sentinel */ } | 968 | { /* sentinel */ } |
| 968 | }; | 969 | }; |
| 969 | char const *str = "command line option"; | 970 | char const *str = "kpti command line option"; |
| 970 | bool meltdown_safe; | 971 | bool meltdown_safe; |
| 971 | 972 | ||
| 972 | meltdown_safe = is_midr_in_range_list(read_cpuid_id(), kpti_safe_list); | 973 | meltdown_safe = is_midr_in_range_list(read_cpuid_id(), kpti_safe_list); |
| @@ -996,6 +997,11 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, | |||
| 996 | } | 997 | } |
| 997 | } | 998 | } |
| 998 | 999 | ||
| 1000 | if (cpu_mitigations_off() && !__kpti_forced) { | ||
| 1001 | str = "mitigations=off"; | ||
| 1002 | __kpti_forced = -1; | ||
| 1003 | } | ||
| 1004 | |||
| 999 | if (!IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0)) { | 1005 | if (!IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0)) { |
| 1000 | pr_info_once("kernel page table isolation disabled by kernel configuration\n"); | 1006 | pr_info_once("kernel page table isolation disabled by kernel configuration\n"); |
| 1001 | return false; | 1007 | return false; |
