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 125F3CDB47E for ; Fri, 20 Oct 2023 08:20:10 +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=htipj1G+GxAeYRhGermyQmTYnjgU2qhjgvvCUU7Qwo4=; b=0t5tXsWf46CsXq F/STSOzofR+O8eTY/a5LHaBRKAwGY/3FO3rVskIZy0o4GYgnAkHX7NbZ8iQIm8rP7X+jchGg555HH tBoeoOcV2BqF1UBSTLowxKClgLQdNihdpEOhmkrmoJtfMIpbrYJyV36mKpdDzD5zhPu3vJTuve2mX TbdxYFgr1j+vLXvPyj5yrBKpPo8/8qd0J/fC9QqQOibWpHxcF/9g9mW5XPntuWVDFWpZ1kvvqKFYH 9ibJTnM5/P4Uu0PEVpi8ICVxEVDpUaHhdE/GGa78EZ60SN99oYVdRn8fuWn1KBHfBZhCcyidEltg+ WjFdrDZPjaR/WOXFTRmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtkjU-001XgC-1C; Fri, 20 Oct 2023 08:19:48 +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 1qtkjR-001XdG-31 for linux-arm-kernel@lists.infradead.org; Fri, 20 Oct 2023 08:19:47 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-407c3adef8eso4533475e9.2 for ; Fri, 20 Oct 2023 01:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697789978; x=1698394778; 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=J6McO7iCkNBRBCpKgUqgVhPb6Hf4s6Lra6fBOLrTfMY=; b=rZLbLLi7fnicRPRWhd4Tjk90HWlevEUag9rLSMfPuOprD/rMAyLs+K7bLsAo5EPJlL /NctXVEzuCn5dnsXWPACvo+CrJAY7vv4hUoTrWaxsfzpebWVMf0NUGaO6SY+nphfZon0 mUy4Hi9hFWTQMLqf4YrVHc+qIxZTGzZutiIGUA+0yB7hSrBGTbastbAjrkSELAwBZQzl b0hsFwGSHcraDhGIrYumxeySrQSfC06a1XR9QfgwTZVzUtU/KPK+s9Izu+djmbXZCoBe aHo8j+5Yt6FpHfOt2/W58sdvBbtBb/Pc5rQNkmGtE1bT44CIMvmzGvq8GaAXjHw+6U12 y6OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697789978; x=1698394778; 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=J6McO7iCkNBRBCpKgUqgVhPb6Hf4s6Lra6fBOLrTfMY=; b=twNmdGil4cGDrgffIqjnyIQ/aUiPsvwjH+GKb/VFma5Y5rNz6SbmtJCCadnG0YeKMN pVjJSPjZYmJ9FCrQ2UgQ9w1atqCZAV8k1X4kvqgfHlNL32R1KVo5YrbRjCP+yz88IeSi qhRFIY42SXgkF8Dst7jCj8dwlPdn5nHFkmYOpzHdpDDIQq1mKC1S+ti4OA0OvQKICER2 PLpMRxGs9vjpmi/nbrGfl9yFClyTtMhagdJ8bbqlv2WsO48V0c/SKwejKgYn35Y1nvVB 1buciEy2CgpvD+fIXxqZonNxL5xund9s96L4ErTCDnfGD6RuBWV0zTrHgQ4jq7yfoSlO khhA== X-Gm-Message-State: AOJu0YzMS/TAw0XJUbkXpIFeEo9FH+5RxpWXi04M5j3UA2AN2lWJ+JyL kxKxmdEE0xkmY8BsAfjcSRTbbg== X-Google-Smtp-Source: AGHT+IGhZf+aOc5CORnKxLgq2L/StMiHIhiN8RZyid6bewWMrLayatbGXf3MAx9RUOUCkHYSPuKNaQ== X-Received: by 2002:a05:600c:3541:b0:405:40c6:2b96 with SMTP id i1-20020a05600c354100b0040540c62b96mr871419wmq.3.1697789978389; Fri, 20 Oct 2023 01:19:38 -0700 (PDT) Received: from google.com (65.0.187.35.bc.googleusercontent.com. [35.187.0.65]) by smtp.gmail.com with ESMTPSA id p15-20020a05600c1d8f00b00402d34ea099sm6402498wms.29.2023.10.20.01.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:19:37 -0700 (PDT) Date: Fri, 20 Oct 2023 09:19:33 +0100 From: Vincent Donnefort To: Sebastian Ene 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: <20231019144032.2943044-1-sebastianene@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231020_011946_002348_77023806 X-CRM114-Status: GOOD ( 27.15 ) 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 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. I believe guests entries should be also available for nVHE and VHE. > > 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. > > 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