[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXE9CcDRVt6U7xXeVozuj9Fjc00xN+ne0aYMMS-wxYPgxQ@mail.gmail.com>
Date: Wed, 8 Mar 2023 10:24:27 +0100
From: Ard Biesheuvel <ardb@...nel.org>
To: Evgeniy Baskov <baskov@...ras.ru>
Cc: Borislav Petkov <bp@...en8.de>, Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Alexey Khoroshilov <khoroshilov@...ras.ru>,
Peter Jones <pjones@...hat.com>,
"Limonciello, Mario" <mario.limonciello@....com>,
joeyli <jlee@...e.com>, lvc-project@...uxtesting.org,
x86@...nel.org, linux-efi@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH v4 04/26] x86/boot: Increase boot page table size
On Thu, 15 Dec 2022 at 13:38, Evgeniy Baskov <baskov@...ras.ru> wrote:
>
> Previous upper limit ignored pages implicitly mapped from #PF handler
> by code accessing ACPI tables (boot/compressed/{acpi.c,efi.c}),
> so theoretical upper limit is higher than it was set.
>
> Using 4KB pages is desirable for better memory protection granularity.
> Approximately twice as much memory is required for those.
>
> Increase initial page table size to 64 4KB page tables.
>
> Tested-by: Mario Limonciello <mario.limonciello@....com>
> Tested-by: Peter Jones <pjones@...hat.com>
> Signed-off-by: Evgeniy Baskov <baskov@...ras.ru>
> ---
> arch/x86/include/asm/boot.h | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
> index 9191280d9ea3..024d972c248e 100644
> --- a/arch/x86/include/asm/boot.h
> +++ b/arch/x86/include/asm/boot.h
> @@ -41,22 +41,24 @@
> # define BOOT_STACK_SIZE 0x4000
>
> # define BOOT_INIT_PGT_SIZE (6*4096)
> -# ifdef CONFIG_RANDOMIZE_BASE
> /*
> * Assuming all cross the 512GB boundary:
> * 1 page for level4
> - * (2+2)*4 pages for kernel, param, cmd_line, and randomized kernel
> - * 2 pages for first 2M (video RAM: CONFIG_X86_VERBOSE_BOOTUP).
> - * Total is 19 pages.
> + * (3+3)*2 pages for param and cmd_line
> + * (2+2+S)*2 pages for kernel and randomized kernel, where S is total number
> + * of sections of kernel. Explanation: 2+2 are upper level page tables.
> + * We can have only S unaligned parts of section: 1 at the end of the kernel
> + * and (S-1) at the section borders. The start address of the kernel is
> + * aligned, so an extra page table. There are at most S=6 sections in
> + * vmlinux ELF image.
> + * 3 pages for first 2M (video RAM: CONFIG_X86_VERBOSE_BOOTUP).
> + * Total is 36 pages.
> + *
> + * Some pages are also required for UEFI memory map and
> + * ACPI table mappings, so we need to add extra space.
> + * FIXME: Figure out exact amount of pages.
So you are rounding up 36 to 64 to account for these pages, right?
So we should either drop the FIXME and explain that this is fine, or
fix it - we cannot merge it like this.
Thanks,
Ard.
> */
> -# ifdef CONFIG_X86_VERBOSE_BOOTUP
> -# define BOOT_PGT_SIZE (19*4096)
> -# else /* !CONFIG_X86_VERBOSE_BOOTUP */
> -# define BOOT_PGT_SIZE (17*4096)
> -# endif
> -# else /* !CONFIG_RANDOMIZE_BASE */
> -# define BOOT_PGT_SIZE BOOT_INIT_PGT_SIZE
> -# endif
> +# define BOOT_PGT_SIZE (64*4096)
>
> #else /* !CONFIG_X86_64 */
> # define BOOT_STACK_SIZE 0x1000
> --
> 2.37.4
>
Powered by blists - more mailing lists