From cded5943467c497f0c655648d9e329a8b4e517f9 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Wed, 18 May 2022 11:05:54 +0200 Subject: [PATCH] lx_emul & arm: define ZERO_PAGE The implementation was copied from the already existing LX-emul implementation for x86 but the commit additionally page-aligns the array that serves as backing store for the zero page as we assume this to be expected by the contrib code. However, this commit doesn't apply the alignment also to the x86 implementation as we agreed, that this should be done in a separate commit. Ref #4397 --- .../lx_emul/shadow/arch/arm/include/asm/pgtable.h | 3 +++ .../lx_emul/shadow/arch/arm64/include/asm/pgtable.h | 3 +++ repos/dde_linux/src/lib/lx_emul/spec/arm/start.c | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/repos/dde_linux/src/include/lx_emul/shadow/arch/arm/include/asm/pgtable.h b/repos/dde_linux/src/include/lx_emul/shadow/arch/arm/include/asm/pgtable.h index 0eae2a7ca7..ad6689b95f 100644 --- a/repos/dde_linux/src/include/lx_emul/shadow/arch/arm/include/asm/pgtable.h +++ b/repos/dde_linux/src/include/lx_emul/shadow/arch/arm/include/asm/pgtable.h @@ -22,6 +22,9 @@ #ifndef __ASSEMBLY__ +extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; +#define ZERO_PAGE(vaddr) ((void)(vaddr),virt_to_page(empty_zero_page)) + pte_t pte_mkwrite(pte_t pte); int pte_none(pte_t pte); diff --git a/repos/dde_linux/src/include/lx_emul/shadow/arch/arm64/include/asm/pgtable.h b/repos/dde_linux/src/include/lx_emul/shadow/arch/arm64/include/asm/pgtable.h index 74707276cc..b90712e359 100644 --- a/repos/dde_linux/src/include/lx_emul/shadow/arch/arm64/include/asm/pgtable.h +++ b/repos/dde_linux/src/include/lx_emul/shadow/arch/arm64/include/asm/pgtable.h @@ -25,6 +25,9 @@ #include +extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; +#define ZERO_PAGE(vaddr) ((void)(vaddr),virt_to_page(empty_zero_page)) + pte_t pte_mkwrite(pte_t pte); pte_t pte_get(pte_t pte); diff --git a/repos/dde_linux/src/lib/lx_emul/spec/arm/start.c b/repos/dde_linux/src/lib/lx_emul/spec/arm/start.c index d0f0bedb6a..475e0f44b5 100644 --- a/repos/dde_linux/src/lib/lx_emul/spec/arm/start.c +++ b/repos/dde_linux/src/lib/lx_emul/spec/arm/start.c @@ -30,6 +30,15 @@ void time_init(void) } +#include + +/* + * Note that empty_zero_page lands in the BSS section and is therefore + * automatically zeroed at program startup. + */ +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] +__attribute__((aligned(PAGE_SIZE))); + void lx_emul_setup_arch(void *dtb) { /* calls from setup_arch of arch/arm64/kernel/setup.c */