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 C1E9EC004C0 for ; Mon, 23 Oct 2023 14:33:14 +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=vVnksLTiADVbtxv5eBiokERtIDU/47HXoLOmVZrTUBA=; b=dIQ3ToETX2JlOE EephckZq8rBeRS27bMuRSSuSm6CTOWctyJIGSafZKJnNifeHyxzyaNcuCjPot20uwJ7yymNYQ848X 7NLVHreJQgMg4zVdA4vISAdwWMJJ6TCrAqZ9pfqJQx7VVt0QZ5CEUqZ1VdJe8iJoRWPHriNZXb0xD LO4BhPkyNVelQkXREg5ZObALX/i0SrVHbOZqe+ht91CMAs3to1vh2QNKBYmnw0GCnEiJkEFeO0h23 OA47cuPnImWEj/TnrVEtlVXva4DUOY6F7DyUFUPaD+XSCrQpccLc2y9gYdbdbuzkxx47TgKP07Hjc LsC02OrwY8RXLoJ6Xk0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1quvz4-007YSW-2y; Mon, 23 Oct 2023 14:32:46 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1quvz2-007YQY-06 for linux-arm-kernel@lists.infradead.org; Mon, 23 Oct 2023 14:32:45 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40853f2e93eso106415e9.0 for ; Mon, 23 Oct 2023 07:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698071559; x=1698676359; 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=a7Ps051HvRlmuSmZt6ySV7oSekeUA2kCbjCKb5l7ziM=; b=LuQYzt6/8lMDr4D1ob+NMbig73C7PGYonsjgYrVhd7PETRaUMBXnIr+GoyefESzupX KuEuOeB/nS02WmPBx/2Lz1BfvZ0r3TjZJxZtzOMu2KmzLndFuJP5DY09dk8iQdcLg/MT cuuq0vVDq0uHL4EVi57HZR1nSD/o6s4va+1fnisfpBzF3UKvzN3s9+BwrRhklN/6qou8 NLZQDZGK4I0n39ewWUYKEoZmzsmBCGz6jX/jgjRS+IMvwyi7EwDAfWdbSbOYfZ+xpdEP AZuOpb7gcwAu3oO6d7G7uYg6B2rPkEJVD2Ft2eVyBHASAmKf3FogA3AaRkb2/i+NDpnT fkew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698071559; x=1698676359; 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=a7Ps051HvRlmuSmZt6ySV7oSekeUA2kCbjCKb5l7ziM=; b=egiA2pXLyaubpivYJJAFh4fTb8Z/jX1f2ZLME7o3FcwMtKoqhkgm1cLBIfEfvbfaIW nuPcFPbSouJCD+txXNO6j398f4HATCNzxlssA1Eg5PZMR27zwvygS22obclm1I24LTCb N4aZXXJYjt3KDy94T28zUirAOkEpc7fOolwLrI9NlniV+WocalWc2Pss83G4MMt6abIp U9HmzJyfdq13Blcv5g9jnF8DzClf5xi2iVJCS9/rS0XVtVbrO15S1N7X3ViKwt5lLlkp zUT6mp9HuwayL4sSAbssY0n51CCgTbVShsoPdWwgUfdPJuqNWLWLJ7QEW+wsQq5IPxxg DYSQ== X-Gm-Message-State: AOJu0YxP8hY7i3SSa3Z1PS7GbMtIeSP6HMDZmgTH4Ef9QVzTIZkkEqIK WQYBevpBcBuOGFrCZ1Gdchk8gw== X-Google-Smtp-Source: AGHT+IHAinTaD2IPkmrEEQ4xgusnoom1aIf5qYF1x2jdlSWU/o73N6AWOkqes0mM/TyNQLfyKWZ4YQ== X-Received: by 2002:a05:600c:4a22:b0:408:2b:5956 with SMTP id c34-20020a05600c4a2200b00408002b5956mr278116wmp.6.1698071558828; Mon, 23 Oct 2023 07:32:38 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id v19-20020a05600c471300b00405959bbf4fsm9691663wmo.19.2023.10.23.07.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:32:38 -0700 (PDT) Date: Mon, 23 Oct 2023 14:32:35 +0000 From: Sebastian Ene To: Vincent Donnefort Cc: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, qperret@google.com, smostafa@google.com Subject: Re: [PATCH v2 00/11] arm64: ptdump: View the second stage page-tables Message-ID: References: <20231019144032.2943044-1-sebastianene@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231023_073244_092007_24EEA4B8 X-CRM114-Status: GOOD ( 34.27 ) 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 Fri, Oct 20, 2023 at 09:19:33AM +0100, Vincent Donnefort wrote: > On Thu, Oct 19, 2023 at 02:40:21PM +0000, Sebastian Ene wrote: > > Hi, > > > > This can be used as a debugging tool for dumping the second stage > > page-tables under debugfs. > > > > From the previous feedback I re-worked the series and added support for > > guest page-tables dumping under VHE & nVHE configuration. I extended the > > list of reviewers as I missed the interested parties in the first round. > > > > When CONFIG_NVHE_EL2_PTDUMP_DEBUGFS is enabled under pKVM environment, > > ptdump registers the 'host_stage2_kernel_page_tables' entry with debugfs. > > Guests are registering a file named '%u_guest_stage2_page_tables' when > > they are created. Hi, > > I believe guests entries should be also available for nVHE and VHE. > Yes, we support dumping the guest stage-2 pagetables with this under both modes. The host stage-2 is available only in kvm.arm.mode="protected". > > > > This allows us to dump the host stage-2 page-tables with the following command: > > cat /sys/kernel/debug/host_stage2_kernel_page_tables. > > As it needs the debugfs anyway, this should probably live in the kvm/ debugfs > folder, while the VMs ptdump should be placed in their respective folder. > > This is quite easy, you should get access to the global kvm_debugfs_dir and > struct kvm->debugfs_dentry. > Right, I was thinking to place them under kvm/ debugfs entry but then I noticed that ptdump files are not registered under this path. > > > > The output is showing the entries in the following format: > > > > > > 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. > > > > Link to the first version: > > https://lore.kernel.org/all/20230927112517.2631674-1-sebastianene@google.com/ > > > > Changelog: > > v1 -> v2: > > * use the stage-2 pagetable walker for dumping descriptors instead of > > the one provided by ptdump. > > > > * support for guests pagetables dumping under VHE/nVHE non-protected > > > > Thanks, > > > > > > Sebastian Ene (11): > > KVM: arm64: Add snap shooting the host stage-2 pagetables > > arm64: ptdump: Use the mask from the state structure > > arm64: ptdump: Add the walker function to the ptdump info structure > > KVM: arm64: Move pagetable definitions to common header > > arm64: ptdump: Introduce stage-2 pagetables format description > > arm64: ptdump: Add hooks on debugfs file operations > > arm64: ptdump: Register a debugfs entry for the host stage-2 > > page-tables > > arm64: ptdump: Parse the host stage-2 page-tables from the snapshot > > arm64: ptdump: Interpret memory attributes based on runtime > > configuration > > arm64: ptdump: Interpret pKVM ownership annotations > > arm64: ptdump: Add support for guest stage-2 pagetables dumping > > > > arch/arm64/include/asm/kvm_asm.h | 1 + > > arch/arm64/include/asm/kvm_pgtable.h | 85 +++ > > arch/arm64/include/asm/ptdump.h | 27 +- > > arch/arm64/kvm/Kconfig | 12 + > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 8 +- > > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 18 + > > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 103 ++++ > > arch/arm64/kvm/hyp/pgtable.c | 98 ++-- > > arch/arm64/kvm/mmu.c | 3 + > > arch/arm64/mm/ptdump.c | 487 +++++++++++++++++- > > arch/arm64/mm/ptdump_debugfs.c | 42 +- > > 11 files changed, 822 insertions(+), 62 deletions(-) > > > > -- > > 2.42.0.655.g421f12c284-goog > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel