[PATCH v3 5/7] arm64: move kernel mapping out of linear region
Ard Biesheuvel
ard.biesheuvel at linaro.org
Mon Dec 7 04:34:19 PST 2015
On 7 December 2015 at 13:33, Ard Biesheuvel <ard.biesheuvel at linaro.org> wrote:
> On 7 December 2015 at 13:26, Catalin Marinas <catalin.marinas at arm.com> wrote:
>> On Mon, Nov 16, 2015 at 12:23:16PM +0100, Ard Biesheuvel wrote:
>>> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
>>> index 23cfc08fc8ba..d3e4b5d6a8d2 100644
>>> --- a/arch/arm64/kernel/head.S
>>> +++ b/arch/arm64/kernel/head.S
>> [...]
>>> @@ -210,7 +210,15 @@ section_table:
>>> ENTRY(stext)
>>> bl preserve_boot_args
>>> bl el2_setup // Drop to EL1, w20=cpu_boot_mode
>>> - adrp x24, __PHYS_OFFSET
>>> +
>>> + /*
>>> + * Before the linear mapping has been set up, __va() translations will
>>> + * not produce usable virtual addresses unless we tweak PHYS_OFFSET to
>>> + * compensate for the offset between the kernel mapping and the base of
>>> + * the linear mapping. We will undo this in map_mem().
>>> + */
>>
>> Minor typo in comment: I guess you meant "__pa() translations will not
>> produce usable...".
>>
>
> No, not quite. __va() translations will normally produce addresses in
> the linear mapping, which will not be set up when we first start using
> it in create_mapping(). So until that time, we have to redirect __va()
> translations into the kernel mapping, where swapper_pg_dir is
> shadowed. I am hoping that Mark's planned changes to create_mapping()
> will make this unnecessary, but I haven't seen any of his code yet.
>
> As far as __pa() is concerned, that translation is actually tweaked so
> it will always produce usable addresses, regardless of whether the
> bias is still set or not. The reason is that va-to-pa translations are
> always unambiguous.
>
... so of course, the comment is still wrong, -> s/virtual/physical/ addresses
>>> diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c
>>> index 5a22a119a74c..f6272f450688 100644
>>> --- a/arch/arm64/mm/dump.c
>>> +++ b/arch/arm64/mm/dump.c
>>> @@ -63,7 +63,8 @@ static struct addr_marker address_markers[] = {
>>> { PCI_IO_END, "PCI I/O end" },
>>> { MODULES_VADDR, "Modules start" },
>>> { MODULES_END, "Modules end" },
>>> - { PAGE_OFFSET, "Kernel Mapping" },
>>> + { KIMAGE_VADDR, "Kernel Mapping" },
>>> + { PAGE_OFFSET, "Linear Mapping" },
>>> { -1, NULL },
>>> };
>>
>> Apart from this, please change the pr_notice() in mem_init() to show the
>> linear mapping at the end (keep them in ascending order).
>>
>
> OK
More information about the linux-arm-kernel
mailing list