Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-05 Thread Nathan Chancellor
On Fri, Feb 05, 2021 at 10:27:54AM -0800, Nick Desaulniers wrote: > On Fri, Feb 5, 2021 at 2:35 AM Borislav Petkov wrote: > > > > On Wed, Feb 03, 2021 at 11:51:48AM -0700, Nathan Chancellor wrote: > > > x86_64 all{mod,yes}config with clang are going to ship broken in 5.11. > > > > Dunno, it is

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-05 Thread Nick Desaulniers
On Fri, Feb 5, 2021 at 2:35 AM Borislav Petkov wrote: > > On Wed, Feb 03, 2021 at 11:51:48AM -0700, Nathan Chancellor wrote: > > x86_64 all{mod,yes}config with clang are going to ship broken in 5.11. > > Dunno, it is still broken here even with those build assertions removed. And > it > ain't

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-05 Thread Borislav Petkov
On Wed, Feb 03, 2021 at 11:51:48AM -0700, Nathan Chancellor wrote: > x86_64 all{mod,yes}config with clang are going to ship broken in 5.11. Dunno, it is still broken here even with those build assertions removed. And it ain't even an all{mod,yes}config - just my machine's config with

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-04 Thread Arvind Sankar
On Thu, Feb 04, 2021 at 11:13:18PM +0100, Borislav Petkov wrote: > On Thu, Feb 04, 2021 at 04:43:58PM -0500, Arvind Sankar wrote: > > This should check EFI_VA_END instead of EFI_VA_START, and maybe throw in > > a BUG_ON if EFI_VA_END >= EFI_VA_START. > > No need: > > if (efi_va <

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-04 Thread Borislav Petkov
On Thu, Feb 04, 2021 at 04:43:58PM -0500, Arvind Sankar wrote: > This should check EFI_VA_END instead of EFI_VA_START, and maybe throw in > a BUG_ON if EFI_VA_END >= EFI_VA_START. No need: if (efi_va < EFI_VA_END) { pr_warn(FW_WARN "VA address range overflow!\n");

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-04 Thread Arvind Sankar
On Thu, Feb 04, 2021 at 11:51:55AM +0100, Borislav Petkov wrote: > On Wed, Feb 03, 2021 at 09:29:18PM +0100, Ard Biesheuvel wrote: > > I think we have agreement on the approach but it is unclear who is > > going to write the patch. > > How's that below? > > And frankly, I'd even vote for

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-04 Thread Nathan Chancellor
On Thu, Feb 04, 2021 at 11:51:55AM +0100, Borislav Petkov wrote: > On Wed, Feb 03, 2021 at 09:29:18PM +0100, Ard Biesheuvel wrote: > > I think we have agreement on the approach but it is unclear who is > > going to write the patch. > > How's that below? > > And frankly, I'd even vote for

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-04 Thread Ard Biesheuvel
On Thu, 4 Feb 2021 at 11:52, Borislav Petkov wrote: > > On Wed, Feb 03, 2021 at 09:29:18PM +0100, Ard Biesheuvel wrote: > > I think we have agreement on the approach but it is unclear who is > > going to write the patch. > > How's that below? > > And frankly, I'd even vote for removing those

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-04 Thread Borislav Petkov
On Wed, Feb 03, 2021 at 09:29:18PM +0100, Ard Biesheuvel wrote: > I think we have agreement on the approach but it is unclear who is > going to write the patch. How's that below? And frankly, I'd even vote for removing those assertions altogether. If somehow the EFI pgd lands somewhere else, the

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-03 Thread Ard Biesheuvel
On Wed, 3 Feb 2021 at 19:51, Nathan Chancellor wrote: > > On Wed, Jan 20, 2021 at 10:33:43AM +0100, Ard Biesheuvel wrote: > > On Mon, 18 Jan 2021 at 22:42, Arvind Sankar wrote: > > > > > > On Mon, Jan 18, 2021 at 09:24:09PM +0100, Borislav Petkov wrote: > > > > > > > As a matter of fact, it

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-02-03 Thread Nathan Chancellor
On Wed, Jan 20, 2021 at 10:33:43AM +0100, Ard Biesheuvel wrote: > On Mon, 18 Jan 2021 at 22:42, Arvind Sankar wrote: > > > > On Mon, Jan 18, 2021 at 09:24:09PM +0100, Borislav Petkov wrote: > > > > > > As a matter of fact, it seems like the four assertions could be > > > > > > combined > > > > >

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-20 Thread Borislav Petkov
On Wed, Jan 20, 2021 at 10:33:43AM +0100, Ard Biesheuvel wrote: > The churn doesn't seem to be worth it, tbh. > > So could we get rid of the complexity here, and only build_bug() on > the start address of the EFI region being outside the topmost p4d? > That should make the PGD test redundant as

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-20 Thread Kirill A. Shutemov
On Mon, Jan 18, 2021 at 04:42:20PM -0500, Arvind Sankar wrote: > AFAICT, MODULES_END is only relevant as being something that happens to > be in the top 512GiB, and -1ul would be clearer. I think you are right. But -1UL is not very self-descriptive. :/ -- Kirill A. Shutemov

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-20 Thread Kirill A. Shutemov
On Fri, Jan 15, 2021 at 02:07:51PM -0500, Arvind Sankar wrote: > On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): > > > > x86_64-linux-ld: arch/x86/platform/efi/efi_64.o: in

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-20 Thread Ard Biesheuvel
On Mon, 18 Jan 2021 at 22:42, Arvind Sankar wrote: > > On Mon, Jan 18, 2021 at 09:24:09PM +0100, Borislav Petkov wrote: > > > > > As a matter of fact, it seems like the four assertions could be > > > > > combined > > > > > into: > > > > > BUILD_BUG_ON((EFI_VA_END & P4D_MASK) !=

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-18 Thread Arvind Sankar
On Mon, Jan 18, 2021 at 09:24:09PM +0100, Borislav Petkov wrote: > > > > As a matter of fact, it seems like the four assertions could be combined > > > > into: > > > > BUILD_BUG_ON((EFI_VA_END & P4D_MASK) != (MODULES_END & P4D_MASK)); > > > > BUILD_BUG_ON((EFI_VA_START & P4D_MASK) !=

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-18 Thread Borislav Petkov
On Sat, Jan 16, 2021 at 05:34:27PM +0100, Ard Biesheuvel wrote: > On Fri, 15 Jan 2021 at 21:27, Arvind Sankar wrote: > > > > On Fri, Jan 15, 2021 at 02:07:51PM -0500, Arvind Sankar wrote: > > > On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > > > > From: Arnd Bergmann > > > > > >

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-16 Thread Ard Biesheuvel
On Fri, 15 Jan 2021 at 21:27, Arvind Sankar wrote: > > On Fri, Jan 15, 2021 at 02:07:51PM -0500, Arvind Sankar wrote: > > On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > > > From: Arnd Bergmann > > > > > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): >

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Arvind Sankar
On Fri, Jan 15, 2021 at 03:12:25PM -0500, Arvind Sankar wrote: > On Fri, Jan 15, 2021 at 08:54:18PM +0100, Arnd Bergmann wrote: > > On Fri, Jan 15, 2021 at 8:18 PM Borislav Petkov wrote: > > > > > > On Fri, Jan 15, 2021 at 02:11:25PM -0500, Arvind Sankar wrote: > > > > That's how build-time

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Arvind Sankar
On Fri, Jan 15, 2021 at 02:07:51PM -0500, Arvind Sankar wrote: > On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): > > > > x86_64-linux-ld: arch/x86/platform/efi/efi_64.o: in

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Arvind Sankar
On Fri, Jan 15, 2021 at 08:54:18PM +0100, Arnd Bergmann wrote: > On Fri, Jan 15, 2021 at 8:18 PM Borislav Petkov wrote: > > > > On Fri, Jan 15, 2021 at 02:11:25PM -0500, Arvind Sankar wrote: > > > That's how build-time assertions work: they are _supposed_ to be > > > optimized away completely

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Arnd Bergmann
On Fri, Jan 15, 2021 at 8:18 PM Borislav Petkov wrote: > > On Fri, Jan 15, 2021 at 02:11:25PM -0500, Arvind Sankar wrote: > > That's how build-time assertions work: they are _supposed_ to be > > optimized away completely when the assertion is true. If they're > > _not_ optimized away, the build

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Borislav Petkov
On Fri, Jan 15, 2021 at 02:11:25PM -0500, Arvind Sankar wrote: > That's how build-time assertions work: they are _supposed_ to be > optimized away completely when the assertion is true. If they're > _not_ optimized away, the build will fail. Yah, that I know, thanks. If gcc really inlines

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Arvind Sankar
On Fri, Jan 15, 2021 at 08:07:29PM +0100, Borislav Petkov wrote: > On Fri, Jan 15, 2021 at 11:32:03AM -0700, Nathan Chancellor wrote: > > I triggered it with CONFIG_UBSAN=y + CONFIG_UBSAN_UNSIGNED_OVERFLOW=y > > (it can be exposed with an allyesconfig/allmodconfig on mainline > > currently). > >

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Arvind Sankar
On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): > > x86_64-linux-ld: arch/x86/platform/efi/efi_64.o: in function > `efi_sync_low_kernel_mappings': > efi_64.c:(.text+0x22c): undefined

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Borislav Petkov
On Fri, Jan 15, 2021 at 11:32:03AM -0700, Nathan Chancellor wrote: > I triggered it with CONFIG_UBSAN=y + CONFIG_UBSAN_UNSIGNED_OVERFLOW=y > (it can be exposed with an allyesconfig/allmodconfig on mainline > currently). Yah, I can trigger with that, thanks. But I'll be damned, check this out:

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Nathan Chancellor
On Fri, Jan 15, 2021 at 07:23:00PM +0100, Borislav Petkov wrote: > On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): > > I have CONFIG_X86_5LEVEL=y, CONFIG_EFI=y and am using

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-15 Thread Borislav Petkov
On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): I have CONFIG_X86_5LEVEL=y, CONFIG_EFI=y and am using Debian clang version 10.0.1-8+b1 but my .config builds just fine. How do you

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-13 Thread Ard Biesheuvel
On Thu, 7 Jan 2021 at 23:34, Arnd Bergmann wrote: > > From: Arnd Bergmann > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): > > x86_64-linux-ld: arch/x86/platform/efi/efi_64.o: in function > `efi_sync_low_kernel_mappings': > efi_64.c:(.text+0x22c): undefined reference

Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-07 Thread Nathan Chancellor
On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): > > x86_64-linux-ld: arch/x86/platform/efi/efi_64.o: in function > `efi_sync_low_kernel_mappings': > efi_64.c:(.text+0x22c): undefined

[PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index

2021-01-07 Thread Arnd Bergmann
From: Arnd Bergmann When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): x86_64-linux-ld: arch/x86/platform/efi/efi_64.o: in function `efi_sync_low_kernel_mappings': efi_64.c:(.text+0x22c): undefined reference to `__compiletime_assert_354' Use the same method as in commit