Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp256262rdd; Wed, 22 Nov 2023 15:19:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGk6hiIqQj0xNxnTcwsZZoeXiBW5hBIO9EbsmjS/U6zACnImcyP/H0Ft+oG98VhToeuiBDk X-Received: by 2002:a05:6a20:e588:b0:186:7842:ad0c with SMTP id ng8-20020a056a20e58800b001867842ad0cmr3640039pzb.35.1700695149389; Wed, 22 Nov 2023 15:19:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700695149; cv=none; d=google.com; s=arc-20160816; b=WPUA3oQDf+T6fVBtPeVYL4qBNPANTSMM6AlhhwBm3ESmh4TeWgRwC5Hbj07eQkWNlz HAKoKyiImf5FawBfbyOIuT2Xykcqgb49Qst596UQMKot5C0IMJYEJ9FhdQheZUo38/vj Ab4cqhCFng2zIVTa5D5M4PpjN7GqtxMFoKEbj6HW2OBm4gelWIuODoC+rYPChhFRpw2I 3M/Dgy2FVIBsrJwCDWbfpKQmCW3Iid52QekR02GJXBDMe8kQ9yu9sRhC7G5glbDozmMb uSs6JqmrPpYK6Ux7EJGM8lemXpZJSZOwa+97jp/xvGxY0BoEbaMNyEep94jfBcGmJF86 aAiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=JxXGMR68Ffnug5d1GsuemuN3GA7Qv3hraWikP3Qedyg=; fh=yT+A6FPEZlMOuSm5kJ2iVXd4DHLGSAFlICh4O+Gupjo=; b=ymGtiBINP13t/62FS201TyNgBhO0WZO5555KzHFNljbtwi0arIw2lRcFubZY2C0nnT chLWWui9BVHvPOFR34xa81pRrLD4qkB+hJ8fioSvJHjPy6FetKA7bnNuercnAOPaKgP+ Dwe2BsyVmza1izig+irvW8QfqcPNWwkbzJxCIIWeV4bpCKLgoIELdkmgWV5EU3W7Tdot jP/lxRP45ptPCnpQITVcqRY2+RsZI3Vhg0oBfmCN8GBFwxF5YnSu5fAdM5aEedTr/BPq v9+BewfCqbJREJ3J75qxUnisQQ71WpVyQlSMd5vHea9h1iDrenC/fdEvACTS7ZJ9tj4E gLIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=EKGjeETg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id f23-20020a63f117000000b005bdc949fee3si85366pgi.880.2023.11.22.15.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 15:19:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=EKGjeETg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7896283037CC; Wed, 22 Nov 2023 15:19:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbjKVXS5 (ORCPT + 99 others); Wed, 22 Nov 2023 18:18:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjKVXS5 (ORCPT ); Wed, 22 Nov 2023 18:18:57 -0500 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47370D8 for ; Wed, 22 Nov 2023 15:18:53 -0800 (PST) Date: Wed, 22 Nov 2023 23:18:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700695131; 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=JxXGMR68Ffnug5d1GsuemuN3GA7Qv3hraWikP3Qedyg=; b=EKGjeETg1FstPJI4IUIF9cjjTbqw4SiOzQYBToAG/PRyaM3apZI2VzkUQzsX64VhacLKYU McFbkQwAgzMlNjIHOG6MJ+5w7jqYHy/LCciVJ3Mit2qHGpRdkTGOSOpKVOycUXo7qdZXMC OhzwgUxs+eWT7kYTCw1de2PfeRGitOE= 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 v3 00/10] arm64: ptdump: View the second stage page-tables Message-ID: References: <20231115171639.2852644-2-sebastianene@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231115171639.2852644-2-sebastianene@google.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 22 Nov 2023 15:19:06 -0800 (PST) Hi Seb, On Wed, Nov 15, 2023 at 05:16:30PM +0000, Sebastian Ene wrote: > Hi, > > This can be used as a debugging tool for dumping the second stage > page-tables. > > When CONFIG_PTDUMP_STAGE2_DEBUGFS is enabled, ptdump registers > '/sys/debug/kvm//stage2_page_tables' entry with debugfs > upon guest creation. This allows userspace tools (eg. cat) to dump the > stage-2 pagetables by reading the registered file. > > Reading the debugfs file shows stage-2 memory ranges in following format: > > > Under pKVM configuration(kvm-arm.mode=protected) ptdump registers an entry > for the host stage-2 pagetables in the following path: > /sys/debug/kvm/host_stage2_page_tables/ > > The tool interprets the pKVM ownership annotation stored in the invalid > entries and dumps to the console the ownership information. To be able > to access the host stage-2 page-tables from the kernel, a new hypervisor > call was introduced which allows us to snapshot the page-tables in a host > provided buffer. The hypervisor call is hidden behind CONFIG_NVHE_EL2_DEBUG > as this should be used under debugging environment. While I think the value of the feature you're proposing is great, I'm not a fan of the current shape of this series. Reusing note_page() for the stage-2 dump is somewhat convenient, but the series pulls a **massive** amount of KVM details outside of KVM: - Open-coding the whole snapshotting interface with EL2 outside of KVM. This is a complete non-starter for me; the kernel<->EL2 interface needs to be owned by the EL1 portions of KVM. - Building page-table walkers using the KVM pgtable library outside of KVM. - Copying (rather than directly calling) the logic responsible for things like FWB and PGD concatenation. - Hoisting the definition of _software bits_ outside of KVM. I'm less concerned about hardware bits since they have an unambiguous meaning. I think exporting the necessary stuff from ptdump into KVM will lead to a much cleaner implementation. -- Thanks, Oliver