On Tue, Jan 10, 2023, Peter Gonda wrote: > Add kvm_vm.protected metadata. Protected VMs memory, potentially > register and other state may not be accessible to KVM. This combined > with a new protected_phy_pages bitmap will allow the selftests to check > if a given pages is accessible. > > Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx> > Cc: Sean Christopherson <seanjc@xxxxxxxxxx> > Cc: Vishal Annapurve <vannapurve@xxxxxxxxxx> > Cc: Ackerley Tng <ackerleytng@xxxxxxxxxx> > cc: Andrew Jones <andrew.jones@xxxxxxxxx> > Originally-by: Michael Roth <michael.roth@xxxxxxx> > Signed-off-by: Peter Gonda <pgonda@xxxxxxxxxx> > --- > .../selftests/kvm/include/kvm_util_base.h | 14 ++++++++++++-- > tools/testing/selftests/kvm/lib/kvm_util.c | 16 +++++++++++++--- > 2 files changed, 25 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h > index fbc2a79369b8..015b59a0b80e 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h > @@ -45,6 +45,7 @@ typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */ > struct userspace_mem_region { > struct kvm_userspace_memory_region region; > struct sparsebit *unused_phy_pages; > + struct sparsebit *protected_phy_pages; > int fd; > off_t offset; > enum vm_mem_backing_src_type backing_src_type; > @@ -111,6 +112,9 @@ struct kvm_vm { > vm_vaddr_t handlers; > uint32_t dirty_ring_size; > > + /* VM protection enabled: SEV, etc*/ > + bool protected; > + > /* Cache of information for binary stats interface */ > int stats_fd; > struct kvm_stats_header stats_header; > @@ -679,10 +683,16 @@ const char *exit_reason_str(unsigned int exit_reason); > > vm_paddr_t vm_phy_page_alloc(struct kvm_vm *vm, vm_paddr_t paddr_min, > uint32_t memslot); > -vm_paddr_t vm_phy_pages_alloc(struct kvm_vm *vm, size_t num, > - vm_paddr_t paddr_min, uint32_t memslot); > +vm_paddr_t _vm_phy_pages_alloc(struct kvm_vm *vm, size_t num, Two underscores please. Ignore the terrible precedent that has been set, we're slowly purging that crud. > + vm_paddr_t paddr_min, uint32_t memslot, bool protected); Wrap, no strong justification for running long in this case since the declaration has already wrapped, and the definition does wrap.