Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3023432lqo; Tue, 21 May 2024 04:50:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRUz2YVQbY8TrSIddYUsyFQK6q/JsZ+N4lmRrRUcNHxDia9Q9pXS0aufSkkXBLShrjA9MZaNsjY/CAreWJ8FepbDetFT/LGk9kzk4gEQ== X-Google-Smtp-Source: AGHT+IFt1tNgLc9hozk+jZW3usrcxvBRApa4bDQTEgRB/3z7EL1fjooB1SQXHZcU8Xx+xfZg9RRN X-Received: by 2002:a17:907:970c:b0:a5c:e7a2:b759 with SMTP id a640c23a62f3a-a5ce7a2b854mr1186425566b.34.1716292225209; Tue, 21 May 2024 04:50:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716292225; cv=pass; d=google.com; s=arc-20160816; b=dAryrR0vC6gezOUT7e+/O4t7rvTFLFnrjwEbuUAfmkG39YYmlEhkut51wSkHCjA53k ID9Yr3VhR9AlKRCfx+jPRBXw+UlTX1g97meNPKyBp3p2LzxLTefGQ2YvuFSmnJt39gcj Q4dI88cvps/DErx+ko2Z4+r4H9ldqCuRN0adDKv6ofDL/4FWZX8iNUDwkTG3rX168Ck8 L624nq8Ocg/t6Qii4eyuETw1bWGJyQzDDPdjhDPKajKiYtwj/Msvxw++NjB+8HN/RAK8 8zQ/mJV8n68n+Eofci43rOvaeuIH+uJS0k8u+bsKrYUcHrD9St4Q7YFOXhpNxKkCyKxD 68Vw== 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=BuXuu2bnylLUwFqILrVy58O+7c/VMKIWm9IXIjW+NvY=; fh=/tocBNknTX0CBdcxdKGUdCq+MQUhEmbYJSr49AVQ1Gk=; b=de8WzxwDBnicpz/mt2CFaZAQKlmPsJZmRVuSOS894/dbpPXv8xyC46++t2wXmNTty4 NFWdMlOje3z9MVkbpF/NZKveRPdx1/fqbrHywuyqKafjmQ9oML27zaq5JY+Q6OM4BdCV BAitu5U/cjqeWFdZN4S9pYjcKz7ykBw6z0R4MsKzHUkaMP73W0CaeXMHkutIFCVonmxy 7GEMa1iebh08jrbIrrp691cpEi3Tfu+Tos2IZlXKIi7hIebzhGWiew6b1nRCR/6BVum5 LN8ezcT4ADNBRBmHTvBsbZAcqx2WtRma5mLjQ+KbmBJSHvo/ERSXWT3NENBb2TgbXASv +KuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QP7xHTIr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a61a0f75b77si205736966b.294.2024.05.21.04.50.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 04:50:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QP7xHTIr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184903-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 am.mirrors.kernel.org (Postfix) with ESMTPS id EDCF51F23543 for ; Tue, 21 May 2024 11:50:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16BBE79949; Tue, 21 May 2024 11:49:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QP7xHTIr" 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 442F547A74 for ; Tue, 21 May 2024 11:49:11 +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=1716292152; cv=none; b=fSRbJNjZMjdBRu05Ggq1tAowdiU5vJQrseQOPfoAuCu3n/zg/MSMkbrAzpgAXdrZSsoDd7GH6gGdUDRtHn6VDgXdyCwXmBF2G2vhDKmiIx9WvVgJ98TZ4c3gqKVKz3cenyYoFXD4YufUCplLcHibc0QWkic3rq4BXja5nKlS9Cs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716292152; c=relaxed/simple; bh=zdSV3EpJ/CKXjaWQ8/cD0+JOT+VH5rhvpIEde4YPaWA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=jI2JSIm+aronf0LB6G2SqFg3rPxv0Wyi3kre5rMfMQzZpeg2sJgP860LDjbjMb7WOAo7Ki0RidR/o7KoCRoTNTks2gDpOv+WENPJ3CqzUVabZD9tm50wKVur1E66pa1QVOvD0lQTbI4Vut4h+Jqz41UnBevyJ3uIgCXebjLD16Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QP7xHTIr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07C0EC4AF09; Tue, 21 May 2024 11:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292151; bh=zdSV3EpJ/CKXjaWQ8/cD0+JOT+VH5rhvpIEde4YPaWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QP7xHTIroKWAL1koAwZ6jjCgJLvRHG023RGth9xuUk2aAr6xVwWVLbscARU+Pv1ub rE7DpLmED0b0CVDykMK6Zx+Q7jnCMVy2PLYf754MVZMJIdV0GVpwGIlm3I3gUCQ0Q6 2H95BXA0It8CFEHUA2Cu/eAEMYUpIeaDtiemAskbUWoLdUlQdP1W1YSYtVV7ha1mAp T00CEcLQ7pEpSb3jAdqZceJbTnCXDIJ0KCDyF2nAHBRoyXITau6AkUfMqaNoMFbKQN QACCVo7OV9T3gy3HBJuXXKgSubA2i3XC1J2EvODkvPbaXRZ/G6/pdAH3MvgRE1voV6 WqhaCAyjmm6LQ== 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 v3 6/9] riscv: mm: Take memory hotplug read-lock during kernel page table dump Date: Tue, 21 May 2024 13:48:27 +0200 Message-Id: <20240521114830.841660-7-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-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.40.1