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

Re: [Xen-devel] [PATCH v3 3/9] x86: Add support for STAC/CLAC instructions



>>> On 28.04.14 at 05:15, <feng.wu@xxxxxxxxx> wrote:
> The STAC/CLAC instructions are only available when SMAP is enabled,
> but on the other hand they aren't needed if SMAP is not available,

I think you got the "enabled" and "available" mixed up here.

> @@ -105,4 +107,48 @@ 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 CPUINFO_FEATURE_OFFSET(feature)                  \
> +        (((feature >> 3) & ~3) + CPUINFO_features)

I gues this wants to go into patch 1.

> +
> +#define ASM_AC(op)                                       \
> +        btl $X86_FEATURE_SMAP & 31,                      \
> +        CPUINFO_FEATURE_OFFSET(X86_FEATURE_SMAP)+boot_cpu_data(%rip); \
> +        jnc 881f;                                        \
> +        op;                                              \
> +881:
> +
> +#define ASM_STAC ASM_AC(__ASM_STAC)
> +#define ASM_CLAC ASM_AC(__ASM_CLAC)

Please pass only STAC/CLAC here, and concatenate the __ASM_
onto them inside the macro (reducing the chance of abuse and
slightly increasing readability).

> +#else
> +#define CPUINFO_FEATURE_OFFSET(feature)                  \
> +        "(((" __stringify(feature) ">> 3) & ~3) + "      \
> +        __stringify(CPUINFO_features)")"
> +
> +#define ASM_AC(op)                                       \
> +        "btl $" __stringify(X86_FEATURE_SMAP) "&31, "    \
> +        CPUINFO_FEATURE_OFFSET(X86_FEATURE_SMAP)         \
> +        "+ boot_cpu_data(%%rip)\n\t"                     \
> +        "jnc 881f\n\t"                                   \
> +         __stringify(op) "\n\t"                          \
> +"881:"
> +
> +#define ASM_STAC ASM_AC(__ASM_STAC)
> +#define ASM_CLAC ASM_AC(__ASM_CLAC)

Also, with these now being identical between asm and C, they could
move ahead of the conditional block.

Jan


_______________________________________________
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®.