From patchwork Mon May 31 08:45:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12288905 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 18252C47082 for ; Mon, 31 May 2021 08:48:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D2706611AC for ; Mon, 31 May 2021 08:48:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2706611AC 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=bombadil.20210309; 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=pCZ4EC8KNpg4PsqBW7em3i8MTWB71YdLNMc/JSMVZIo=; b=nJCpnKTGnpJUAc 2NRoVamz/tpO0NSyZH1RxFzXIfAw6MWM92my35qKLzKjqdzaOfDLn+qjySQjWnuT3YUW3FmvkqExA 3hnwNa26cjKknmXChl7H0GAOZ04sKCBgNhGz+SKTqUj5JkbY9Cec0HQCvVl19b500VpTFxnPqvdGM 3f3igco79MBdnvAmeTn+k6JbyCLqwr8gkVQ8qzqfNnFLfQUj+LT/GyQamycHYUYwh08QqSMDHMwX1 7Zr9HwRWIQ/oVm3P607L/4jqlbpkndArww61clqdEqnljIvnqcn8X0iGpRHZG3s1dzFv7qkr1lBJT CXMALLhbG5uHy36pDpmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lndZ2-00BWAB-OW; Mon, 31 May 2021 08:46:24 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lndYp-00BW8f-Vx for linux-arm-kernel@lists.infradead.org; Mon, 31 May 2021 08:46:14 +0000 Received: by mail-pl1-x635.google.com with SMTP id v13so4860595ple.9 for ; Mon, 31 May 2021 01:46:11 -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=U0waVifzBAtCWMpyTCX/XUC7ce55I6cPGggbE8PRRcE=; b=FUPxp1dBJwvmNZfKJDJhHoOZTJ/ufpAULm+4Hpm2nYz9rsJaSZqzYKz9xUtyCLccRs jifH4NEsoM5sNuGYv+T2ltVuAQDnY3H5lqkmnMbLWtut6dcFB1ayutGdljmxU1IlGWTg pTZAR3/I+/IlPjXN0DF4g4+xUBKlfRSR+MJHZiPvsB2V1e8hwvMOVbJMELuYHak9GAe7 jYyqrs0CKPK2nmFmwnQzK0olieEMMLrq0WrYxSNSEkp8uIORiQmHoqsm1g6812qTwNDb 6tEDRfQf5DO/SxAEYQ6QouK6/Sy3cegzmL+8Z7sH6t9TZgdhPMnrfBkP9QG9GQM5c9VI Ga0w== 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=U0waVifzBAtCWMpyTCX/XUC7ce55I6cPGggbE8PRRcE=; b=td4iVlK9Uj2nhncIU80nNaTTP05Vco1lqjgLRL/CT5E8QTxdxwDyxq9z3rBVeOQikn lRmtf9iiEU9pt6rJ/HAl2PN4qRB68bzr5stzIOatjgBCi4OvYwiMrpjZlq29uLjH7uzq 4o3kCjvCepYQR2Vj9CpgTN0zxj8HKz84WJH9Kb9e0gu+2dw5iSu7kbg1Mi7zw0LZC+Vm qLCY9v/5dmfnA1UrLNfCllfSHEcO72ym5CU1P49xmvVcAF/ItfdGz9aUYc6uLYgDsht0 ssFdODV7VCvYOP+SJXPsw2UbavCTA4Q3ifptnpUoj2Yd+fFC+HknmBns1jsUWiXw4sJG hhuA== X-Gm-Message-State: AOAM533179aVfZN/sWHoVl94EfDH7uUISxQiwEXmbJ3y0v9NRJvQpJQV Kb5qGPZAlWRwQdVaMn2/ksv63tdz5FdBzuw= X-Google-Smtp-Source: ABdhPJwH6wLHQbE3IKiiFGY7Zj1jKFMhJWBZSdXwGrStlOZunKqufpGmJxqkAOQwgJozDElLU2oIRQ== X-Received: by 2002:a17:902:c1d2:b029:101:656b:8c06 with SMTP id c18-20020a170902c1d2b0290101656b8c06mr13079691plc.77.1622450770790; Mon, 31 May 2021 01:46:10 -0700 (PDT) Received: from qualcomm-amberwing-rep-18.khw4.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id fs24sm5125677pjb.6.2021.05.31.01.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 01:46:10 -0700 (PDT) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu , Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , Kristina Martsenko , James Morse , Steven Price , Jonathan Cameron , Pavel Tatashin , Anshuman Khandual , Atish Patra , Mike Rapoport , Logan Gunthorpe , Mark Brown Subject: [PATCHv3 1/5] arm64/mm: introduce pgtable allocator for idmap_pg_dir and init_pg_dir Date: Mon, 31 May 2021 04:45:36 -0400 Message-Id: <20210531084540.78546-2-kernelfans@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210531084540.78546-1-kernelfans@gmail.com> References: <20210531084540.78546-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210531_014612_181321_47ED33F4 X-CRM114-Status: GOOD ( 12.23 ) 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 When building a pgtable, __create_pgd_mapping() resorts to pgtable allocator to alloc mem. By introducing an allocator, __create_pgd_mapping() can consider both idmap_pg_dir and init_pg_dir as a memory pool, and get memory from them during the building of pgtable. Signed-off-by: Pingfan Liu Cc: Catalin Marinas Cc: Will Deacon Cc: Ard Biesheuvel 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 6dd9369e3ea0..f4fc905718ca 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -90,6 +90,28 @@ pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, } EXPORT_SYMBOL(phys_mem_access_prot); +struct headpool { + phys_addr_t start; + unsigned long size; + unsigned long next_idx; +}; + +static struct headpool cur_pool __initdata; + +void __init set_cur_headpool(phys_addr_t start, unsigned long size) +{ + cur_pool.start = start; + cur_pool.size = size; + cur_pool.next_idx = 0; +} + +phys_addr_t __init head_pgtable_alloc(unsigned long unused_a) +{ + unsigned long idx = cur_pool.next_idx++; + + return cur_pool.start + (idx << PAGE_SHIFT); +} + static phys_addr_t __init early_pgtable_alloc(int shift) { phys_addr_t phys;