x86: mmu: add kconfig CONFIG_X86_EXTRA_PAGE_TABLE_PAGES

The whole page table is pre-allocated at build time and is
dependent on the range of address space. This kconfig allows
reserving extra pages (of size CONFIG_MMU_PAGE_SIZE) to
the page table so that gen_mmu.py can make use of these
extra pages.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2021-03-02 14:14:15 -08:00 committed by Anas Nashif
commit 3ebcd8307e
2 changed files with 20 additions and 3 deletions

View file

@ -368,6 +368,18 @@ config X86_MAX_ADDITIONAL_MEM_DOMAINS
Zephyr test cases assume 3 additional domains can be instantiated.
config X86_EXTRA_PAGE_TABLE_PAGES
int "Reserve extra pages in page table"
default 0
depends on X86_MMU
help
The whole page table is pre-allocated at build time and is
dependent on the range of address space. This allows reserving
extra pages (of size CONFIG_MMU_PAGE_SIZE) to the page table
so that gen_mmu.py can make use of these extra pages.
Says 0 unless absolutely sure that this is necessary.
config X86_NO_MELTDOWN
bool
help

View file

@ -252,11 +252,16 @@ static const struct paging_level paging_levels[] = {
#define NUM_TABLE_PAGES (NUM_PT + NUM_PD)
#endif /* CONFIG_X86_64 */
#define INITIAL_PTABLE_PAGES \
(NUM_TABLE_PAGES + CONFIG_X86_EXTRA_PAGE_TABLE_PAGES)
#ifdef CONFIG_X86_PAE
/* Toplevel PDPT wasn't included as it is not a page in size */
#define INITIAL_PTABLE_SIZE ((NUM_TABLE_PAGES * CONFIG_MMU_PAGE_SIZE) + 0x20)
#define INITIAL_PTABLE_SIZE \
((INITIAL_PTABLE_PAGES * CONFIG_MMU_PAGE_SIZE) + 0x20)
#else
#define INITIAL_PTABLE_SIZE (NUM_TABLE_PAGES * CONFIG_MMU_PAGE_SIZE)
#define INITIAL_PTABLE_SIZE \
(INITIAL_PTABLE_PAGES * CONFIG_MMU_PAGE_SIZE)
#endif
/* "dummy" pagetables for the first-phase build. The real page tables
@ -1396,7 +1401,7 @@ void arch_mem_domain_thread_remove(struct k_thread *thread)
/*
* Pool of free memory pages for copying page tables, as needed.
*/
#define PTABLE_COPY_SIZE (NUM_TABLE_PAGES * CONFIG_MMU_PAGE_SIZE)
#define PTABLE_COPY_SIZE (INITIAL_PTABLE_PAGES * CONFIG_MMU_PAGE_SIZE)
static uint8_t __noinit
page_pool[PTABLE_COPY_SIZE * CONFIG_X86_MAX_ADDITIONAL_MEM_DOMAINS]