Re: [PATCH] make KVM conform to sucky rdmsr interface

Andrew Morton
2007-03-22T21:30:11Z

On Thu, 22 Mar 2007 18:49:30 +1100
Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org> wrote:

> rdmsr_safe() takes pointers. rdmsr() modifies its arguments. What a
> mess.
>
> Fix rdmsr_safe() with !CONFIG_PARAVIRT.
>
> Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
>
> diff -r a7f78e8eacc8 include/asm-i386/msr.h
> --- a/include/asm-i386/msr.h Thu Mar 22 12:38:35 2007 +1100
> +++ b/include/asm-i386/msr.h Thu Mar 22 18:40:35 2007 +1100
> @@ -96,12 +96,12 @@ static inline void wrmsrl (unsigned long
> (native_write_msr(msr, ((unsigned long long)val2 << 32) | val1))
>
> /* rdmsr with exception handling */
> -#define rdmsr_safe(msr,val1,val2) \
> +#define rdmsr_safe(msr,p1,p2) \
> ({ \
> int __err; \
> - unsigned long long __val = native_read_msr(msr, &__err); \
> - val1 = __val; \
> - val2 = __val >> 32; \
> + unsigned long long __val = native_read_msr(msr, &__err);\
> + (*p1) = __val; \
> + (*p2) = __val >> 32; \
> __err; \
> })

Linus's tree has

/* rdmsr with exception handling */
#define rdmsr_safe(msr,a,b) ({ int ret__; \
asm volatile("2: rdmsr ; xorl %0,%0\n" \
"1:\n\t" \
".section .fixup,\"ax\"\n\t" \
"3: movl %4,%0 ; jmp 1b\n\t" \
".previous\n\t" \
".section __ex_table,\"a\"\n" \
" .align 4\n\t" \
" .long 2b,3b\n\t" \
".previous" \
: "=r" (ret__), "=a" (*(a)), "=d" (*(b)) \
: "c" (msr), "i" (-EFAULT));\
ret__; })

(secret decoder ring: resize your xterm to 100 cols to read the above. Sigh).

Which tree are you patching??