Re: [PATCH v4 12/19] ARM: LPAE: Add context switching support

From: Catalin Marinas
Date: Sat Feb 19 2011 - 18:17:03 EST


On Saturday, 19 February 2011, Russell King - ARM Linux
<linux@xxxxxxxxxxxxxxxx> wrote:
> On Mon, Feb 14, 2011 at 01:24:06PM +0000, Catalin Marinas wrote:
>> On Sat, 2011-02-12 at 10:44 +0000, Russell King - ARM Linux wrote:
>> > On Mon, Jan 24, 2011 at 05:55:54PM +0000, Catalin Marinas wrote:
>> > > +#ifdef CONFIG_ARM_LPAE
>> > > +#define cpu_set_asid(asid) { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
>> > > + Â Â unsigned long ttbl, ttbh; Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
>> > > +   asm("  mrrc  Âp15, 0, %0, %1, c2       Â@ read TTBR0\n" \
>> > > +     "  mov   %1, %1, lsl #(48 - 32)     Â@ set ASID\n"  \
>> > > +     "  mcrr  Âp15, 0, %0, %1, c2       Â@ set TTBR0\n" Â\
>> > > + Â Â Â Â : "=r" (ttbl), "=r" (ttbh) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â\
>> > > + Â Â Â Â : "r" (asid & ~ASID_MASK)); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
>> >
>> > This is wrong:
>> > 1. It does nothing with %2 (the new asid)
>> > 2. it shifts the high address bits of TTBR0 left 16 places each time its
>> > Â Âcalled.
>>
>> It was worse actually, not even compiled in because it had output
>> arguments but it wasn't volatile. Some early clobber is also needed.
>> What about this:
>>
>> #define cpu_set_asid(asid) { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â\
>> Â Â Â unsigned long ttbl, ttbh; Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
>> Â Â Â asm volatile( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
>>    "    mrrc  Âp15, 0, %0, %1, c2       Â@ read TTBR0\n" \
>>    "    mov   %1, %2, lsl #(48 - 32)     Â@ set ASID\n"  \
>>    "    mcrr  Âp15, 0, %0, %1, c2       Â@ set TTBR0\n" Â\
>> Â Â Â : "=&r" (ttbl), "=&r" (ttbh) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â\
>> Â Â Â : "r" (asid & ~ASID_MASK)); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
>> }
>
> So we don't care about the low 16 bits of ttbh which can be simply zeroed?

Since the pgd is always allocated from lowmem, it is within 32-bit of
physical address and we can safely ignore ttbh. I could write a
comment here to this.

Catalin

--
Catalin
¢éì®&Þ~º&¶¬–+-±éÝ¥Šw®žË±Êâmébžìdz¹Þ)í…æèw*jg¬±¨¶‰šŽŠÝj/êäz¹ÞŠà2ŠÞ¨è­Ú&¢)ß«a¶Úþø®G«éh®æj:+v‰¨Šwè†Ù>Wš±êÞiÛaxPjØm¶Ÿÿà -»+ƒùdš_