From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,INCLUDES_PULL_REQUEST, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFE64C07E95 for ; Sun, 4 Jul 2021 15:09:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 821EB613B7 for ; Sun, 4 Jul 2021 15:09:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 821EB613B7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2E/iztbhedntMwFev08hxU8Cr3wycsn+OtG9B/SxGBY=; b=Mfe7cbgw4/jE6d vbUyxp2t2pmnjPQjNXvhxgAJh1Ty6uwvnq3//0pGtBy9nZYaPcXzYca8l6uo46/Uvk9/P0EuM4MB3 h2U0bzqVp6/ViCBG2DuC6b93xPiAL8pvGwvTIyEhI/bCIR/x/YS7Nf/tDZZH0YYM1KAGQEIFPE22W aZMIxwXRkpAbYcBu95jmcRXaAsDi3US9SOcQuONU+zsSw49FR00zmMY9H3fcQSgtFwfVJGIuL5adG LrRdwOSXNpmS3/VKmuXG+F4tKw9z0TvUstGAOn0Q2tWKRQnVfQmk92Rf/qozJf0uzF2q9Phv2mDq1 NGDaQ+WCX42wiVvCfSYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m03jF-006RDZ-80; Sun, 04 Jul 2021 15:08:17 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m03jA-006RCw-JD for linux-arm-kernel@lists.infradead.org; Sun, 04 Jul 2021 15:08:14 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AEE7613BA; Sun, 4 Jul 2021 15:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625411291; bh=kJrhh6BxzSNFGHYJ+mlmwYJIYNaq1EtlJUumheQZPao=; h=Date:From:To:Cc:Subject:From; b=IW/0QBXAUkmSO7TuKZvWoE4iUg3mf6DsEp2WDDZFw7Klt3LLWP1IZUVTv56ksS2Ka 0VPqP7UohT/wy1NfzAezLFV7OEcsk1L07mm1BfkV+lVIc5w9i9dQ2l9Kcgcq0P7yXo Gu7njoftfGKtL+61K6w7x3kISJnPpJZJTIrYgHbuFN/Ht6vqCcT02Q/3eDhHxieq6B pJzdMLfrzGdyBlFrAff/snNR62uTpx2j9D0IzpB5RJRPoK8+w1j2v+wAD0SgUYwvJF dlDHjpN0frUMkzz42JxcV9DWxB2Tv99KKePvUL0Y+p2FdrYqjwU7SDFkauPqI3HgVj GpKgreh6b4xvQ== Date: Sun, 4 Jul 2021 18:08:03 +0300 From: Mike Rapoport To: Linus Torvalds Cc: Andrew Morton , Kefeng Wang , Mike Rapoport , Mike Rapoport , Russell King , Tony Lindgren , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [GIT PULL] memblock, arm: fix crashes caused by holes in the memory map Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210704_080812_706905_C94366F7 X-CRM114-Status: GOOD ( 11.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Linus, The following changes since commit c4681547bcce777daf576925a966ffa824edd09d: Linux 5.13-rc3 (2021-05-23 11:42:48 -1000) are available in the Git repository at: ssh://git@gitolite.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git = tags/memblock-v5.14-rc1 for you to fetch changes up to a4d5613c4dc6d413e0733e37db9d116a2a36b9f3: arm: extend pfn_valid to take into account freed memory map alignment (20= 21-06-30 11:39:00 +0300) ---------------------------------------------------------------- memblock, arm: fix crashes caused by holes in the memory map The coordination between freeing of unused memory map, pfn_valid() and core mm assumptions about validity of the memory map in various ranges was not designed for complex layouts of the physical memory with a lot of holes all over the place. Kefen Wang reported crashes in move_freepages() on a system with the following memory layout [1]: =A0 node=A0=A0 0: [mem 0x0000000080a00000-0x00000000855fffff] =A0 node=A0=A0 0: [mem 0x0000000086a00000-0x0000000087dfffff] =A0 node=A0=A0 0: [mem 0x000000008bd00000-0x000000008c4fffff] =A0 node=A0=A0 0: [mem 0x000000008e300000-0x000000008ecfffff] =A0 node=A0=A0 0: [mem 0x0000000090d00000-0x00000000bfffffff] =A0 node=A0=A0 0: [mem 0x00000000cc000000-0x00000000dc9fffff] =A0 node=A0=A0 0: [mem 0x00000000de700000-0x00000000de9fffff] =A0 node=A0=A0 0: [mem 0x00000000e0800000-0x00000000e0bfffff] =A0 node=A0=A0 0: [mem 0x00000000f4b00000-0x00000000f6ffffff] =A0 node=A0=A0 0: [mem 0x00000000fda00000-0x00000000ffffefff] These crashes can be mitigated by enabling CONFIG_HOLES_IN_ZONE on ARM and essentially turning pfn_valid_within() to pfn_valid() instead of having it hardwired to 1 on that architecture, but this would require to keep CONFIG_HOLES_IN_ZONE solely for this purpose. A cleaner approach is to update ARM's implementation of pfn_valid() to take into accounting rounding of the freed memory map to pageblock boundaries and make sure it returns true for PFNs that have memory map entries even if there is no physical memory backing those PFNs. [1] https://lore.kernel.org/lkml/2a1592ad-bc9d-4664-fd19-f7448a37edc0@huawe= i.com ---------------------------------------------------------------- Mike Rapoport (4): memblock: free_unused_memmap: use pageblock units instead of MAX_ORDER memblock: align freed memory map on pageblock boundaries with SPARSEM= EM memblock: ensure there is no overflow in memblock_overlaps_region() arm: extend pfn_valid to take into account freed memory map alignment arch/arm/mm/init.c | 13 ++++++++++++- mm/memblock.c | 26 ++++++++++++++------------ 2 files changed, 26 insertions(+), 13 deletions(-) -- = Sincerely yours, Mike. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,INCLUDES_PULL_REQUEST,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DF65C07E95 for ; Sun, 4 Jul 2021 15:08:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFF1F613E2 for ; Sun, 4 Jul 2021 15:08:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFF1F613E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1002F6B0011; Sun, 4 Jul 2021 11:08:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B0BE6B0036; Sun, 4 Jul 2021 11:08:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E92856B005D; Sun, 4 Jul 2021 11:08:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id C02B46B0011 for ; Sun, 4 Jul 2021 11:08:13 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4613E1695E for ; Sun, 4 Jul 2021 15:08:13 +0000 (UTC) X-FDA: 78325236066.01.4EE68B2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf23.hostedemail.com (Postfix) with ESMTP id DC2BF90000B0 for ; Sun, 4 Jul 2021 15:08:12 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AEE7613BA; Sun, 4 Jul 2021 15:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625411291; bh=kJrhh6BxzSNFGHYJ+mlmwYJIYNaq1EtlJUumheQZPao=; h=Date:From:To:Cc:Subject:From; b=IW/0QBXAUkmSO7TuKZvWoE4iUg3mf6DsEp2WDDZFw7Klt3LLWP1IZUVTv56ksS2Ka 0VPqP7UohT/wy1NfzAezLFV7OEcsk1L07mm1BfkV+lVIc5w9i9dQ2l9Kcgcq0P7yXo Gu7njoftfGKtL+61K6w7x3kISJnPpJZJTIrYgHbuFN/Ht6vqCcT02Q/3eDhHxieq6B pJzdMLfrzGdyBlFrAff/snNR62uTpx2j9D0IzpB5RJRPoK8+w1j2v+wAD0SgUYwvJF dlDHjpN0frUMkzz42JxcV9DWxB2Tv99KKePvUL0Y+p2FdrYqjwU7SDFkauPqI3HgVj GpKgreh6b4xvQ== Date: Sun, 4 Jul 2021 18:08:03 +0300 From: Mike Rapoport To: Linus Torvalds Cc: Andrew Morton , Kefeng Wang , Mike Rapoport , Mike Rapoport , Russell King , Tony Lindgren , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [GIT PULL] memblock, arm: fix crashes caused by holes in the memory map Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="IW/0QBXA"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=rppt@kernel.org X-Stat-Signature: br9oy8nggfqxqzzyxsp9iwfdtakfonhz X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DC2BF90000B0 X-HE-Tag: 1625411292-247475 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Linus, The following changes since commit c4681547bcce777daf576925a966ffa824edd0= 9d: Linux 5.13-rc3 (2021-05-23 11:42:48 -1000) are available in the Git repository at: ssh://git@gitolite.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.gi= t tags/memblock-v5.14-rc1 for you to fetch changes up to a4d5613c4dc6d413e0733e37db9d116a2a36b9f3: arm: extend pfn_valid to take into account freed memory map alignment (= 2021-06-30 11:39:00 +0300) ---------------------------------------------------------------- memblock, arm: fix crashes caused by holes in the memory map The coordination between freeing of unused memory map, pfn_valid() and co= re mm assumptions about validity of the memory map in various ranges was not designed for complex layouts of the physical memory with a lot of holes a= ll over the place. Kefen Wang reported crashes in move_freepages() on a system with the following memory layout [1]: =A0 node=A0=A0 0: [mem 0x0000000080a00000-0x00000000855fffff] =A0 node=A0=A0 0: [mem 0x0000000086a00000-0x0000000087dfffff] =A0 node=A0=A0 0: [mem 0x000000008bd00000-0x000000008c4fffff] =A0 node=A0=A0 0: [mem 0x000000008e300000-0x000000008ecfffff] =A0 node=A0=A0 0: [mem 0x0000000090d00000-0x00000000bfffffff] =A0 node=A0=A0 0: [mem 0x00000000cc000000-0x00000000dc9fffff] =A0 node=A0=A0 0: [mem 0x00000000de700000-0x00000000de9fffff] =A0 node=A0=A0 0: [mem 0x00000000e0800000-0x00000000e0bfffff] =A0 node=A0=A0 0: [mem 0x00000000f4b00000-0x00000000f6ffffff] =A0 node=A0=A0 0: [mem 0x00000000fda00000-0x00000000ffffefff] These crashes can be mitigated by enabling CONFIG_HOLES_IN_ZONE on ARM an= d essentially turning pfn_valid_within() to pfn_valid() instead of having i= t hardwired to 1 on that architecture, but this would require to keep CONFIG_HOLES_IN_ZONE solely for this purpose. A cleaner approach is to update ARM's implementation of pfn_valid() to ta= ke into accounting rounding of the freed memory map to pageblock boundaries and make sure it returns true for PFNs that have memory map entries even = if there is no physical memory backing those PFNs. [1] https://lore.kernel.org/lkml/2a1592ad-bc9d-4664-fd19-f7448a37edc0@hua= wei.com ---------------------------------------------------------------- Mike Rapoport (4): memblock: free_unused_memmap: use pageblock units instead of MAX_OR= DER memblock: align freed memory map on pageblock boundaries with SPARS= EMEM memblock: ensure there is no overflow in memblock_overlaps_region() arm: extend pfn_valid to take into account freed memory map alignme= nt arch/arm/mm/init.c | 13 ++++++++++++- mm/memblock.c | 26 ++++++++++++++------------ 2 files changed, 26 insertions(+), 13 deletions(-) --=20 Sincerely yours, Mike.