Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp329772rdb; Thu, 21 Dec 2023 10:14:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHfvlfoIgmPdX/2fcCcRNbsgo1l26p2DtqAWepcG3ELgO9trOm+z8bM9NPTeSGs5hKxHm5 X-Received: by 2002:a17:906:5a5c:b0:a23:6708:cdd0 with SMTP id my28-20020a1709065a5c00b00a236708cdd0mr86496ejc.88.1703182478190; Thu, 21 Dec 2023 10:14:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703182478; cv=none; d=google.com; s=arc-20160816; b=hAKIJRjuQgnQxAYtwCrA2YqReS393JUDBdPp/YY/QPMmynLrquzpvqdC2H8qWeQ5ik IzVuUr6RcK4yiBp0Cbo+4Zw3f8v0iIC0qucET9AlwuIvYxdRPPhczu8GV4pelKUHIfyi 2XngJATZPBQJ6cJ3XHX1Py1Bl6ZHS+fcx3lOll8iPsyVYy/uXTfIHnsX2GhcxiQyhzjZ CM6LDT4BiKR+nEVT3fWzgD+sEFMSPOoO/0UhG9knKh9ER4OcrlJ896LIA1zK7FsOPbBS SWF1c0C16Eh+XBn7LGoVxoWIuat556kRwSM6C74IuOo7q+B6+TUpIFSAfM8AK4HTVbVV 8/yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=Aup1y7DMypb5wPtcvwloevUDTj0Q9j+BJY8D6Z+NijM=; fh=yT+A6FPEZlMOuSm5kJ2iVXd4DHLGSAFlICh4O+Gupjo=; b=nPfvH18n8MMzBQTsaO6VrD+X2ANNswrokV2li/Q4lyNxJUauDahFkZdCrlScVNF3RO hJwZrS6DVTyAdgxJtd5R/jaKUpPhG24FaHstjbPwuB+/LIaD96f6qNcCwHuYEVX/EhDD mbuKCEJgjcf5dwF3xGLi2JK8VXdVL2br661K83rXiFfTNoo7WkAOQI3I51LwUlXN2/zP 8hCjAkkJcHe/YOAzSbGBQ4vemC6HkNAYaOvyT5JeIluTSVNqEC7WD3q99UVDFh4WYBvO yc8BJHh36V4tTMqV1ESwtv0U1jw4z2hukL5uduBbxM2kjQJarv9XEt5irrxYZhsPcN+5 astA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=as0Ierba; spf=pass (google.com: domain of linux-kernel+bounces-8902-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p6-20020a1709061b4600b009fbeaecade1si1015559ejg.700.2023.12.21.10.14.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:14:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8902-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=@linux.dev header.s=key1 header.b=as0Ierba; spf=pass (google.com: domain of linux-kernel+bounces-8902-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8902-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E717E1F22B1D for ; Thu, 21 Dec 2023 18:14:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C71BF63509; Thu, 21 Dec 2023 18:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="as0Ierba" X-Original-To: linux-kernel@vger.kernel.org Received: from out-175.mta0.migadu.com (out-175.mta0.migadu.com [91.218.175.175]) (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 F2EDE634F5 for ; Thu, 21 Dec 2023 18:14:27 +0000 (UTC) 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 Date: Thu, 21 Dec 2023 18:14:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1703182465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Aup1y7DMypb5wPtcvwloevUDTj0Q9j+BJY8D6Z+NijM=; b=as0IerbasBR/dZTFoOiCqg7ve4xqsh2t0qP46njjzYZ5anYkz4I53EyK5yrZ65gvXkLG8l Qsppl/r8B7BRLiAW5ZDQdOjRkLXVwrfgjH5TSQ/O2PUPLGQYg8oc/0G3yiL9DstFvGKLIa Xgfr0FgAPAFwRjen+HVwg1K/91IWx/0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sebastian Ene Cc: will@kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vdonnefort@google.com, qperret@google.com, smostafa@google.com Subject: Re: [PATCH v4 02/10] KVM: arm64: Add ptdump registration with debugfs for the stage-2 pagetables Message-ID: References: <20231218135859.2513568-2-sebastianene@google.com> <20231218135859.2513568-4-sebastianene@google.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20231218135859.2513568-4-sebastianene@google.com> X-Migadu-Flow: FLOW_OUT On Mon, Dec 18, 2023 at 01:58:52PM +0000, Sebastian Ene wrote: > +config PTDUMP_STAGE2_DEBUGFS > + bool "Present the stage-2 pagetables to debugfs" > + depends on PTDUMP_DEBUGFS && KVM > + default n > + help > + Say Y here if you want to show the stage-2 kernel pagetables > + layout in a debugfs file. This information is only useful for kernel developers > + who are working in architecture specific areas of the kernel. > + It is probably not a good idea to enable this feature in a production > + kernel. It isn't really a good idea to mount debugfs at all in a production system. There are already plenty worse interfaces lurking in that filesystem. The pKVM portions already depend on CONFIG_NVHE_EL2_DEBUG, so I don't see a need for this Kconfig option. > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index e5f75f1f1..ee8d7cb67 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -40,6 +40,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -2592,6 +2593,7 @@ static __init int kvm_arm_init(void) > if (err) > goto out_subs; > > + kvm_ptdump_register_host(); > kvm_arm_initialised = true; > > return 0; > diff --git a/arch/arm64/kvm/kvm_ptdump.h b/arch/arm64/kvm/kvm_ptdump.h > new file mode 100644 > index 000000000..98b595ce8 > --- /dev/null > +++ b/arch/arm64/kvm/kvm_ptdump.h > @@ -0,0 +1,18 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +// > +// Copyright (C) Google, 2023 > +// Author: Sebastian Ene You've got the comment styles backwards for these. The SPDX license uses the 'C++' style comment (//), whereas your multiline comment should always use a 'C' style comment (/* */). > +struct kvm_ptdump_register { > + void *(*get_ptdump_info)(struct kvm_ptdump_register *reg); > + void (*put_ptdump_info)(void *priv); > + int (*show_ptdump_info)(struct seq_file *m, void *v); > + void *priv; > +}; Please thoroughly consider the necessity of this. You're wrapping a callback structure with yet another callback structure. IMO, it would make a lot more sense to implement the file ops structure for every walker variant you need and avoid the indirection, it's hard to understand. > +void kvm_ptdump_register_host(void) > +{ > + if (!is_protected_kvm_enabled()) > + return; > + > + kvm_ptdump_debugfs_register(&host_reg, "host_page_tables", > + kvm_debugfs_dir); > +} > + > +static int __init kvm_host_ptdump_init(void) > +{ > + host_reg.priv = (void *)host_s2_pgtable_pages(); > + return 0; > +} > + > +device_initcall(kvm_host_ptdump_init); Why can't all of this be called from finalize_pkvm()? > -- > 2.43.0.472.g3155946c3a-goog > -- Thanks, Oliver