Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756358AbcCOQDq (ORCPT ); Tue, 15 Mar 2016 12:03:46 -0400 Received: from mail.skyhub.de ([78.46.96.112]:37284 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755918AbcCOQDo (ORCPT ); Tue, 15 Mar 2016 12:03:44 -0400 Date: Tue, 15 Mar 2016 17:03:19 +0100 From: Borislav Petkov To: Matt Fleming Cc: Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" , Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Ben Hutchings , Brian Gerst , Denys Vlasenko , Linus Torvalds , Maarten Lankhorst , Matthew Garrett , Peter Zijlstra , Raphael Hertzog , Roger Shimizu , Scott Ashcroft Subject: Re: [PATCH] x86/mm/pat: Fix boot crash when 1GB pages are not supported by cpu Message-ID: <20160315160318.GF4559@pd.tnic> References: <1457951581-27353-1-git-send-email-matt@codeblueprint.co.uk> <1457951581-27353-2-git-send-email-matt@codeblueprint.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1457951581-27353-2-git-send-email-matt@codeblueprint.co.uk> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2951 Lines: 76 On Mon, Mar 14, 2016 at 10:33:01AM +0000, Matt Fleming wrote: > Scott reports that with the new separate EFI page tables he's seeing > the following error on boot, caused by setting reserved bits in the > page table structures (fault code is PF_RSVD | PF_PROT), > > swapper/0: Corrupted page table at address 17b102020 > PGD 17b0e5063 PUD 1400000e3 > Bad pagetable: 0009 [#1] SMP > > On first inspection the PUD is using a 1GB page size (_PAGE_PSE) and > looks fine but that's only true if support for 1GB PUD pages > ("pdpe1gb") is present in the cpu. > > Scott's Intel Celeron N2820 does not have that feature and so the > _PAGE_PSE bit is reserved. Fix this issue by making the 1GB mapping > code in conditional on "cpu_has_gbpages". > > This issue didn't come up in the past because the required mapping for > the faulting address (0x17b102020) will already have been setup by the > kernel in early boot before we got to efi_map_regions(), but we no > longer use the standard kernel page tables during EFI calls. > > Reported-by: Scott Ashcroft > Tested-by: Scott Ashcroft > Cc: Ard Biesheuvel > Cc: Ben Hutchings > Cc: Borislav Petkov > Cc: Brian Gerst > Cc: Denys Vlasenko > Cc: "H. Peter Anvin" > Cc: Linus Torvalds > Cc: Maarten Lankhorst > Cc: Matthew Garrett > Cc: Peter Zijlstra > Cc: Raphael Hertzog > Cc: Roger Shimizu > Cc: Thomas Gleixner > Cc: linux-efi@vger.kernel.org > Signed-off-by: Matt Fleming > --- > arch/x86/mm/pageattr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c > index 14c38ae80409..fcf8e290740a 100644 > --- a/arch/x86/mm/pageattr.c > +++ b/arch/x86/mm/pageattr.c > @@ -1055,7 +1055,7 @@ static int populate_pud(struct cpa_data *cpa, unsigned long start, pgd_t *pgd, > /* > * Map everything starting from the Gb boundary, possibly with 1G pages > */ > - while (end - start >= PUD_SIZE) { > + while (cpu_has_gbpages && end - start >= PUD_SIZE) { > set_pud(pud, __pud(cpa->pfn << PAGE_SHIFT | _PAGE_PSE | > massage_pgprot(pud_pgprot))); > > -- Yap, looks ok to me as a minimal fix: Acked-by: Borislav Petkov As a future cleanup, I'd carve out the sections of populate_pud() which map the stuff up to the Gb boundary and the trailing leftover into a helper, say, __populate_pud_chunk() or so which goes and populates with smaller sizes, i.e., 2M and 4K and the lower levels. This'll make populate_pud() more readable too. Thanks. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.