diff mbox series

[1/2] x86/cpu-policy: add (another) size check of deep_features[]

Message ID c3ff2769-f9c3-eea8-9109-d1218b4e034d@suse.com (mailing list archive)
State New, archived
Headers show
Series x86/cpu-policy: minor adjustments | expand

Commit Message

Jan Beulich Aug. 29, 2023, 12:15 p.m. UTC
Having this check in library code guarantees that the tool stack use(s)
will also be covered.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Dropping the check from arch/x86/cpu-policy.c:build_assertions() in
exchange may be an option. While there checking is against FSCAPINTS,
the difference is only on the surface: That's a #define resolving to
FEATURESET_NR_ENTRIES.

Really the duplication of deep_features[] itself is also somewhat odd.
While not quite as big as deep_deps[], both Xen and libxg could
certainly get away with just a single instance each.
diff mbox series

Patch

--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -298,6 +298,7 @@  const uint32_t *x86_cpu_policy_lookup_de
     } deep_deps[] = INIT_DEEP_DEPS;
     unsigned int start = 0, end = ARRAY_SIZE(deep_deps);
 
+    BUILD_BUG_ON(ARRAY_SIZE(deep_features) != FEATURESET_NR_ENTRIES);
     BUILD_BUG_ON(ARRAY_SIZE(deep_deps) != NR_DEEP_DEPS);
 
     /* Fast early exit. */