linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Remove uses of struct page from x86 and arm64 MMU
@ 2021-06-25  7:36 David Stevens
  2021-06-25  7:36 ` [PATCH v2 1/5] KVM: do not allow mapping valid but non-refcounted pages David Stevens
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: David Stevens @ 2021-06-25  7:36 UTC (permalink / raw)
  To: Marc Zyngier, Huacai Chen, Aleksandar Markovic, Paul Mackerras,
	Paolo Bonzini, Nick Piggin
  Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, Will Deacon,
	Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, Zhenyu Wang, Zhi Wang, linux-arm-kernel, kvmarm,
	linux-kernel, linux-mips, kvm, kvm-ppc, linuxppc-dev,
	intel-gvt-dev, intel-gfx, dri-devel, David Stevens

KVM supports mapping VM_IO and VM_PFNMAP memory into the guest by using
follow_pte in gfn_to_pfn. However, the resolved pfns may not have
assoicated struct pages, so they should not be passed to pfn_to_page.
This series removes such calls from the x86 and arm64 secondary MMU. To
do this, this series introduces gfn_to_pfn_page functions that parallel
the gfn_to_pfn functions. These functions take an extra out parameter
which  contains the page if the hva was resovled by gup. This allows the
caller to call put_page only when necessated by gup.

The gfn_to_pfn functions are depreciated. For now the functions remain
with identical behavior to before, but callers should be migrated to the
new gfn_to_pfn_page functions. I added new functions instead of simply
adding another parameter to the existing functions to make it easier to
track down users of the deprecated functions.

I have migrated the x86 and arm64 secondary MMUs to the new
gfn_to_pfn_page functions.

This addresses CVE-2021-22543 on x86 and arm64.

v1 -> v2:
 - Introduce new gfn_to_pfn_page functions instead of modifying the
   behavior of existing gfn_to_pfn functions, to make the change less
   invasive.
 - Drop changes to mmu_audit.c
 - Include Nicholas Piggin's patch to avoid corrupting refcount in the
   follow_pte case, and use it in depreciated gfn_to_pfn functions.
 - Rebase on kvm/next

David Stevens (4):
  KVM: mmu: introduce new gfn_to_pfn_page functions
  KVM: x86/mmu: use gfn_to_pfn_page
  KVM: arm64/mmu: use gfn_to_pfn_page
  KVM: mmu: remove over-aggressive warnings

Nicholas Piggin (1):
  KVM: do not allow mapping valid but non-refcounted pages

 arch/arm64/kvm/mmu.c            |  26 +++--
 arch/x86/kvm/mmu/mmu.c          |  50 ++++-----
 arch/x86/kvm/mmu/mmu_internal.h |   3 +-
 arch/x86/kvm/mmu/paging_tmpl.h  |  23 +++--
 arch/x86/kvm/mmu/tdp_mmu.c      |   6 +-
 arch/x86/kvm/mmu/tdp_mmu.h      |   4 +-
 arch/x86/kvm/x86.c              |   6 +-
 include/linux/kvm_host.h        |  17 +++
 virt/kvm/kvm_main.c             | 177 +++++++++++++++++++++++++-------
 9 files changed, 222 insertions(+), 90 deletions(-)

-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-25  8:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25  7:36 [PATCH v2 0/5] Remove uses of struct page from x86 and arm64 MMU David Stevens
2021-06-25  7:36 ` [PATCH v2 1/5] KVM: do not allow mapping valid but non-refcounted pages David Stevens
2021-06-25  7:58   ` Christian Borntraeger
2021-06-25  8:07     ` Paolo Bonzini
2021-06-25  7:36 ` [PATCH v2 2/5] KVM: mmu: introduce new gfn_to_pfn_page functions David Stevens
2021-06-25  7:36 ` [PATCH v2 3/5] KVM: x86/mmu: use gfn_to_pfn_page David Stevens
2021-06-25  7:36 ` [PATCH v2 4/5] KVM: arm64/mmu: " David Stevens
2021-06-25  7:36 ` [PATCH v2 5/5] KVM: mmu: remove over-aggressive warnings David Stevens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).