Re: [PATCH 2/2] ARM: LPAE: reduce damage caused by idmap to virtual memory layout
From: Konstantin Khlebnikov
Date: Tue Jul 29 2014 - 08:37:16 EST
On Tue, Jul 29, 2014 at 2:57 PM, Russell King - ARM Linux
<linux@xxxxxxxxxxxxxxxx> wrote:
> On Mon, Jul 28, 2014 at 11:57:16PM +0400, Konstantin Khlebnikov wrote:
>> On Mon, Jul 28, 2014 at 11:42 PM, Russell King - ARM Linux
>> <linux@xxxxxxxxxxxxxxxx> wrote:
>> > On Mon, Jul 28, 2014 at 11:29:39PM +0400, Konstantin Khlebnikov wrote:
>> >> Ok, before switching from identity mapping to normal mapping kernel must
>> >> switch instruction pointer from physical address to virtual.
>> >
>> > "switch instruction pointer from physical address to virtual."
>> >
>> > There's no such distinction for the instruction pointer.
>>
>> I know. I mean "logically".
>>
> ...
>>
>> Sorry but I'm really look so dumb? Maybe it's true, it's almost
>> midnight at my side.
>
> When you use language which suggests a lack of understanding, then
> I will explain things.
>
>> > It doesn't matter, provided the kernel text and data in the virtual
>> > address space are not overwritten by the identity mapping. If it
>> > ends up in the vmalloc or IO space, that should not be a problem.
>>
>> In my case it's been overwritten.
>> And it always happens when PHYS_OFFSET >= PAGE_OFFSET
>> because in case of LPAE idmap always overwrites 1Gb at once.
>
> Right, I now see what you're getting at. Here's a better description
> which I've used when committing your patch. I've only taken patch 2
> at the present time.
>
>
Ok. Thank you for your time.
>
> On LPAE, each level 1 (pgd) page table entry maps 1GiB, and the level 2
> (pmd) entries map 2MiB.
>
> When the identity mapping is created on LPAE, the pgd pointers are copied
> from the swapper_pg_dir. If we find that we need to modify the contents
> of a pmd, we allocate a new empty pmd table and insert it into the
> appropriate 1GB slot, before then filling it with the identity mapping.
>
> However, if the 1GB slot covers the kernel lowmem mappings, we obliterate
> those mappings.
>
> When replacing a PMD, first copy the old PMD contents to the new PMD, so
> that we preserve the existing mappings in the 1GiB region, particularly
> the mappings of the kernel itself.
>
>
> --
> FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
> according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/