Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp233783lqr; Wed, 5 Jun 2024 04:43:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2vyU9J0YoJl1MnH5FbcO533GFOQpr6Q6O9roKzdglDAK/B3QJcdBPPvon7lHOO8hRwHnnvR4LyRtT1Dr8b8Iz93K33emYKg26zkkuAQ== X-Google-Smtp-Source: AGHT+IHSecpx1zBtOUrK/Po3pGIN3UdxIjwgG1wMJ5fNO7nPB6qNF5ETg4yQB9giv0Jbs0yYccBT X-Received: by 2002:a05:6214:57c5:b0:6b0:3e49:efe3 with SMTP id 6a1803df08f44-6b03e49f033mr19891586d6.5.1717587810162; Wed, 05 Jun 2024 04:43:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717587810; cv=pass; d=google.com; s=arc-20160816; b=FYGlCwxjH1X5I9lanejoxs8+B/FU0kRNNc9CasiR5J+a7tK5YOZKKmwChQ07inwRzR rvB9pr0r1E7GzYunBMbGfGCsrLNqZFjzigW0KLmNQgz31Ev945ckL8U1jxoD9mxopmIh WIB0DoaulzUp2cHE4IG/0oG8O/3PZBkAnV7gIuV84Ch85PcmFFVU6T3NSn94PkW6HUl0 1SldRYgyhQEBe/wjHrfE1MGcFuQXQyrpZ15zaYgcKaXn0f7OeOxm3NWpyVXrCqO/fhTi mJQIXO8wNx3g9E84TJ/qwNvNPi9bfBwZCiuntYDxVS92Gn7hnb3k61oGaUx/jQPzhEML ye0Q== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=q//qbYvUf5ZweB0+VVWPtHbCbaK2TrYguToZahahUIk=; fh=/tocBNknTX0CBdcxdKGUdCq+MQUhEmbYJSr49AVQ1Gk=; b=o1AXCHgGn0sddodsD56m6EoTsVGp/pBugQTE+cOD/hB25QHj0uRzdt8mWSU7dXTach kFbheKvgz6BndOJLNd6nZuCNLnOM0/jQ9BCC4lpIxPN7rI12gEORPKwUCkkiITjjXRY3 IndBefmuwtH9kR4hiwL8MOXtwgk/mypVZO92xhQ5ij6UsDoq0MtYt/lme0fvjb1Jksu/ WouIF8XwScfb7STgOnphaWbZz6UgY2rRzVwNS7o3+qBu/BPT7lsOrdA74ro4VdqQjtPj sW4YlSIFxOQNbb5KVmsiH7uRwhxOWx4oL4fOnnQfiNEoIl3sWN0vhl0FIL5vRomBF5gU il2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=actIwcGK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202282-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b416b0bsi133698946d6.420.2024.06.05.04.43.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 04:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=actIwcGK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202282-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 F12B11C23AE7 for ; Wed, 5 Jun 2024 11:43:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BA02195FC8; Wed, 5 Jun 2024 11:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="actIwcGK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 59904194A74 for ; Wed, 5 Jun 2024 11:41:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717587708; cv=none; b=cI2GaU8JqPjcd++XNq6hUYGYIKROQuDYRgCkFuSxclwL7J1zkE57iI54IKaeDkk1HZmiZ2xU7bWazBljrn5WYJteqfZ6fJE2117+JrMmdT+JeorPzRViQceyExKdfz4RrmyXPqr4qNvMEdNftVIBzZ0QwV6v7+L7pwsfJ9zo5wo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717587708; c=relaxed/simple; bh=tu3HoOPPrk12D/HHChqAMB+6RlcJ+H95I8FoF9tFiiY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kGwO1gmz6TyswVEKG1xfHnG/fO34dTnWfkSh2n4GvD3y3jXBraCKPqjQZPI+J5QqKIYTZ9tRPaPFTOE6WZBr2k5P1mnaJHlUI+D4mAnw6Ed3daR8Lwv7ZUfK+J/Sxj+5vIz02u+mKarC25kVmwiiqR1WDt1TPjEcW6FGMwp0WyE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=actIwcGK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADA0FC32786; Wed, 5 Jun 2024 11:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587708; bh=tu3HoOPPrk12D/HHChqAMB+6RlcJ+H95I8FoF9tFiiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=actIwcGKL7lMw7iHm/kYeLU0Im0MKA4ATYjc0eCD0iqFPQA3+RyZqVf1nydSeSUj0 gF9ZhAi8Cz89TfrWUuVf9dhYSzuUycsqYPT4dufEA7HfktKoCVWT5gVywjFH44bLxq FNTCqSW9+FkXOpJ/wxpC8P41lR4dMjOqX+wX6c6+uyD4sHqI51jkPKWdIKeosTC0K2 WSBy6vQk9sC3vPE9M08ir3qL9i3FzdGxn8iAQdWQ8EjWNitOO9u8IfVkxzec9k0tt9 kNzLKT3wBJLZ8wQiEitzX09XtnmJ30P5wj/gY3ges2Va9UAhUDJXEgw+464CKsyQPH ZFrpv32CPOuLg== From: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v4 07/11] riscv: mm: Take memory hotplug read-lock during kernel page table dump Date: Wed, 5 Jun 2024 13:40:50 +0200 Message-ID: <20240605114100.315918-8-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Björn Töpel During memory hot remove, the ptdump functionality can end up touching stale data. Avoid any potential crashes (or worse), by holding the memory hotplug read-lock while traversing the page table. This change is analogous to arm64's commit bf2b59f60ee1 ("arm64/mm: Hold memory hotplug lock while walking for kernel page table dump"). Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Björn Töpel --- arch/riscv/mm/ptdump.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c index 1289cc6d3700..9d5f657a251b 100644 --- a/arch/riscv/mm/ptdump.c +++ b/arch/riscv/mm/ptdump.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -370,7 +371,9 @@ bool ptdump_check_wx(void) static int ptdump_show(struct seq_file *m, void *v) { + get_online_mems(); ptdump_walk(m, m->private); + put_online_mems(); return 0; } -- 2.43.0