The branch stable/14 has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7cd4ec4adb8f3727f59b6208b9e3bcc6c0bf30c0

commit 7cd4ec4adb8f3727f59b6208b9e3bcc6c0bf30c0
Author:     Andrew Turner <[email protected]>
AuthorDate: 2025-09-04 14:57:41 +0000
Commit:     Andrew Turner <[email protected]>
CommitDate: 2026-01-14 21:14:15 +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
    
    (cherry picked from commit c76b0247a95ed090cc0d83b2698228d2937af3e6)
---
 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 dbb92d75dd85..f61f727315a6 100644
--- a/sys/arm64/include/cpu.h
+++ b/sys/arm64/include/cpu.h
@@ -202,6 +202,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

Reply via email to