linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] Verify dirty logging works properly with page stats
@ 2022-04-01  6:36 Mingwei Zhang
  2022-04-01  6:36 ` [PATCH v3 1/6] KVM: x86/mmu: Set lpage_disallowed in TDP MMU before setting SPTE Mingwei Zhang
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Mingwei Zhang @ 2022-04-01  6:36 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, kvm, linux-kernel, Mingwei Zhang, Yosry Ahmed,
	Ben Gardon, David Matlack, Jing Zhang, Peter Xu

This patch set aims to fix a bug in which KVM incorrectly assumes a large
page as a NX huge page. The bug would prevent guest VM from regaining large
pages and cause performance issue. We fix the bug by explicitly checking
the lpage_disallowed field in the shadow page.  Moreover, to fix the bug
properly for TDP MMU, we integrate two patches from Sean that ensures that
we update lpage_disallowed in shadow page before making spte visible to
guest.

To verify the bug fixed, we use dirty logging as the testing target and
dirty_log_perf_test as the selftest binary. By adding the code to check the
page stats from the per-VM interface, we discovered that VMs could regain
large pages after dirty logging disabled. We also verify the existence of
the bug if running with unpatched kernels.

To make the selftest working properly with per-VM stats interface, we
borrowes two patches come from Ben's series: "[PATCH 00/13] KVM: x86: Add a
cap to disable NX hugepages on a VM" [1].

[1] https://lore.kernel.org/all/20220310164532.1821490-2-bgardon@google.com/T/


v2 -> v3:
 - Update lpage_disallowed before making spte visible [seanjc].
 - Adding tdp_mmu_pages stats [seanjc]
 - update comments in selftest [bgardon]

v2: https://lore.kernel.org/lkml/20220323184915.1335049-1-mizhang@google.com/T/

v1 -> v2:
 - Update the commit message. [dmatlack]
 - Update the comments in patch 3/4 to clarify the motivation. [bgardon]
 - Add another iteration in dirty_log_perf_test to regain pages [bgardon]


Ben Gardon (2):
  KVM: selftests: Dump VM stats in binary stats test
  KVM: selftests: Test reading a single stat

Mingwei Zhang (2):
  KVM: x86/mmu: explicitly check nx_hugepage in
    disallowed_hugepage_adjust()
  selftests: KVM: use page stats to check if dirty logging works
    properly

Sean Christopherson (2):
  KVM: x86/mmu: Set lpage_disallowed in TDP MMU before setting SPTE
  KVM: x86/mmu: Track the number of TDP MMU pages, but not the actual
    pages

 arch/x86/include/asm/kvm_host.h               |  11 +-
 arch/x86/kvm/mmu/mmu.c                        |  28 ++-
 arch/x86/kvm/mmu/mmu_internal.h               |   2 +-
 arch/x86/kvm/mmu/tdp_mmu.c                    |  36 ++--
 .../selftests/kvm/dirty_log_perf_test.c       |  53 +++++
 .../selftests/kvm/include/kvm_util_base.h     |   2 +
 .../selftests/kvm/kvm_binary_stats_test.c     |   6 +
 tools/testing/selftests/kvm/lib/kvm_util.c    | 196 ++++++++++++++++++
 8 files changed, 303 insertions(+), 31 deletions(-)

-- 
2.35.1.1094.g7c7d902a7c-goog


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

end of thread, other threads:[~2022-04-04 21:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-01  6:36 [PATCH v3 0/6] Verify dirty logging works properly with page stats Mingwei Zhang
2022-04-01  6:36 ` [PATCH v3 1/6] KVM: x86/mmu: Set lpage_disallowed in TDP MMU before setting SPTE Mingwei Zhang
2022-04-04 17:58   ` Ben Gardon
2022-04-04 18:19     ` Sean Christopherson
2022-04-04 18:54       ` Ben Gardon
2022-04-01  6:36 ` [PATCH v3 2/6] KVM: x86/mmu: Track the number of TDP MMU pages, but not the actual pages Mingwei Zhang
2022-04-01 14:22   ` Sean Christopherson
2022-04-01  6:36 ` [PATCH v3 3/6] KVM: x86/mmu: explicitly check nx_hugepage in disallowed_hugepage_adjust() Mingwei Zhang
2022-04-01 14:33   ` Sean Christopherson
2022-04-01  6:36 ` [PATCH v3 4/6] KVM: selftests: Dump VM stats in binary stats test Mingwei Zhang
2022-04-01  6:36 ` [PATCH v3 5/6] KVM: selftests: Test reading a single stat Mingwei Zhang
2022-04-01  6:36 ` [PATCH v3 6/6] selftests: KVM: use page stats to check if dirty logging works properly Mingwei Zhang

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).