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

Re: [Xen-devel] [PATCH v8 2/7] x86: Clear AC bit in RFLAGS to protect Xen itself by SMAP

>>> On 09.05.14 at 11:32, <JBeulich@xxxxxxxx> wrote:
>>>> On 09.05.14 at 07:34, <feng.wu@xxxxxxxxx> wrote:
>> --- a/xen/include/asm-x86/asm_defns.h
>> +++ b/xen/include/asm-x86/asm_defns.h
>> @@ -190,7 +190,12 @@ static inline void stac(void)
>>  #endif
>>  #ifdef __ASSEMBLY__
>> -.macro SAVE_ALL
>> +.macro SAVE_ALL op=0
>> +.if \op == CLAC
>> +        ASM_CLAC
>> +.elseif \op == STAC
>> +        ASM_STAC
>> +.endif
> If this really works with all assembler versions we support, that's of
> course fine; I wouldn't have thought this is being accepted by gas.

Just tried it out - it sort of works, but leverages what as far as I know
is undefined behavior: It ends up inserting undefined symbols CLAC
and STAC into the symbol table, which the linker is free to error out

So instead of (just giving the example I experimented with)

.macro m1 a=0
.if \a == A
        .byte   1
.elseif \a == B
        .byte   -1
        .byte   0

please use

.macro m2 a
.ifeqs "\a", "A"
        .byte   2
.ifeqs "\a", "B"
        .byte   -2
.ifnb \a

(except of course you can't use .exitm directly in SAVE_ALL, i.e. you
either need to use nested if/else constructs or a second helper macro.

Yet another option would be to simply use the concatenation ASM_\a
if \a is non-empty, but that would require ASM_STAC and ASM_CLAC to
become assembler equates or some such rather than C preprocessor


Xen-devel mailing list



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