Re: [PATCH v5 0/6] Move swapper_pg_dir to rodata section.

2018-09-25 Thread Jun Yao
Hi Mark, On Mon, Sep 24, 2018 at 06:19:36PM +0100, Mark Rutland wrote: > Hi, > > On Mon, Sep 17, 2018 at 12:43:27PM +0800, Jun Yao wrote: > > Version 5 changes: > > 1. Correct spelling and indentation errors[1]. > > 2. Update init_mm.pgd by assembly[2]. >

Re: [PATCH v5 0/6] Move swapper_pg_dir to rodata section.

2018-09-25 Thread Jun Yao
Hi James, On Fri, Sep 21, 2018 at 11:26:39PM +0100, James Morse wrote: > Hi Jun, > > On 09/17/2018 05:43 AM, Jun Yao wrote: > > Version 5 changes: > > 1. Correct spelling and indentation errors[1]. > > 2. Update init_mm.pgd by assembly[2]. > > 3.

[PATCH v5 6/6] arm64/mm: Move {idmap_pg_dir .. swapper_pg_dir} to rodata section.

2018-09-16 Thread Jun Yao
Move the idmap_pg_dir/tramp_pg_dir/reserved_ttbr0/swapper_pg_dir to the rodata section. When the kernel is initialized, the idmap_pg_dir, tramp_pg_dir and reserved_ttbr0 will not change. And it's safe to move them to rodata section. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.

[PATCH v5 4/6] arm64/mm: Create the final page table directly in swapper_pg_dir.

2018-09-16 Thread Jun Yao
As the initial page table is created in the init_pg_dir, we can set up the final page table directly in the swapper_pg_dir. And it only contains the top level page table, so we can reduce it to a page size. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/mm/mmu.c

[PATCH v5 1/6] arm64/mm: Introduce the init_pg_dir.

2018-09-16 Thread Jun Yao
init_pg_dir to vmlinux.lds.S and boiler-plate clearing/cleaning/invalidating it in head.S. Signed-off-by: Jun Yao --- arch/arm64/include/asm/assembler.h | 29 + arch/arm64/kernel/head.S | 22 +++--- arch/arm64/kernel/vmlinux.lds.S| 8

[PATCH v5 2/6] arm64/mm: Pass ttbr1 as a parameter to __enable_mmu().

2018-09-16 Thread Jun Yao
The kernel will set up the initial page table in the init_pg_dir. However, it will create the final page table in the swapper_pg_dir during the initialization process. We need to let __enable_mmu() know which page table to use. Signed-off-by: Jun Yao --- arch/arm64/kernel/head.S | 19

[PATCH v5 0/6] Move swapper_pg_dir to rodata section.

2018-09-16 Thread Jun Yao
://www.spinics.net/lists/arm-kernel/msg675193.html [3] https://www.spinics.net/lists/arm-kernel/msg675196.html Jun Yao (6): arm64/mm: Introduce the init_pg_dir. arm64/mm: Pass ttbr1 as a parameter to __enable_mmu(). arm64/mm: Create the initial page table in the init_pg_dir. arm64/mm: Create the final page

[PATCH v5 5/6] arm64/mm: Populate the swapper_pg_dir by fixmap.

2018-09-16 Thread Jun Yao
Attack). Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 38 ++-- arch/arm64/mm/mmu.c | 25 +++-- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h

[PATCH v5 3/6] arm64/mm: Create the initial page table in the init_pg_dir.

2018-09-16 Thread Jun Yao
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. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 2 ++ arch/arm64

Re: [RESEND PATCH v4 5/6] arm64/mm: Populate the swapper_pg_dir by fixmap.

2018-09-13 Thread Jun Yao
Hi James, On Fri, Sep 07, 2018 at 10:58:22AM +0100, James Morse wrote: > On 22/08/18 10:54, Jun Yao wrote: > > WRITE_ONCE(*pmdp, pmd); > > dsb(ishst); > > } > > @@ -480,6 +511,19 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd) > > > >

Re: [RESEND PATCH v4 5/6] arm64/mm: Populate the swapper_pg_dir by fixmap.

2018-09-10 Thread Jun Yao
Hi James, On Fri, Sep 07, 2018 at 10:58:22AM +0100, James Morse wrote: > On 22/08/18 10:54, Jun Yao wrote: > > WRITE_ONCE(*pmdp, pmd); > > dsb(ishst); > > } > > @@ -480,6 +511,19 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd) > > > >

[RESEND PATCH v4 5/6] arm64/mm: Populate the swapper_pg_dir by fixmap.

2018-08-22 Thread Jun Yao
Attack). Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 68 ++-- arch/arm64/mm/mmu.c | 2 + 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 46ef21ebfe47

[RESEND PATCH v4 6/6] arm64/mm: Move {idmap_pg_dir .. swapper_pg_dir} to rodata section.

2018-08-22 Thread Jun Yao
Move the idmap_pg_dir/tramp_pg_dir/reserved_ttbr0/swapper_pg_dir to the rodata section. When the kernel is initialized, the idmap_pg_dir, tramp_pg_dir and reserved_ttbr0 will not change. And it's safe to move them to rodata section. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.

[RESEND PATCH v4 4/6] arm64/mm: Create the final page table directly in swapper_pg_dir.

2018-08-22 Thread Jun Yao
As the initial page table is created in the init_pg_dir, we can set up the final page table directly in the swapper_pg_dir. And it only contains the top level page table, so we can reduce it to a page size. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/mm/mmu.c

[RESEND PATCH v4 3/6] arm64/mm: Create the initial page table in the init_pg_dir.

2018-08-22 Thread Jun Yao
. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 2 ++ arch/arm64/kernel/head.S | 9 ++--- arch/arm64/mm/mmu.c | 14 ++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h

[RESEND PATCH v4 2/6] arm64/mm: Pass ttbr1 as a parameter to __enable_mmu().

2018-08-22 Thread Jun Yao
The kernel sets up the initial page table in the init_pg_dir. However, it will create the final page table in the swapper_pg_dir during the initialization process. We need to let __enable_mmu() know which page table to use. Signed-off-by: Jun Yao --- arch/arm64/kernel/head.S | 21

[RESEND PATCH v4 1/6] arm64/mm: Introduce the init_pg_dir.

2018-08-22 Thread Jun Yao
To make the swapper_pg_dir read only, we will move it to the rodata section. And force the kernel to set up the initial page table in the init_pg_dir. After generating all levels page table, we copy only the top level into the swapper_pg_dir during paging_init(). Signed-off-by: Jun Yao --- arch

[RESEND PATCH v4 0/6] arm64/mm: Move swapper_pg_dir to rodata

2018-08-22 Thread Jun Yao
2. CONFIG_ARM64_4K_PAGES/CONFIG_ARM64_VA_BITS_39 3. CONFIG_ARM64_64K_PAGES/CONFIG_ARM64_VA_BITS_48 4. CONFIG_ARM64_64K_PAGES/CONFIG_ARM64_VA_BITS_42 Jun Yao (6): arm64/mm: Introduce the init_pg_dir. arm64/mm: Pass ttbr1 as a parameter to __enable_mmu(). arm64/mm: Create

Re: [PATCH v3 3/5] arm64/mm: Create initial page tables in init_pg_dir

2018-08-15 Thread Jun Yao
Hi James, On Fri, Jul 06, 2018 at 03:41:07PM +0100, James Morse wrote: > I missed one: head.S has a call to kasan_early_init() before start_kernel(), > this goes messing with the page tables, and calls pgd_offset_k(), which pulls > in > swapper_pg_dir. This one is enabled by CONFIG_KASAN. > > So

[RESEND PATCH v4 3/6] arm64/mm: Create initial page tables in

2018-07-18 Thread Jun Yao
Create initial page tables in init_pg_dir and then create final page tables in swapper_pg_dir directly. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 2 ++ arch/arm64/kernel/head.S | 9 ++--- arch/arm64/mm/mmu.c | 27 --- 3

[RESEND PATCH v4 5/6] arm64/mm: Populate swapper_pg_dir by

2018-07-18 Thread Jun Yao
To move swapper_pg_dir to .rodata section, we populate it by fixmap. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 68 ++-- arch/arm64/mm/mmu.c | 2 + 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include

[RESEND PATCH v4 6/6] arm64/mm: Move

2018-07-18 Thread Jun Yao
Move {idmap_pg_dir, tramp_pg_dir, reserved_ttbr0, swapper_pg_dir} to .rodata section. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.lds.S | 39 - 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64

[RESEND PATCH v4 4/6] arm64/mm: Make swapper_pg_dir smaller

2018-07-18 Thread Jun Yao
We setup final page tables in swapper_pg_dir, which just contains PGD. And the PUD/PMD are allocated dynamically. So we can make it smaller. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/mm/mmu.c | 8 2 files changed, 1 insertion(+), 9

