On 27/10/2025 5:26 pm, Teddy Astie wrote:
> I'm not a fan of doing a inline cpuid check here, but I don't have a
> better approach in mind.

I'm not sure if there's enough information in leaf 6 to justify putting
it fully into the CPUID infrastructure.

But, if you do something like this:

diff --git a/xen/include/xen/lib/x86/cpu-policy.h 
b/xen/include/xen/lib/x86/cpu-policy.h
index f94f23e159d2..d02fe4d22151 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -121,7 +121,13 @@ struct cpu_policy
             uint64_t :64, :64; /* Leaf 0x3 - PSN. */
             uint64_t :64, :64; /* Leaf 0x4 - Structured Cache. */
             uint64_t :64, :64; /* Leaf 0x5 - MONITOR. */
-            uint64_t :64, :64; /* Leaf 0x6 - Therm/Perf. */
+
+            /* Leaf 0x6 - Thermal and Perf. */
+            struct {
+                bool /* a */ dts:1;
+                uint32_t /* b */:32, /* c */:32, /* d */:32;
+            };
+
             uint64_t :64, :64; /* Leaf 0x7 - Structured Features. */
             uint64_t :64, :64; /* Leaf 0x8 - rsvd */
             uint64_t :64, :64; /* Leaf 0x9 - DCA */


then ...

> diff --git a/xen/arch/x86/platform_hypercall.c 
> b/xen/arch/x86/platform_hypercall.c
> index 79bb99e0b6..3190803cc2 100644
> --- a/xen/arch/x86/platform_hypercall.c
> +++ b/xen/arch/x86/platform_hypercall.c
> @@ -86,6 +86,12 @@ static bool msr_read_allowed(unsigned int msr)
>  
>      case MSR_MCU_OPT_CTRL:
>          return cpu_has_srbds_ctrl;
> +    

You've added trailing whitespace here.

> +    case MSR_IA32_TEMPERATURE_TARGET:
> +    case MSR_IA32_THERM_STATUS:
> +    case MSR_IA32_PACKAGE_THERM_STATUS:
> +        return boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
> +            (cpuid_eax(0x6) & 0x1); /* Digital temperature sensor */

... you ought to be able to use host_policy.basic.dts here.  In
principle the Intel check can be dropped too.

~Andrew

Reply via email to