lkml.org 
[lkml]   [2018]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v5 3/6] arm64/mm: Create the initial page table in the init_pg_dir.
From
Date
Hi Mark,

On 24/09/18 14:34, Mark Rutland wrote:
> On Mon, Sep 17, 2018 at 12:43:30PM +0800, Jun Yao wrote:
>> Create the initial page table in the init_pg_dir. And update the
>> init_mm.pgd to make sure that pgd_offset_k() works correctly. When
>> the final page table is created, we redirect the init_mm.pgd to the
>> swapper_pg_dir.

>> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
>> index de2aaea00bd2..cf8a58211b80 100644
>> --- a/arch/arm64/kernel/head.S
>> +++ b/arch/arm64/kernel/head.S
>> @@ -376,7 +376,7 @@ __create_page_tables:
>> /*
>> * Map the kernel image (starting with PHYS_OFFSET).
>> */
>> - adrp x0, swapper_pg_dir
>> + adrp x0, init_pg_dir
>> mov_q x5, KIMAGE_VADDR + TEXT_OFFSET // compile time __va(_text)
>> add x5, x5, x23 // add KASLR displacement
>> mov x4, PTRS_PER_PGD
>> @@ -439,6 +439,11 @@ __primary_switched:
>> bl __pi_memset
>> dsb ishst // Make zero page visible to PTW
>>
>> + // Update init_mm.pgd
>> + adrp x0, init_pg_dir
>> + adr_l x1, init_mm
>> + str x0, [x1, #MM_PGD]
>> +
>
> We should be able to set this up statically with INIT_MM_CONTEXT(). i.e.
> in <asm/mmu.h> have:
>
> #define INIT_MM_CONTEXT(name) \
> .pgd = init_pg_dir

Aha, I didn't think this would be possible because we end up setting .pgd twice,
but gcc says that's fine, it gets the last value:
https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

(and it looks like clang has a test for this)


Thanks,

James

\
 
 \ /
  Last update: 2018-10-01 15:50    [W:0.065 / U:1.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site