Mapping an executable page

Thomas De Schampheleire patrickdepinguin+linuxppc at gmail.com
Wed Jun 22 17:52:29 EST 2011


On Tue, Jun 14, 2011 at 10:26 PM, Scott Wood <scottwood at freescale.com> wrote:
> On Tue, 14 Jun 2011 10:56:31 +0200
> Thomas De Schampheleire <patrickdepinguin+linuxppc at gmail.com> wrote:
>
>> * Therefore, to make sure that the mapping I intended with __ioremap()
>> is actually reflected in the TLB tables, I added dummy reads of each
>> page in the TLB, prior to jumping to the boot code, as follows:
>>                 /* make sure memory is read, once every 4Kbyte is enough */
>>                 for (p = vaddr; p < vaddr + map_size; p += 0x1000) {
>>                         unsigned long dummy = *(volatile unsigned long *)p;
>>                         (void)dummy;
>>                 }
>>
>> * After these changes (make sure all code is mapped + make sure to
>> read all pages so that the TLBs are updated), my scenario works fine.
>
> This is fragile -- you are assuming that it's possible to fit this
> set of pages in TLB0 all at once, and that none of them will be
> evicted/invalidated by the time you're done.

You're right. I think that disabling interrupts (which I can do
because I'm in a reset scenario) should fix this right? See also my
reply to Timur Tabi's post.

>
> If you really need to do this, I sugest using settlbcam() from
> arch/powerpc/mm/fsl_booke_mmu.c to create TLB1 entries with IPROT set.

Unfortunately, settlbcam is not exported to modules. Since I prefer to
be able to do all this from a kernel module, I cannot use that
function. Thanks for the suggestion though.

>
> Better still if you could live with whatever memory the kernel has already
> pinned.

In this case it is not possible. I need to jump to boot code which is
residing somewhere in physical RAM, outside the kernel memory ranges.

Best regards,
Thomas


More information about the Linuxppc-dev mailing list