From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39A50C35274 for ; Thu, 21 Dec 2023 18:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=APi3rGnvgUQFEW8CvqCnYufGGC82AjWQktmD/Xgzuvs=; b=qDAsRTXlaruK5p z4/2zYeisZ942HaKaWb22/ofLorBY+JZIWlI+cWZy1CqpZgO5FmJx2FEqdahp1i4oDbMq4jQ9Hgl5 hbCJ/Su4ZVF/lVdRCQV08QXgQFvnNkwIuBu5g/hmS5I1Rn18CIWL08hF2n8xlozwh9EMumRpHpG7y +BHv5dCbgfQyXE3EIn/JXkcVAnaJg4zpASSLvgOvUeBjklvIEGym33YWGqxgb68/z+ij2JO95B9P7 YS5QZbxsCq7s82VGNf5xlLS7KP5NGJsMmdCJepJ0dnq3q6inToOgEd60hYQ0QLM3TojiMneFFQM1G jollfPIux+lfavlT+szQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGNZ8-003ltu-0t; Thu, 21 Dec 2023 18:14:38 +0000 Received: from out-176.mta0.migadu.com ([2001:41d0:1004:224b::b0]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGNZ4-003lsb-0w for linux-arm-kernel@lists.infradead.org; Thu, 21 Dec 2023 18:14:36 +0000 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231218135859.2513568-4-sebastianene@google.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231221_101434_754262_D37589CB X-CRM114-Status: GOOD ( 24.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel