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 E3582C2BD09 for ; Fri, 28 Jun 2024 20:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jm4qG4jRCo56oJ0Gz0jQZFPpgs7Y8kASTCWIVGIqg04=; b=I6fSDew9FrwZPMmw1YtyPeWsft aFDVIq+oerQAtdfRXoKGM1TP5yowk5rRaN67yvchxe2B6JHdixilFDsqLg1PAPb6DDokJMOyApL8o Noi0oKFZRv6FB4di9dZgJJF58CWo7714X1K6RTx35mM41DHcqh+gI1UogDucV6/ITCmpTThhN8krz 8dmbM/sa9IxS3mWG/L+capoFRTaxMbxJHMmqZs8cKHvYoRzV7KDGoGSXGkz6Hsw+1H9NHOl2Uw+Vh C4vEgSWjOPYJKkB4Lhgvtbb4iykoLYS8pS1/qfnUUQAg4pnF6ZFbN0akgRSlAO/RN76YBA3Zf+xpH NohZ06DQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNIXL-0000000EuUm-2z6B; Fri, 28 Jun 2024 20:49:39 +0000 Received: from out-186.mta0.migadu.com ([2001:41d0:1004:224b::ba]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNIXC-0000000EuSs-2Hm7 for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2024 20:49:32 +0000 X-Envelope-To: sebastianene@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719607765; 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=jm4qG4jRCo56oJ0Gz0jQZFPpgs7Y8kASTCWIVGIqg04=; b=DldBWtS7JkZ+XMO2kxkCv9BeXtdroJZvvDHu+jjNdE4iSJybzG4ffHXET0pTFxfa5lkXJ0 /FNgUg7PQ0IR9wwdeCsofKNATSODWS6HreWGN3Q1u5NAWGX7kDcayuAVPM9EfDK4Tkv7Im T1QG+OJozVc858vX33SmdzNmSMmnEI4= X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: alexghiti@rivosinc.com X-Envelope-To: ankita@nvidia.com X-Envelope-To: ardb@kernel.org X-Envelope-To: catalin.marinas@arm.com X-Envelope-To: christophe.leroy@csgroup.eu X-Envelope-To: james.morse@arm.com X-Envelope-To: vdonnefort@google.com X-Envelope-To: mark.rutland@arm.com X-Envelope-To: maz@kernel.org X-Envelope-To: rananta@google.com X-Envelope-To: ryan.roberts@arm.com X-Envelope-To: shahuang@redhat.com X-Envelope-To: suzuki.poulose@arm.com X-Envelope-To: will@kernel.org X-Envelope-To: yuzenghui@huawei.com X-Envelope-To: kvmarm@lists.linux.dev X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: kernel-team@android.com Date: Fri, 28 Jun 2024 20:49:19 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sebastian Ene Cc: akpm@linux-foundation.org, alexghiti@rivosinc.com, ankita@nvidia.com, ardb@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, james.morse@arm.com, vdonnefort@google.com, mark.rutland@arm.com, maz@kernel.org, rananta@google.com, ryan.roberts@arm.com, shahuang@redhat.com, suzuki.poulose@arm.com, will@kernel.org, yuzenghui@huawei.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v7 6/6] KVM: arm64: Expose guest stage-2 pagetable config to debugfs Message-ID: References: <20240621123230.1085265-1-sebastianene@google.com> <20240621123230.1085265-7-sebastianene@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240621123230.1085265-7-sebastianene@google.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_134931_010261_FA551A42 X-CRM114-Status: GOOD ( 20.66 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jun 21, 2024 at 12:32:30PM +0000, Sebastian Ene wrote: > Make the start level and the IPA bits properties available in the > virtual machine debugfs directory. Make sure that the KVM structure > doesn't disappear behind our back and keep a reference to the KVM struct > while these files are opened. > > Signed-off-by: Sebastian Ene > --- > arch/arm64/kvm/ptdump.c | 50 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 50 insertions(+) > > diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c > index cc1d4fdddc6e..17649e3cbc8f 100644 > --- a/arch/arm64/kvm/ptdump.c > +++ b/arch/arm64/kvm/ptdump.c > @@ -215,8 +215,58 @@ static const struct file_operations kvm_ptdump_guest_fops = { > .release = kvm_ptdump_guest_close, > }; > > +static int kvm_pgtable_debugfs_show(struct seq_file *m, void *unused) > +{ > + const struct file *file = m->file; > + struct kvm_pgtable *pgtable = m->private; > + > + if (!strcmp(file_dentry(file)->d_iname, "ipa_range")) > + seq_printf(m, "%2u\n", pgtable->ia_bits); > + else if (!strcmp(file_dentry(file)->d_iname, "stage2_levels")) > + seq_printf(m, "%1d\n", pgtable->start_level); The name of the file suggests sounds like this is the number of page table levels instead of the starting level of the walk. So instead: seq_printf(m, "%1d\n", KVM_PGTABLE_LAST_LEVEL - pgtable->start_level + 1); > + return 0; > +} > + > +static int kvm_pgtable_debugfs_open(struct inode *m, struct file *file) > +{ > + struct kvm *kvm = m->i_private; > + struct kvm_s2_mmu *mmu; > + struct kvm_pgtable *pgtable; > + int ret; > + > + if (!kvm_get_kvm_safe(kvm)) > + return -ENOENT; > + > + mmu = &kvm->arch.mmu; > + pgtable = mmu->pgt; nitpick: pgtable = &kvm->arch.mmu.pgt -- Thanks, Oliver