[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 1/7] x86: Add support for STAC/CLAC instructions




> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@xxxxxxxx]
> Sent: Wednesday, April 23, 2014 6:17 PM
> To: Wu, Feng
> Cc: andrew.cooper3@xxxxxxxxxx; ian.campbell@xxxxxxxxxx; Dong, Eddie;
> Nakajima, Jun; Tian, Kevin; xen-devel@xxxxxxxxxxxxx
> Subject: Re: [PATCH v2 1/7] x86: Add support for STAC/CLAC instructions
> 
> >>> On 23.04.14 at 16:34, <feng.wu@xxxxxxxxx> wrote:
> > @@ -103,4 +105,45 @@ void ret_from_intr(void);
> >
> >  #endif
> >
> > +/* "Raw" instruction opcodes */
> > +#define __ASM_CLAC      .byte 0x0f,0x01,0xca
> > +#define __ASM_STAC      .byte 0x0f,0x01,0xcb
> > +
> > +#ifdef __ASSEMBLY__
> > +#define ASM_AC(op)                                       \
> > +        pushq %rax;                                      \
> > +        leaq boot_cpu_data(%rip), %rax;                  \
> > +        btl $X86_FEATURE_SMAP-7*32, CPUINFO86_leaf7_features(%rax);
> \
> > +        jnc 881f;                                        \
> > +        op;                                              \
> > +881:    popq %rax
> 
> So why are you pushing/popping %rax here? There's no need for the
> lea.
> 
> And the hard coded 7 here should be replaced too; I don't see a need
> for CPUINFO86_leaf7_features either - just calculate everything you
> need from X86_FEATURE_SMAP (these are all constants, so other than
> the expression getting a little long there's nothing keeping this from
> being a single btl).

In my understanding, CPUINFO86_leaf7_features is the offset for
x86_capability[i] in struct cpuinfo_x86{}, seems we cannot get the
right offset only from X86_FEATURE_SMAP?

> 
> > +#define ASM_STAC(prefix) ASM_AC(__ASM_STAC, prefix)
> > +#define ASM_CLAC(prefix) ASM_AC(__ASM_CLAC, prefix)
> 
> What is "prefix" good for here, i.e. why can't you put the % right
> in the macro?

Because this macro will be used in the basic inline assembly (use "%" as the 
register prefix)
and extended assembly (use "%%" as the register prefix).

> 
> Jan

Thanks,
Feng

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.