Commit 66e12279 authored by Kristina Martšenko's avatar Kristina Martšenko

arm64: cpufeature: handle conflicts based on capability

Each system capability can be of either boot, local, or system scope,
depending on when the state of the capability is finalized. When we
detect a conflict on a late CPU, we either offline the CPU or panic the
system. We currently always panic if the conflict is caused by a boot
scope capability, and offline the CPU if the conflict is caused by a
local or system scope capability.

We're going to want to add a new capability (for pointer authentication)
which needs to be boot scope but doesn't need to panic the system when a
conflict is detected. So add a new flag to specify whether the
capability requires the system to panic or not. Current boot scope
capabilities are updated to set the flag, so there should be no
functional change as a result of this patch.
Reviewed-by: default avatarKees Cook <>
Reviewed-by: Suzuki Poulose's avatarSuzuki K Poulose <>
Signed-off-by: default avatarKristina Martšenko <>
parent 9391c36d
......@@ -210,6 +210,10 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;
* In some non-typical cases either both (a) and (b), or neither,
* should be permitted. This can be described by including neither
* or both flags in the capability's type field.
* In case of a conflict, the CPU is prevented from booting. If the
* ARM64_CPUCAP_PANIC_ON_CONFLICT flag is specified for the capability,
* then a kernel panic is triggered.
......@@ -242,6 +246,8 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;
/* Is it safe for a late CPU to miss this capability when system has it */
/* Panic when a conflict is detected */
* CPU errata workarounds that need to be enabled at boot time if one or
......@@ -281,9 +287,11 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;
* CPU feature used early in the boot based on the boot CPU. All secondary
* CPUs must match the state of the capability as detected by the boot CPU.
* CPUs must match the state of the capability as detected by the boot CPU. In
* case of a conflict, a kernel panic is triggered.
struct arm64_cpu_capabilities {
const char *desc;
......@@ -347,6 +355,12 @@ cpucap_late_cpu_permitted(const struct arm64_cpu_capabilities *cap)
return !!(cap->type & ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU);
static inline bool
cpucap_panic_on_conflict(const struct arm64_cpu_capabilities *cap)
return !!(cap->type & ARM64_CPUCAP_PANIC_ON_CONFLICT);
* Generic helper for handling capabilties with multiple (match,enable) pairs
* of call backs, sharing the same capability bit.
......@@ -1847,10 +1847,8 @@ static void __init enable_cpu_capabilities(u16 scope_mask)
* Run through the list of capabilities to check for conflicts.
* If the system has already detected a capability, take necessary
* action on this CPU.
* Returns "false" on conflicts.
static bool verify_local_cpu_caps(u16 scope_mask)
static void verify_local_cpu_caps(u16 scope_mask)
int i;
bool cpu_has_cap, system_has_cap;
......@@ -1895,10 +1893,12 @@ static bool verify_local_cpu_caps(u16 scope_mask)
pr_crit("CPU%d: Detected conflict for capability %d (%s), System: %d, CPU: %d\n",
smp_processor_id(), caps->capability,
caps->desc, system_has_cap, cpu_has_cap);
return false;
return true;
if (cpucap_panic_on_conflict(caps))
......@@ -1908,12 +1908,8 @@ static bool verify_local_cpu_caps(u16 scope_mask)
static void check_early_cpu_features(void)
* Early features are used by the kernel already. If there
* is a conflict, we cannot proceed further.
if (!verify_local_cpu_caps(SCOPE_BOOT_CPU))
static void
......@@ -1961,8 +1957,7 @@ static void verify_local_cpu_capabilities(void)
* check_early_cpu_features(), as they need to be verified
* on all secondary CPUs.
if (!verify_local_cpu_caps(SCOPE_ALL & ~SCOPE_BOOT_CPU))
verify_local_cpu_caps(SCOPE_ALL & ~SCOPE_BOOT_CPU);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment