On Fri, Aug 05, 2022, Sean Christopherson wrote: > WARN and kill the VM if KVM attempts to double count an NX huge page, > i.e. attempts to re-tag a shadow page with "NX huge page disallowed". > KVM does NX huge page accounting only when linking a new shadow page, and > it should be impossible for a new shadow page to be already accounted. > E.g. even in the TDP MMU case, where vCPUs can race to install a new > shadow page, only the "winner" will account the installed page. > > Kill the VM instead of continuing on as either KVM has an egregious bug, > e.g. didn't zero-initialize the data, or there's host data corruption, in > which carrying on is dangerous, e.g. could cause silent data corruption > in the guest. > > Reported-by: David Matlack <dmatlack@xxxxxxxxxx> > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> Reviewed-by: Mingwei Zhang <mizhang@xxxxxxxxxx> > --- > arch/x86/kvm/mmu/mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 3e1317325e1f..36b898dbde91 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -804,7 +804,7 @@ static void account_shadowed(struct kvm *kvm, struct kvm_mmu_page *sp) > > void account_huge_nx_page(struct kvm *kvm, struct kvm_mmu_page *sp) > { > - if (sp->lpage_disallowed) > + if (KVM_BUG_ON(sp->lpage_disallowed, kvm)) > return; > > ++kvm->stat.nx_lpage_splits; > -- > 2.37.1.559.g78731f0fdb-goog >