From patchwork Wed Feb 13 11:53:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10809659 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 00D031390 for ; Wed, 13 Feb 2019 11:54:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 211CE2964E for ; Wed, 13 Feb 2019 11:54:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1446129A3C; Wed, 13 Feb 2019 11:54:04 +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 7C2B32973A for ; Wed, 13 Feb 2019 11:54:03 +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=/YinQNQS8QG7Hpe4IwnGLeNOR4DNXa3hjQA5p56UeBc=; b=nUUpTqpsS6DZX9 9zX3qrkxWhNL4B4rTq2rIfHpeBhyucG40gSUyjkLfaTKbNqZb5ig8DdQUWeRj83UEVUb7EKt2AODz BBx44ZxWLG0l1AnR0RC26ld6R88eICvJu3i4yQ+ffTLYeaYAoBV1/+PwsSkFLgeGhqZkjbYY7edb+ mTUjFdBRewC63q1luQrIxcTUKpBLbudbNGBhnvhRB3d/cQpusb7Fw0kMVngg6ZGknoYX/h0F+XSLj pgL8B796e8Ebbn2JGbkBz/V2YXSQms1C9KNF/ae0t3uKPjHwW/wIYZI7nma/W7IH6v3DSEXOlxrqL tRSZULaw6NxW1nh4mm3Q==; 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 1gtt72-0007ox-Cu; Wed, 13 Feb 2019 11:54:00 +0000 Received: from esa3.hgst.iphmx.com ([216.71.153.141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtt6m-0007Mh-Jo for linux-riscv@lists.infradead.org; Wed, 13 Feb 2019 11:53:48 +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=1550058825; x=1581594825; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=KQcGW8lAHUewzSPpCVt2l3wyt8C2e+e5pUxeKnjvl8E=; b=I+VCSK9bV8TxBJ99oj6AFso2B2AUuY2oYjwIw9MKz/1vRayNrRngf70S xMiG6Ve43mLnnyDUt+2r/MTN+kldP3R9e9ZMym4VYAaK09nD+AdX+Mh+r 18xHNjgHH+V//j5+rYP7014j+7jjKu5ONBTuO3+VT29Gfu69bL5B/qCZP HFZE0DVwtextqr6fp44PYj97LoX27qy+ZyfxIygfZ4nCbLJ6J9vcZroks ozZG3NTNaWGNpQKONS8adOXp3pn2TMkYZTy3tDfQKcUyONoRHQVVvAp2o Mt5I+ygxv+Di9QqeEHMqsO9u6/BqLbMtRXT7uxsBfaNzcHT4wI3Olfyax Q==; X-IronPort-AV: E=Sophos;i="5.58,365,1544457600"; d="scan'208";a="106122630" Received: from mail-by2nam01lp2052.outbound.protection.outlook.com (HELO NAM01-BY2-obe.outbound.protection.outlook.com) ([104.47.34.52]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2019 19:53:44 +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=Vfy9a7eQpprxHOxnGVIApyfvb1IkN/Eoi7kyg0aj3DU=; b=Gm8ymGkcNxlkUJzKDRBv5rgxN5j5PdjDgt/nGEmPJpf1lNHSCglRdibdyJuVoTN7q4BK5W/7fvaBfqsCfJfSpEhOQw2xn08s2BdivynXX2LTOBNxIRm26d1UB4R1lzcw+hh1jc7fgNsxeNZtth473wFOlOv0oI8xVARHxdqveNE= Received: from DM6PR04MB6059.namprd04.prod.outlook.com (20.178.226.89) by DM6PR04MB6171.namprd04.prod.outlook.com (20.178.227.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.19; Wed, 13 Feb 2019 11:53:42 +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 11:53:42 +0000 From: Anup Patel To: Palmer Dabbelt , Albert Ou Subject: [PATCH v6 3/5] RISC-V: Move setup_vm() to mm/init.c Thread-Topic: [PATCH v6 3/5] RISC-V: Move setup_vm() to mm/init.c Thread-Index: AQHUw5LEqZUXVUXd9EWkO2EciZPqYA== Date: Wed, 13 Feb 2019 11:53:42 +0000 Message-ID: <20190213115301.103989-4-anup.patel@wdc.com> References: <20190213115301.103989-1-anup.patel@wdc.com> In-Reply-To: <20190213115301.103989-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0007.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::17) 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: [49.207.52.22] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b9cb2d7f-1d15-4967-e7cb-08d691a9e661 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:DM6PR04MB6171; x-ms-traffictypediagnostic: DM6PR04MB6171: wdcipoutbound: EOP-TRUE x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; DM6PR04MB6171; 23:hMp3BXTmo6atw/NvBhCZhXdbfFeK9G28jPITtpm?= =?iso-8859-1?q?GMYa1LGIGcvxSbu?= =?iso-8859-1?q?AqyDGwI5vfFKooJHfrjBedqnlb5RGero7bdJU/D+2Gql25QWKLdmw8OUqxch?= =?iso-8859-1?q?uIaBdeArjPNK4EwrNNLO6RKKF8+LzdusSZqyRyTW0YCQNCGyX+EVh3V6DZOm?= =?iso-8859-1?q?oi6TAnIrIbbay5ZITIV+mOvPc5Wa4hJWTEoP1HLOUMysYNT+mYzke0Tqw2vR?= =?iso-8859-1?q?mBx1IH5LSHwadFz9l+KN3qPtA2L6435McaC0Zlq+DuBdlcNnr919aLhGXR6r?= =?iso-8859-1?q?a6d53lWVXs/3wy9F14O1/0qyCnFR1iyb8eKwTLOLV3EsJycJQr+sqgw/f3+G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55OaDz66i3iGjH2x9RYOVU6hqe5XJTvzBUhFL9jZMZxG+OkfHJ?= =?iso-8859-1?q?7tSKb03+bE40fiMvUfyPs4xD2f?= x-microsoft-antispam-prvs: x-forefront-prvs: 094700CA91 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(346002)(39860400002)(136003)(396003)(199004)(189003)(52116002)(4326008)(66066001)(71190400001)(76176011)(316002)(8676002)(6436002)(106356001)(6486002)(6116002)(71200400001)(105586002)(3846002)(53936002)(386003)(44832011)(6506007)(6512007)(256004)(55236004)(97736004)(8936002)(54906003)(478600001)(72206003)(305945005)(26005)(102836004)(446003)(186003)(68736007)(1076003)(14454004)(81156014)(81166006)(7736002)(25786009)(99286004)(36756003)(2171002)(486006)(86362001)(11346002)(2616005)(50226002)(110136005)(476003)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM6PR04MB6171; 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: p3mkempJrc+2kJTsavInElWPc47QyJsLVPJ/T++PkLEuPYTbyn9wKUmkaHQAcataEq2LcJRtlmQVyVA31V6p1XXomwn5eAGqdkfufP2QSHRidlC2Z0Ubheu8UJI0GSo9pNf+5JwCtr3fWaxcnloqhBWB3uSZVj8zdd2AOBcvY1k2B3bONx0PJxFCwfk4K4ID5UiP1JKM5xLnxg3v1YM/h98DIrdWstExH49ycEBj6lXZOOZ2PQOVCUDHEIev83oJOwAlLiQq/PqiX/VvmhFg8ROB2pcEaNX/ekHDjGO+3XiWM/tq0OrX3GPLMLC7EtPryXh73RpAaS8PVWMRF4oPXiaemE0q2qiRjfdwwmx7j6LV2R81MEWq2iOb0FrYScsRMyfRw7E5e5lMAoL656GY8Sop3zMAWyJ0uyw5dtve2q4= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9cb2d7f-1d15-4967-e7cb-08d691a9e661 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2019 11:53:39.1040 (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: DM6PR04MB6171 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190213_035345_051425_DF4D56AC X-CRM114-Status: GOOD ( 14.57 ) 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" , Mike Rapoport , 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 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 49bce6692f39..cffe0b3caba4 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -69,55 +69,6 @@ void __init smp_setup_processor_id(void) cpuid_to_hartid_map(0) = boot_cpu_hartid; } -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 bedaf04f9c2f..358e3d5daa29 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -140,3 +140,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 +}