Re: [PATCH 1/3] x86 msr: msr goto extension support
From: Peter Zijlstra
Date: Fri Aug 01 2014 - 04:05:57 EST
On Thu, Jul 31, 2014 at 02:05:48PM -0700, Andy Lutomirski wrote:
> On 07/31/2014 02:41 AM, kan.liang@xxxxxxxxx wrote:
> > +/*
> > + * The _goto version is rdmsrl/wrmsrl with exception handling
> > + * The advantage (than _safe) is that it can directly jump in the
> > + * exception handling code, and never test in the "fast" path.
> > + *
> > + * Since _goto doesn't support output, try to protect the output
> > + * registers by clobbers, and process the registers immediately.
> > + */
> > +#define rdmsrl_goto(msr, result, fail_label) \
> > +do { \
> > + DECLARE_ARGS(val, low, high); \
> > + asm_volatile_goto("2: rdmsr\n" \
> > + "1:\n\t" \
> > + _ASM_EXTABLE(2b, %l[fail_label]) \
> > + : /* No outputs. */ \
> > + : "c" (msr) \
> > + : "%rax", "%rdx" \
> > + : fail_label); \
> > + asm volatile ("" \
> > + : EAX_EDX_RET(val, low, high) \
> > + : ); \
>
> This is scary -- the compiler is free to optimize this incorrectly, and
> it doesn't even seem very farfetched to me.
Quite so, lets add Jakub.
Attachment:
pgpYDSuxiRQb9.pgp
Description: PGP signature