~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/mwait.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/include/asm/mwait.h (Version linux-6.11-rc3) and /arch/i386/include/asm-i386/mwait.h (Version linux-5.0.21)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 #ifndef _ASM_X86_MWAIT_H                          
  3 #define _ASM_X86_MWAIT_H                          
  4                                                   
  5 #include <linux/sched.h>                          
  6 #include <linux/sched/idle.h>                     
  7                                                   
  8 #include <asm/cpufeature.h>                       
  9 #include <asm/nospec-branch.h>                    
 10                                                   
 11 #define MWAIT_SUBSTATE_MASK             0xf       
 12 #define MWAIT_CSTATE_MASK               0xf       
 13 #define MWAIT_SUBSTATE_SIZE             4         
 14 #define MWAIT_HINT2CSTATE(hint)         (((hin    
 15 #define MWAIT_HINT2SUBSTATE(hint)       ((hint    
 16 #define MWAIT_C1_SUBSTATE_MASK  0xf0              
 17                                                   
 18 #define CPUID_MWAIT_LEAF                5         
 19 #define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1       
 20 #define CPUID5_ECX_INTERRUPT_BREAK      0x2       
 21                                                   
 22 #define MWAIT_ECX_INTERRUPT_BREAK       0x1       
 23 #define MWAITX_ECX_TIMER_ENABLE         BIT(1)    
 24 #define MWAITX_MAX_WAIT_CYCLES          UINT_M    
 25 #define MWAITX_DISABLE_CSTATES          0xf0      
 26 #define TPAUSE_C01_STATE                1         
 27 #define TPAUSE_C02_STATE                0         
 28                                                   
 29 static __always_inline void __monitor(const vo    
 30                              unsigned long edx    
 31 {                                                 
 32         /* "monitor %eax, %ecx, %edx;" */         
 33         asm volatile(".byte 0x0f, 0x01, 0xc8;"    
 34                      :: "a" (eax), "c" (ecx),     
 35 }                                                 
 36                                                   
 37 static __always_inline void __monitorx(const v    
 38                               unsigned long ed    
 39 {                                                 
 40         /* "monitorx %eax, %ecx, %edx;" */        
 41         asm volatile(".byte 0x0f, 0x01, 0xfa;"    
 42                      :: "a" (eax), "c" (ecx),     
 43 }                                                 
 44                                                   
 45 static __always_inline void __mwait(unsigned l    
 46 {                                                 
 47         mds_idle_clear_cpu_buffers();             
 48                                                   
 49         /* "mwait %eax, %ecx;" */                 
 50         asm volatile(".byte 0x0f, 0x01, 0xc9;"    
 51                      :: "a" (eax), "c" (ecx));    
 52 }                                                 
 53                                                   
 54 /*                                                
 55  * MWAITX allows for a timer expiration to get    
 56  * addition to the default MWAIT exit conditio    
 57  * monitored virtual address.                     
 58  *                                                
 59  * Registers:                                     
 60  *                                                
 61  * MWAITX ECX[1]: enable timer if set             
 62  * MWAITX EBX[31:0]: max wait time expressed i    
 63  * frequency is the same as the TSC frequency.    
 64  *                                                
 65  * Below is a comparison between MWAIT and MWA    
 66  *                                                
 67  *                 MWAIT                          
 68  * opcode          0f 01 c9           |           
 69  * ECX[0]                  value of RFLAGS.IF     
 70  * ECX[1]          unused/#GP if set  |           
 71  * ECX[31:2]                     unused/#GP if    
 72  * EAX                           unused (reser    
 73  * EBX[31:0]       unused             |           
 74  *                                                
 75  *                 MONITOR                        
 76  * opcode          0f 01 c8           |           
 77  * EAX                     (logical) address t    
 78  * ECX                     #GP if not zero        
 79  */                                               
 80 static __always_inline void __mwaitx(unsigned     
 81                                      unsigned     
 82 {                                                 
 83         /* No MDS buffer clear as this is AMD/    
 84                                                   
 85         /* "mwaitx %eax, %ebx, %ecx;" */          
 86         asm volatile(".byte 0x0f, 0x01, 0xfb;"    
 87                      :: "a" (eax), "b" (ebx),     
 88 }                                                 
 89                                                   
 90 /*                                                
 91  * Re-enable interrupts right upon calling mwa    
 92  * no interrupt can fire _before_ the executio    
 93  * instruction must be placed between "sti" an    
 94  *                                                
 95  * This is necessary because if an interrupt q    
 96  * executing mwait, it would otherwise go unno    
 97  * would not be reprogrammed accordingly befor    
 98  */                                               
 99 static __always_inline void __sti_mwait(unsign    
100 {                                                 
101         mds_idle_clear_cpu_buffers();             
102         /* "mwait %eax, %ecx;" */                 
103         asm volatile("sti; .byte 0x0f, 0x01, 0    
104                      :: "a" (eax), "c" (ecx));    
105 }                                                 
106                                                   
107 /*                                                
108  * This uses new MONITOR/MWAIT instructions on    
109  * which can obviate IPI to trigger checking o    
110  * We execute MONITOR against need_resched and    
111  * through MWAIT. Whenever someone changes nee    
112  * up from MWAIT (without an IPI).                
113  *                                                
114  * New with Core Duo processors, MWAIT can tak    
115  * capability.                                    
116  */                                               
117 static __always_inline void mwait_idle_with_hi    
118 {                                                 
119         if (static_cpu_has_bug(X86_BUG_MONITOR    
120                 if (static_cpu_has_bug(X86_BUG    
121                         mb();                     
122                         clflush((void *)&curre    
123                         mb();                     
124                 }                                 
125                                                   
126                 __monitor((void *)&current_thr    
127                                                   
128                 if (!need_resched()) {            
129                         if (ecx & 1) {            
130                                 __mwait(eax, e    
131                         } else {                  
132                                 __sti_mwait(ea    
133                                 raw_local_irq_    
134                         }                         
135                 }                                 
136         }                                         
137         current_clr_polling();                    
138 }                                                 
139                                                   
140 /*                                                
141  * Caller can specify whether to enter C0.1 (l    
142  * power saving) or C0.2 state (saves more pow    
143  * latency). This may be overridden by the IA3    
144  * which can force requests for C0.2 to be dow    
145  */                                               
146 static inline void __tpause(u32 ecx, u32 edx,     
147 {                                                 
148         /* "tpause %ecx, %edx, %eax;" */          
149         #ifdef CONFIG_AS_TPAUSE                   
150         asm volatile("tpause %%ecx\n"             
151                      :                            
152                      : "c"(ecx), "d"(edx), "a"    
153         #else                                     
154         asm volatile(".byte 0x66, 0x0f, 0xae,     
155                      :                            
156                      : "c"(ecx), "d"(edx), "a"    
157         #endif                                    
158 }                                                 
159                                                   
160 #endif /* _ASM_X86_MWAIT_H */                     
161                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php