git: c76b0247a95e - main - arm64: Add a function to check a range of CPU revs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 04 Sep 2025 16:28:50 UTC
The branch main has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=c76b0247a95ed090cc0d83b2698228d2937af3e6
commit c76b0247a95ed090cc0d83b2698228d2937af3e6
Author: Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2025-09-04 14:57:41 +0000
Commit: Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2025-09-04 14:58:25 +0000
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
---
sys/arm64/include/cpu.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
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