diff options
author | Haozhong Zhang <haozhong.zhang@intel.com> | 2015-10-20 03:39:04 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-11-10 06:06:16 -0500 |
commit | 381d585c80e34988269bd7901ad910981e900be1 (patch) | |
tree | 771900b748040495069fdad4c517f658159e3d6c /include/linux/math64.h | |
parent | 35181e86df97e4223f4a28fb33e2bcf3b73de141 (diff) |
KVM: x86: Replace call-back set_tsc_khz() with a common function
Both VMX and SVM propagate virtual_tsc_khz in the same way, so this
patch removes the call-back set_tsc_khz() and replaces it with a common
function.
Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/linux/math64.h')
-rw-r--r-- | include/linux/math64.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/linux/math64.h b/include/linux/math64.h index 44282ec7b682..6e8b5b270ffe 100644 --- a/include/linux/math64.h +++ b/include/linux/math64.h | |||
@@ -214,4 +214,33 @@ static inline u64 mul_u64_u64_shr(u64 a, u64 b, unsigned int shift) | |||
214 | 214 | ||
215 | #endif | 215 | #endif |
216 | 216 | ||
217 | #ifndef mul_u64_u32_div | ||
218 | static inline u64 mul_u64_u32_div(u64 a, u32 mul, u32 divisor) | ||
219 | { | ||
220 | union { | ||
221 | u64 ll; | ||
222 | struct { | ||
223 | #ifdef __BIG_ENDIAN | ||
224 | u32 high, low; | ||
225 | #else | ||
226 | u32 low, high; | ||
227 | #endif | ||
228 | } l; | ||
229 | } u, rl, rh; | ||
230 | |||
231 | u.ll = a; | ||
232 | rl.ll = (u64)u.l.low * mul; | ||
233 | rh.ll = (u64)u.l.high * mul + rl.l.high; | ||
234 | |||
235 | /* Bits 32-63 of the result will be in rh.l.low. */ | ||
236 | rl.l.high = do_div(rh.ll, divisor); | ||
237 | |||
238 | /* Bits 0-31 of the result will be in rl.l.low. */ | ||
239 | do_div(rl.ll, divisor); | ||
240 | |||
241 | rl.l.high = rh.l.low; | ||
242 | return rl.ll; | ||
243 | } | ||
244 | #endif /* mul_u64_u32_div */ | ||
245 | |||
217 | #endif /* _LINUX_MATH64_H */ | 246 | #endif /* _LINUX_MATH64_H */ |