Date: Mon, 7 Apr 2003 01:00:47 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 28417 for review Message-ID: <200304070800.h3780lLb050926@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=28417 Change 28417 by peter@peter_overcee on 2003/04/07 01:00:41 argh. dont ask for 64 bit register when we mean %eax/%edx. Otherwise we get what we ask for.. The *msr instructions are 32 bit.. (!) Affected files ... .. //depot/projects/hammer/sys/x86_64/include/cpufunc.h#9 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/include/cpufunc.h#9 (text+ko) ==== @@ -315,37 +315,37 @@ static __inline u_long read_rflags(void) { - u_long ef; + u_long rf; - __asm __volatile("pushfq; popq %0" : "=r" (ef)); - return (ef); + __asm __volatile("pushfq; popq %0" : "=r" (rf)); + return (rf); } static __inline u_int64_t rdmsr(u_int msr) { - u_int64_t rv; + u_int32_t low, high; - __asm __volatile("rdmsr" : "=A" (rv) : "c" (msr)); - return (rv); + __asm __volatile("rdmsr" : "=a" (low), "=d" (high) : "c" (msr)); + return (low | ((u_int64_t)high << 32)); } static __inline u_int64_t rdpmc(u_int pmc) { - u_int64_t rv; + u_int32_t low, high; - __asm __volatile("rdpmc" : "=A" (rv) : "c" (pmc)); - return (rv); + __asm __volatile("rdpmc" : "=a" (low), "=d" (high) : "c" (pmc)); + return (low | ((u_int64_t)high << 32)); } static __inline u_int64_t rdtsc(void) { - u_int64_t rv; + u_int32_t low, high; - __asm __volatile("rdtsc" : "=A" (rv)); - return (rv); + __asm __volatile("rdtsc" : "=a" (low), "=d" (high)); + return (low | ((u_int64_t)high << 32)); } static __inline void @@ -355,15 +355,19 @@ } static __inline void -write_rflags(u_long ef) +write_rflags(u_long rf) { - __asm __volatile("pushq %0; popfq" : : "r" (ef)); + __asm __volatile("pushq %0; popfq" : : "r" (rf)); } static __inline void wrmsr(u_int msr, u_int64_t newval) { - __asm __volatile("wrmsr" : : "A" (newval), "c" (msr)); + u_int32_t low, high; + + low = newval; + high = newval >> 32; + __asm __volatile("wrmsr" : : "a" (low), "d" (high), "c" (msr)); } static __inline void @@ -557,11 +561,11 @@ u_int64_t rdtsc(void); u_int read_rflags(void); void wbinvd(void); -void write_rflags(u_int ef); +void write_rflags(u_int rf); void wrmsr(u_int msr, u_int64_t newval); void load_dr7(u_int dr7); register_t intr_disable(void); -void intr_restore(register_t ef); +void intr_restore(register_t rf); #endif /* __GNUC__ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304070800.h3780lLb050926>