[RESEND PATCH v4 1/6] arm64/mm: Introduce init_pg_dir

2018-07-18 Thread Jun Yao
Add init_pg_dir to vmlinux.lds.S and boiler-plate clearing/cleaning/invalidating it in head.S. Signed-off-by: Jun Yao --- arch/arm64/include/asm/assembler.h | 29 + arch/arm64/kernel/head.S | 22 +++--- arch/arm64/kernel/vmlinux.lds.S

[RESEND PATCH v4 0/6] arm64/mm: Move

2018-07-18 Thread Jun Yao
[4] https://lkml.org/lkml/2018/7/11/782 Jun Yao (6): arm64/mm: Introduce init_pg_dir arm64/mm: Make __enable_mmu() take the ttbr1 page as an argument arm64/mm: Create initial page tables in init_pg_dir arm64/mm: Make swapper_pg_dir smaller arm64/mm: Populate swapper_pg_dir by fix

[RESEND PATCH v4 2/6] arm64/mm: Make __enable_mmu() take the

2018-07-18 Thread Jun Yao
Make __enable_mmu() take the physical address of the ttbr1 page as an argument. Signed-off-by: Jun Yao --- arch/arm64/kernel/head.S | 21 - arch/arm64/kernel/sleep.S | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch

[PATCH v4 3/6] arm64/mm: Create initial page tables in init_pg_dir

2018-07-17 Thread Jun Yao
Create initial page tables in init_pg_dir and then create final page tables in swapper_pg_dir directly. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 2 ++ arch/arm64/kernel/head.S | 4 ++-- arch/arm64/kernel/setup.c| 1 + arch/arm64/mm/mmu.c | 24

[PATCH v4 1/6] arm64/mm: Introduce init_pg_dir

2018-07-17 Thread Jun Yao
Add init_pg_dir to vmlinux.lds.S and boiler-plate clearing/cleaning/invalidating it in head.S. Signed-off-by: Jun Yao --- arch/arm64/include/asm/assembler.h | 29 + arch/arm64/kernel/head.S | 22 +++--- arch/arm64/kernel/vmlinux.lds.S

[PATCH v4 6/6] arm64/mm: Move {idmap_pg_dir, swapper_pg_dir} to .rodata section

2018-07-17 Thread Jun Yao
Move {idmap_pg_dir, tramp_pg_dir, reserved_ttbr0, swapper_pg_dir} to .rodata section. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.lds.S | 39 - 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64

[PATCH v4 5/6] arm64/mm: Populate swapper_pg_dir by fixmap

2018-07-17 Thread Jun Yao
To move swapper_pg_dir to .rodata section, we populate it by fixmap. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 68 ++-- arch/arm64/mm/mmu.c | 2 + 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include

[PATCH v4 0/6] arm64/mm: Move {idmap_pg_dir,swapper_pg_dir} to

2018-07-17 Thread Jun Yao
10476595/ [1] https://lkml.org/lkml/2018/7/6/238 [2] https://lkml.org/lkml/2018/7/6/239 [3] https://lkml.org/lkml/2018/7/6/243 [4] https://lkml.org/lkml/2018/7/11/782 Jun Yao (6): arm64/mm: Introduce init_pg_dir arm64/mm: Make __enable_mmu() take the ttbr1 page as an argument arm64/mm: Create in

[PATCH v4 2/6] arm64/mm: Make __enable_mmu() take the ttbr1 page as an argument

2018-07-17 Thread Jun Yao
Make __enable_mmu() take the physical address of the ttbr1 page as an argument. Signed-off-by: Jun Yao --- arch/arm64/kernel/head.S | 21 - arch/arm64/kernel/sleep.S | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch

[PATCH v4 4/6] arm64/mm: Make swapper_pg_dir smaller

2018-07-17 Thread Jun Yao
We setup final page tables in swapper_pg_dir, which just contains PGD. And the PUD/PMD are allocated dynamically. So we can make it smaller. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/mm/mmu.c | 8 2 files changed, 1 insertion(+), 9

[PATCH v3 2/5] arm64/mm: Make __enable_mmu() take the ttbr1 page as an argument

2018-07-02 Thread Jun Yao
Make __enable_mmu() take the physical address of the ttbr1 page as an argument. Signed-off-by: Jun Yao --- arch/arm64/kernel/head.S | 5 - arch/arm64/kernel/sleep.S | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S

[PATCH v3 5/5] arm64/mm: Move {idmap_pg_dir, swapper_pg_dir} to .rodata section

2018-07-02 Thread Jun Yao
Move {idmap_pg_dir, swapper_pg_dir} to .rodata section and populate swapper_pg_dir by fixmap. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgalloc.h | 48 arch/arm64/include/asm/pgtable.h | 15 +- arch/arm64/kernel/vmlinux.lds.S | 22

[PATCH v3 4/5] arm64/mm: Make swapper_pg_dir smaller

2018-07-02 Thread Jun Yao
Make swapper_pg_dir smaller so we don't need to memblock_free() it. Signed-off-by: Jun Yao --- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/mm/mmu.c | 8 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/k

[PATCH v3 0/5] Move {idmap_pg_dir,swapper_pg_dir} to .rodata

2018-07-02 Thread Jun Yao
these patches. v2: https://patchwork.kernel.org/patch/10485641/ v1: https://patchwork.kernel.org/patch/10476595/ [1] https://patchwork.kernel.org/patch/10485641/ [2] https://patchwork.kernel.org/patch/10485643/ Jun Yao (5): arm64/mm: Introduce init_pg_dir arm64/mm: Make __enable_mmu() take the

[PATCH v3 1/5] arm64/mm: Introduce init_pg_dir

2018-07-02 Thread Jun Yao
Add init_pg_dir to vmlinux.lds.S and boiler-plate clearing/cleaning/invalidating it in head.S. Signed-off-by: Jun Yao --- arch/arm64/include/asm/assembler.h | 23 +++ arch/arm64/kernel/head.S | 24 ++-- arch/arm64/kernel/vmlinux.lds.S| 7

[PATCH v3 3/5] arm64/mm: Create initial page tables in init_pg_dir

2018-07-02 Thread Jun Yao
Create initial page tables in init_pg_dir and then create final page tables in swapper_pg_dir directly. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 2 ++ arch/arm64/kernel/head.S | 4 ++-- arch/arm64/kernel/setup.c| 1 + arch/arm64/mm/mmu.c | 24

[PATCH v2 2/2] arm64/mm: Move {tramp_pg_dir, swapper_pg_dir} to .rodata section

2018-06-25 Thread Jun Yao
by fixmap. Signed-off-by: Jun Yao --- arch/arm64/include/asm/fixmap.h | 1 + arch/arm64/include/asm/pgalloc.h | 33 arch/arm64/include/asm/pgtable.h | 5 + arch/arm64/kernel/head.S | 6 +++--- arch/arm64/kernel/vmlinux.lds.S | 23 ++

[PATCH v2 0/2] Move {tramp_pg_dir,swapper_pg_dir} to .rodata

2018-06-25 Thread Jun Yao
32MB block) CONFIG_ARM64_VA_BITS_42(64KB granule, 512MB block) If these configurations are selected, we move {tramp_pg_dir, swapper_pg_dir} to .rodata section. And we update swapper_pg_dir by fixmap. [1] https://patchwork.kernel.org/patch/10476597/ Jun Yao (2):

[PATCH v2 1/2] arm64/mm: Introduce init_pg_dir

2018-06-25 Thread Jun Yao
We setup initial page tables in init_pg_dir, which is a reserved area of the __initdata section. And in paging_init(), we no longer need a temporary top-level and we can setup final page tables in swapper_pg_dir directly. Signed-off-by: Jun Yao --- arch/arm64/include/asm/fixmap.h | 1 - arch

Re: [PATCH 1/1] arm64/mm: move {idmap_pg_dir,tramp_pg_dir,swapper_pg_dir} to .rodata section

2018-06-22 Thread Jun Yao
gt; >>>> On 21 June 2018 at 04:51, Jun Yao wrote: > >>>>> On Wed, Jun 20, 2018 at 12:09:49PM +0200, Ard Biesheuvel wrote: > >>>>>> As for swapper_pg_dir, it would indeed be nice if we could keep those > >>>>>> mappings read-

Re: [PATCH 1/1] arm64/mm: move {idmap_pg_dir,tramp_pg_dir,swapper_pg_dir} to .rodata section

2018-06-21 Thread Jun Yao
On Thu, Jun 21, 2018 at 11:29:52AM +0200, Ard Biesheuvel wrote: > On 21 June 2018 at 10:59, James Morse wrote: > > On 21/06/18 07:39, Ard Biesheuvel wrote: > >> On 21 June 2018 at 04:51, Jun Yao wrote: > >>> On Wed, Jun 20, 2018 at 12:09:49PM +0200, Ard Biesheuvel

