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 69122C52D7C for ; Fri, 23 Aug 2024 05:23:26 +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=Uet9U2HrK3DDTVPxLWw7T/TPH3t4QYpkiQ6FRu69I08=; b=MGHNkhx52WCuO9rAkJYxGQDhVr 49wIzAQeUeXqPL7ErrKT0F0Uxa8JZJMM5Mr9F2AjsPy54JHCbNcayyKujDJnhnYJZ6zbD84tEc7MC s4A2UWGCOzwE4pFPRQipd7Bxm931GPOo52B6kviIZhNEQcb92yReIs9FS4erHeLxQ6w7bTZrC0Mvp 6qQIWrOYseWxNdVdQiBM0M0gRcqoQ2f7ym41l3QXtW1sU3LUfF9R8ovllQ8D9t04sk7iqdLw/GiE4 URGAROMlXDJqY7k8LvHDGAw7J8l7p6izMp8TNOarMyfVkxw+4CfPpOn2ChjskREA7aEmYP3Fw6Jbn xx0ZNX1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shMlV-0000000FIYh-2Y3s; Fri, 23 Aug 2024 05:23:13 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shMkN-0000000FIFv-1Rpn for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 05:22:04 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5bebb241fddso5151a12.1 for ; Thu, 22 Aug 2024 22:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724390520; x=1724995320; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Uet9U2HrK3DDTVPxLWw7T/TPH3t4QYpkiQ6FRu69I08=; b=aOM6op4npcboCykBwdaaYW6w1EzgPQB+UP/ptnN4u4s5KRjkzx452Oxz6mn2P8Zfgc f4sBay8aHEuTTfQisEkoiZEM67CP2W2F1f9zYlbeF4AD6EEDFewMU0afPxLDmUH5zuxr nYhK+nh/qO4pr+zfC/VkpZ/7s+l/+Ugn2ln2FyA55EEFAmdXcyt5SMoVMJCi0YeVvAff /AeXB/ruxQ7m8Akk1FLj2xGA1LWRNK9Nk490PPFzSVVx4YKgqyn7j8n2Y4XJMCsj5L8m VxD1+OXlPTY1P37IphtUHYQPKInkoYctTEyzzcBPq9OSiUulmbsN4em5yniiEPcEfg7p /J1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724390520; x=1724995320; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Uet9U2HrK3DDTVPxLWw7T/TPH3t4QYpkiQ6FRu69I08=; b=gn4oTD9AYAry4obThYj5jUB1M0cCMlvSujbuerDdAqDV/+J/6yMRuJdYLdnK0tIuhN ZeUH3AtCnApDasPS9xPE3HqkVNSOzknLI1vxXqZSbkTCszVwMq/d9/+dKs8XRXOZWsvi MqgSapxRea4OL4liwWRalHXKdsOr/4++M+DU+GrFyy9YLHDOfCYs5a/oy+pA3dQYHOWB PzTxec+bvSK6avxL+3/48hxEzDs3YemWm+51Y28Qz0SOqvica4Q3SVhOHaeYo57rgiYp HlCgcGEBeTuImC9WXmuRV/cx4dmnaCqfiliFoqasnduZzjFJ4kqqhTpfW6irgA6qmPKs IEmQ== X-Forwarded-Encrypted: i=1; AJvYcCW6JVpGHMwxz3PAXr3hh559zxw1x6zsMZV+GqcbBBPhWuZjuz/TpkAuBbqwo04ZRMT22Ka//UOV/UoGpE2/ezy1@lists.infradead.org X-Gm-Message-State: AOJu0Yw2rn+PIqbvM5CkFNlsF5OHGkI6OMJOtQL7ZovbksL5660wFvhr mhz8mhHeYZrmkgS3I0YBf8H8nG7LWuLwz1a0yFvzr+3lphxdNzGiO8fJHkwYEw== X-Google-Smtp-Source: AGHT+IHX7tl5DbRivNHSGrXaXjN7w0N7ivyfde8OdjfcE2wwK+UU5/Q3ZPbA/FFuKu71Tegra0xcDA== X-Received: by 2002:a05:6402:51d1:b0:59f:9f59:9b07 with SMTP id 4fb4d7f45d1cf-5c0870abd46mr92310a12.4.1724390520099; Thu, 22 Aug 2024 22:22:00 -0700 (PDT) Received: from google.com (44.232.78.34.bc.googleusercontent.com. [34.78.232.44]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37308110436sm3247482f8f.11.2024.08.22.22.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 22:21:59 -0700 (PDT) Date: Fri, 23 Aug 2024 05:21:58 +0000 From: Sebastian Ene To: Marc Zyngier 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, oliver.upton@linux.dev, 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 v8 5/6] KVM: arm64: Initialize the ptdump parser with stage-2 attributes Message-ID: References: <20240816123906.3683425-1-sebastianene@google.com> <20240816123906.3683425-6-sebastianene@google.com> <86plq3xoly.wl-maz@kernel.org> <8634mwy1mt.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8634mwy1mt.wl-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240822_222203_442771_97EEEC04 X-CRM114-Status: GOOD ( 30.94 ) 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 Thu, Aug 22, 2024 at 05:15:54PM +0100, 'Marc Zyngier' via kernel-team wrote: > On Tue, 20 Aug 2024 15:20:25 +0100, > Marc Zyngier wrote: > > > > On Fri, 16 Aug 2024 13:39:05 +0100, > > Sebastian Ene wrote: > > > > > > Define a set of attributes used by the ptdump parser to display the > > > properties of a guest memory region covered by a pagetable descriptor. > > > Build a description of the pagetable levels and initialize the parser > > > with this configuration. > > > > > > Signed-off-by: Sebastian Ene > > > --- > > > arch/arm64/kvm/ptdump.c | 135 ++++++++++++++++++++++++++++++++++++++-- > > > 1 file changed, 129 insertions(+), 6 deletions(-) > > > > > > diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c > > > index 52483d56be2e..79be07ec3c3c 100644 > > > --- a/arch/arm64/kvm/ptdump.c > > > +++ b/arch/arm64/kvm/ptdump.c > > > @@ -14,6 +14,51 @@ > > > #include > > > > > > > > > +#define MARKERS_LEN (2) > > > +#define KVM_PGTABLE_MAX_LEVELS (KVM_PGTABLE_LAST_LEVEL + 1) > > > + > > > +struct kvm_ptdump_guest_state { > > > + struct kvm *kvm; > > > + struct ptdump_pg_state parser_state; > > > + struct addr_marker ipa_marker[MARKERS_LEN]; > > > + struct ptdump_pg_level level[KVM_PGTABLE_MAX_LEVELS]; > > > + struct ptdump_range range[MARKERS_LEN]; > > > +}; > > > + > > > +static const struct ptdump_prot_bits stage2_pte_bits[] = { > > > + { > > > + .mask = PTE_VALID, > > > + .val = PTE_VALID, > > > + .set = " ", > > > + .clear = "F", > > > + }, { > > > + .mask = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | PTE_VALID, > > > + .val = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | PTE_VALID, > > > + .set = "R", > > > + .clear = " ", > > > + }, { > > > + .mask = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | PTE_VALID, > > > + .val = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | PTE_VALID, > > > + .set = "W", > > > + .clear = " ", > > > + }, { > > > + .mask = KVM_PTE_LEAF_ATTR_HI_S2_XN | PTE_VALID, > > > + .val = PTE_VALID, > > > + .set = " ", > > > + .clear = "X", > > > + }, { > > > + .mask = KVM_PTE_LEAF_ATTR_LO_S2_AF | PTE_VALID, > > > + .val = KVM_PTE_LEAF_ATTR_LO_S2_AF | PTE_VALID, > > > + .set = "AF", > > > + .clear = " ", > > > + }, { > > > + .mask = PTE_TABLE_BIT | PTE_VALID, > > > + .val = PTE_VALID, > > > + .set = "BLK", > > > + .clear = " ", > > > + }, > > > +}; > > > + > > > static int kvm_ptdump_visitor(const struct kvm_pgtable_visit_ctx *ctx, > > > enum kvm_pgtable_walk_flags visit) > > > { > > > @@ -40,15 +85,81 @@ static int kvm_ptdump_show_common(struct seq_file *m, > > > return kvm_pgtable_walk(pgtable, 0, BIT(pgtable->ia_bits), &walker); > > > } > > > > > > +static int kvm_ptdump_build_levels(struct ptdump_pg_level *level, u32 start_lvl) > > > +{ > > > + static const char * const level_names[] = {"PGD", "PUD", "PMD", "PTE"}; > > > > How about 5 level page tables, which we support since v6.8? The > > architecture uses a SL=-1 in this case, and I have the feeling this is > > going to expose in a lovely way, given that you use a u32 for > > start_level... :-/ > Hello Marc, > Talking to Oliver, I just had an epiphany: we never have a 5th level > with KVM, because we always use concatenated page tables at the start > level. So the depth is still 4 levels, but we get up to 16 pages at > level 0, and that's how we expand the IPA space from 48 to 52 bits. > Thanks for letting me know. Then it should be fine keeping that as an unisgned integer. > So by the look of it, your code should still be OK with only 4 levels. > Thanks, Seb > Apologies for leading you in the wrong direction. > > M. > > -- > Without deviation from the norm, progress is not possible. > > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >