On 16.06.2023 15:10, Roger Pau Monne wrote: > @@ -119,6 +103,21 @@ int x86_msr_copy_from_buffer(struct cpu_policy *p, > return rc; > } > > +const uint64_t *x86_msr_get_entry_const(const struct cpu_policy *p, > + uint32_t idx)
I don't think idx needs to be of a fixed width type; unsigned int ought to be quite fine. > +{ > + switch ( idx ) > + { > + case MSR_INTEL_PLATFORM_INFO: > + return &p->platform_info.raw; > + > + case MSR_ARCH_CAPABILITIES: > + return &p->arch_caps.raw; Earlier on (also for the CPUID counterpart) a risky aspect of this didn't occur to me: The validity of the returned pointer is tied to the scope of the object the address of which was passed in. I'm afraid this is an aspect which is easy to miss, and hence wants calling out in the comments in cpu-policy.h (provided we're okay to accept this risk in the first place). Jan