diff options
| author | Andrew Turner <andrew@FreeBSD.org> | 2025-09-04 14:57:41 +0000 |
|---|---|---|
| committer | Andrew Turner <andrew@FreeBSD.org> | 2025-09-04 14:58:25 +0000 |
| commit | c76b0247a95ed090cc0d83b2698228d2937af3e6 (patch) | |
| tree | 76e03056a9ea67106472589b47db41a63b114be4 | |
| parent | 4bc68fa98f68211ee7943d77cfc91f60ccb5880d (diff) | |
arm64: Add a function to check a range of CPU revs
Add a function that can check if a given midr is within a range of
revisions. This will be used to check if a CPU is affected by a known
erratum.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D52187
| -rw-r--r-- | sys/arm64/include/cpu.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/arm64/include/cpu.h b/sys/arm64/include/cpu.h index 59cda36f275e..f07b67d18abf 100644 --- a/sys/arm64/include/cpu.h +++ b/sys/arm64/include/cpu.h @@ -196,6 +196,31 @@ #define CPU_MATCH_RAW(mask, devid) \ (((mask) & PCPU_GET(midr)) == ((mask) & (devid))) +#if !defined(__ASSEMBLER__) +static inline bool +midr_check_var_part_range(u_int midr, u_int impl, u_int part, u_int var_low, + u_int part_low, u_int var_high, u_int part_high) +{ + /* Check for the correct part */ + if (CPU_IMPL(midr) != impl || CPU_PART(midr) != part) + return (false); + + /* Check if the variant is between var_low and var_high inclusive */ + if (CPU_VAR(midr) < var_low || CPU_VAR(midr) > var_high) + return (false); + + /* If the variant is the low value, check if the part is high enough */ + if (CPU_VAR(midr) == var_low && CPU_PART(midr) < part_low) + return (false); + + /* If the variant is the high value, check if the part is low enough */ + if (CPU_VAR(midr) == var_high && CPU_PART(midr) > part_high) + return (false); + + return (true); +} +#endif + /* * Chip-specific errata. This defines are intended to be * booleans used within if statements. When an appropriate |
