linux/arch/x86/kvm/mmu
Ben Gardon 7cca2d0b7e KVM: x86/mmu: Protect TDP MMU page table memory with RCU
In order to enable concurrent modifications to the paging structures in
the TDP MMU, threads must be able to safely remove pages of page table
memory while other threads are traversing the same memory. To ensure
threads do not access PT memory after it is freed, protect PT memory
with RCU.

Protecting concurrent accesses to page table memory from use-after-free
bugs could also have been acomplished using
walk_shadow_page_lockless_begin/end() and READING_SHADOW_PAGE_TABLES,
coupling with the barriers in a TLB flush. The use of RCU for this case
has several distinct advantages over that approach.
1. Disabling interrupts for long running operations is not desirable.
   Future commits will allow operations besides page faults to operate
   without the exclusive protection of the MMU lock and those operations
   are too long to disable iterrupts for their duration.
2. The use of RCU here avoids long blocking / spinning operations in
   perfromance critical paths. By freeing memory with an asynchronous
   RCU API we avoid the longer wait times TLB flushes experience when
   overlapping with a thread in walk_shadow_page_lockless_begin/end().
3. RCU provides a separation of concerns when removing memory from the
   paging structure. Because the RCU callback to free memory can be
   scheduled immediately after a TLB flush, there's no need for the
   thread to manually free a queue of pages later, as commit_zap_pages
   does.

Fixes: 95fb5b0258 ("kvm: x86/mmu: Support MMIO in the TDP MMU")
Reviewed-by: Peter Feiner <pfeiner@google.com>
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Ben Gardon <bgardon@google.com>

Message-Id: <20210202185734.1680553-18-bgardon@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-02-04 05:27:42 -05:00
..
mmu_audit.c KVM: Stop using deprecated jump label APIs 2021-02-04 05:27:29 -05:00
mmu_internal.h KVM: x86/mmu: Protect TDP MMU page table memory with RCU 2021-02-04 05:27:42 -05:00
mmu.c KVM: x86/mmu: Fix braces in kvm_recover_nx_lpages 2021-02-04 05:27:39 -05: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: x86: use static calls to reduce kvm_x86_ops overhead 2021-02-04 05:27:30 -05:00
spte.h KVM: x86/mmu: Use boolean returns for (S)PTE accessors 2021-02-04 05:27:15 -05:00
tdp_iter.c KVM: x86/mmu: Protect TDP MMU page table memory with RCU 2021-02-04 05:27:42 -05:00
tdp_iter.h KVM: x86/mmu: Protect TDP MMU page table memory with RCU 2021-02-04 05:27:42 -05:00
tdp_mmu.c KVM: x86/mmu: Protect TDP MMU page table memory with RCU 2021-02-04 05:27:42 -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