Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp630411pxv; Thu, 15 Jul 2021 11:59:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySs/bzsCsm8+zmkqpKEgW/tJOYLkEa56yDPNKRSlQ1YJbhO/jL5wHcJzPNTkKtPv8l1ATM X-Received: by 2002:a05:6602:1c4:: with SMTP id w4mr4164564iot.44.1626375564854; Thu, 15 Jul 2021 11:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375564; cv=none; d=google.com; s=arc-20160816; b=cxcEsVujZKOSOQDNlKGzkeE0hFfYbeItBjjxuR7a8cjuz8QeYmUWjoUngyFDX2MbHw s+IWyGt/KpA8t2++m+qmHkLq8Sh40eM5xd8KALnJvmMesFzb5KEua8iHJzL5gdZD8rKq ITW32d+qMFIe9w5vEfmOURvOr0Xxhtuv5BNQpeoQD0cJ1YP2KQYH+lZ9WXRg2nTohcAR XZkZfaIm7AbFUmgwwamzTL90zUBfk96rgRkT6qbHgZVt7/cqX1S7Wl1KvuKSc44Fwmv2 bBfOnw8ff0F6tsuKM4F786zYJKEXARpSCvcd7HkOpHYfxnQYOZ0UKrz5LIezqYSJEBex eC2Q== 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=/+bUJP7niUbD+esIsDIjiXsnhFt+WnZAnYX0/bdjjFE=; b=krmGOvQin4aJp3fgaACkWxResmzKAGo1xVXbLPOyahF6id9FPVumzQGK5wsBw9Mz30 L1moDPHp3lfVgmR4rg4BQo/kOJIPsqGaGMm83cTsEykm2iEkErBKd9WRxsJj+W0VVTpS H9BLJhSagecTAW2wB/94LBiSjk3vKJS39tO+wBfzWKh2e2aj6QxsRLMoLSw++/lEW9WC AXzdQgfjzC+YIH4wZ+Okw4IggrIHVVmV3SRi4KXFOLr/78qN+T0foW8BJK64pxzwxH7W yL8SeDGPgUoWcLNgBvcZIledwWLLz0ztQBj+W+KO/bqK/lDH+HFgcKZZ8dX4eFLN78Oe 8vUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GF9nD/nU"; 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 x9si7213161jat.100.2021.07.15.11.59.12; Thu, 15 Jul 2021 11:59: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="GF9nD/nU"; 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 S243047AbhGOTAK (ORCPT + 99 others); Thu, 15 Jul 2021 15:00:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:57842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239873AbhGOSxa (ORCPT ); Thu, 15 Jul 2021 14:53:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 532E9613D7; Thu, 15 Jul 2021 18:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375036; bh=GptNHRxt4NSFEH5/XvLFiuhi1vJsblNqdlsj4pppnKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GF9nD/nUm9gddXEUv0XPHlfH8i5iRpN/7z8Bv3/jhPwEUFs+b5s3wCrLu9YT89Xtr 1tQR39A1IVIc1Wy0Ysdfic+WX3L5YtQrkypqOFszNA5RN5iIktLRM1L1QXoTjT6Vds 07/ajePffoiK5skGe+UTKMZMiA5zWwWkzh6rZC0s= 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.10 131/215] MIPS: loongsoon64: Reserve memory below starting pfn to prevent Oops Date: Thu, 15 Jul 2021 20:38:23 +0200 Message-Id: <20210715182622.760276781@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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 cf9459f79f9b..e4c461df3ee6 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -182,6 +182,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