Re: [PATCH 1/1] arm64/mm: move {idmap_pg_dir,tramp_pg_dir,swapper_pg_dir} to .rodata section

2018-06-20 Thread Jun Yao
Hi Ard, On Wed, Jun 20, 2018 at 12:09:49PM +0200, Ard Biesheuvel wrote: > On 20 June 2018 at 10:57, Jun Yao wrote: > > Move {idmap_pg_dir,tramp_pg_dir,swapper_pg_dir} to .rodata > > section. And update the swapper_pg_dir by fixmap. > > > > I think we may be able t

[PATCH 1/1] arm64/mm: move {idmap_pg_dir,tramp_pg_dir,swapper_pg_dir} to .rodata section

2018-06-20 Thread Jun Yao
Move {idmap_pg_dir,tramp_pg_dir,swapper_pg_dir} to .rodata section. And update the swapper_pg_dir by fixmap. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgalloc.h | 19 +++ arch/arm64/kernel/vmlinux.lds.S | 32 ++-- arch/arm64/mm/mmu.c

[PATCH 0/1] Move {idmap_pg_dir,tramp_pg_dir,swapper_pg_dir}

2018-06-20 Thread Jun Yao
://www.openwall.com/lists/kernel-hardening/2018/05/31/1 [2] https://patchwork.kernel.org/patch/10449589/ Jun Yao (1): arm64/mm: move {idmap_pg_dir,tramp_pg_dir,swapper_pg_dir} to .rodata section arch/arm64/include/asm/pgalloc.h | 19 +++ arch/arm64/kernel/vmlinux.lds.S | 32

[PATCH v3 1/3] arm64/mm: pass swapper_pg_dir as an argument to __enable_mmu()

2018-06-05 Thread Jun Yao
Introduce __pa_swapper_pg_dir to save physical address of swapper_pg_dir. And pass it as an argument to __enable_mmu(). Signed-off-by: Jun Yao --- arch/arm64/include/asm/mmu_context.h | 4 +--- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/kernel/cpufeature.c | 2 +- arch

[PATCH v3 3/3] arm64/mm: migrate swapper_pg_dir and tramp_pg_dir

2018-06-05 Thread Jun Yao
Migrate swapper_pg_dir and tramp_pg_dir. And their virtual addresses do not correlate with kernel's address. Signed-off-by: Jun Yao --- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/mm/mmu.c | 79 +--- 2 files changed, 52 insertions(+

[PATCH v3 2/3] arm64/mm: introduce variable to save new swapper_pg_dir address

2018-06-05 Thread Jun Yao
Prepare for migrating swapper_pg_dir, introduce new_swapper_pg_dir to save virtual address of swapper_pg_dir. Signed-off-by: Jun Yao --- arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/mm/kasan_init.c | 2 +- arch/arm64/mm/mmu.c

[PATCH v3 0/3] arm64/mm: migrate swapper_pg_dir

2018-06-05 Thread Jun Yao
.html [v1] https://www.spinics.net/lists/kernel/msg2819351.html Jun Yao (3): arm64/mm: pass swapper_pg_dir as an argument to __enable_mmu() arm64/mm: introduce variable to save new swapper_pg_dir address arm64/mm: migrate swapper_pg_dir and tramp_pg_dir arch/arm64/include/asm/mmu_context.h

[PATCH v2 2/3] arm64/mm: introduce variable to save new swapper_pg_dir address

2018-06-05 Thread Jun Yao
Prepare for migrating swapper_pg_dir, introduce new_swapper_pg_dir to save virtual address of swapper_pg_dir. Signed-off-by: Jun Yao --- arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/mm/kasan_init.c | 2 +- arch/arm64/mm/mmu.c

[PATCH v2 1/3] arm64/mm: pass swapper_pg_dir as an argument to __enable_mmu()

2018-06-05 Thread Jun Yao
Introduce __pa_swapper_pg_dir to save physical address of swapper_pg_dir. And pass it as an argument to __enable_mmu(). Signed-off-by: Jun Yao --- arch/arm64/include/asm/mmu_context.h | 4 +--- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/kernel/cpufeature.c | 2 +- arch

[PATCH v2 3/3] arm64/mm: migrate swapper_pg_dir and tramp_pg_dir

2018-06-05 Thread Jun Yao
Migrate swapper_pg_dir and tramp_pg_dir. And their virtual addresses do not correlate with kernel's address. Signed-off-by: Jun Yao --- arch/arm64/mm/mmu.c | 75 - 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/arch/arm64/mm/mm

[PATCH v2 0/3] arm64/mm: migrate swapper_pg_dir

2018-06-05 Thread Jun Yao
.html [2] https://www.spinics.net/lists/kernel/msg2819455.html Jun Yao (3): arm64/mm: pass swapper_pg_dir as an argument to __enable_mmu() arm64/mm: introduce variable to save new swapper_pg_dir address arm64/mm: migrate swapper_pg_dir and tramp_pg_dir arch/arm64/include/asm/mmu_context.h

Re: [PATCH 0/4] arm64/mm: migrate swapper_pg_dir

2018-06-04 Thread Jun Yao
On 1 Jun 2018 at 10:42:10, Robin Murphy wrote: >> Currently, The offset between swapper_pg_dir and _text is >> fixed. When attackers know the address of _text(no KASLR or >> breaking KASLR), they can caculate the address of >> swapper_pg_dir. Then KSMA(Kernel Space Mirroring Attack) can >> be appl

[PATCH 4/4] arm64/mm: migrate swapper_pg_dir and tramp_pg_dir

2018-06-01 Thread Jun Yao
Migrate swapper_pg_dir and tramp_pg_dir. And their virtual addresses do not correlate with kernel's address. Signed-off-by: Jun Yao --- arch/arm64/mm/mmu.c | 70 +++-- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/arch/arm64/mm/mm

[PATCH 3/4] arm64/mm: make tramp_pg_dir and swapper_pg_dir adjacent

2018-06-01 Thread Jun Yao
To defense KSMA, we need to migrate tramp_pg_dir and swapper_pg_dir together. Make them adjacent to avoid modifying tramp_(un)map_kernel. Signed-off-by: Jun Yao --- arch/arm64/kernel/entry.S | 4 ++-- arch/arm64/kernel/vmlinux.lds.S | 9 + 2 files changed, 7 insertions(+), 6

[PATCH 2/4] arm64/mm: introduce variable to save new swapper_pg_dir address

2018-06-01 Thread Jun Yao
Prepare for migrating swapper_pg_dir, introduce new_swapper_pg_dir to save virtual address of swapper_pg_dir. Signed-off-by: Jun Yao --- arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/mm/kasan_init.c | 2 +- arch/arm64/mm/mmu.c

[PATCH 1/4] arm64/mm: pass swapper_pg_dir as an argument to __enable_mmu()

2018-06-01 Thread Jun Yao
Introduce __pa_swapper_pg_dir to save physical address of swapper_pg_dir. And pass it as an argument to __enable_mmu(). Signed-off-by: Jun Yao --- arch/arm64/include/asm/mmu_context.h | 4 +--- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/kernel/cpufeature.c | 2 +- arch

[PATCH 0/4] arm64/mm: migrate swapper_pg_dir

2018-06-01 Thread Jun Yao
is dynamically allocated. Since it is allocated during the kernel boot process and the address is relatively fixed, further randomization may be required. Jun Yao (4): arm64/mm: pass swapper_pg_dir as an argument to __enable_mmu() arm64/mm: introduce variable to save new swapper_pg_dir address

[PATCH v2 1/2] arm64/mm: split tramp_pg_dir off from the data segment

2018-05-31 Thread Jun Yao
In order to make tramp_pg_dir read-only, split it off from the data segment and create a dedicated pgdir segment for it. Signed-off-by: Jun Yao --- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/vmlinux.lds.S | 3 +++ arch/arm64/mm/mmu.c | 13 + 3 files

[PATCH v2 2/2] arm64/mm: make tramp_pg_dir read-only

2018-05-31 Thread Jun Yao
Make tramp_pg_dir read-only. Signed-off-by: Jun Yao --- arch/arm64/mm/mmu.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a675fb88914e..2c6e6433090c 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -542,6 +542,7 @@ static

[PATCH v2 0/2] mark tramp_pg_dir read-only

2018-05-31 Thread Jun Yao
Version 2 changes: split tramp_pg_dir off from the data segment and create a dedicated pgdir segment for it. Jun Yao (2): arm64/mm: split tramp_pg_dir off from the data segment arm64/mm: make tramp_pg_dir read-only arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel