Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4828700imj; Wed, 13 Feb 2019 01:39:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IYZuspLW0jGIjFT0zQt8+ososIpczg5Zu2jOzG3kR2onSjXxYMRsT5cQlt84YtWroTv+YwQ X-Received: by 2002:a63:4b5e:: with SMTP id k30mr7972677pgl.212.1550050762073; Wed, 13 Feb 2019 01:39:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550050762; cv=none; d=google.com; s=arc-20160816; b=CxsdgfaOjUGmVsnvxwfq570/62SD0rEyVDHmi3xglKfiZ/9lQwd62X8P18eCax8bAY Q+7usC/hZ7mih/x4RUuNtrGO1/zfFO7J0IohEqot6T3XBTlNmputi5xCc2r2HcDgLeEc 7TYjdBbYetABjONY6uz00qoBLC2LG+/FcVLANE7rh9TEmXWFlE1Sz+XRvCHl+hQ5OZ+9 K5rUqyxlaPpCsehyUkQxxIFadYqVBVfMQFJI3SLL5CuLl8oh4tfenfuFR/cXrB8XKqD/ 7beAYlUNMND8vTm58IEnxHKh4M2dwQW7oayguD3o7X1UINAjyQsqVpJ+aGAqS/V/Fdsk gxYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :wdcipoutbound:content-language:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-signature; bh=PJY7sWbcAVPre4asLkQ/uKfSKIpiTlgqnZgh0KYFeFE=; b=WPi6ZrUVABYyUnvbmrU+snFaV+91keBdTCiYigDQ+3mgVcphPtu421LXAwMr3qi6FA XHeoXdvObcZYmm47V84IH6Nk74uXdWG3O3W4fTNNqfZC7z/F6Xwk2rlSTDwOMfPXUs5t RMEqOFprqTU/k1BwQzSBL+/ZTB4UnIrLqOTsLGdI6tP5npnxP/WfM7SVSiV1RZ0WzEd/ rPOHZDPU+Hr7RZIxGvgw07j3zg4LeW00wW3Kx25eGWUm7dpo6GINjTM+wLwDurwvgSkd eMu1vTbOOUUXtOfoTXZKSJnB+vg+stX4yhuqd8bCTujn/Q5FjpqSEwiupDEm7lY5voyn 1Jug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=o8POxGFY; dkim=pass header.i=@sharedspace.onmicrosoft.com header.s=selector1-wdc-com header.b=ZQdsTTYc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb2si18688375plb.201.2019.02.13.01.39.06; Wed, 13 Feb 2019 01:39:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=o8POxGFY; dkim=pass header.i=@sharedspace.onmicrosoft.com header.s=selector1-wdc-com header.b=ZQdsTTYc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733074AbfBMGcS (ORCPT + 99 others); Wed, 13 Feb 2019 01:32:18 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:24582 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728793AbfBMGcR (ORCPT ); Wed, 13 Feb 2019 01:32:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1550039537; x=1581575537; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=7AOlzjSj/WH9jMA4KAlBpIw3dgu/3amnrTdBqVuJ7o4=; b=o8POxGFYFexiw01ssQtta0eKnbTgiJQsEY4ofhJMJV51Jo/p/SpQNPWX UDEeEg+TZIq7LRLk0YwmEt6oRTdEDHglxOiMM2Slu539otnGNdXVKcxmJ YwSpk7in/RUS1XZTlJ+qnToOcZmInJ89dC4Jb2fUX0LaZHRPtrQFmHPJ8 Hl+JABjK7bTdH81yvPBw5BMJ9QVBjim67G4JBcythVWwYOD0FbbJYLrVg jOJggMCBI+48c7avCG1LLXzVeZGHL8h5HufiN43OkNE2UzkSvGqxqwu7q 12Te1EuOu66pH3BVZFJZZBklhfI38TzH5Cpx4VSmdO0e/AXE2IPtv+eEs w==; X-IronPort-AV: E=Sophos;i="5.58,364,1544457600"; d="scan'208";a="206244724" Received: from mail-by2nam03lp2056.outbound.protection.outlook.com (HELO NAM03-BY2-obe.outbound.protection.outlook.com) ([104.47.42.56]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2019 14:32:16 +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=PJY7sWbcAVPre4asLkQ/uKfSKIpiTlgqnZgh0KYFeFE=; b=ZQdsTTYcbpj7fOnE/WJMpE0QQynJAqo5xMIoHJl3prcE3f4EQWNUPAY2NmsiNk6KljuW+YzENcVmnZRwe7zL/C+QBKeDAkIpfSOoHbVWfo5MQt+W9lQvEdnp43a7/DOCawBsX2/ClrEyzWq/kcdLvb+xgIKY6DloVWkvPYEBz/A= Received: from DM6PR04MB6059.namprd04.prod.outlook.com (20.178.226.89) by DM6PR04MB5628.namprd04.prod.outlook.com (20.179.51.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.16; Wed, 13 Feb 2019 06:32:15 +0000 Received: from DM6PR04MB6059.namprd04.prod.outlook.com ([fe80::d006:5be7:c3f:ba6c]) by DM6PR04MB6059.namprd04.prod.outlook.com ([fe80::d006:5be7:c3f:ba6c%2]) with mapi id 15.20.1601.023; Wed, 13 Feb 2019 06:32:15 +0000 From: Anup Patel To: Palmer Dabbelt , Albert Ou CC: Atish Patra , Paul Walmsley , Christoph Hellwig , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Anup Patel Subject: [PATCH v4 4/6] RISC-V: Move setup_vm() to mm/init.c Thread-Topic: [PATCH v4 4/6] RISC-V: Move setup_vm() to mm/init.c Thread-Index: AQHUw2XcDqJ7FZsjdUi9mP3ngbpFlg== Date: Wed, 13 Feb 2019 06:32:15 +0000 Message-ID: <20190213063127.28703-5-anup.patel@wdc.com> References: <20190213063127.28703-1-anup.patel@wdc.com> In-Reply-To: <20190213063127.28703-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0027.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::13) To DM6PR04MB6059.namprd04.prod.outlook.com (2603:10b6:5:129::25) 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: [129.253.179.161] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cec771fe-7800-487e-244c-08d6917cfec8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4618075)(2017052603328)(7153060)(7193020);SRVR:DM6PR04MB5628; x-ms-traffictypediagnostic: DM6PR04MB5628: wdcipoutbound: EOP-TRUE x-microsoft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m7vND2AP4614m13WBOBR4MbX21G+YMJoeJZpzDn?= =?iso-8859-1?Q?bv5FAE4YDtzsE0ORf+1IqyPzy1H8gEApxVlObWhw23PlwfMtQhozHcB5s9?= =?iso-8859-1?Q?FQsvo5F30lG+kjnah7fyWlJ1imNgsMfXRnq6NlcoLrY4J9K1G+2oJvPNV5?= =?iso-8859-1?Q?h87/0EMgt36TgiHPQs7dA4wXYIaBPxwsavIuz87NffkX8Qp3tG1G+R9pxg?= =?iso-8859-1?Q?ZsDize4AdNlLY2Eu2GNfjvw+AooiaEDjuIaH8UOb8PKPD8+39dPuRgVzRw?= =?iso-8859-1?Q?yY1Rbn6btj8wOAKWNFiYh/6fnOTBssPZNB05WzHnRTaM9Fsx5r42kM91Dx?= =?iso-8859-1?Q?eXtqnj993kxyBU+iHJgjG6rUVpyqw7hLQZ2fa00K8jmzbmAaAGmuybqBq/?= =?iso-8859-1?Q?6rw7YSnen/vl2cpvmkGoZL1G03QeR0aJbI3ltrYSGJI4z4c7tcrJdydfo6?= =?iso-8859-1?Q?VQ=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 094700CA91 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(376002)(136003)(39860400002)(366004)(199004)(189003)(14454004)(478600001)(4326008)(106356001)(97736004)(86362001)(50226002)(66066001)(102836004)(2906002)(6436002)(256004)(6512007)(105586002)(72206003)(25786009)(26005)(53936002)(6486002)(36756003)(316002)(186003)(8676002)(7736002)(81166006)(81156014)(8936002)(110136005)(54906003)(11346002)(2616005)(6116002)(71200400001)(3846002)(71190400001)(68736007)(2171002)(52116002)(76176011)(6506007)(386003)(99286004)(1076003)(305945005)(476003)(44832011)(486006)(446003);DIR:OUT;SFP:1102;SCL:1;SRVR:DM6PR04MB5628;H:DM6PR04MB6059.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: s4CciL6aitM+8GTm3MGsU/LcXMrp89YSZffXLgTS7jErRxkaVny4Egbwd/5XUn/PK3mto6Oi445sDDPbmJ6ESc+m0QTOsbRo72G7NmAgGXpI19KfIUrf5Iytgt6mubvdlDmUkeKNik8NYMUA6EhZ06YjzfyM6B7DWXdFj9q+1kE3Xb0uFO51+x7k5gqOfCd6RKgmfFEsu8Jzc2yray/ZzCHFbm43CIq2s/NDxPwPs1c8g7BaOh9qgBg9N55fKuzzmVH6udJipZR7ohP8MDV68vbmdcyfWq3uNgAWdFLYx2lNQ5kDh7Wsmxvq4znIBjy1qZybwkowEW3KJr8cPCMAIzPFguOkiCOSaj7qkACllcQWJdFfu6+J/7eM/gcjZFxb+zg4l82Mk5ntKbL/tiEuKyB9Iict6yI2ajmnxFL/XWU= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: cec771fe-7800-487e-244c-08d6917cfec8 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2019 06:32:12.5674 (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: DM6PR04MB5628 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Palmer Dabbelt --- 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 lon= g end) } #endif /* CONFIG_BLK_DEV_INITRD */ =20 -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 =3D (uintptr_t) &_start; - pgprot_t prot =3D __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC); - - va_pa_offset =3D PAGE_OFFSET - pa; - pfn_base =3D PFN_DOWN(pa); - - /* Sanity check alignment and size */ - BUG_ON((PAGE_OFFSET % PGDIR_SIZE) !=3D 0); - BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) !=3D 0); - -#ifndef __PAGETABLE_PMD_FOLDED - trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =3D - pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd), - __pgprot(_PAGE_TABLE)); - trampoline_pmd[0] =3D pfn_pmd(PFN_DOWN(pa), prot); - - for (i =3D 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { - size_t o =3D (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; - swapper_pg_dir[o] =3D - pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i, - __pgprot(_PAGE_TABLE)); - } - for (i =3D 0; i < ARRAY_SIZE(swapper_pmd); i++) - swapper_pmd[i] =3D pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot); -#else - trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =3D - pfn_pgd(PFN_DOWN(pa), prot); - - for (i =3D 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { - size_t o =3D (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; - swapper_pg_dir[o] =3D - 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 =3D (uintptr_t) &_start; + pgprot_t prot =3D __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC); + + va_pa_offset =3D PAGE_OFFSET - pa; + pfn_base =3D PFN_DOWN(pa); + + /* Sanity check alignment and size */ + BUG_ON((PAGE_OFFSET % PGDIR_SIZE) !=3D 0); + BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) !=3D 0); + +#ifndef __PAGETABLE_PMD_FOLDED + trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =3D + pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd), + __pgprot(_PAGE_TABLE)); + trampoline_pmd[0] =3D pfn_pmd(PFN_DOWN(pa), prot); + + for (i =3D 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { + size_t o =3D (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; + swapper_pg_dir[o] =3D + pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i, + __pgprot(_PAGE_TABLE)); + } + for (i =3D 0; i < ARRAY_SIZE(swapper_pmd); i++) + swapper_pmd[i] =3D pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot); +#else + trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =3D + pfn_pgd(PFN_DOWN(pa), prot); + + for (i =3D 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { + size_t o =3D (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; + swapper_pg_dir[o] =3D + pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot); + } +#endif +} --=20 2.17.1