From patchwork Tue Feb 12 14:00:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10807979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06DED922 for ; Tue, 12 Feb 2019 14:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EABF82B56B for ; Tue, 12 Feb 2019 14:00:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E85072B8F1; Tue, 12 Feb 2019 14:00:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D6762B56B for ; Tue, 12 Feb 2019 14:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l63ax3OQk2YSMEulJ0WRqI8JW7g5IltRO/rQC7R3np0=; b=SkCSVBmbc6uk+T YYJkSFP4tB6MTwrQkn7KMkK53wrOHODnkHSnDq56bHHAdn/4PyMYHyrs4uYF9NN0PaoT/+mFCXeqR JEeI/xIUMxTymCJk3g7/aW15Yzk+V4/NQIOXYU4vokREt0EFecbvp/G6Cz5ysexTdusQRfzWHyUbd dwHmAuh2oI4ydFIS6vMWYkvCHQhkveW87+X4t0IWH+KgOmZuxKOe5zmhf2paJrHYTIq7x+nPCnCgr L1B8qN8LFk/746inrngcQnhpLqm1gCOhtUwhKvQV+s9AwzTtCRxtT+PQBX5tkJI1lbTcVqBbNEQkm sxs8hsSVkcGRWnxJp6Ig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtYc3-00038K-Q7; Tue, 12 Feb 2019 14:00:39 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtYc0-000358-2s for linux-riscv@lists.infradead.org; Tue, 12 Feb 2019 14:00:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1549980036; x=1581516036; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=/9qqvZm9BuFaUahBO5rE9KWZFbLQhXyUVzJqiZgjWRo=; b=gZuGVdfEbGdIfjBEYQIbZYEKvCjR8GQtBTZnl75oYA48y2fhh7QCBp69 Kro0Vchj6k1PFQWD9hmm7y/V/FBjLepzBKa2ZjsQ98QwZMW0DqG7Hx6z2 3bIB2cXVUgwn9obi25qU4Lx6CwOpqLcVC/1ItNEru3yh2lyioykF/0ZTa 5oQL+dGs449b0f87Oa3BPjvSzy66+03+sRRDibd7hhzqScYh3pORkDwYX Z1hZe15xWwbpqbwmYXFcSdGytAxZGREROfaRkWWylddruSIOA/Bv2ZpAW 9uEBa5QJajH7NEMdzErYs1lBH3MSmW//SoK5xg4gkXg5CjImwxY1pc4b/ A==; X-IronPort-AV: E=Sophos;i="5.58,362,1544457600"; d="scan'208";a="102320639" Received: from mail-bn3nam04lp2053.outbound.protection.outlook.com (HELO NAM04-BN3-obe.outbound.protection.outlook.com) ([104.47.46.53]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2019 22:00:32 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d0F4pvgq60HxEKWnoc+e9Gn5WgL9ePYqiMQTmBSNiP8=; b=irxJEDkreoMiqZ1UWfGVA1njvyCU8WVp1wsH94sulULJEPkCe/qemhLACCk4YgHD4zGM5gtqeP0CCDvdD6hN79QPfKL4vvM98GpO+FLMXloHivNgDP6pQPmpVrPqH3/pwX9fLx3so/YWruytk6rOiNbKOYFcoXo3gruFiqUhlWc= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.247.148) by MN2PR04MB6224.namprd04.prod.outlook.com (20.178.247.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.22; Tue, 12 Feb 2019 14:00:31 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::2cdb:c465:af57:8be1]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::2cdb:c465:af57:8be1%7]) with mapi id 15.20.1601.023; Tue, 12 Feb 2019 14:00:31 +0000 From: Anup Patel To: Palmer Dabbelt , Albert Ou Subject: [PATCH v3 4/6] RISC-V: Move setup_vm() to mm/init.c Thread-Topic: [PATCH v3 4/6] RISC-V: Move setup_vm() to mm/init.c Thread-Index: AQHUwttQVbyPbi79K06WYpnA0PywoQ== Date: Tue, 12 Feb 2019 14:00:30 +0000 Message-ID: <20190212135942.105008-5-anup.patel@wdc.com> References: <20190212135942.105008-1-anup.patel@wdc.com> In-Reply-To: <20190212135942.105008-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0126.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::20) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:de::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.205] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 69d173a4-763b-43c4-fc69-08d690f2731f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4618075)(2017052603328)(7153060)(7193020); SRVR:MN2PR04MB6224; x-ms-traffictypediagnostic: MN2PR04MB6224: wdcipoutbound: EOP-TRUE x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; MN2PR04MB6224; 23:bD1z6jr0MatCoyNxyOAFkgQC3IYwJ8ZXKKLSZ66?= =?iso-8859-1?q?qwvoVBsKtzcjs9O?= =?iso-8859-1?q?7Wr5s4hBatV3giXWnKqdORBZN8cjhgPuB4tBh4R/dnQnCrfWMl8m+Wjoe20Y?= =?iso-8859-1?q?2WrL/iPkcunezFQMkrXSk1JZbaaL2Jd/IyI9fyMJ7tcUrvKJXFMVWizsyRad?= =?iso-8859-1?q?yYOy5mpJ24Yn/xniOJZyfm27TRx0X5CEduRVCFzhvRuz5QgRtfT6/PQ8LCo/?= =?iso-8859-1?q?q6WGZ4lxGJp/qfGfSYzl4EaSKwCNO3gs4U8Yq6Fjf8Tgt3Wf683y1ZMT6oW3?= =?iso-8859-1?q?wSxebbiv3hco0o6BBvrqYsU5xsbUWYzVfn9tLnxioG53v0oilJANBb2GsEpG?= =?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iTCW7yqI+TdK2bmsTFVWd1RFXppfgF98N7fWpd/p7I?= =?iso-8859-1?q?95bjZW/9S00I7I7in7Xt6QntkR?= x-microsoft-antispam-prvs: x-forefront-prvs: 0946DC87A1 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(396003)(39860400002)(346002)(376002)(136003)(199004)(189003)(11346002)(25786009)(2616005)(72206003)(486006)(2171002)(478600001)(4326008)(446003)(14454004)(6512007)(476003)(52116002)(36756003)(110136005)(97736004)(3846002)(6116002)(8936002)(50226002)(76176011)(54906003)(99286004)(7736002)(256004)(106356001)(316002)(81166006)(105586002)(68736007)(186003)(8676002)(44832011)(1076003)(6486002)(6436002)(86362001)(66066001)(53936002)(2906002)(305945005)(55236004)(386003)(71200400001)(102836004)(6506007)(71190400001)(26005)(81156014); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB6224; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: pKKXRZr34twV7Kh87BLcJ4WhxsrdStFAmA1BoRLsfURuewQTtgSgmG+pl0w7X7FlrC30vY3b7tHg7hPGy1gcw10HxXICQqW51rdYEhDWhgP1vrKJq5kbRrZs7VcX3nZbW5LMBhV7bTC3LE9lIOaR5MQPUSz+JSjvHE4/Be5scC2gF2H4v5IKGuTORsxWjMURpbM9IXBR8xTlJpBQrt0k8xQ4iPuuaFEM2cEjKa/O8Q12wG/c72iwuLO4m6Wpp2XcqICw9fRWBnKwepqm6uIzys15xaTqW0JMSUlHLJdxebSiwsDhmGwyEoNUmN+hMQogDhhJBVygjYMN8EeXw9OKpTorukQYojNSCrcKR1H41s3eAKPiWkvtNR023fKoEKRgXC7ndebo3I7YGhSE/D09g6nytTuN2f3bqqjOPl2Bgk0= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69d173a4-763b-43c4-fc69-08d690f2731f X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Feb 2019 14:00:28.3107 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6224 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190212_060036_242892_73C3CCB0 X-CRM114-Status: GOOD ( 15.07 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , "linux-kernel@vger.kernel.org" , Christoph Hellwig , Atish Patra , Paul Walmsley , "linux-riscv@lists.infradead.org" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The setup_vm() is responsible for setting up initial page table hence should be placed in mm/init.c. Signed-off-by: Anup Patel Reviewed-by: Christoph Hellwig --- arch/riscv/kernel/setup.c | 49 --------------------------------------- arch/riscv/mm/init.c | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index ab29a66a17fc..9cd583b6d1cd 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -102,55 +102,6 @@ void free_initrd_mem(unsigned long start, unsigned long end) } #endif /* CONFIG_BLK_DEV_INITRD */ -pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; -pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); - -#ifndef __PAGETABLE_PMD_FOLDED -#define NUM_SWAPPER_PMDS ((uintptr_t)-PAGE_OFFSET >> PGDIR_SHIFT) -pmd_t swapper_pmd[PTRS_PER_PMD*((-PAGE_OFFSET)/PGDIR_SIZE)] __page_aligned_bss; -pmd_t trampoline_pmd[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); -#endif - -asmlinkage void __init setup_vm(void) -{ - extern char _start; - uintptr_t i; - uintptr_t pa = (uintptr_t) &_start; - pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC); - - va_pa_offset = PAGE_OFFSET - pa; - pfn_base = PFN_DOWN(pa); - - /* Sanity check alignment and size */ - BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0); - BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) != 0); - -#ifndef __PAGETABLE_PMD_FOLDED - trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = - pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd), - __pgprot(_PAGE_TABLE)); - trampoline_pmd[0] = pfn_pmd(PFN_DOWN(pa), prot); - - for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { - size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; - swapper_pg_dir[o] = - pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i, - __pgprot(_PAGE_TABLE)); - } - for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++) - swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot); -#else - trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = - pfn_pgd(PFN_DOWN(pa), prot); - - for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { - size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; - swapper_pg_dir[o] = - pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot); - } -#endif -} - void __init parse_dtb(unsigned int hartid, void *dtb) { if (!early_init_dt_scan(__va(dtb))) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index a57dba8ac9e7..7ed6ae90cf6b 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -103,3 +103,52 @@ void __init setup_bootmem(void) &memblock.memory, 0); } } + +pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; +pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); + +#ifndef __PAGETABLE_PMD_FOLDED +#define NUM_SWAPPER_PMDS ((uintptr_t)-PAGE_OFFSET >> PGDIR_SHIFT) +pmd_t swapper_pmd[PTRS_PER_PMD*((-PAGE_OFFSET)/PGDIR_SIZE)] __page_aligned_bss; +pmd_t trampoline_pmd[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); +#endif + +asmlinkage void __init setup_vm(void) +{ + extern char _start; + uintptr_t i; + uintptr_t pa = (uintptr_t) &_start; + pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC); + + va_pa_offset = PAGE_OFFSET - pa; + pfn_base = PFN_DOWN(pa); + + /* Sanity check alignment and size */ + BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0); + BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) != 0); + +#ifndef __PAGETABLE_PMD_FOLDED + trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = + pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd), + __pgprot(_PAGE_TABLE)); + trampoline_pmd[0] = pfn_pmd(PFN_DOWN(pa), prot); + + for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { + size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; + swapper_pg_dir[o] = + pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i, + __pgprot(_PAGE_TABLE)); + } + for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++) + swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot); +#else + trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = + pfn_pgd(PFN_DOWN(pa), prot); + + for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { + size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; + swapper_pg_dir[o] = + pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot); + } +#endif +}