From patchwork Fri Nov 18 05:31:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 22105 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp8302wrr; Thu, 17 Nov 2022 21:34:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf7caQA58gBx8O6cpiUEJ5lI0uZs/jwwL7vUkeKP2xBqNKngyQs2P4bWVRvUlt/3YQbIbxf5 X-Received: by 2002:a17:902:9a8e:b0:186:e5dc:4c55 with SMTP id w14-20020a1709029a8e00b00186e5dc4c55mr5840710plp.148.1668749658216; Thu, 17 Nov 2022 21:34:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668749658; cv=none; d=google.com; s=arc-20160816; b=ErPDLDltjaIRUC0IWk/xxyX5bz7wtiaY4S7bLgBdFvDBKUD8YjZyCgC28DSY7fvRoa LbL7hv7gbD4bZUHaEZfRQARIQFZt6Q6ypDXnw9Xpu3XS2nXUrfsieNSPp5/nIKffug22 tGmHsdq+accMH6Iqy8gkCF/Ip+M/8Bt2HFvVMlGzmlcBtA6BHLKE2grgVWi03IxPRdr+ xLG0U9Q3mrkuHuBue3td3rgAOOU06vuq0ZuMmz+IvsAscKG9J+XdwDH4eo4yJaLNXC/p tvCSPTv+uiTiW0oXpBcE7hoex6P4Sca/nNcydcIB7MGzs0jNioEjHp2cmkHBT5N1smv1 Qpjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Y/tsnrid5MB7hMPggrb3hTOIXUhx8e2sAYMov5KvcGQ=; b=T9KNgI4jRirtrFbena6/ToFAWLvJ/4uoXBwsdERIFVu9BgfU2oqsZKeLbc3ljmfhXK kN/4O3sk1yUID/VJJnAxylewXQP3WvXvVd0wwlwsZD99WuOMR4gqrTjHVf5dWyaMn64q UjlIAFvyYSYKq2SI3o99if6rFxHUEatZ0EoBPDfZksRFc0cgQiOE6yFD8BjrMLplTp11 BxFPIoqRjKiM8FG6EGtjJiGyU2EM6QTn/NvDkunDykXyZQMI6IPsVRDemJQNbY6sgUyG XRyrVc8Y9zUm51kUVmAHhcSWl0urw3e6cUgxGJo5tl28nbUzz4U1/vDqFCCZHrrsV3E8 kNQA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a6542c5000000b004700981177dsi2949270pgp.528.2022.11.17.21.33.59; Thu, 17 Nov 2022 21:34:18 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235120AbiKRFbP (ORCPT + 99 others); Fri, 18 Nov 2022 00:31:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbiKRFbN (ORCPT ); Fri, 18 Nov 2022 00:31:13 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6E81D87A49 for ; Thu, 17 Nov 2022 21:31:11 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4595223A; Thu, 17 Nov 2022 21:31:17 -0800 (PST) Received: from a077893.blr.arm.com (unknown [10.162.41.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0C5873F587; Thu, 17 Nov 2022 21:31:07 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Mark Rutland , Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH] arm64/mm: Drop redundant BUG_ON(!pgtable_alloc) Date: Fri, 18 Nov 2022 11:01:02 +0530 Message-Id: <20221118053102.500216-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749810841850641102?= X-GMAIL-MSGID: =?utf-8?q?1749810841850641102?= __create_pgd_mapping_locked() expects a page allocator used while mapping a virtual range. This page allocator function propagates down the call chain, while building intermediate levels in the page table. Passed page allocator is a necessary ingredient required to build the page table but its presence can be asserted just once in the very beginning rather than in all the down stream functions. This consolidates BUG_ON(!pgtable_alloc) checks just in a single place i.e __create_pgd_mapping_locked(). Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: Andrew Morton Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual Acked-by: Mark Rutland --- This applies on v6.1-rc5 arch/arm64/mm/mmu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 5a19950e7289..97ca82001089 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -207,7 +207,6 @@ static void alloc_init_cont_pte(pmd_t *pmdp, unsigned long addr, if (flags & NO_EXEC_MAPPINGS) pmdval |= PMD_TABLE_PXN; - BUG_ON(!pgtable_alloc); pte_phys = pgtable_alloc(PAGE_SHIFT); __pmd_populate(pmdp, pte_phys, pmdval); pmd = READ_ONCE(*pmdp); @@ -285,7 +284,6 @@ static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr, if (flags & NO_EXEC_MAPPINGS) pudval |= PUD_TABLE_PXN; - BUG_ON(!pgtable_alloc); pmd_phys = pgtable_alloc(PMD_SHIFT); __pud_populate(pudp, pmd_phys, pudval); pud = READ_ONCE(*pudp); @@ -324,7 +322,6 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, if (flags & NO_EXEC_MAPPINGS) p4dval |= P4D_TABLE_PXN; - BUG_ON(!pgtable_alloc); pud_phys = pgtable_alloc(PUD_SHIFT); __p4d_populate(p4dp, pud_phys, p4dval); p4d = READ_ONCE(*p4dp); @@ -383,6 +380,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); do { next = pgd_addr_end(addr, end);