x86/idle: Fixes and cleanup
cover x86/idle: Fixes and cleanup
Assorted fixes for mwait/monitor that I've had sitting around too long.
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1887059030
Andrew Cooper (4):
x86/idle: Move monitor()/mwait() wrappers into cpu-idle.c x86/idle: Remove MFENCEs for CLFLUSH_MONITOR
Revert part of "x86/mwait-idle: disable IBRS during long idle" x86/idle: Misc cleanup
xen/arch/x86/acpi/cpu_idle.c | 94 ++++++++++++-------------- xen/arch/x86/cpu/intel.c | 3 +- xen/arch/x86/cpu/mwait-idle.c | 12 +--- xen/arch/x86/include/asm/cpufeatures.h | 3 +- xen/arch/x86/include/asm/processor.h | 17 ----- 5 files changed, 51 insertions(+), 78 deletions(-)
base-commit: cc7394164633e75fb61d52565f75271e0b7f1236
Signature · 1 line
2.39.5
PATCH 1/4 x86/idle: Move monitor()/mwait() wrappers into cpu-idle.c
They're not used by any other translation unit, so shouldn't live in asm/processor.h, which is included almost everywhere.
Our new toolchain baseline knows the MONITOR/MWAIT instructions, so use them directly rather than using raw hex.
Change the hint/extention parameters from long to int. They're specified to remain 32bit operands even 64-bit mode.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/x86/acpi/cpu_idle.c | 21 +++++++++++++++++---- xen/arch/x86/include/asm/processor.h | 17 ----------------- 2 files changed, 17 insertions(+), 21 deletions(-)
xen/arch/x86/acpi/cpu_idle.c +17 -4
@@ -60,6 +60,19 @@/*#define DEBUG_PM_CX*/ +static always_inline void monitor( +const void *addr,unsigned int ecx,unsigned int edx) +{ + asmvolatile ("monitor" + ::"a" (addr),"c" (ecx),"d" (edx) ); +} + +static always_inline void mwait(unsigned int eax, unsigned int ecx) +{ + asmvolatile ("mwait" + ::"a" (eax),"c" (ecx) ); +} +#define GET_HW_RES_IN_NS (msr, val) \ do { rdmsrl(msr, val); val = tsc_ticks2ns(val); } while( 0 )#define GET_MC6_RES (val) GET_HW_RES_IN_NS(0x664, val)
@@ -470,7 +483,7 @@ void mwait_idle_with_hints(unsigned int eax, unsigned int ecx)mb (); } -__monitor (monitor_addr,0 ,0 ); +monitor (monitor_addr,0 ,0 );smp_mb ();/*
@@ -484,7 +497,7 @@ void mwait_idle_with_hints(unsigned int eax, unsigned int ecx)cpumask_set_cpu (cpu, &cpuidle_mwait_flags);spec_ctrl_enter_idle (info); -__mwait (eax, ecx); +mwait (eax, ecx);spec_ctrl_exit_idle (info);cpumask_clear_cpu (cpu, &cpuidle_mwait_flags);
@@ -915,9 +928,9 @@ void cf_check acpi_dead_idle(void)*/ mb ();clflush (mwait_ptr); -__monitor (mwait_ptr,0 ,0 ); +monitor (mwait_ptr,0 ,0 );mb (); -__mwait (cx->address,0 ); +mwait (cx->address,0 ); } } else if ( (current_cpu_data.x86_vendor &
xen/arch/x86/include/asm/processor.h +0 -17
@@ -315,23 +315,6 @@ static always_inline void set_in_cr4 (unsigned long mask) cr4_pv32_mask |= (mask &XEN_CR4_PV32_BITS ); } -static always_inline void __monitor(const void *eax, unsigned long ecx, -unsigned long edx) -{ -/* "monitor %eax,%ecx,%edx;" */ - asmvolatile ( -".byte 0x0f,0x01,0xc8;" - : :"a" (eax),"c" (ecx),"d" (edx) ); -} - -static always_inline void __mwait(unsigned long eax, unsigned long ecx) -{ -/* "mwait %eax,%ecx;" */ - asmvolatile ( -".byte 0x0f,0x01,0xc9;" - : :"a" (eax),"c" (ecx) ); -} -#define IOBMP_BYTES 8192#define IOBMP_INVALID_OFFSET 0x8000
Signature · 1 line
2.39.5
Re: [PATCH 1/4] x86/idle: Move monitor()/mwait() wrappers into cpu-idle.c
Quoted 10 lines · Andrew Cooper
They're not used by any other translation unit, so shouldn't live in
asm/processor.h, which is included almost everywhere.Our new toolchain baseline knows the MONITOR/MWAIT instructions, so use them directly rather than using raw hex.
Change the hint/extention parameters from long to int. They're specified to remain 32bit operands even 64-bit mode.
Signed-off-by Andrew Cooper <[email protected]>
We may need to undo this though if we ever meant to use mwait elsewhere, like for spinlocks. Many years ago that idea was entertained some, but it may well be that it was given up altogether by now.
Jan
Re: [PATCH 1/4] x86/idle: Move monitor()/mwait() wrappers into cpu-idle.c
Quoted 4 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper
They're not used by any other translation unit, so shouldn't live in
asm/processor.h, which is included almost everywhere.
Quoted 8 lines
Quoted 7 lines
Our new toolchain baseline knows the MONITOR/MWAIT instructions, so use them directly rather than using raw hex.
Change the hint/extention parameters from long to int. They're specified to remain 32bit operands even 64-bit mode.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>
Thanks.
Quoted 3 lines
We may need to undo this though if we ever meant to use mwait elsewhere, like for spinlocks. Many years ago that idea was entertained some, but it may well be that it was given up altogether by now.
If they need to move back into a header, that's fine, but it will be something new.
That said, I'm not sure how useful it would be to mwait on a spinlock. You'd need the spinlock in its own cacheline or you'll get false wakeups triggered by CPU which has the has the lock writing adjacent to the lock. Transitions in and out of idle like this are almost certainly more expensive than a pause loop.
~Andrew
PATCH 2/4 x86/idle: Remove MFENCEs for CLFLUSH_MONITOR
In reply to Andrew CooperCommit 48d32458bcd4 ("x86, idle: add barriers to CLFLUSH workaround") was inherited from Linux and added MFENCEs around the AAI65 errata fix.
The SDM now states:
Executions of the CLFLUSH instruction are ordered with respect to each other and with respect to writes, locked read-modify-write instructions, and fence instructions[1].
with footnote 1 reading:
Earlier versions of this manual specified that executions of the CLFLUSH instruction were ordered only by the MFENCE instruction. All processors implementing the CLFLUSH instruction also order it relative to the other operations enumerated above.
I.e. the MFENCEs came about because of an incorrect statement in the SDM.
The Spec Update (no longer available on Intel's website) simply says "issue a CLFLUSH", with no mention of MFENCEs.
As this erratum is specific to Intel, it's fine to remove the the MFENCEs; AMD CPUs of a similar vintage do port otherwise-unordered CLFLUSHs.
Move the feature bit into the BUG range (rather than FEATURE), and move the workaround into monitor() itself.
The erratum check itself must use setup_force_cpu_cap(). It needs activating if any CPU needs it, not if all of them need it.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
https://git.kernel.org/linus/1f13c60d84e880df6698441026e64f84c7110c49 is my equivalent patch to Linux.
--- xen/arch/x86/acpi/cpu_idle.c | 22 +++------------------- xen/arch/x86/cpu/intel.c | 3 ++- xen/arch/x86/include/asm/cpufeatures.h | 3 ++- 3 files changed, 7 insertions(+), 21 deletions(-)
xen/arch/x86/acpi/cpu_idle.c +3 -19
@@ -63,6 +63,9 @@ static always_inline void monitor(const void *addr,unsigned int ecx,unsigned int edx) { + alternative_input("", "clflush (%[addr])", X86_BUG_CLFLUSH_MONITOR, + [addr] "a" (addr)); + asmvolatile ("monitor" ::"a" (addr),"c" (ecx),"d" (edx) ); }
@@ -476,13 +479,6 @@ void mwait_idle_with_hints(unsigned int eax, unsigned int ecx)s_time_t expires =per_cpu (timer_deadline, cpu);const void *monitor_addr = &mwait_wakeup (cpu); -if (boot_cpu_has (X86_FEATURE_CLFLUSH_MONITOR ) ) - { -mb (); -clflush (monitor_addr); -mb (); - } -monitor (monitor_addr,0 ,0 );smp_mb ();
@@ -917,19 +913,7 @@ void cf_check acpi_dead_idle(void)while (1 ) { -/* -* 1. The CLFLUSH is a workaround for erratum AAI65 for -* the Xeon 7400 series. -* 2. The WBINVD is insufficient due to the spurious-wakeup -* case where we return around the loop. -* 3. Unlike wbinvd, clflush is a light weight but not serializing -* instruction, hence memory fence is necessary to make sure all -* load/store visible before flush cache line. -*/ -mb (); -clflush (mwait_ptr);monitor (mwait_ptr,0 ,0 ); -mb ();mwait (cx->address,0 ); } }
xen/arch/x86/cpu/intel.c +2 -1
@@ -446,6 +446,7 @@ static void __init probe_mwait_errata(void)* * Xeon 7400 erratum AAI65 (and further newer Xeons) * MONITOR/MWAIT may have excessive false wakeups +* https://web.archive.org/web/20090219054841/http://download.intel.com/design/xeon/specupdt/32033601.pdf */ static void Intel_errata_workarounds (struct cpuinfo_x86 *c) {
@@ -463,7 +464,7 @@ static void Intel_errata_workarounds(struct cpuinfo_x86 *c)if (c->x86 ==6 && cpu_has_clflush && (c->x86_model ==29 || c->x86_model ==46 || c->x86_model ==47 )) -__set_bit (X86_FEATURE_CLFLUSH_MONITOR , c->x86_capability); +setup_force_cpu_cap (X86_BUG_CLFLUSH_MONITOR );probe_c3_errata (c);if (system_state < SYS_STATE_smp_boot)
xen/arch/x86/include/asm/cpufeatures.h +2 -1
@@ -19,7 +19,7 @@ XEN_CPUFEATURE(ARCH_PERFMON, X86_SYNTH( 3)) /* Intel Architectural PerfMon XEN_CPUFEATURE(TSC_RELIABLE, X86_SYNTH( 4)) /* TSC is known to be reliable */ XEN_CPUFEATURE(XTOPOLOGY, X86_SYNTH( 5)) /* cpu topology enum extensions */XEN_CPUFEATURE (CPUID_FAULTING ,X86_SYNTH (6 ))/* cpuid faulting */ -XEN_CPUFEATURE(CLFLUSH_MONITOR, X86_SYNTH( 7)) /* clflush reqd with monitor */ +/* Bit 7 unused */ XEN_CPUFEATURE(APERFMPERF, X86_SYNTH( 8)) /* APERFMPERF */ XEN_CPUFEATURE(MFENCE_RDTSC, X86_SYNTH( 9)) /* MFENCE synchronizes RDTSC */XEN_CPUFEATURE (XEN_SMEP ,X86_SYNTH (10 ))/* SMEP gets used by Xen itself */
@@ -52,6 +52,7 @@ XEN_CPUFEATURE(USE_VMCALL, X86_SYNTH(30)) /* Use VMCALL instead of VMMCAL#define X86_BUG_NULL_SEG X86_BUG( 1)/* NULL-ing a selector preserves the base and limit. */ #define X86_BUG_CLFLUSH_MFENCE X86_BUG( 2)/* MFENCE needed to serialise CLFLUSH */ #define X86_BUG_IBPB_NO_RET X86_BUG( 3)/* IBPB doesn't flush the RSB/RAS */ +#define X86_BUG_CLFLUSH_MONITOR X86_BUG( 4)/* MONITOR requires CLFLUSH */ #define X86_SPEC_NO_LFENCE_ENTRY_PV X86_BUG(16)/* (No) safety LFENCE for SPEC_CTRL_ENTRY_PV. */ #define X86_SPEC_NO_LFENCE_ENTRY_INTR X86_BUG(17)/* (No) safety LFENCE for SPEC_CTRL_ENTRY_INTR. */
Signature · 1 line
2.39.5
Re: [PATCH 2/4] x86/idle: Remove MFENCEs for CLFLUSH_MONITOR
Quoted 9 lines · Andrew Cooper
Commit
48d32458bcd4("x86, idle: add barriers to CLFLUSH workaround") was inherited from Linux and added MFENCEs around the AAI65 errata fix.The SDM now states:
Executions of the CLFLUSH instruction are ordered with respect to each other and with respect to writes, locked read-modify-write instructions, and fence instructions[1].
Quoted 8 lines
with footnote 1 reading:
Earlier versions of this manual specified that executions of the CLFLUSH instruction were ordered only by the MFENCE instruction. All processors implementing the CLFLUSH instruction also order it relative to the other operations enumerated above.
I.e. the MFENCEs came about because of an incorrect statement in the SDM.
And their exact placement even differed between the two sites.
Quoted 5 lines
The Spec Update (no longer available on Intel's website) simply says "issue a CLFLUSH", with no mention of MFENCEs.
As this erratum is specific to Intel, it's fine to remove the the MFENCEs; AMD CPUs of a similar vintage do port otherwise-unordered CLFLUSHs.
Nit: DYM "sport"? I think the corresponding Linux commit that I once looked at has it that way.
Quoted 10 lines
Move the feature bit into the BUG range (rather than FEATURE), and move the workaround into
monitor()itself.The erratum check itself must use
setup_force_cpu_cap(). It needs activating if any CPU needs it, not if all of them need it.Fixes 48d32458bcd4 ("x86, idle: add barriers to CLFLUSH workaround")Fixes 96d1b237ae9b ("x86/Intel: work around Xeon 7400 series erratum AAI65")Signed-off-by Andrew Cooper <[email protected]>
Re: [PATCH 2/4] x86/idle: Remove MFENCEs for CLFLUSH_MONITOR
Quoted 20 lines · Jan Beulich
Quoted 9 lines · Andrew Cooper
Commit
48d32458bcd4("x86, idle: add barriers to CLFLUSH workaround") was inherited from Linux and added MFENCEs around the AAI65 errata fix.The SDM now states:
Executions of the CLFLUSH instruction are ordered with respect to each other and with respect to writes, locked read-modify-write instructions, and fence instructions[1].
Quoted 8 lines
with footnote 1 reading:
Earlier versions of this manual specified that executions of the CLFLUSH instruction were ordered only by the MFENCE instruction. All processors implementing the CLFLUSH instruction also order it relative to the other operations enumerated above.
I.e. the MFENCEs came about because of an incorrect statement in the SDM.
And their exact placement even differed between the two sites.
Quoted 7 lines
Quoted 5 lines
The Spec Update (no longer available on Intel's website) simply says "issue a CLFLUSH", with no mention of MFENCEs.
As this erratum is specific to Intel, it's fine to remove the the MFENCEs; AMD CPUs of a similar vintage do port otherwise-unordered CLFLUSHs.
Nit: DYM "sport"? I think the corresponding Linux commit that I once looked at has it that way.
Oops, yes I did.
Quoted 4 lines
Quoted 4 lines
Move the feature bit into the BUG range (rather than FEATURE), and move the workaround into
monitor()itself.
Quoted 8 lines
Quoted 7 lines
The erratum check itself must use
setup_force_cpu_cap(). It needs activating if any CPU needs it, not if all of them need it.Fixes 48d32458bcd4 ("x86, idle: add barriers to CLFLUSH workaround")Fixes 96d1b237ae9b ("x86/Intel: work around Xeon 7400 series erratum AAI65")Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>
Thanks.
~Andrew
PATCH 3/4 Revert part of "x86/mwait-idle: disable IBRS during long idle"
In reply to Andrew CooperMost of the patch (handling of CPUIDLE_FLAG_IBRS) is fine, but the adjustements to mwait_idle() are not.
spec_ctrl_{enter,exit}_idle() do more than just alter MSR_SPEC_CTRL.IBRS. The VERW and RSB stuff are **unsafe** to omit.
The only reason this doesn't need an XSA is because no changes were made to the lower level mwait_idle_with_hints(), and thus it remained properly protected.
I.e. This change only served to double the expensive operations in the case it was trying to optimise.
I have an idea of how to plumb this more nicely, but it requires larger changes to legacy IBRS handling to not make spec_ctrl_enter_idle() vulnerable in other ways. In the short term, simply take out the perf hit.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/x86/cpu/mwait-idle.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
xen/arch/x86/cpu/mwait-idle.c +2 -10
@@ -875,7 +875,6 @@ static const struct cpuidle_state snr_cstates[] = { static void cf_check mwait_idle(void) {unsigned int cpu =smp_processor_id (); -struct cpu_info *info =get_cpu_info ();struct acpi_processor_power *power = processor_powers[cpu];struct acpi_processor_cx *cx =NULL ;unsigned int next_state;
@@ -902,6 +901,8 @@ static void cf_check mwait_idle(void)pm_idle_save (); else { +struct cpu_info *info =get_cpu_info (); +spec_ctrl_enter_idle (info);safe_halt ();spec_ctrl_exit_idle (info);
@@ -928,11 +929,6 @@ static void cf_check mwait_idle(void)if ((cx->type >=3 ) &&errata_c6_workaround ()) cx = power->safe_state; -if (cx->ibrs_disable) { -ASSERT (!cx->irq_enable_early); -spec_ctrl_enter_idle (info); - } -#if 0 /* XXX Can we/do we need to do something similar on Xen? */ /* * leave_mm() to avoid costly and often unnecessary wakeups
@@ -964,10 +960,6 @@ static void cf_check mwait_idle(void)/* Now back in C0. */ update_idle_stats (power, cx, before, after); - -if (cx->ibrs_disable) -spec_ctrl_exit_idle (info); -local_irq_enable (); TRACE_TIME(TRC_PM_IDLE_EXIT, cx->type, after,
Signature · 1 line
2.39.5
Re: [PATCH 3/4] Revert part of "x86/mwait-idle: disable IBRS during long idle"
Quoted 10 lines · Andrew Cooper
Most of the patch (handling of
CPUIDLE_FLAG_IBRS) is fine, but the adjustements tomwait_idle()are not.spec_ctrl_{enter,exit}_idle() do more than just alter MSR_SPEC_CTRL.IBRS. The VERW and RSB stuff are **unsafe** to omit.
The only reason this doesn't need an XSA is because no changes were made to the lower level
mwait_idle_with_hints(), and thus it remained properly protected.
Quoted 6 lines
I.e. This change only served to double the expensive operations in the case it was trying to optimise.
I have an idea of how to plumb this more nicely, but it requires larger changes to legacy IBRS handling to not make
spec_ctrl_enter_idle()vulnerable in other ways.
What are the concerns here? As it looks skipping the MSR write would look to require checking some (per-CPU) conditional. Conditional branches can't really be of concern, or the "if (cx->ibrs_disable)" that you're now removing again would have been of concern, too. Hence simply a new SCF_ flag would look to be sufficient, for mwait_idle() to convey the necessary info to spec_ctrl_enter_idle()?
Quoted 4 lines
In the short term, simply take out the perf hit.
Fixes 08acdf9a2615 ("x86/mwait-idle: disable IBRS during long idle")Signed-off-by Andrew Cooper <[email protected]>
Re: [PATCH 3/4] Revert part of "x86/mwait-idle: disable IBRS during long idle"
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Andrew Cooper
Most of the patch (handling of
CPUIDLE_FLAG_IBRS) is fine, but the adjustements tomwait_idle()are not.spec_ctrl_{enter,exit}_idle() do more than just alter MSR_SPEC_CTRL.IBRS. The VERW and RSB stuff are **unsafe** to omit.
The only reason this doesn't need an XSA is because no changes were made to the lower level
mwait_idle_with_hints(), and thus it remained properly protected.I.e. This change only served to double the expensive operations in the case it was trying to optimise.
Quoted 7 lines
Quoted 3 lines
I have an idea of how to plumb this more nicely, but it requires larger changes to legacy IBRS handling to not make
spec_ctrl_enter_idle()vulnerable in other ways.What are the concerns here? As it looks skipping the MSR write would look to require checking some (per-CPU) conditional. Conditional branches can't really be of concern, or the "if (
cx->ibrs_disable)" that you're now removing again would have been of concern, too.
The conditional branches are what set off alarm bells in the first place.
A conditional branch in enter should be ok; HLT and MWAIT should be serialising enough.
A conditional branch in exit is not ok without extra safety measures.
I can expand on this in the commit message if you'd like. I was trying to not be overly critical...
Quoted 3 lines
Hence simply a new
SCF_
flag would look to be sufficient, formwait_idle()to convey the necessary info tospec_ctrl_enter_idle()?
I've got a local patch going that route, but it needs more than just an SCF flag. This is the "requires larger changes".
Quoted 7 lines
Quoted 5 lines
In the short term, simply take out the perf hit.
Fixes 08acdf9a2615 ("x86/mwait-idle: disable IBRS during long idle")Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>
Thanks.
~Andrew
Re: [PATCH 3/4] Revert part of "x86/mwait-idle: disable IBRS during long idle"
Quoted 25 lines · Andrew Cooper
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Andrew Cooper
Most of the patch (handling of
CPUIDLE_FLAG_IBRS) is fine, but the adjustements tomwait_idle()are not.spec_ctrl_{enter,exit}_idle() do more than just alter MSR_SPEC_CTRL.IBRS. The VERW and RSB stuff are **unsafe** to omit.
The only reason this doesn't need an XSA is because no changes were made to the lower level
mwait_idle_with_hints(), and thus it remained properly protected.I.e. This change only served to double the expensive operations in the case it was trying to optimise.
Quoted 7 lines
Quoted 3 lines
I have an idea of how to plumb this more nicely, but it requires larger changes to legacy IBRS handling to not make
spec_ctrl_enter_idle()vulnerable in other ways.What are the concerns here? As it looks skipping the MSR write would look to require checking some (per-CPU) conditional. Conditional branches can't really be of concern, or the "if (
cx->ibrs_disable)" that you're now removing again would have been of concern, too.The conditional branches are what set off alarm bells in the first place.
Quoted 7 lines
A conditional branch in enter should be ok; HLT and MWAIT should be serialising enough.
A conditional branch in exit is not ok without extra safety measures.
I can expand on this in the commit message if you'd like. I was trying to not be overly critical...
For me, the answer here is sufficient, I guess. Hence I won't insist on you amending the description. It may help others and/or some time into the future, though.
Jan
PATCH 4/4 x86/idle: Misc cleanup
In reply to Andrew CooperSort includes, and drop trailing whitespace.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/x86/acpi/cpu_idle.c | 51 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 26 deletions(-)
xen/arch/x86/acpi/cpu_idle.c +25 -26
@@ -1,6 +1,6 @@/* -* cpu_idle - xen idle state module derived from Linux -* drivers/acpi/processor_idle.c & +* cpu_idle - xen idle state module derived from Linux +* drivers/acpi/processor_idle.c & * arch/x86/kernel/acpi/cstate.c * * Copyright (C) 2001, 2002 Andy Grover <[email protected]>
@@ -30,34 +30,34 @@* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include <xen/errno.h> -#include <xen/lib.h> -#include <xen/types.h> #include <xen/acpi.h> -#include <xen/smp.h> +#include <xen/cpu.h> +#include <xen/errno.h> #include <xen/guest_access.h> +#include <xen/irq.h> #include <xen/keyhandler.h> +#include <xen/lib.h> +#include <xen/notifier.h> #include <xen/param.h> -#include <xen/trace.h> -#include <xen/irq.h> -#include <xen/sections.h> - -#include <asm/io.h> -#include <asm/iocap.h> -#include <asm/hpet.h> -#include <asm/processor.h> #include <xen/pmstat.h> +#include <xen/sections.h> +#include <xen/smp.h> #include <xen/softirq.h> -#include <public/platform.h> -#include <public/sysctl.h> +#include <xen/trace.h> +#include <acpi/cpufreq/cpufreq.h> #include <asm/apic.h> #include <asm/cpuidle.h> +#include <asm/hpet.h> +#include <asm/io.h> +#include <asm/iocap.h> #include <asm/mwait.h> -#include <xen/notifier.h> -#include <xen/cpu.h> +#include <asm/processor.h> #include <asm/spec_ctrl.h> +#include <public/platform.h> +#include <public/sysctl.h> +/*#define DEBUG_PM_CX*/ static always_inline void monitor(
@@ -791,7 +791,7 @@ static void cf_check acpi_processor_idle(void)case ACPI_STATE_C3 :/* -* Before invoking C3, be aware that TSC/APIC timer may be +* Before invoking C3, be aware that TSC/APIC timer may be * stopped by H/W. Without carefully handling of TSC/APIC stop issues, * deep C state can't work correctly. */
@@ -1082,7 +1082,7 @@ static int check_cx(struct acpi_processor_power *power, xen_processor_cx_t *cx)break ;case ACPI_ADR_SPACE_FIXED_HARDWARE : -if ( cx->reg.bit_width !=VENDOR_INTEL || +if ( cx->reg.bit_width !=VENDOR_INTEL || cx->reg.bit_offset !=NATIVE_CSTATE_BEYOND_HALT )return -EINVAL ;
@@ -1269,14 +1269,14 @@ static void print_cx_pminfo(uint32_t cpu, struct xen_processor_power *power)"\t pwr_setup_done[%d], bm_rld_set[%d]\n" , power->flags.bm_control, power->flags.bm_check, power->flags.has_cst, power->flags.power_setup_done, power->flags.bm_rld_set); - + states = power->states; - +for ( i =0 ; i < power->count; i++ ) {if (unlikely (copy_from_guest_offset (&state, states, i,1 )) )return ; - +printk ("\tstates[%d]:\n" , i);printk ("\t\treg.space_id = %#x\n" , state.reg.space_id);printk ("\t\treg.bit_width = %#x\n" , state.reg.bit_width);
@@ -1289,7 +1289,7 @@ static void print_cx_pminfo(uint32_t cpu, struct xen_processor_power *power) csd = state.dp;printk ("\t\tdp(@0x%p)\n" , csd.p); - +if ( csd.p !=NULL ) {if (unlikely (copy_from_guest (&dp, csd,1 )) )
@@ -1388,7 +1388,7 @@ long set_cx_pminfo(uint32_t acpi_id, struct xen_processor_power *power) dead_idle = acpi_dead_idle; } - +return 0 ; }
@@ -1676,4 +1676,3 @@ static int __init cf_check cpuidle_presmp_init(void)return 0 ; }presmp_initcall (cpuidle_presmp_init); -
Signature · 1 line
2.39.5
Re: [PATCH 4/4] x86/idle: Misc cleanup
Quoted 5 lines · Andrew Cooper
Sort includes, and drop trailing whitespace.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>