From patchwork Thu Nov 9 22:58:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Reddy X-Patchwork-Id: 10052065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E6E76032D for ; Thu, 9 Nov 2017 22:59:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F6222AF29 for ; Thu, 9 Nov 2017 22:59:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81A9B2AF11; Thu, 9 Nov 2017 22:59:39 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 E1F212AF11 for ; Thu, 9 Nov 2017 22:59:38 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wRV9Zs2NyGG8bRsFatBsIUrAVkWcHFLpf2BWqx/kq50=; b=hDf8iYXxKRNVkW Cf+vxIvcsPp92QBJBlxGcoPZYKHEnOakY/sfTH/FVVZpKSQ957A0qlNJ/+qhwnlBWCtSvU2J5stJu VjGIx6yt6GVq+2K73AOIn/uSnFMnZBPZZOoq76rzy5j09k7pk2SGPXZaJO9kaWkXyc1AdLchFVEzA 3dAuItdXQBnj7bwopnRp8PDY+09sDSJkf/BI6MdzejWGXTV/scUtXM9fa+UU5JPz7q/6e7nqarjdO Hm0rshI2Mr8uIm980GXc+h3LYDR+oi2+qe+ozlI5TMYvV9B2rBpx9oPuTViSu/fqsv72+G7QzaTMk n7zX6k/vMM1a5BB7vWlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eCvnO-0000lH-G9; Thu, 09 Nov 2017 22:59:38 +0000 Received: from hqemgate15.nvidia.com ([216.228.121.64]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eCvnK-0000jd-QU for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2017 22:59:36 +0000 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Thu, 09 Nov 2017 14:59:12 -0800 Received: from HQMAIL107.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 09 Nov 2017 14:59:13 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 09 Nov 2017 14:59:13 -0800 Received: from HQMAIL108.nvidia.com (172.18.146.13) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Thu, 9 Nov 2017 22:59:13 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server id 15.0.1293.2 via Frontend Transport; Thu, 9 Nov 2017 22:59:13 +0000 Received: from vdumpa-ubuntu.nvidia.com (Not Verified[172.17.186.11]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 09 Nov 2017 14:59:12 -0800 From: Krishna Reddy To: , , , , , , , Subject: [PATCH] arm64: mm: Set MAX_PHYSMEM_BITS based on ARM64_VA_BITS Date: Thu, 9 Nov 2017 14:58:59 -0800 Message-ID: <1510268339-21989-1-git-send-email-vdumpa@nvidia.com> X-Mailer: git-send-email 2.1.4 X-NVConfidentiality: public MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171109_145934_875647_6BA6DC4B X-CRM114-Status: UNSURE ( 9.55 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP MAX_PHYSMEM_BITS greater than ARM64_VA_BITS is causing memory access fault, when HMM_DMIRROR test is enabled. In the failing case, ARM64_VA_BITS=39 and MAX_PHYSMEM_BITS=48. HMM_DMIRROR test selects phys memory range from end based on MAX_PHYSMEM_BITS and gets mapped into VA space linearly. As VA space is 39-bit and phys space is 48-bit, this has caused incorrect mapping and leads to memory access fault. Limiting the MAX_PHYSMEM_BITS to ARM64_VA_BITS fixes the issue and is the right thing instead of hard coding it as 48-bit always. [ 3.378655] Unable to handle kernel paging request at virtual address 3befd000000 [ 3.378662] pgd = ffffff800a04b000 [ 3.378900] [3befd000000] *pgd=0000000081fa3003, *pud=0000000081fa3003, *pmd=0060000268200711 [ 3.378933] Internal error: Oops: 96000044 [#1] PREEMPT SMP [ 3.378938] Modules linked in: [ 3.378948] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.9.52-tegra-g91402fdc013b-dirty #51 [ 3.378950] Hardware name: quill (DT) [ 3.378954] task: ffffffc1ebac0000 task.stack: ffffffc1eba64000 [ 3.378967] PC is at __memset+0x1ac/0x1d0 [ 3.378976] LR is at sparse_add_one_section+0xf8/0x174 [ 3.378981] pc : [] lr : [] pstate: 404000c5 [ 3.378983] sp : ffffffc1eba67a40 [ 3.378993] x29: ffffffc1eba67a40 x28: 0000000000000000 [ 3.378999] x27: 000000000003ffff x26: 0000000000000040 [ 3.379005] x25: 00000000000003ff x24: ffffffc1e9f6cf80 [ 3.379010] x23: ffffff8009ecb2d4 x22: 000003befd000000 [ 3.379015] x21: ffffffc1e9923ff0 x20: 000000000003ffff [ 3.379020] x19: 00000000ffffffef x18: ffffffffffffffff [ 3.379025] x17: 00000000000024d7 x16: 0000000000000000 [ 3.379030] x15: ffffff8009cd8690 x14: ffffffc1e9f6c70c [ 3.379035] x13: ffffffc1e9f6c70b x12: 0000000000000030 [ 3.379039] x11: 0000000000000040 x10: 0101010101010101 [ 3.379044] x9 : 0000000000000000 x8 : 000003befd000000 [ 3.379049] x7 : 0000000000000000 x6 : 000000000000003f [ 3.379053] x5 : 0000000000000040 x4 : 0000000000000000 [ 3.379058] x3 : 0000000000000004 x2 : 0000000000ffffc0 [ 3.379063] x1 : 0000000000000000 x0 : 000003befd000000 [ 3.379064] [ 3.379069] Process swapper/0 (pid: 1, stack limit = 0xffffffc1eba64028) [ 3.379071] Call trace: [ 3.379079] [] __memset+0x1ac/0x1d0 [ 3.379085] [] __add_pages+0x130/0x2e0 [ 3.379093] [] hmm_devmem_pages_create+0x20c/0x310 [ 3.379100] [] hmm_devmem_add+0x1d4/0x270 [ 3.379128] [] dmirror_probe+0x50/0x158 [ 3.379137] [] platform_drv_probe+0x60/0xc8 [ 3.379143] [] driver_probe_device+0x26c/0x420 [ 3.379149] [] __driver_attach+0x124/0x128 [ 3.379155] [] bus_for_each_dev+0x88/0xe8 [ 3.379166] [] driver_attach+0x30/0x40 [ 3.379171] [] bus_add_driver+0x1f8/0x2b0 [ 3.379177] [] driver_register+0x68/0x100 [ 3.379183] [] __platform_driver_register+0x5c/0x68 [ 3.379192] [] hmm_dmirror_init+0x88/0xc4 [ 3.379200] [] do_one_initcall+0x5c/0x170 [ 3.379208] [] kernel_init_freeable+0x1b8/0x258 [ 3.379231] [] kernel_init+0x18/0x108 [ 3.379236] [] ret_from_fork+0x10/0x40 [ 3.379246] ---[ end trace 578db63bb139b8b8 ]--- Signed-off-by: Krishna Reddy --- arch/arm64/include/asm/sparsemem.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/include/asm/sparsemem.h b/arch/arm64/include/asm/sparsemem.h index 74a9d301819f..19ecd0b0f3a3 100644 --- a/arch/arm64/include/asm/sparsemem.h +++ b/arch/arm64/include/asm/sparsemem.h @@ -17,7 +17,13 @@ #define __ASM_SPARSEMEM_H #ifdef CONFIG_SPARSEMEM + +#ifdef CONFIG_ARM64_VA_BITS +#define MAX_PHYSMEM_BITS CONFIG_ARM64_VA_BITS +#else #define MAX_PHYSMEM_BITS 48 +#endif + #define SECTION_SIZE_BITS 30 #endif