From patchwork Sat Apr 10 09:56:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12195557 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,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 7D32EC43462 for ; Sat, 10 Apr 2021 10:00:53 +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 1921F610A2 for ; Sat, 10 Apr 2021 10:00:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1921F610A2 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=KOybZY7To4V21iK6gWRe/mF2R/jDk8n4PArqRhHCzXE=; b=bCNjbM10yNmDGRX6CMthncXfo 9DRcn7Bvfl3VFbOfQQb34wgebCKldYhSqVfvi1p4rH7hNceJKXOnnZ9etSme97P9dCdKKei0kuQ1f 8sNQfntrwkXAeunUCAMQ904NlsyDx6UTDPT3u5QWC5BPMoc8Tte9HNYpmJkzPK29lx5LqvZft7G0I GO9Sg5wDbADVqm82G7ujoXpb08QqVTOwwTasyI5gq/sbSC87EJorR1vif6PxK0KCpjncnhECFj+GX dctAVJ7Xkve77wID1jNd3osNUDnVDxIK+rUR54wfxjazmghkhYZqCL97zD4Qpwlh9FYi5qK/BGhjs a6LL6Lgmg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVAO7-002bgO-9D; Sat, 10 Apr 2021 09:58:47 +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 1lVAN6-002bS2-LA for linux-arm-kernel@desiato.infradead.org; Sat, 10 Apr 2021 09:57:46 +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=4k9OCzuAlGUr1qN4c20ToMLFDYt1W8fv6NNCJVMwj6E=; b=BYeF2Vw2pFaAp3BxDOU/bsBp+0 Zwo431pfboPPdtkixChh1dU0yzXcEzG4gJ+VxmmFKUIN1DoWoIr3Lk1cgZOxRP5vsecSxJNDujvDK Gkx14jvx5x0YdtDbUdZLkVZllQNHMnPswWZV9pZLWQDVDHbDr38WAW/3Yy9x0gm12YUUPzwA0otOf XK/4zDVsmktnR2N+MCFug9FwJ7iXpyWkR4IwFF2Wvdq4CiDToguXABo2dzvY2WKp65L1XnMfPLVWh /et/FeJt58eGWhE1+o1UHcyIGQQTEBC23Hp3GqEypkw2qCgLkEOVltpq/drwat2tmc4AurMtScaaE 1gXy6CEw==; Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVAN4-0051aA-7H for linux-arm-kernel@lists.infradead.org; Sat, 10 Apr 2021 09:57:43 +0000 Received: by mail-pg1-x535.google.com with SMTP id d10so5660256pgf.12 for ; Sat, 10 Apr 2021 02:57:41 -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=4k9OCzuAlGUr1qN4c20ToMLFDYt1W8fv6NNCJVMwj6E=; b=tTs6ql0MPJNA7zh7rONg2jJCmvqJ9dJhGUGCk/UywB2JrjstCQDYDikt80Ek4RD6u7 /alVX+hx2Vl7SkTAFiceeFwKeRih7HDbcixlgT24pUpidGRzancSJCIG6KHPeetEWp6Q xSLfYwys6fROXgXnAZ8M9vlyYMg7JqrN+Lsdx1HftFgN2KNfmFtTeSWR82vcoMmfYhe5 5KHpXctP/I+/UF9NgyMusmTtXojCG5re1lgiIINBNWOJd7hEL6liV8O2PcjABb21pjQS NZq3pws6gV/nvF2hECX7ZuTHpL6YT3a6IAlYerC1xTlhndNqc2e59vSrnOHITLDP0VRf ylGQ== 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=4k9OCzuAlGUr1qN4c20ToMLFDYt1W8fv6NNCJVMwj6E=; b=b8tUyKyp7h+QH8xUxV3paeA8IxG7c/Fhm2lehXjm+c4eu3fXBvdj6Z59w/YZaWBf+1 /+gaO+dV/WYXIGh/KMvLGRNguOPz0/TvQmvq8xz4KkWKS9ZkGRoN7Y8QcXyLe0JZgFys ecfOGDpAdRf9OqIeqKrQFBxq8lRg7f+OPYQfFWfyvLH295MFpWoEQMzYorBfqJgoK8bF 65zkkjdKDTATJ/Q+rUHJjp6E4sX2l3oa9dNRf0a/bLGDS3ttvStiKAwMhbYKalZ8cFMw Qx9KXtiojy+3cYIckIVGvNG5cI9JBjWx3NhH5At1ViaiQw0AuYOsiJx31UVu88hOls/G yvUg== X-Gm-Message-State: AOAM531K1iDwmgIecJF+Y4Tji4JgzyhEDtE88+XZKRh/kBWNRvh4rETa ZfohHOBBlmusKBXyJ4qdo27A0xqREg== X-Google-Smtp-Source: ABdhPJxmkEniuTDO2wFQeKRt+swrMZkECeyIwnPsK1LAT+FR1lDvsfTLyUGdzlao6oz9GLHP8a3/Ww== X-Received: by 2002:a65:5c4d:: with SMTP id v13mr559053pgr.161.1618048661298; Sat, 10 Apr 2021 02:57:41 -0700 (PDT) Received: from x1pad.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id m14sm3836322pfh.89.2021.04.10.02.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Apr 2021 02:57:41 -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: [RFC 6/8] arm64/mm: introduce pgtable allocator for head Date: Sat, 10 Apr 2021 17:56:52 +0800 Message-Id: <20210410095654.24102-7-kernelfans@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210410095654.24102-1-kernelfans@gmail.com> References: <20210410095654.24102-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210410_025742_283286_3E6A93C8 X-CRM114-Status: GOOD ( 10.89 ) 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 From the view of __create_pgd_mapping(), both idmap_pg_dir and init_pg_dir can be treated as a memory pool. Introduce an allocator working on them, so __create_pgd_mapping() can create mapping. 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.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 628752c3cfd0..b546e47543e2 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -86,6 +86,28 @@ pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, } EXPORT_SYMBOL(phys_mem_access_prot); +struct mempool { + unsigned long start; + unsigned long size; + unsigned long next_idx; +}; + +struct mempool cur_pool; + +void set_cur_mempool(unsigned long start, unsigned long size) +{ + cur_pool.start = start; + cur_pool.size = size; + cur_pool.next_idx = 0; +} + +unsigned long __init head_pgtable_alloc(unsigned long unused_a, void *unused_b) +{ + unsigned long idx = cur_pool.next_idx++; + + return cur_pool.start + (idx << PAGE_SHIFT); +} + static unsigned long __init early_pgtable_alloc(unsigned long unused_a, void *unused_b) { phys_addr_t phys;