Lines Matching +full:low +full:- +full:to +full:- +full:high
1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include "msr-index.h"
38 * both i386 and x86_64 returns 64-bit value in edx:eax, but gcc's "A"
44 /* Using 64-bit values saves one instruction clearing the high half of low */
45 #define DECLARE_ARGS(val, low, high) unsigned long low, high argument
46 #define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32) argument
47 #define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high) argument
49 #define DECLARE_ARGS(val, low, high) unsigned long long val argument
50 #define EAX_EDX_VAL(val, low, high) (val) argument
51 #define EAX_EDX_RET(val, low, high) "=A" (val) argument
55 * Be very careful with includes. This header is prone to include loops.
58 #include <linux/tracepoint-defs.h>
76 * on them - those are *purely* for accessing MSRs and nothing more. So don't even
77 * think of extending them - you will be slapped with a stinking trout or a frozen
82 DECLARE_ARGS(val, low, high); in __rdmsr()
87 : EAX_EDX_RET(val, low, high) : "c" (msr)); in __rdmsr()
89 return EAX_EDX_VAL(val, low, high); in __rdmsr()
92 static __always_inline void __wrmsr(unsigned int msr, u32 low, u32 high) in __wrmsr() argument
97 : : "c" (msr), "a"(low), "d" (high) : "memory"); in __wrmsr()
107 #define native_wrmsr(msr, low, high) \ argument
108 __wrmsr(msr, low, high)
129 DECLARE_ARGS(val, low, high); in native_read_msr_safe()
134 : [err] "=r" (*err), EAX_EDX_RET(val, low, high) in native_read_msr_safe()
137 do_trace_read_msr(msr, EAX_EDX_VAL(val, low, high), *err); in native_read_msr_safe()
138 return EAX_EDX_VAL(val, low, high); in native_read_msr_safe()
143 native_write_msr(unsigned int msr, u32 low, u32 high) in native_write_msr() argument
145 __wrmsr(msr, low, high); in native_write_msr()
148 do_trace_write_msr(msr, ((u64)high << 32 | low), 0); in native_write_msr()
153 native_write_msr_safe(unsigned int msr, u32 low, u32 high) in native_write_msr_safe() argument
161 : "c" (msr), "0" (low), "d" (high) in native_write_msr_safe()
164 do_trace_write_msr(msr, ((u64)high << 32 | low), err); in native_write_msr_safe()
172 * rdtsc() - returns the current TSC without ordering constraints
174 * rdtsc() returns the result of RDTSC as a 64-bit integer. The
178 * results can be non-monotonic if compared on different CPUs.
182 DECLARE_ARGS(val, low, high); in rdtsc()
184 asm volatile("rdtsc" : EAX_EDX_RET(val, low, high)); in rdtsc()
186 return EAX_EDX_VAL(val, low, high); in rdtsc()
190 * rdtsc_ordered() - read the current TSC in program order
192 * rdtsc_ordered() returns the result of RDTSC as a 64-bit integer.
193 * It is ordered like a load to a global in-memory counter. It should
194 * be impossible to observe non-monotonic rdtsc_unordered() behavior
199 DECLARE_ARGS(val, low, high); in rdtsc_ordered()
202 * The RDTSC instruction is not ordered relative to memory in rdtsc_ordered()
206 * immediately after an appropriate barrier appears to be in rdtsc_ordered()
218 : EAX_EDX_RET(val, low, high) in rdtsc_ordered()
222 return EAX_EDX_VAL(val, low, high); in rdtsc_ordered()
227 DECLARE_ARGS(val, low, high); in native_read_pmc()
229 asm volatile("rdpmc" : EAX_EDX_RET(val, low, high) : "c" (counter)); in native_read_pmc()
231 do_trace_rdpmc(counter, EAX_EDX_VAL(val, low, high), 0); in native_read_pmc()
232 return EAX_EDX_VAL(val, low, high); in native_read_pmc()
240 * Access to machine-specific registers (available on 586 and better only)
242 * pointer indirection), this allows gcc to optimize better
245 #define rdmsr(msr, low, high) \ argument
248 (void)((low) = (u32)__val); \
249 (void)((high) = (u32)(__val >> 32)); \
252 static inline void wrmsr(unsigned int msr, u32 low, u32 high) in wrmsr() argument
254 native_write_msr(msr, low, high); in wrmsr()
266 static inline int wrmsr_safe(unsigned int msr, u32 low, u32 high) in wrmsr_safe() argument
268 return native_write_msr_safe(msr, low, high); in wrmsr_safe()
272 #define rdmsr_safe(msr, low, high) \ argument
276 (*low) = (u32)__val; \
277 (*high) = (u32)(__val >> 32); \
289 #define rdpmc(counter, low, high) \ argument
292 (low) = (u32)_l; \
293 (high) = (u32)(_l >> 32); \
301 * 64-bit version of wrmsr_safe():