Re: [PATCH v5 08/13] x86/fsgsbase/64: Introduce the FIND_PERCPU_BASE macro

From: Bae, Chang Seok
Date: Wed Feb 13 2019 - 13:47:41 EST



> On Feb 2, 2019, at 09:17, Andy Lutomirski <luto@xxxxxxxxxx> wrote:
>
> On Fri, Feb 1, 2019 at 12:55 PM Chang S. Bae <chang.seok.bae@xxxxxxxxx> wrote:
>>
>> +
>> +/*
>> + * CPU/node NR is loaded from the limit (size) field of a special segment
>> + * descriptor entry in GDT.
>> + */
>> +.macro LOAD_CPU_AND_NODE_SEG_LIMIT reg:req
>> + movq $__CPUNODE_SEG, \reg
>> + lsl \reg, \reg
>> +.endm
>> +
>
> Please put the alternative in here instead of in FIND_PERCPU_BASE.

I would like to apply your comment though, build errors will come up due to the
__CPUNODE_SEG. So, still hoping the alternative line below is straightforward enough.
Will send out a revision, that reflects all other comments, shortly.

Chang

>
>> +/*
>> + * Fetch the per-CPU GSBASE value for this processor and put it in @reg.
>> + * We normally use %gs for accessing per-CPU data, but we are setting up
>> + * %gs here and obviously can not use %gs itself to access per-CPU data.
>> + */
>> +.macro FIND_PERCPU_BASE reg:req
>>
>> + ALTERNATIVE \
>> + "LOAD_CPU_AND_NODE_SEG_LIMIT \reg", \
>> + "RDPID \reg", \
>> + X86_FEATURE_RDPID
>> + andq $VDSO_CPUNODE_MASK, \reg
>> + movq __per_cpu_offset(, \reg, 8), \reg
>> +.endm