1
0
Fork 0
alistair23-linux/arch/x86/kvm/mmu
Ben Gardon a889ea54b3 KVM: x86/mmu: Ensure TDP MMU roots are freed after yield
Many TDP MMU functions which need to perform some action on all TDP MMU
roots hold a reference on that root so that they can safely drop the MMU
lock in order to yield to other threads. However, when releasing the
reference on the root, there is a bug: the root will not be freed even
if its reference count (root_count) is reduced to 0.

To simplify acquiring and releasing references on TDP MMU root pages, and
to ensure that these roots are properly freed, move the get/put operations
into another TDP MMU root iterator macro.

Moving the get/put operations into an iterator macro also helps
simplify control flow when a root does need to be freed. Note that using
the list_for_each_entry_safe macro would not have been appropriate in
this situation because it could keep a pointer to the next root across
an MMU lock release + reacquire, during which time that root could be
freed.

Reported-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Fixes: faaf05b00a ("kvm: x86/mmu: Support zapping SPTEs in the TDP MMU")
Fixes: 063afacd87 ("kvm: x86/mmu: Support invalidate range MMU notifier for TDP MMU")
Fixes: a6a0b05da9 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
Fixes: 1488199856 ("kvm: x86/mmu: Support disabling dirty logging for the tdp MMU")
Signed-off-by: Ben Gardon <bgardon@google.com>
Message-Id: <20210107001935.3732070-1-bgardon@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-01-07 18:11:31 -05:00
..
mmu.c Merge branch 'kvm-master' into kvm-next 2021-01-07 18:06:52 -05:00
mmu_audit.c KVM: x86/mmu: Rename page_header() to to_shadow_page() 2020-07-08 16:21:55 -04:00
mmu_internal.h kvm: x86/mmu: NX largepage recovery for TDP MMU 2020-10-23 03:42:16 -04:00
mmutrace.h kvm: x86/mmu: Add TDP MMU SPTE changed trace point 2020-11-19 10:57:16 -05:00
page_track.c kvm: mmu: page_track: Fix RCU list API usage 2020-08-24 18:36:23 -07:00
paging_tmpl.h kvm: x86/mmu: Remove disallowed_hugepage_adjust shadow_walk_iterator arg 2020-10-21 18:17:02 -04:00
spte.c KVM: mmu: Fix SPTE encoding of MMIO generation upper half 2020-12-11 19:18:43 -05:00
spte.h KVM: mmu: Fix SPTE encoding of MMIO generation upper half 2020-12-11 19:18:43 -05:00
tdp_iter.c kvm: x86/mmu: Support zapping SPTEs in the TDP MMU 2020-10-21 18:17:02 -04:00
tdp_iter.h kvm: x86/mmu: Support dirty logging for the TDP MMU 2020-10-23 03:42:13 -04:00
tdp_mmu.c KVM: x86/mmu: Ensure TDP MMU roots are freed after yield 2021-01-07 18:11:31 -05:00
tdp_mmu.h KVM: x86/mmu: Get root level from walkers when retrieving MMIO SPTE 2021-01-07 18:00:24 -05:00