Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp156558rdb; Wed, 17 Jan 2024 22:19:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSxl2pe38cWhqqSDZJSeMNWaA+LR3kT0//qrZTLsiCDW4t7eF7gDW9Ajs8Q6UfHVk23Gut X-Received: by 2002:ac8:598a:0:b0:429:ccec:af20 with SMTP id e10-20020ac8598a000000b00429ccecaf20mr445160qte.35.1705558762059; Wed, 17 Jan 2024 22:19:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705558762; cv=pass; d=google.com; s=arc-20160816; b=U3C5ALsUky4LS9z/XFNOwMJeAu53iYwhESUbqUf4r8Y/YGtvqRwx2bz+pTZJvoIqVg XLtwGdKa8kA+DkToc8Jj+r8ySDMhmYELVzdL11o6XmGOoTgi1YyGM0H0/tp6TSrvpcJN mrqW/ZCcLhHuq9WxbC6pm/c3Hgg5+9WNLpz9qGOxDqb8H6S0eOooQNkb4JIxMy/GFsAH oEz19hWGDCuOMIw7mDFdEB9KnJ4Y1GKzLYaQMwFf0OW5gIlZ5k+rdN5wdqQ8fTeKBKwT Jg+1SegKvNiSCStndtaCI1wLhbIHa8iQftQnf1hvnRR6N2UG4GYT6TrTUOjn/7QHDdVp YgRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=sH3eJ1PeLEzp5iMX2ShmJd90S2HOzxuMkVgsHD8St1Y=; fh=QZU3guN9hBCNbG3XWCsoVTJE3Km/GRJW/frPYUuNAVA=; b=xw2e8qcob3it7BofhxKAVo78vCUEvbaJ1+Spzc611VXnRVMA9UsqQtMEvK8cFzTkB2 Bw9SSmdQrYEyEiDW9QN3KU9dMY/WgLV1TCs26FbB/WzZMC4nmrAKf3adIUd4uxe+OVL2 OCFjDSOkgpZb1S0gnnQyB+TzS4tVlmBglEwhay49QABcY9gDmqIG5ZSzXaQmfFHkzSbh fm/5+wOWN69ixOZJb68BId8qiPlHhpM/9xx/NwHeUXuytifPrEqsD7bKhn9Br1fj2GQp zo6rWRifbEI9BvHljyCcLSWNJRqzpBBT2Z4HtWcT2KI7C0SdT6Yh4mRwjENmwqXDh1Bm 9j6Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=q2SumlNy; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-29732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c5-20020ac87d85000000b00429f6bc97dfsi6173355qtd.272.2024.01.17.22.19.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 22:19:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=q2SumlNy; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-29732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CD53B1C222AC for ; Thu, 18 Jan 2024 06:19:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AFED9444; Thu, 18 Jan 2024 06:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="q2SumlNy" Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD6BB79E4 for ; Thu, 18 Jan 2024 06:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705558754; cv=none; b=BtLVVp1UEZaj4sYXxhkp+gmL1cgmM7C+PwO/aj5/JPp6YqJ/lKqyqw7koi19lPqrgXYuvGOh79bTRkHwJSaP3+IjVZ0Z+HJziJEHAbB5PPzuFQgjsC7d95wdE7L0BccC3VsAL3j1gQeH2BakyUfTVrMe86bSfjGwnh0uQI8xKlU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705558754; c=relaxed/simple; bh=OzKnacBlOGRsazVvabreopds5Qg+gZxPBfXopYaD548=; h=X-Report-Abuse:DKIM-Signature:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Transfer-Encoding:X-Migadu-Flow; b=DOVCt1pGVpmkNzDeki2cBgr5hI5BkT/pIrIh9aRn6+zrTwNQK+UIE26Xho3PwDDoE6K+5vpeQmO95Hh6ZbadKiU2MtFOefiUQGWYJYD7ul1Iy8B+zpOEFS2umENONd+rpBlu7XQKVnrx3eIKl9Re4ykaRCOiJJpPRGFwoUoArjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=q2SumlNy; arc=none smtp.client-ip=95.215.58.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705558750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=sH3eJ1PeLEzp5iMX2ShmJd90S2HOzxuMkVgsHD8St1Y=; b=q2SumlNy5FfAKZtKClDn1OZKQxeQKmH5Ko8ONI9YBImUJweeTR0HEQzbzogjPn7TpyvV+/ 8ZS/gh2bUD/06yC8yrpxg0VMAs5WzeXGxNeSj0pCv/MQE6LWrhKsYgZJV2Dywlsff9GjUN lZXP7e+Ow4a2bjv8x9ynsVWigz+rWj8= From: Yajun Deng To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] memblock: fix crash when reserved memory is not added to memory Date: Thu, 18 Jan 2024 14:18:53 +0800 Message-Id: <20240118061853.2652295-1-yajun.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT After commit 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()"), we set nid on all reserved pages based on memory region, but some reserved memory may not be added to memory on certain architectures. The nid is invalid. Add the nid check, make sure the nid is valid by early_pfn_to_nid(). Fixes: 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()") Signed-off-by: Yajun Deng --- mm/memblock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memblock.c b/mm/memblock.c index abd92869874d..4dcb2ee35eca 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2176,6 +2176,9 @@ static void __init memmap_init_reserved_pages(void) start = region->base; end = start + region->size; + if (nid == NUMA_NO_NODE || nid >= MAX_NUMNODES) + nid = early_pfn_to_nid(PFN_DOWN(start)); + reserve_bootmem_region(start, end, nid); } } -- 2.25.1