[PATCH v6 29/38] KVM: arm64: Use page-table to track page ownership

Will Deacon will at kernel.org
Mon Mar 22 11:27:41 GMT 2021


On Fri, Mar 19, 2021 at 10:01:37AM +0000, Quentin Perret wrote:
> As the host stage 2 will be identity mapped, all the .hyp memory regions
> and/or memory pages donated to protected guestis will have to marked
> invalid in the host stage 2 page-table. At the same time, the hypervisor
> will need a way to track the ownership of each physical page to ensure
> memory sharing or donation between entities (host, guests, hypervisor) is
> legal.
> 
> In order to enable this tracking at EL2, let's use the host stage 2
> page-table itself. The idea is to use the top bits of invalid mappings
> to store the unique identifier of the page owner. The page-table owner
> (the host) gets identifier 0 such that, at boot time, it owns the entire
> IPA space as the pgd starts zeroed.
> 
> Provide kvm_pgtable_stage2_set_owner() which allows to modify the
> ownership of pages in the host stage 2. It re-uses most of the map()
> logic, but ends up creating invalid mappings instead. This impacts
> how we do refcount as we now need to count invalid mappings when they
> are used for ownership tracking.
> 
> Signed-off-by: Quentin Perret <qperret at google.com>
> ---
>  arch/arm64/include/asm/kvm_pgtable.h |  20 +++++
>  arch/arm64/kvm/hyp/pgtable.c         | 126 ++++++++++++++++++++++-----
>  2 files changed, 122 insertions(+), 24 deletions(-)

Acked-by: Will Deacon <will at kernel.org>

Will



More information about the linux-arm-kernel mailing list