Re: [tip:x86/asm] x86/i386: Make sure stack-protector segment base is cache aligned

Tejun Heo
2009-09-04T02:51:57Z

Hello,

H. Peter Anvin wrote:
> On 09/03/2009 01:45 PM, Jeremy Fitzhardinge wrote:
>> Two problems:
>>
>> * gcc generates %gs: references for stack-protector, but we use %fs
>> for percpu data (because restoring %fs is faster if it's a null
>> selector; TLS uses %gs). I guess we could use %fs if
>> !CONFIG_CC_STACKPROTECTOR, or %gs if we are using it (though that
>> has some fiddly ramifications for things like ptrace).
>
> Well, by touching two segments we're getting the worst of both worlds,
> so at least assuming some significant number of real-world deployments
> use CC_STACKPROTECTOR, we really don't want to pessimize that case too much.

Yes, this one definitely seems doable. BTW, how much performance does
CC_STACKPROTECTOR cost? That's an ambiguous question but really any
number would help to develop a general sense. Considering fedora is
doing it by default, I assume it isn't too high?

>> * The i386 percpu %fs base is offset by -__per_cpu_start from the
>> percpu variables, so we can directly refer to %fs:per_cpu__foo.
>> I'm not sure what it would take to unify i386 to use the same
>> scheme as x86-64.
>
> OK, I was under the impression that that had already been done (and no,
> I didn't bother to look at the code.) I guess I was wrong (and yes,
> this is an absolute precondition.)

I tried this a while ago but hit an obstacle which I don't remember
what exactly was now and decided the conversion wasn't worth the
trouble. IIRC, it was something substantial. I'll dig through my
trees.

Thanks.

--
tejun