From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B3F9C433FE for ; Mon, 21 Nov 2022 12:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ChWkTqul1mp9U9SI6bbaGB7lRIAcyBypZkIS3W+t00Q=; b=FCJuFbawBtGf/m D8LxRBo5Lex/EfLPpWgNaJFftBlRKPW0XBrfcb+9y4rjZJ5HnxyaWiQ7MrWXtAaBMiJaHJPj8tm7r x/HWKe85xJ9lS1Gt/C3kIRxw91ZGCFqzNdpK7i9IX8OfA0sSxKf05qq56CmQlRY6re6hpcgHqpSjI lSfKBH5JXZpOnPKzaMQYpbAVbHdASeC6+KB35QA2dgtQ4N1x1kGQruZc4tNgj3G1xHRWp+mqaDRGT AARdo1tPdbO4F9AdNMqg9tt8ILVUlJRtJ1kSgEjGv6BhmT2HsboTb9FMhJdH21HkoeaxGpu9UCeRH MeQv8VmUMSneeTLp5Now==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox6H0-00DoZT-JI; Mon, 21 Nov 2022 12:51:42 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox6Gw-00DoTV-Ur for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2022 12:51:40 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5E9B4B80F9D; Mon, 21 Nov 2022 12:51:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EF7EC433D6; Mon, 21 Nov 2022 12:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669035095; bh=hk2aUB5pt6JJuleoc6iOhWpUXoHz8hORZDiVJL9+98E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X23QJBIvxLaqj+idLvRDjxZNy0pQ+W06sbxOwUSmAMlztiAwic772hPgi8gNLaaz2 3KheMwlIfveytbwuy6GV4tLt6PKeZ9nQ+2Um8OOn/s3KeUNwForpVeqeiKm1vN7hz5 BKBxnxWch1TUjp15tQSbFj30dmHoGT9ndz51eRXvvPaoNnXAiqmVX8y5FrnImRdjLr hwslneyM/kPzb0tykmlgexVdB2BSVi+OoydRwkFsAn4fhv80xagF4//unPtmlXjlsL q+gZDCA32Y5o3+AjVCwX+RBjpHy+IFliStcd/r2aPQGM1QDeQ8bD39ix2MyJHLy19u P92fWO3ZpiaCA== Date: Mon, 21 Nov 2022 12:51:29 +0000 From: Will Deacon To: Mark Rutland Cc: Anshuman Khandual , Nathan Chancellor , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Andrew Morton , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] arm64/mm: Drop redundant BUG_ON(!pgtable_alloc) Message-ID: <20221121125128.GA7097@willie-the-truck> References: <20221118053102.500216-1-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221121_045139_340608_4C38EB59 X-CRM114-Status: GOOD ( 34.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Nov 21, 2022 at 12:27:51PM +0000, Mark Rutland wrote: > On Mon, Nov 21, 2022 at 11:00:42AM +0530, Anshuman Khandual wrote: > > On 11/20/22 21:46, Nathan Chancellor wrote: > > > I just bisected a boot failure in our QEMU-based continuous integration > > > setup to this change as commit 9ed2b4616d4e ("arm64/mm: Drop redundant > > > BUG_ON(!pgtable_alloc)") in the arm64 tree. There is no output so the > > > panic clearly happens early at boot. If I move back to the previous > > > commit and add a WARN_ON() like so: > > > > > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > > > index d386033a074c..9280a92ff920 100644 > > > --- a/arch/arm64/mm/mmu.c > > > +++ b/arch/arm64/mm/mmu.c > > > @@ -383,6 +383,7 @@ static void __create_pgd_mapping_locked(pgd_t *pgdir, phys_addr_t phys, > > > phys &= PAGE_MASK; > > > addr = virt & PAGE_MASK; > > > end = PAGE_ALIGN(virt + size); > > > + WARN_ON(!pgtable_alloc); > > > > > > do { > > > next = pgd_addr_end(addr, end); > > > > > > I do see some stacktraces. I have attached the boot log from QEMU. > > > > > > If there is any additional information I can provide or patches I can > > > test, I am more than happy to do so. > > > > There are couple of instances, where __create_pgd_mapping() function gets called > > without a valid pgtable alloc function (NULL is passed on instead), as it is not > > expected to allocate page table pages, during the mapping process. The following > > change after this patch should solve the reported problem. > > > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > > index 9ea8e9039992..a00563122fcb 100644 > > --- a/arch/arm64/mm/mmu.c > > +++ b/arch/arm64/mm/mmu.c > > @@ -42,6 +42,7 @@ > > #define NO_BLOCK_MAPPINGS BIT(0) > > #define NO_CONT_MAPPINGS BIT(1) > > #define NO_EXEC_MAPPINGS BIT(2) /* assumes FEAT_HPDS is not used */ > > +#define NO_ALLOC_MAPPINGS BIT(3) /* does not allocate page table pages */ > > > > int idmap_t0sz __ro_after_init; > > > > @@ -380,7 +381,7 @@ static void __create_pgd_mapping_locked(pgd_t *pgdir, phys_addr_t phys, > > phys &= PAGE_MASK; > > addr = virt & PAGE_MASK; > > end = PAGE_ALIGN(virt + size); > > - BUG_ON(!pgtable_alloc); > > + BUG_ON(!(flags & NO_ALLOC_MAPPINGS) && !pgtable_alloc); > > > > do { > > next = pgd_addr_end(addr, end); > > @@ -453,7 +454,7 @@ static void __init create_mapping_noalloc(phys_addr_t phys, unsigned long virt, > > return; > > } > > __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, NULL, > > - NO_CONT_MAPPINGS); > > + NO_CONT_MAPPINGS | NO_ALLOC_MAPPINGS); > > } > > > > void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, > > @@ -481,7 +482,7 @@ static void update_mapping_prot(phys_addr_t phys, unsigned long virt, > > } > > > > __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, NULL, > > - NO_CONT_MAPPINGS); > > + NO_CONT_MAPPINGS | NO_ALLOC_MAPPINGS); > > > > /* flush the TLBs after updating live kernel mappings */ > > flush_tlb_kernel_range(virt, virt + size); > > This is now more complicated than what we had originally, and it doesn't catch > the case where the caller sets NO_ALLOC_MAPPINGS but the callee ends up needing > to perform an allocation, which the old code would have caught. > > This is clearly more subtle than we thought initially; for now could we please > just drop the patch? Absolutely, this was supposed to be a trivial cleanup but clearly it's much more than that. I'll revert it today. Thanks, Nathan! Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel