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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 D95FCC4338F for ; Tue, 27 Jul 2021 20:38:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 67AF160F9E for ; Tue, 27 Jul 2021 20:38:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 67AF160F9E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A7CCC8D0001; Tue, 27 Jul 2021 16:38:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1FB76B005D; Tue, 27 Jul 2021 16:38:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90E7D8D0001; Tue, 27 Jul 2021 16:38:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id E36616B0036 for ; Tue, 27 Jul 2021 16:38:38 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F390418027FB3 for ; Tue, 27 Jul 2021 20:38:36 +0000 (UTC) X-FDA: 78409531032.39.18463BB Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf21.hostedemail.com (Postfix) with ESMTP id 66985D019FB9 for ; Tue, 27 Jul 2021 20:38:36 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 65FBF6056B; Tue, 27 Jul 2021 20:38:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627418312; bh=m4pTLRxNjQ5nrW4+WylpHblD4H7E+5v4AVz71ixTU7U=; h=From:To:Cc:Subject:Date:From; b=jFFIcxi7MiAGoX1FaofoGp1RfNm/xlAaCEtXz2oOyuj+wsOwyHZt7ziSZWTza7yVA yuvEvuL0XvwoePf25ipmXSDhc9RArOpGOt5oPIx8udzt71emuyQhyFp8ILQEMnYePk ihKjfE4b9WZab2EG3TkDTO+EokRokdHIPIy30oy1BwLm+1ITa88OmWHjZ0nnYRfHXR Z3OJ6vNOZSPoYjfkxd8i2NTt6yywGFWGJ48lA0To48MMezxXV2HtcvtT6gknQxWBLj aG9g5xniVbVSNGtbGWs7KR0iKogwE3+FRA3RZWMml3ZdcuXK6u4rLnzaycTqneD1Cb nh9xtn0nMtvGw== From: Mike Rapoport To: Matt Turner Cc: Michael Cree , Mike Rapoport , Mike Rapoport , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org Subject: [PATCH] alpha: register early reserved memory in memblock Date: Tue, 27 Jul 2021 23:38:24 +0300 Message-Id: <20210727203824.12312-1-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jFFIcxi7; spf=pass (imf21.hostedemail.com: domain of rppt@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 66985D019FB9 X-Stat-Signature: 4zhg6nddoj94owrz6yop3ecamo59fe51 X-HE-Tag: 1627418316-967803 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: From: Mike Rapoport The memory reserved by console/PALcode or non-volatile memory is not adde= d to memblock.memory. Since commit fa3354e4ea39 (mm: free_area_init: use maximal zone PFNs rath= er than zone sizes) the initialization of the memory map relies on the accuracy of memblock.memory to properly calculate zone sizes. The holes i= n memblock.memory caused by absent regions reserved by the firmware cause incorrect initialization of struct pages which leads to BUG() during the initial page freeing: BUG: Bad page state in process swapper pfn:2ffc53 page:fffffc000ecf14c0 refcount:0 mapcount:1 mapping:0000000000000000 inde= x:0x0 flags: 0x0() raw: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 raw: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 page dumped because: nonzero mapcount Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-03841-gfa3354e4ea39-dirty #= 26 fffffc0001b5bd68 fffffc0001b5be80 fffffc00011cd148 fffffc000ecf14c= 0 fffffc00019803df fffffc0001b5be80 fffffc00011ce340 fffffc000ecf14c= 0 0000000000000000 fffffc0001b5be80 fffffc0001b482c0 fffffc00027d661= 8 fffffc00027da7d0 00000000002ff97a 0000000000000000 fffffc0001b5be8= 0 fffffc00011d1abc fffffc000ecf14c0 fffffc0002d00000 fffffc0001b5be8= 0 fffffc0001b2350c 0000000000300000 fffffc0001b48298 fffffc0001b482c= 0 Trace: [] bad_page+0x168/0x1b0 [] free_pcp_prepare+0x1e0/0x290 [] free_unref_page+0x2c/0xa0 [] cmp_ex_sort+0x0/0x30 [] cmp_ex_sort+0x0/0x30 [] _stext+0x1c/0x20 Fix this by registering the reserved ranges in memblock.memory. Link: https://lore.kernel.org/lkml/20210726192311.uffqnanxw3ac5wwi@ivybri= dge Fixes: fa3354e4ea39 ("mm: free_area_init: use maximal zone PFNs rather th= an zone sizes") Reported-by: Matt Turner Cc: Signed-off-by: Mike Rapoport --- arch/alpha/kernel/setup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index 7d56c217b235..b4fbbba30aa2 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -319,18 +319,19 @@ setup_memory(void *kernel_end) i, cluster->usage, cluster->start_pfn, cluster->start_pfn + cluster->numpages); =20 - /* Bit 0 is console/PALcode reserved. Bit 1 is - non-volatile memory -- we might want to mark - this for later. */ - if (cluster->usage & 3) - continue; - end =3D cluster->start_pfn + cluster->numpages; if (end > max_low_pfn) max_low_pfn =3D end; =20 memblock_add(PFN_PHYS(cluster->start_pfn), cluster->numpages << PAGE_SHIFT); + + /* Bit 0 is console/PALcode reserved. Bit 1 is + non-volatile memory -- we might want to mark + this for later. */ + if (cluster->usage & 3) + memblock_reserve(PFN_PHYS(cluster->start_pfn), + cluster->numpages << PAGE_SHIFT); } =20 /* base-commit: d8079fac168168b25677dc16c00ffaf9fb7df723 --=20 2.28.0