From patchwork Thu Oct 6 09:52:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 9364537 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 48D786077E for ; Thu, 6 Oct 2016 09:56:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38CD628E95 for ; Thu, 6 Oct 2016 09:56:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CE9528E97; Thu, 6 Oct 2016 09:56:28 +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.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 62E7D28E95 for ; Thu, 6 Oct 2016 09:56:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bs5Mu-0004gF-6r; Thu, 06 Oct 2016 09:53:36 +0000 Received: from mail-by2nam03on0058.outbound.protection.outlook.com ([104.47.42.58] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bs5Mp-0004d4-6Y for linux-arm-kernel@lists.infradead.org; Thu, 06 Oct 2016 09:53:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vLJpLn4oxdU/O6G0vsX4zL9RMiqg3SDhkVse4F5rjQU=; b=e+bCttlAZpLFT5MiaqXCbkTTwwYvetrSqVw0+gv2Bco3s10JUdkKhkTcxCTxCeG8L42DHNwxnIWMu03w5S+rPXZWciPw36JTA5pWoTo0dTdNxmZIoNKxX+7/bczETmrOf8PvxVM8JSfVQeXpgTaBYxBHR7vE71CE+2mkklcGqWU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Robert.Richter@cavium.com; Received: from rric.localdomain (92.229.86.66) by CY1PR07MB2345.namprd07.prod.outlook.com (10.166.194.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Thu, 6 Oct 2016 09:53:03 +0000 From: Robert Richter To: Catalin Marinas , Will Deacon Subject: [PATCH] arm64: mm: Fix memmap to be initialized for the entire section Date: Thu, 6 Oct 2016 11:52:07 +0200 Message-ID: <1475747527-32387-1-git-send-email-rrichter@cavium.com> X-Mailer: git-send-email 2.7.0.rc3 MIME-Version: 1.0 X-Originating-IP: [92.229.86.66] X-ClientProxiedBy: AM5PR0501CA0021.eurprd05.prod.outlook.com (10.164.187.31) To CY1PR07MB2345.namprd07.prod.outlook.com (10.166.194.144) X-MS-Office365-Filtering-Correlation-Id: 1c9e846f-20a2-4fa5-c951-08d3edce91fd X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2345; 2:HM7ar0lkJ2uR+6ijyP8kDMKKYnq/Yxlczevm034qC1nXwCUlQu1OSe3vR5oQoL24n9bD3+4GzHBeRJTp4vgH7/WsCJfOQXqkWtg48vxTGUuXRBZepfrHPATJOcsHEGMDC0qS1/LqKq39U3X5yAiWuiWfnq43TvF25MeO5etim1D5TwmHedtza5/6ua3ULh2C60h/yIY/sOC/atFnAJERHg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GngXsA1Uv028H8GyvIYWjDMwcP2eRp0Zfut6yGm4GSGEqRZHFLc7o5EPfNQ8eUmjyrbvrCW0E3N31bjQMrsnqTjFgFEHaINIM/uA1n0Ex0Qs8yKXwiDwYzWToAOfDAtHfCY1cRclE6JdhRliTyQZkNYSJprjsRwwQ74NOxoBdWRTjRP7cwdP0PAdfhoRuo+GrNTP+2gmk7mjCscjCDZmhqjbd8kJuX70+HFnyqZ9Bvz8VNSs6Yzjd+vWqsiJ0coL87pwV9/tSOI05kzSGPo5Am4O+BmwcFZHPW9fTtTjd0F50n2y511KBKHQLafAdSvlLgFwU/WBuRDA25EY4sjddLbnOe8OVOASa1tCdty899Ex5EwRS+uIpNSzLghrJ2H7Ql X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:CY1PR07MB2345; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2345; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2345; 4:bZ7o9+PXK/7EI6VgtRfdnoC8XF51elKMpCRxGY4HZRAn1nV4UWvUGnd90bEH5oMKdJbuDZjN85EpBLuFJeIXQUHDdNAlcLSNHxvcK6kNSahvWaoMy0Ijubou/GIvc+YPlL8ya1eL3TD8kaOXJqPVNpbdYcCCx0W1J7El39tc8Ebms/0CaYYQlqgjWqLE/Avx3DXEU33KsYSPc2sjf6JGA8Kqkd4JT56RU2FJqmwQ8xd/N8GMTk97bLyjW/tdRKkEap7ffnw9nliFmQCiGSnn+hGtzSz+s5wEsq7yopfWcg8z1+wiaWFrNlTPHmn7YJE0r9ijR5TieW9IQufwSaUd6lM911AsLPj4O+evSJs8ssNBesM/jp55YrcOPMED4tG7vZy9jRuVhvOpG1JsPMjwnbzze1JprL4ToN2mrRXeQ0oiyLP9Cr6UKlgMiPe/dupO5xWE/40oUL8SQCaFxRf81g== X-Forefront-PRVS: 00872B689F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(7846002)(7736002)(305945005)(81156014)(47776003)(66066001)(8676002)(4326007)(19580395003)(81166006)(2906002)(50466002)(48376002)(50986999)(101416001)(19580405001)(77096005)(575784001)(42186005)(3846002)(6116002)(36756003)(189998001)(97736004)(586003)(5003940100001)(5001770100001)(5660300001)(105586002)(229853001)(106356001)(92566002)(33646002)(50226002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2345; H:rric.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2345; 23:1FxatQmPhFaYagw/StmEyRoDQhkc6kGvHlyp8HEc0?= =?us-ascii?Q?awT8S3HZzLzzFpV6oxb/7+dVz9fle441DwJzVNpm41uN9dvWWMqVKlZP34SK?= =?us-ascii?Q?Sx3026wBn9X9t69/Pp8tb1Q8vjD43JxCr83sZYakP9o0iN+nvzHbN0x/WxhY?= =?us-ascii?Q?bBVvmLOKhXnu/s6WdAfQQW/6cO6K0yMRpa6zp64CJVERkXbb+hj40z3yHxRY?= =?us-ascii?Q?/YwSMNWGOtm33jeVyv1tMY45h82D3A/akdtG+h1LwFf2NjFv+fji0xuo2RTW?= =?us-ascii?Q?DCtnZGt4KJMfb5dPUtJL2kSLsjdQV7MDua/oiL+h0m6YMmlaE2BT+Nkv76e9?= =?us-ascii?Q?9zmjOs/uMjG2kLuqZnu7QYezmNDMDaBcMWBxRTTEQuBeELuEO58ykwpo3KvH?= =?us-ascii?Q?1hmxLmVUwdIF2e45oXGrUqLvRkyhEBcNJuCKPZzJSFZIgOYP3TcIZ5Xe3gai?= =?us-ascii?Q?6Z5VVn8oSzbKirpVZfexsCxddISl+gsj9VJY1pgSrLQzTRn8gCmGM4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9uanIJ+Jhib5Mcc4o7xuKtX0HuaB9BEEUrVLZPCy6uuzNDsF+Bzc4CuRPk6Wx7i4hmPFsw5pHxJM4C2V5gKRDtWH4kPpawUFg51foOs1PaYooFPnB7hkQw7b4JumUAcHpxq2O01U=; 24:ByyRsRX0Ok1ldR6Ne5cgvZmv4ytVxfKeTVI1n+w0E9NhxqddrnXn6n0Dgt8vkANwFtzb4oHRZS/4VDGZtsNzvyLNTSnd/QAr22yBGYmE1Jc=; 7:F0dtajPF7ROPOBoaEus0/mlKOnzQDeJ/4XT6ph6+7EAhWlhgR4NzCqshnaT0Cvct2I9jGSrC2cSbbzrALB2nLzAcd4xM1OQExFHGWecpAcCzTmmFXyv5+5aOrThJTQveNIbEmPDz4/zVPLKZ9wFoFVk2EdWjzpIE0tKEg7YkgMaPiV4HU/USaSCZmLXH1OTvDjGXSVGPKQvNSHhH2juPRxvgcDx3o+GeQB9TvI1FpuYoTmgBjHlLxkdl3dFl5630BtJWjfv4s28yqJcl6MBw19lANARFskB4HJsE3/QYlGfDUg1itQjJSmM3Q9kqGqhqfIi5SDJQikdPgvwW4l6clA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2016 09:53:03.7849 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2345 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161006_025331_333919_2ED17E32 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-efi@vger.kernel.org, David Daney , Ard Biesheuvel , linux-kernel@vger.kernel.org, Robert Richter , Hanjun Guo , linux-arm-kernel@lists.infradead.org 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 There is a memory setup problem on ThunderX systems with certain memory configurations. The symptom is kernel BUG at mm/page_alloc.c:1848! This happens for some configs with 64k page size enabled. The bug triggers for page zones with some pages in the zone not assigned to this particular zone. In my case some pages that are marked as nomap were not reassigned to the new zone of node 1, so those are still assigned to node 0. The reason for the mis-configuration is a change in pfn_valid() which reports pages marked nomap as invalid: 68709f45385a arm64: only consider memblocks with NOMAP cleared for linear mapping This causes pages marked as nomap being no long reassigned to the new zone in memmap_init_zone() by calling __init_single_pfn(). Fixing this by restoring the old behavior of pfn_valid() to use memblock_is_memory(). Also changing users of pfn_valid() in arm64 code to use memblock_is_map_memory() where necessary. This only affects code in ioremap.c. The code in mmu.c still can use the new version of pfn_valid(). Should be marked stable v4.5.. Signed-off-by: Robert Richter Acked-by: Ard Biesheuvel --- arch/arm64/mm/init.c | 2 +- arch/arm64/mm/ioremap.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index bbb7ee76e319..25b8659c2a9f 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -147,7 +147,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) #ifdef CONFIG_HAVE_ARCH_PFN_VALID int pfn_valid(unsigned long pfn) { - return memblock_is_map_memory(pfn << PAGE_SHIFT); + return memblock_is_memory(pfn << PAGE_SHIFT); } EXPORT_SYMBOL(pfn_valid); #endif diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index 01e88c8bcab0..c17c220b0c48 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -55,7 +56,7 @@ static void __iomem *__ioremap_caller(phys_addr_t phys_addr, size_t size, /* * Don't allow RAM to be mapped. */ - if (WARN_ON(pfn_valid(__phys_to_pfn(phys_addr)))) + if (WARN_ON(memblock_is_map_memory(phys_addr))) return NULL; area = get_vm_area_caller(size, VM_IOREMAP, caller); @@ -96,7 +97,7 @@ EXPORT_SYMBOL(__iounmap); void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size) { /* For normal memory we already have a cacheable mapping. */ - if (pfn_valid(__phys_to_pfn(phys_addr))) + if (memblock_is_map_memory(phys_addr)) return (void __iomem *)__phys_to_virt(phys_addr); return __ioremap_caller(phys_addr, size, __pgprot(PROT_NORMAL),