From patchwork Sun Apr 25 14:13:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12223339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5585CC433B4 for ; Sun, 25 Apr 2021 14:17:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D54C1600EF for ; Sun, 25 Apr 2021 14:17:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D54C1600EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BfpHguH35gKY6grGGGOdPF5boh53d0u3X8ov4BYFOZ4=; b=QIppWyHTdyUm1odGmxBFEFL5M L40Fdc34rm7tCUpqSDFYlHSEfTa89JOvuwiOFVJOo/oyByCzk0G/GF7mWPRUrBuIciOWJYQeDS8RY Ch+p6rVqFKqH+l40pKUtdt7huAxDyREW7+IknPAW8Wk8BMdERT6rKK4fafdwYhbRHy0PTtreF94ce MCTUf/5hGspyvM4YMIkNi/EvyXtMis0/PWx2ADnmgwKKauLP9r88SsJrxwoSrvfoS7Bx2iuwFvDtv Cg64aHVFmjKReqiWA0KyL6NhHUt15qDfvwRvyWnbt+ljZ5faANGn9fBfa5TWp+4hrzrmfhw/vRvz8 VWS39mP+w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lafXx-005ilO-96; Sun, 25 Apr 2021 14:15:41 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lafWf-005iLJ-7u for linux-arm-kernel@desiato.infradead.org; Sun, 25 Apr 2021 14:14:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=0DMdoS9Veuec0V12Q3JRfqDfDGvqnbvmLeiD7/pgGow=; b=wTUYKSILyjaA/gUhQ7FsOeqR45 FHypD/lqqOvzpjMGe29PLYKl/45qvvjU8U9I6z2ZZbVKRA0pblV3uJ51sf1+OYUtcluM7z+l5cCzV nbwXikmuPiAXtwofy7GH7Jjr+egf096A/KGb2ABWa4E4Fp28sctyZSFQIYDhFbAWLZHCn8/67+PK1 H6Kqaab3qTrQOPQD5gmg6mSug329fz79PV6C8xxXZ+OAIvNnmv4xuiyD7KEMXQMH2Z6FPC+U1ZHTf c2Y7SH3X05491IaPAVoeRGOrOBqOfzNDS5rtCn0mSbDVFl1ogak1z2ODGJHNjhnySJpupjPyMqIcp IcvfORgg==; Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lafWc-00FT78-O7 for linux-arm-kernel@lists.infradead.org; Sun, 25 Apr 2021 14:14:20 +0000 Received: by mail-pj1-x1029.google.com with SMTP id g1-20020a17090adac1b0290150d07f9402so3662687pjx.5 for ; Sun, 25 Apr 2021 07:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0DMdoS9Veuec0V12Q3JRfqDfDGvqnbvmLeiD7/pgGow=; b=tK0DIC5R9Leye4jivEJeBNQln26p6351TkUiOPwsWHq/Qz9AYlnk1rA3dBSDBVHPU+ SmvsQgkdAs50MeaO6jVn11Hr3evXxd+cGLzLg9zfrLlW0kMYOrp90qrS1y0ROOfdHJdP 6OP0XxYJyQbJ1qDBpnw9CstpYhTRDJ3dYdqCh1aa8fjYstjuBD6sH+7ZQpTcAWgK6O9f hQdQcwU/88CEw/GV/FR/8HtQ4HGQQik92JtYTCKMktekmd5eGNp05h0OvYGTkyp+S4eS 3HAZ29ebKFf2mU90YbOeiY0mc349Z6Zr6vjfTQBYmKo0kE/zV0UAO+0lrNGjRKTx64cj zfMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0DMdoS9Veuec0V12Q3JRfqDfDGvqnbvmLeiD7/pgGow=; b=G6RoP8w1wBAN8y3LeSACmVfzDKDXy498lbXlRruudRf1aiwKxrZU4hukiu2hC1uXzR SidhME6F+G7I1IQpL3rIVqdTA8ZhY1PqI3sMVVm6ED9NDCIYze9dBK4wLYXjgL4ddtjM hO7h6Vw7KOBkbcU3rG56WMh3XUpKHLeXUo5nRbrPbM2ho2ckVjLh27IZDfJGCUDDWcvs vHB1DsSF6Axb14WrhWCsKdwzCJvn3rDvGAqdc5rhQl9DSZFbOP1kZr2na7LgTr84DUWj h6j74o7SWfdWnE411NA+3ibirWzXn30gs2SsjXl9ayM9/lf4qaL1NkCXoS68FnJ1Hthf Idmg== X-Gm-Message-State: AOAM532mpV71bDzgJorIgT+oJsennhBRK+FgAj3eViuq203gDKtgQWpp 5erv078JNAAFkctsbg2H2AFN2TPoJA== X-Google-Smtp-Source: ABdhPJw1vKXRaq3WoSn9xF1VwgnaG0Tx42JBNMT/wuDQOxBFrSY+31y58PiWMHZ5DjfHVwkFJ8Wwnw== X-Received: by 2002:a17:902:6b8c:b029:ea:f54f:c330 with SMTP id p12-20020a1709026b8cb02900eaf54fc330mr13778469plk.10.1619360058195; Sun, 25 Apr 2021 07:14:18 -0700 (PDT) Received: from x1pad.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id r32sm1007139pgm.49.2021.04.25.07.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Apr 2021 07:14:17 -0700 (PDT) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu , Catalin Marinas , Will Deacon , Marc Zyngier , Kristina Martsenko , James Morse , Steven Price , Jonathan Cameron , Pavel Tatashin , Anshuman Khandual , Atish Patra , Mike Rapoport , Logan Gunthorpe , Mark Brown Subject: [PATCHv2 09/10] arm64/mm: make __create_pgd_mapping() coped with pgtable's paddr Date: Sun, 25 Apr 2021 22:13:03 +0800 Message-Id: <20210425141304.32721-10-kernelfans@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210425141304.32721-1-kernelfans@gmail.com> References: <20210425141304.32721-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210425_071418_805576_D422C46D X-CRM114-Status: GOOD ( 14.26 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch is the last preparation for calling __create_pgd_mapping() from head.S. Under mmu-offset situation, pud_t */pmd_t */pte_t * points to paddr. During the building of pgtable, they should be carefully handled to avoid the involvement of __va(). Signed-off-by: Pingfan Liu Cc: Catalin Marinas Cc: Will Deacon Cc: Marc Zyngier Cc: Kristina Martsenko Cc: James Morse Cc: Steven Price Cc: Jonathan Cameron Cc: Pavel Tatashin Cc: Anshuman Khandual Cc: Atish Patra Cc: Mike Rapoport Cc: Logan Gunthorpe Cc: Mark Brown To: linux-arm-kernel@lists.infradead.org --- arch/arm64/mm/mmu_include.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/mmu_include.c b/arch/arm64/mm/mmu_include.c index 746cb2b502a3..c4ea00bae4df 100644 --- a/arch/arm64/mm/mmu_include.c +++ b/arch/arm64/mm/mmu_include.c @@ -54,6 +54,9 @@ static void init_pte(pmd_t *pmdp, unsigned long addr, unsigned long end, if (likely(!(flags & NO_FIXMAP))) ptep = pte_set_fixmap_offset(pmdp, addr); + else if (flags & BOOT_HEAD) + /* for head.S, there is no __va() */ + ptep = (pte_t *)__pmd_to_phys(*pmdp) + pte_index(addr); else ptep = pte_offset_kernel(pmdp, addr); do { @@ -121,10 +124,19 @@ static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end, unsigned long next; pmd_t *pmdp; - if (likely(!(flags & NO_FIXMAP))) + if (likely(!(flags & NO_FIXMAP))) { pmdp = pmd_set_fixmap_offset(pudp, addr); - else + } else if (flags & BOOT_HEAD) { +#if CONFIG_PGTABLE_LEVELS > 2 + /* for head.S, there is no __va() */ + pmdp = (pmd_t *)__pud_to_phys(*pudp) + pmd_index(addr); +#else + pmdp = (pmd_t *)pudp; +#endif + } else { pmdp = pmd_offset(pudp, addr); + } + do { pmd_t old_pmd = READ_ONCE(*pmdp); @@ -228,10 +240,19 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, } SAFE_BUG_ON(flags, p4d_bad(p4d)); - if (likely(!(flags & NO_FIXMAP))) + if (likely(!(flags & NO_FIXMAP))) { pudp = pud_set_fixmap_offset(p4dp, addr); - else + } else if (flags & BOOT_HEAD) { +#if CONFIG_PGTABLE_LEVELS > 3 + /* for head.S, there is no __va() */ + pudp = (pud_t *)__p4d_to_phys(*p4dp) + pud_index(addr); +#else + pudp = (pud_t *)p4dp; +#endif + } else { pudp = pud_offset(p4dp, addr); + } + do { pud_t old_pud = READ_ONCE(*pudp);