KVM: PPC: Book3S HV nestedv2: Invalidate RPT before deleting a guest
authorJordan Niethe <jniethe5@gmail.com>
Fri, 1 Dec 2023 13:26:06 +0000 (18:56 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 7 Dec 2023 12:33:07 +0000 (23:33 +1100)
An L0 must invalidate the L2's RPT during H_GUEST_DELETE if this has not
already been done. This is a slow operation that means H_GUEST_DELETE
must return H_BUSY multiple times before completing. Invalidating the
tables before deleting the guest so there is less work for the L0 to do.

Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231201132618.555031-2-vaibhav@linux.ibm.com
arch/powerpc/include/asm/kvm_book3s.h
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_hv_nested.c

index 4f527d09c92b973bc57155a0129647e38514c8c1..a37736ed372888f738fb898201156a68822c4b74 100644 (file)
@@ -302,6 +302,7 @@ void kvmhv_nested_exit(void);
 void kvmhv_vm_nested_init(struct kvm *kvm);
 long kvmhv_set_partition_table(struct kvm_vcpu *vcpu);
 long kvmhv_copy_tofrom_guest_nested(struct kvm_vcpu *vcpu);
+void kvmhv_flush_lpid(u64 lpid);
 void kvmhv_set_ptbl_entry(u64 lpid, u64 dw0, u64 dw1);
 void kvmhv_release_all_nested(struct kvm *kvm);
 long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu);
index 1ed6ec140701d5f77d60f16eecf18de04fda5e18..5543e8490cd9f00c9e2e1558c39e533348424594 100644 (file)
@@ -5691,10 +5691,12 @@ static void kvmppc_core_destroy_vm_hv(struct kvm *kvm)
                        kvmhv_set_ptbl_entry(kvm->arch.lpid, 0, 0);
        }
 
-       if (kvmhv_is_nestedv2())
+       if (kvmhv_is_nestedv2()) {
+               kvmhv_flush_lpid(kvm->arch.lpid);
                plpar_guest_delete(0, kvm->arch.lpid);
-       else
+       } else {
                kvmppc_free_lpid(kvm->arch.lpid);
+       }
 
        kvmppc_free_pimap(kvm);
 }
index 3b658b8696bca670d37af06c68dffedae9ef8934..5c375ec1a3c6084be948ccc41e803f8e6da14dc2 100644 (file)
@@ -503,7 +503,7 @@ void kvmhv_nested_exit(void)
        }
 }
 
-static void kvmhv_flush_lpid(u64 lpid)
+void kvmhv_flush_lpid(u64 lpid)
 {
        long rc;