Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4203096rwb; Mon, 21 Nov 2022 05:06:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6anN5NhwlmG50a7wpxAan03XnkiJAJ4zcBN+MRV1bPaQ5RDe91rldoqsJzV/AL/gGuzVl4 X-Received: by 2002:a17:902:b283:b0:179:fe08:48da with SMTP id u3-20020a170902b28300b00179fe0848damr2988671plr.154.1669036007002; Mon, 21 Nov 2022 05:06:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669036006; cv=none; d=google.com; s=arc-20160816; b=KMZsFWdzwufrcZqrYUR5dYHx058SHiueWw5lnqQtINc0nfPjsQsFV2B/W5v1d4NkKP SBEcNNU7ZugPy09OlKIvbYgqvT+XquccjoZpKPCU1ew9S2nWHrmKzlCccrO/ltdp806U eIKfCGmihFRKFRIITG9XT4kv61oZXCLKkIwNruHzHRucNMuTLggZic7JP0+PbxgXhBQb IEJaa7BsQCvioziwZh+8fUqfOKu9gr3CnUWoVwIm1PMVstpwEiHHMnb62Pcq90bra3q3 6PTK5Wp1x1Zt8vb/jJyWOVez71sc4j9uv5iMN9OBPOEf5sS/2nx1tje9AAXHgUuRW4oJ iE9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=aGDG6uWlUz77IvPdCWKZCkjPb1NozmX0QmMG0Jm91c8=; b=lx/NIkNYUoiIeLPDFCo6ImhJ4HDmDq36E65PwHFiKS/qLAqeNKT7PFRh3Vf2OdcdQE LJTWFYSW2XSbL93aNR7G7kh1UCrLMHlPAhDgyDWq1Wy+ft6rxc10xuAhXMIuZEpBO/77 mpJGeT1gQD5JBdwOqUd+Kwy6295+H04CfXqv/5VTt02fx7ZZuT269P2gyQ4MHda1MY56 /tKrLcM9QJmSFFQrUHnE6Htuhc0e9TNSt8xBZ2tMGb/X3FFRxDUrolTxtzfMMg9nIPoL lNrKVrnZDDpMAjYdIBjpSasy2B01FTbwECOyHO754Fpl2BsgHRvKpI7tCByu75vgXMKz aNaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X23QJBIv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m4-20020a1709026bc400b0017b2fe7de33si10357922plt.10.2022.11.21.05.06.33; Mon, 21 Nov 2022 05:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X23QJBIv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229687AbiKUMvk (ORCPT + 92 others); Mon, 21 Nov 2022 07:51:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiKUMvh (ORCPT ); Mon, 21 Nov 2022 07:51:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 488A0B6B07 for ; Mon, 21 Nov 2022 04:51:36 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id C56EE611A5 for ; Mon, 21 Nov 2022 12:51:35 +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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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