Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2709528lqo; Tue, 14 May 2024 07:06:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWUENQvuSmnYXN+7OCJks0Ax24Ta2yNtjv0DgpPHLzRllQm7OgxRBalpwA/Nlp66b5UUWduB62pzW0Nd4f/BLenc+A/05ZAcO79quXdUg== X-Google-Smtp-Source: AGHT+IFLTQYmOjk69ecilKqD5jHBTGUbAM7H/1RHYa7HT40h4UkZRgURZwSZLcVPgLcLpONPcGPp X-Received: by 2002:a05:622a:1456:b0:43d:8b77:7dca with SMTP id d75a77b69052e-43dfdb07855mr146477171cf.13.1715695591411; Tue, 14 May 2024 07:06:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715695591; cv=pass; d=google.com; s=arc-20160816; b=ixYzsQT99ZXHvbjxFfnJfTWHhka+RcpeOJGVeal8VS4s9rGVNzNKijG4URhKu5RcLo npfj8JerBNkeVFGiyamKUEO7EU7uN7W2QMWf3Do/R3RD4Ylwt2Hake+xIYc02jo9s1GL lR2m+oLe0/T0bn0BFK/zpDNph9LRhnbFuvoQEXHEdJuU2EMnNNLXW2lPe+Bj86OCgc4T LRTD/Xi/a7+XMw+qc/SzU2m1yDmsY05F2m5z4su9CdiKYKzy4k7relHeaqR+aUEO2bDV XfgrpK/GL2yKOM2LZyHIUrvlE5UpdAv9/Pb6PSkDO9qcKg7gHDyUX3bDaUiBNY+/A0rW xrfQ== 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=HmEirQnD2a44bOYNrbhBt5+emQXsA+YdRl4voQyD5Ms=; fh=uMFliFihFxUmoRF8pjhRbK6V6DFjFNjH6h18EfWUiEU=; b=PfCoCXESMBvWB4EqY8d+kVSNBeMuYhV/iw4MRz0fAeVEATFf8Jc9sFhOb6IPsciKqL tA3HMmLCRa6WIjAO+Ji9QoogQVnZYwRBqXRHxs5T0Am4F8VWqUbRD2oV1ylQezuC0WTg jlvMAV5rlcdM075qdVZzPPFVwJIbeicN1ElnkfSb2TMQ6st7hmtcS4gLUcU3VT5roo9X SDTVP1Irmjb7nXI7s6HobmcYbtaHH9laGKChEzjAWSzrBx14hrN8NB5MWFycw5UiEWDE fM3FjrP6+ZBV6qlzyeOzP4ymUKYlOCtZjse/qnNE9v8KmOd9AYvni4UWzpNF+KzkNHl4 OB9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AnRBLrwi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-178784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178784-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 d75a77b69052e-43df8aaab99si112159361cf.428.2024.05.14.07.06.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 07:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178784-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=AnRBLrwi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-178784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178784-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 9711F1C223B6 for ; Tue, 14 May 2024 14:06:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8393E146D7F; Tue, 14 May 2024 14:05:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AnRBLrwi" 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 B11EA145322 for ; Tue, 14 May 2024 14:05:26 +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=1715695526; cv=none; b=YkFM7AL93+T8xDzQnfbP2mCs4Co8vylxibV820iD7+cyUie7o5+QaRp102ztrTSVOeIgmwSF1sBHcGjEXGyy2HLjpte0qfxW3GVb7MVi1eN+lO7dIPgYpazSXWuAf7MVTiLEuKWFCa2H1vMn5kX6wVKp9zSG95WyeUVPjLCbbno= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715695526; c=relaxed/simple; bh=KbKqzNvXWA/Za9nd3AYnat1xf+LOO0b3PgRZV0HvyKk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=dCxAQBXHYzI9PJzNORWjYQ3w7+ZJoRroNT0s7kkP0jFWj8gcim3EAw6V3xfW65I4TsukivRDsVw+XTEZrCqkZzLwl/bV7bPkBkwRMF1TH7ssRAzmE5sTTygTuLfuSEyW2epNVaPCh4CbtIyAEYcFnVvIFrSrXzirI9DbLYaLD0k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AnRBLrwi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3894C32781; Tue, 14 May 2024 14:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715695526; bh=KbKqzNvXWA/Za9nd3AYnat1xf+LOO0b3PgRZV0HvyKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AnRBLrwiGydV55YKVxP1C2hTU/+iQo4dd8w0faa4jtVHR4jHZ5anUbKb5yZ5ye3XS ys1kla9pYrDzdZbLunoTrtdPNqqAUbKtu1CJ//68MFbQyh5y7aZhC46YK55JtaUZA5 ra5G2sERmBqf/UFx2SPaMVXfoiGS2kPxfZFkZNOUlVD19QOqS/SUV5MZU/mFGOVgDv IXn6OG9dtirrJO/Dh3vnNlqnjzdI4qDmljqWq0kBU+c0CiDbOdoWE/pFltLXqLokVT r19LtiBw6rEEkbg+nNadg08rNjWgfdZZVOpJ69iuykQqloruiT2sEewRtB7kCuWmPz qDl5PWv830HDA== 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 Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Oscar Salvador , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v2 5/8] riscv: mm: Take memory hotplug read-lock during kernel page table dump Date: Tue, 14 May 2024 16:04:43 +0200 Message-Id: <20240514140446.538622-6-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240514140446.538622-1-bjorn@kernel.org> References: <20240514140446.538622-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"). 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