Enable pagetable tracking and mapping for SEV VMs to allow guest code to execute guest_map_region_shared/private APIs.
Signed-off-by: Vishal Annapurve vannapurve@google.com --- tools/testing/selftests/kvm/lib/x86_64/sev.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/tools/testing/selftests/kvm/lib/x86_64/sev.c b/tools/testing/selftests/kvm/lib/x86_64/sev.c index 96d3dbc2ba74..0dfffdc224d6 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/sev.c +++ b/tools/testing/selftests/kvm/lib/x86_64/sev.c @@ -215,6 +215,8 @@ static void sev_vm_measure(struct kvm_vm *vm) pr_debug("\n"); }
+#define GUEST_PGT_MIN_VADDR 0x10000 + struct kvm_vm *sev_vm_init_with_one_vcpu(uint32_t policy, void *guest_code, struct kvm_vcpu **cpu) { @@ -224,6 +226,7 @@ struct kvm_vm *sev_vm_init_with_one_vcpu(uint32_t policy, void *guest_code,
vm = ____vm_create(mode, nr_pages);
+ vm_set_pgt_alloc_tracking(vm); kvm_sev_ioctl(vm, KVM_SEV_INIT, NULL);
configure_sev_pte_masks(vm); @@ -238,6 +241,8 @@ struct kvm_vm *sev_vm_init_with_one_vcpu(uint32_t policy, void *guest_code,
void sev_vm_finalize(struct kvm_vm *vm, uint32_t policy) { + vm_map_page_table(vm, GUEST_PGT_MIN_VADDR); + sev_vm_launch(vm, policy);
sev_vm_measure(vm);