The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=ddc20379099b8c3fea87bc0a8f2c8b6585b1d0bc
commit ddc20379099b8c3fea87bc0a8f2c8b6585b1d0bc Author: Andrew Turner <[email protected]> AuthorDate: 2025-09-04 14:44:31 +0000 Commit: Andrew Turner <[email protected]> CommitDate: 2026-01-14 21:14:12 +0000 arm64: Add a sysctl to see if features are enabled This will also be used as a tunable to control features in a later change. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D52357 (cherry picked from commit 9204a315a71c5aa9a9b8c11f2dcefb155dd5fc34) --- sys/arm64/arm64/cpu_feat.c | 7 +++++-- sys/arm64/include/cpu_feat.h | 13 ++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/arm64/arm64/cpu_feat.c b/sys/arm64/arm64/cpu_feat.c index cc262394913d..fd1b8429295f 100644 --- a/sys/arm64/arm64/cpu_feat.c +++ b/sys/arm64/arm64/cpu_feat.c @@ -32,6 +32,8 @@ #include <machine/cpu.h> #include <machine/cpu_feat.h> +SYSCTL_NODE(_hw, OID_AUTO, feat, CTLFLAG_RD, 0, "CPU features/errata"); + /* TODO: Make this a list if we ever grow a callback other than smccc_errata */ static cpu_feat_errata_check_fn cpu_feat_check_cb = NULL; @@ -97,8 +99,9 @@ enable_cpu_feat(uint32_t stage) /* Shouldn't be possible */ MPASS(errata_status != ERRATA_UNKNOWN); - feat->feat_enable(feat, errata_status, errata_list, - errata_count); + if (feat->feat_enable(feat, errata_status, errata_list, + errata_count)) + feat->feat_enabled = true; } } diff --git a/sys/arm64/include/cpu_feat.h b/sys/arm64/include/cpu_feat.h index 6a0b2d78f526..f62f3e334dc1 100644 --- a/sys/arm64/include/cpu_feat.h +++ b/sys/arm64/include/cpu_feat.h @@ -29,6 +29,7 @@ #define _MACHINE_CPU_FEAT_H_ #include <sys/linker_set.h> +#include <sys/sysctl.h> typedef enum { ERRATA_UNKNOWN, /* Unknown erratum */ @@ -52,7 +53,7 @@ struct cpu_feat; typedef bool (cpu_feat_check)(const struct cpu_feat *, u_int); typedef bool (cpu_feat_has_errata)(const struct cpu_feat *, u_int, u_int **, u_int *); -typedef void (cpu_feat_enable)(const struct cpu_feat *, cpu_feat_errata, +typedef bool (cpu_feat_enable)(const struct cpu_feat *, cpu_feat_errata, u_int *, u_int); struct cpu_feat { @@ -61,18 +62,24 @@ struct cpu_feat { cpu_feat_has_errata *feat_has_errata; cpu_feat_enable *feat_enable; uint32_t feat_flags; + bool feat_enabled; }; SET_DECLARE(cpu_feat_set, struct cpu_feat); -#define CPU_FEAT(name, check, has_errata, enable, flags) \ +SYSCTL_DECL(_hw_feat); + +#define CPU_FEAT(name, descr, check, has_errata, enable, flags) \ static struct cpu_feat name = { \ .feat_name = #name, \ .feat_check = check, \ .feat_has_errata = has_errata, \ .feat_enable = enable, \ .feat_flags = flags, \ + .feat_enabled = false, \ }; \ -DATA_SET(cpu_feat_set, name) +DATA_SET(cpu_feat_set, name); \ +SYSCTL_BOOL(_hw_feat, OID_AUTO, name, CTLFLAG_RD, &name.feat_enabled, \ + 0, descr) /* * Allow drivers to mark an erratum as worked around, e.g. the Errata
