From patchwork Sun Apr 25 14:12:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12223321 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=-8.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_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 C1AFDC433B4 for ; Sun, 25 Apr 2021 14:15:36 +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 46E2260232 for ; Sun, 25 Apr 2021 14:15:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46E2260232 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: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:In-Reply-To:References:List-Owner; bh=oLrlzZfnsgaUEnCQhq67WO0CT18oIoAqZ6865b93pZc=; b=DGzqtQvIyGEGeStK1DIHRPN9+O WvdFjMfXlwzIh9imIiWtgn4jROKh77wTDVYnb+tRCvieqvTNwgqsYHca2Dj9uQ+xpmO3nhFAW8CLi F1xqYh/F5nXsb3nxwbTsUpq0sann9Upxg866YGm4X55HK+xaNpIecxdE43m1qhYBGcKNQ/mUVkhf/ PDDCkubwkGrvHU6lLuzBZCP1xga5kF0y8yOrE0pxkSw/dNSY4+n8DUv5fiotXt/u1Wwu0IoLwLaFA aMs5i0qymoitpoVfZH+tKjWYXIf38s6nwwbKh9QjcM+4ctJ0ae2UIZUgz4NDlxhfpYQdsAKRMwf3R MgrqbCHw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lafVo-005iFH-O1; Sun, 25 Apr 2021 14:13:28 +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 1lafVm-005iF2-9i for linux-arm-kernel@desiato.infradead.org; Sun, 25 Apr 2021 14:13:26 +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:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=le6LPu1cou+YvEKCt0AWQ/cmPj9y83b8cfhHPd6lzCQ=; b=rTq0PBB644x6VJ6Z5ayO+i1LzP mU3JrP82NshN94kwfSNBPHGuz5d65KWSjMvUaezLpQ4GsBIPyKAmZIDPWNKuIRMonc4Os41s6mtmr dRTork5xzMwOdufyLsl62gea2vavwU/hoYTQjry5SPtOhTu+xIT5W9+OPbnvLyJi+mo1wcDTgOcga q5E6L0HNdnoxaQZm5oW1NzTDSZCubQxn5FB0rbKP1EEfjU7NezcCMwHaGAXc2OAhyLLktTq3qIWPG Ta2gWDXVT7wylovFvWxPthZCLMIyo+x5F8y3E0iixRkvGBjnJp+hxSip+cDFwdSaIdCyK2jC98Gm3 CLHv33aQ==; Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lafVj-00FT3f-BY for linux-arm-kernel@lists.infradead.org; Sun, 25 Apr 2021 14:13:24 +0000 Received: by mail-pf1-x435.google.com with SMTP id m11so37252357pfc.11 for ; Sun, 25 Apr 2021 07:13:22 -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:mime-version :content-transfer-encoding; bh=le6LPu1cou+YvEKCt0AWQ/cmPj9y83b8cfhHPd6lzCQ=; b=IiGwuqluWwsnWiaVRkFHnstil27LXQVV49Esp5h07LB+D8EcaT/LO2RR9fBnsypQa3 z0wLWXkvRVaUyJ0qfo92PZbLsWe0M+RhVbvqXXyhcYbmK6EstUSjy2ZEykUFXzQiBU6N T1AojF+QLhTCkOEXxMh4cX99/Bree8T4L0ZwYyYx2rVETUDbVxbLieN/JodbbnW/N5zg O009cXbtdiXNXPk5BdVRRfiUOStA1HQ9eyuNj7DcKz5Hb5q4Jf7SIAPbSEaBbK8mJkOi 7OFilFRIqGR0Q2JTrXhyDf9iGjxrYLdRumOkbrAxt0skHHwY3TfysXGwchvmqpo4qXKW gbXA== 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:mime-version :content-transfer-encoding; bh=le6LPu1cou+YvEKCt0AWQ/cmPj9y83b8cfhHPd6lzCQ=; b=P9amAZ4loCRhV/l6i5esfedQokbxtuW/KAXq7nZufhs4pst0M6rwlt1Xk/1ivXibxk OamS+u4mbdcZVGK9GGFBXcj7e/iMAhlDMrUR9ar+AlNSlL+XGnjku2B6FX2L2neTtRLE gw6m8Fcx8WBrhGSb5N+N/HC+5MuqNLAV6C4hckjetBefkwjQr9JRxdbXS2KVkXBEbRik 6ytzAoUO5eF68nR5MnaGl/3K0zxmq75jHsfWHMFuyV7HQC2kFnsddW0AO4OrxqGHhApS vA7wfvYjucMHATQeP53uk+yUyqM2aUt1/RCizbbw9aS6vemJb+0Vtm8hnZ/UBEF0Jz92 6zXQ== X-Gm-Message-State: AOAM533gIN1RiDuPsG1m43WyTopHbT4Ckzy/GQZSlsAUiXPNpIuzA3pp sTLI6C34Ic1LZoJRjvdFAXVVpwW6sA== X-Google-Smtp-Source: ABdhPJyDH46G3w6VrtA5uQpiIofUOzsCwbXz1iouyl3f3Y2Muz7Bka4GfJzQhGjvtu4kCXOIMEgGZQ== X-Received: by 2002:a63:4423:: with SMTP id r35mr13071892pga.13.1619360001650; Sun, 25 Apr 2021 07:13:21 -0700 (PDT) Received: from x1pad.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id r32sm1007139pgm.49.2021.04.25.07.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Apr 2021 07:13:20 -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 00/10] use __create_pgd_mapping() to implement idmap and unify codes Date: Sun, 25 Apr 2021 22:12:54 +0800 Message-Id: <20210425141304.32721-1-kernelfans@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210425_071323_434714_86A0FCE0 X-CRM114-Status: GOOD ( 12.36 ) 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 series aim to share the pgtable manipulation code to head.S and trans_pgd_idmap_page(). The core of the idea is by redefinition the CONFIG_PGTABLE_LEVEL, two sets of pgtable manipulation code are generated, one as now is for swapper_pg_dir, the other one is for idmap. And a dedicated create_idmap() API is introduced. The series can be grouped into two [1~5/10] achieves porting trans_pgd_idmap_page() and introduce create_idmap() API [6-10/10] replace head.S pgtable manipulation asm with calling to __create_pgd_mapping() This series can success booting with the following configuration on Cavium ThunderX 88XX cpu : PAGE_SIZE VA PA PGTABLE_LEVEL 4K 48 48 4 4K 39 48 3 16K 48 48 4 16K 47 48 3 64K 52 52 3 64K 42 52 2 History RFC: https://lore.kernel.org/linux-arm-kernel/20210410095654.24102-1-kernelfans@gmail.com/ 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 Pingfan Liu (10): arm64/mm: split out __create_pgd_mapping() routines arm64/mm: change __create_pgd_mapping() to accept nr_entries param and introduce create_idmap() arm64/mm: change __create_pgd_mapping() to accept extra parameter for allocator arm64/mm: enable __create_pgd_mapping() to run across different pgtable arm64/mm: port trans_pgd_idmap_page() onto create_idmap() arm64/mm: introduce pgtable allocator for idmap_pg_dir and init_pg_dir arm64/pgtable-prot.h: reorganize to cope with asm arm64/mmu_include.c: disable WARN_ON() and BUG_ON() when booting. arm64/mm: make __create_pgd_mapping() coped with pgtable's paddr arm64/head: convert idmap_pg_dir and init_pg_dir to __create_pgd_mapping() arch/arm64/Kconfig | 4 + arch/arm64/include/asm/pgalloc.h | 29 +++ arch/arm64/include/asm/pgtable-prot.h | 34 ++- arch/arm64/kernel/head.S | 196 ++++---------- arch/arm64/mm/Makefile | 2 + arch/arm64/mm/idmap_mmu.c | 39 +++ arch/arm64/mm/mmu.c | 362 ++++++-------------------- arch/arm64/mm/mmu_include.c | 320 +++++++++++++++++++++++ arch/arm64/mm/trans_pgd.c | 62 +++-- 9 files changed, 579 insertions(+), 469 deletions(-) create mode 100644 arch/arm64/mm/idmap_mmu.c create mode 100644 arch/arm64/mm/mmu_include.c