All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Ene <sebastianene@google.com>
To: Vincent Donnefort <vdonnefort@google.com>
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
Date: Mon, 23 Oct 2023 14:32:35 +0000	[thread overview]
Message-ID: <ZTaEAyuoEQ3cSbjT@google.com> (raw)
In-Reply-To: <ZTI4FcFkgwnLv0-1@google.com>

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:
> > <IPA range> <size> <descriptor type> <access permissions> <mem_attributes>
> > 
> > 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

WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Ene <sebastianene@google.com>
To: Vincent Donnefort <vdonnefort@google.com>
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
Date: Mon, 23 Oct 2023 14:32:35 +0000	[thread overview]
Message-ID: <ZTaEAyuoEQ3cSbjT@google.com> (raw)
In-Reply-To: <ZTI4FcFkgwnLv0-1@google.com>

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:
> > <IPA range> <size> <descriptor type> <access permissions> <mem_attributes>
> > 
> > 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
> > 

  reply	other threads:[~2023-10-23 14:33 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19 14:40 [PATCH v2 00/11] arm64: ptdump: View the second stage page-tables Sebastian Ene
2023-10-19 14:40 ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 01/11] KVM: arm64: Add snap shooting the host stage-2 pagetables Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-26 12:45   ` kernel test robot
2023-10-26 12:45     ` kernel test robot
2023-10-19 14:40 ` [PATCH v2 02/11] arm64: ptdump: Use the mask from the state structure Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 03/11] arm64: ptdump: Add the walker function to the ptdump info structure Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 04/11] KVM: arm64: Move pagetable definitions to common header Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 05/11] arm64: ptdump: Introduce stage-2 pagetables format description Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 06/11] arm64: ptdump: Add hooks on debugfs file operations Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 07/11] arm64: ptdump: Register a debugfs entry for the host stage-2 page-tables Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 08/11] arm64: ptdump: Parse the host stage-2 page-tables from the snapshot Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 09/11] arm64: ptdump: Interpret memory attributes based on runtime configuration Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 10/11] arm64: ptdump: Interpret pKVM ownership annotations Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-19 14:40 ` [PATCH v2 11/11] arm64: ptdump: Add support for guest stage-2 pagetables dumping Sebastian Ene
2023-10-19 14:40   ` Sebastian Ene
2023-10-20  8:40   ` Vincent Donnefort
2023-10-20  8:40     ` Vincent Donnefort
2023-10-23 14:45     ` Sebastian Ene
2023-10-23 14:45       ` Sebastian Ene
2023-10-20  8:19 ` [PATCH v2 00/11] arm64: ptdump: View the second stage page-tables Vincent Donnefort
2023-10-20  8:19   ` Vincent Donnefort
2023-10-23 14:32   ` Sebastian Ene [this message]
2023-10-23 14:32     ` Sebastian Ene

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZTaEAyuoEQ3cSbjT@google.com \
    --to=sebastianene@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=kernel-team@android.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=qperret@google.com \
    --cc=smostafa@google.com \
    --cc=vdonnefort@google.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.