mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: Jun Yao <yaojun8558363@gmail.com>,
	linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
	will.deacon@arm.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/6] arm64/mm: Create the initial page table in the init_pg_dir.
Date: Mon, 1 Oct 2018 14:49:05 +0100	[thread overview]
Message-ID: <d3e8eae0-3429-d0ab-9e77-a56e26791450@arm.com> (raw)
In-Reply-To: <20180924133437.zr2u5c42rfmhro6o@lakrids.cambridge.arm.com>

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

  reply	other threads:[~2018-10-01 13:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-17  4:43 [PATCH v5 0/6] Move swapper_pg_dir to rodata section Jun Yao
2018-09-17  4:43 ` [PATCH v5 1/6] arm64/mm: Introduce the init_pg_dir Jun Yao
2018-09-24 13:01   ` Mark Rutland
2018-09-24 14:03     ` Mark Rutland
2018-09-17  4:43 ` [PATCH v5 2/6] arm64/mm: Pass ttbr1 as a parameter to __enable_mmu() Jun Yao
2018-09-24 13:26   ` Mark Rutland
2018-09-17  4:43 ` [PATCH v5 3/6] arm64/mm: Create the initial page table in the init_pg_dir Jun Yao
2018-09-24 13:34   ` Mark Rutland
2018-10-01 13:49     ` James Morse [this message]
2018-09-17  4:43 ` [PATCH v5 4/6] arm64/mm: Create the final page table directly in swapper_pg_dir Jun Yao
2018-09-17  4:43 ` [PATCH v5 5/6] arm64/mm: Populate the swapper_pg_dir by fixmap Jun Yao
2018-09-24 16:36   ` Mark Rutland
2018-10-01 10:41     ` James Morse
2018-10-01 13:49       ` James Morse
2018-09-24 16:54   ` Mark Rutland
2018-09-17  4:43 ` [PATCH v5 6/6] arm64/mm: Move {idmap_pg_dir .. swapper_pg_dir} to rodata section Jun Yao
2018-09-21 22:26 ` [PATCH v5 0/6] Move swapper_pg_dir " James Morse
2018-09-25  8:56   ` Jun Yao
2018-09-24 17:19 ` Mark Rutland
2018-09-25  9:53   ` Jun Yao
2018-09-25 14:06     ` Mark Rutland, catalin.marinas
2018-09-25 14:38       ` Catalin Marinas
2018-10-03 13:33       ` James Morse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3e8eae0-3429-d0ab-9e77-a56e26791450@arm.com \
    --to=james.morse@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=will.deacon@arm.com \
    --cc=yaojun8558363@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®