kvm:x86:Call BUG_ON marco if calls to x86_set_memory_region fail in kvm_arch_destroy
Paolo Bonzini
maintainerQuoted 32 lines · Nicholas Krause
This fixes the calls to
x86_memory_regionto trigger a kernel oopes for tracing if a bug arises in the functionkvm_arch_destroydue to the failing of any of its internal calls tox86_set_memory_region.Signed-off-by Nicholas Krause <[email protected]>--- arch/x86/kvm/x86.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)arch/x86/kvm/x86.c +3
-2@@ -7745,6 +7745,7 @@ EXPORT_SYMBOL_GPL(x86_set_memory_region);void kvm_arch_destroy_vm (struct kvm *kvm) { +int ret;if (current->mm == kvm->mm) {/* * Free memory regions allocated on behalf of userspace, @@ -7754,13 +7755,16 @@ void kvm_arch_destroy_vm(struct kvm *kvm)struct kvm_userspace_memory_region mem;memset (&mem,0 ,sizeof (mem)); mem.slot =APIC_ACCESS_PAGE_PRIVATE_MEMSLOT ; -x86_set_memory_region (kvm, &mem); + ret =x86_set_memory_region (kvm, &mem); +BUG_ON (ret); mem.slot =IDENTITY_PAGETABLE_PRIVATE_MEMSLOT ; -x86_set_memory_region (kvm, &mem);
arch/x86/kvm/x86.c void kvm_arch_destroy_vm(struct kvm *kvm) · line 7770
Quoted 10 lines
arch/x86/kvm/x86.c +4
-1+ ret =x86_set_memory_region (kvm, &mem); +BUG_ON (ret); mem.slot =TSS_PRIVATE_MEMSLOT ; -x86_set_memory_region (kvm, &mem); + ret =x86_set_memory_region (kvm, &mem); +BUG_ON (ret); }kvm_iommu_unmap_guest (kvm);kfree (kvm->arch.vpic);
No, not at all! Leaking 12k of RAM is not a reason to crash the machine. WARN_ON would be acceptable.
Paolo