Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp709477pxv; Thu, 15 Jul 2021 14:06:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW90pLlO1S2tdZ6hW24dNMwGQ2X/1stE/DxvO6YDtWyOb63V4TClvzF8mM/Le/uMQ+nwYp X-Received: by 2002:a17:906:9c84:: with SMTP id fj4mr7359688ejc.356.1626383184802; Thu, 15 Jul 2021 14:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383184; cv=none; d=google.com; s=arc-20160816; b=rcoRtuZj99DHBsQ/d5cKmRMpk1n2KncsQhe2gmPAKQBR5ne4NNI+Bkwjt6mQB0pOmz 2VJkhao05OqEIjXDnp31Gk7k9h2shM73wYCbcTCKzaZ4bCrLO0I2AZdA0CQxlpNr+BRL BSGOUvUeU81TBVZqn0fOgH2vrb91TslNH7xViMSAMiaR3M2cIUegd5L2gQiw6jSeisTF kSo27xlpyn8m9mLvwV5r4WyvkuFJK9e3NQee/Twbn3ZuCcdiaPa6Z1BhTHM+HNW5JHQC KZOOVAN+IMvv8hDBafJrjCkS+PMIinpxQD5qvhdEeNxa86+wjQBGS7ejVP0zp0DwaSGj HsAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mITFTC0OCiPBX3Mi+lzZZ9VYyALX4Nn6bJyq4SF6yxY=; b=z4yxQs2AfgCu3+Zc/cOx3TaoGGB6+s4QXGtVMRj+fWxZeaz09W8N7VBHWvzc++CrP/ n6A8Yy/nx9cgdFyRzGxeeqX2ZYQl5b95ADkmuu+9G9C+F0DUUquMxoyxkRlKLyXEOWc0 mhobRL7Mw+aU9nv7te67Zmy9Zr8zdDUlRxGVjCChW0u18uvzHMBAoyUenaeoqA0GsnS8 9Qaz4XyscZSavH5N7gpC3wPbNvZ8TBoqgTaqKkAKRHbVvEaFuGMuE7v/2HX8//WvxZcQ M6sa5WqcbAj3xME5m9ibVoMMO6vRerGMwkA6qpddmNPr3STMsUsPDvcp19hy9BL6/zzO Lh+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MZpKcpo0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ec55si8387801edb.572.2021.07.15.14.05.58; Thu, 15 Jul 2021 14:06:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MZpKcpo0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243996AbhGOTR3 (ORCPT + 99 others); Thu, 15 Jul 2021 15:17:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:38802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243370AbhGOTEU (ORCPT ); Thu, 15 Jul 2021 15:04:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91736613FD; Thu, 15 Jul 2021 18:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375591; bh=Ww0TzZHtaUT5LYnKFZ3fmFAe+pRCnhdhpKfT7Z/wy+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MZpKcpo0Qcd2vJJbC7w57r4Tid2FQb4LfuTEnicefxXvqIY6J7vFlKfLyluN42P2s xwNdpdDSZ3PqZ3r0NUM7QEcxnt6mHjOTkkWmMFDMufc0bcQ9PMeD8NwWlxlAWYmwEw QvGJnIKuQXa6L5dlL/hn+0L8vBs+mnbFi5iFw0ps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, zhanglianjie , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.12 151/242] MIPS: loongsoon64: Reserve memory below starting pfn to prevent Oops Date: Thu, 15 Jul 2021 20:38:33 +0200 Message-Id: <20210715182619.836639834@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: zhanglianjie [ Upstream commit 6817c944430d00f71ccaa9c99ff5b0096aeb7873 ] The cause of the problem is as follows: 1. when cat /sys/devices/system/memory/memory0/valid_zones, test_pages_in_a_zone() will be called. 2. test_pages_in_a_zone() finds the zone according to stat_pfn = 0. The smallest pfn of the numa node in the mips architecture is 128, and the page corresponding to the previous 0~127 pfn is not initialized (page->flags is 0xFFFFFFFF) 3. The nid and zonenum obtained using page_zone(pfn_to_page(0)) are out of bounds in the corresponding array, &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)], access to the out-of-bounds zone member variables appear abnormal, resulting in Oops. Therefore, it is necessary to keep the page between 0 and the minimum pfn to prevent Oops from appearing. Signed-off-by: zhanglianjie Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/loongson64/numa.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index a8f57bf01285..a791863ed352 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -118,6 +118,9 @@ static void __init node_mem_init(unsigned int node) if (node_end_pfn(0) >= (0xffffffff >> PAGE_SHIFT)) memblock_reserve((node_addrspace_offset | 0xfe000000), 32 << 20); + + /* Reserve pfn range 0~node[0]->node_start_pfn */ + memblock_reserve(0, PAGE_SIZE * start_pfn); } } -- 2.30.2