Re: [PATCH 05/12] KVM: MMU: avoid NULL-pointer dereference on page freeing bugs

From: Paolo Bonzini
Date: Fri Feb 11 2022 - 06:21:25 EST


On 2/11/22 01:24, Sean Christopherson wrote:
sp = to_shadow_page(*root_hpa & PT64_BASE_ADDR_MASK);
+ if (WARN_ON(!sp))

Should this be KVM_BUG_ON()? I.e. when you triggered these, would continuing on
potentially corrupt guest data, or was it truly benign-ish?

It only triggered on the mode_switch SVM unit test (with npt=0); so, in a very small test which just hung after the bug. The WARN however was the 10-minute difference between rmmod and reboot...

I didn't use KVM_BUG_ON because we're in a pretty deep call stack (kvm_mmu_new_pgd, itself called from nested vmentry) and all sort of stuff will happen before bailing out. My mental model is to use KVM_BUG_ON in situations for which error propagation is possible and clean.

Paolo