Skip to contentSkip to conversation

THERM_CONTROL_MSR mucks with Xen cpufreq code.

RFC PATCH New Konrad Rzeszutek Wilk 3 participants 5 messages Dec 18, 2015 – Dec 21, 2015

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 THERM_CONTROL_MSR mucks with Xen cpufreq code.

Hey,

I've gotten feedback from some of the internal BIOS folks who had noticied some issues (the machine is running very slowly) which we found out was due to the ACPI DSDT being busted and the Linux kernel (dom0) programming the _wrong_ values in the T-state MSR.

While this got fixed in the BIOS - it occurred to me that we really shouldn't let dom0 poke at this MSR?
The patch that added this functionality didn't have much details.

#1 lore raw

RFC PATCH 1/1 x86: Limit MSR_IA32_THERM_CONTROL and MSR_IA32_ENERGY_PERF_BIAS

Those two allow the OS pinned dom0 to change the T-state (throttling) behind the Xen cpufreq code.

The patch that introduced this: f78e2193b6409577314167ed9e077de7ac3e652f

x86: Enable THERM_CONTROL_MSR write for dom0 even when cpufreq=xen

is very lacking on details.

Anyhow this patch in effect reverts the above commit. It is also lacking in details :-)

---
 xen/arch/x86/traps.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
xen/arch/x86/traps.c +1 -9
index e105b95..78395ef 100644
@@ -2614,23 +2614,15 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
                 goto fail;
             break;
         case MSR_IA32_PERF_CTL:
-            if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
-                goto fail;
-            if ( !is_cpufreq_controller(currd) )
-                break;
-            if ( wrmsr_safe(regs->ecx, msr_content) != 0 )
-                goto fail;
-            break;
         case MSR_IA32_THERM_CONTROL:
         case MSR_IA32_ENERGY_PERF_BIAS:
             if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
                 goto fail;
-            if ( !is_hardware_domain(currd) || !is_pinned_vcpu(v) )
+            if ( !is_cpufreq_controller(currd) )
                 break;
             if ( wrmsr_safe(regs->ecx, msr_content) != 0 )
                 goto fail;
             break;
-
         case MSR_AMD64_DR0_ADDRESS_MASK:
             if ( !boot_cpu_has(X86_FEATURE_DBEXT) || (msr_content >> 32) )
                 goto fail;
Signature · 1 line
2.1.0
#2 lore raw

Re: [PATCH RFC] x86: Limit MSR_IA32_THERM_CONTROL and MSR_IA32_ENERGY_PERF_BIAS

Quoted 10 lines · Konrad Rzeszutek Wilk

Those two allow the OS pinned dom0 to change the T-state (throttling) behind the Xen cpufreq code.

The patch that introduced this: f78e2193b6409577314167ed9e077de7ac3e652f

x86: Enable THERM_CONTROL_MSR write for dom0 even when cpufreq=xen

Quoted 6 lines

is very lacking on details.

Anyhow this patch in effect reverts the above commit. It is also lacking in details :-)

We absolutely shouldn't let dom0 play with controls behind the back of a driver in Xen.

It would be nice if we can find out some of the reasoning behind this change, but I am in principle for it.

~Andrew

#3 lore raw

Re: [PATCH RFC] x86: Limit MSR_IA32_THERM_CONTROL and MSR_IA32_ENERGY_PERF_BIAS

Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 18.12.15 at 22:31, <[email protected]> wrote:
Quoted 12 lines · Konrad Rzeszutek Wilk

Those two allow the OS pinned dom0 to change the T-state (throttling) behind the Xen cpufreq code.

The patch that introduced this: f78e2193b6409577314167ed9e077de7ac3e652f

x86: Enable THERM_CONTROL_MSR write for dom0 even when cpufreq=xen

is very lacking on details.

Quoted 7 lines
Quoted 4 lines

Anyhow this patch in effect reverts the above commit. It is also lacking in details :-)

We absolutely shouldn't let dom0 play with controls behind the back of a driver in Xen.

Correct. Just that there still is no Tx state driver in Xen.

Quoted 2 lines

It would be nice if we can find out some of the reasoning behind this change, but I am in principle for it.

See above - the lack of a hypervisor side driver.

Jan

#4 lore raw

Re: [PATCH RFC] x86: Limit MSR_IA32_THERM_CONTROL and MSR_IA32_ENERGY_PERF_BIAS

In reply to Konrad Rzeszutek Wilk
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 18.12.15 at 21:46, <[email protected]> wrote:
xen/arch/x86/traps.c +0 -4
@@ -2614,23 +2614,15 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
                 goto fail;
             break;
         case MSR_IA32_PERF_CTL:
-            if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
-                goto fail;
-            if ( !is_cpufreq_controller(currd) )
-                break;

xen/arch/x86/traps.c static int emulate_privileged_op(struct cpu_user_regs *regs) · line 2622

Quoted 10 lines
xen/arch/x86/traps.c +1 -4
-            if ( wrmsr_safe(regs->ecx, msr_content) != 0 )
-                goto fail;
-            break;
         case MSR_IA32_THERM_CONTROL:
         case MSR_IA32_ENERGY_PERF_BIAS:
             if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
                 goto fail;
-            if ( !is_hardware_domain(currd) || !is_pinned_vcpu(v) )
+            if ( !is_cpufreq_controller(currd) )
                 break;

Are all three MSRs really only relevant to P-state handling? I don't think so, and hence their accessibility shouldn't be controlled by a P-state related conditional.

As an aside, I also think that we should do away with Dom0-driven P-states (I don't think any Dom0 other than XenoLinux ones ever supported this mode).

Jan