KVM: Explicitly disallow activatating a gfn_to_pfn_cache with INVALID_GPA
authorSean Christopherson <seanjc@google.com>
Wed, 20 Mar 2024 00:15:42 +0000 (17:15 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 8 Apr 2024 20:20:24 +0000 (13:20 -0700)
commitfc62a4e8dee2d1a9037e8cdeaa52ba67457f7300
tree765d6ba61f0775c3953518d4bd1257a6182a2912
parent5c9ca4ed890889a2b7c300c4f63f3baf3f63383f
KVM: Explicitly disallow activatating a gfn_to_pfn_cache with INVALID_GPA

Explicit disallow activating a gfn_to_pfn_cache with an error gpa, i.e.
INVALID_GPA, to ensure that KVM doesn't mistake a GPA-based cache for an
HVA-based cache (KVM uses INVALID_GPA as a magic value to differentiate
between GPA-based and HVA-based caches).

WARN if KVM attempts to activate a cache with INVALID_GPA, purely so that
new caches need to at least consider what to do with a "bad" GPA, as all
existing usage of kvm_gpc_activate() guarantees gpa != INVALID_GPA.  I.e.
removing the WARN in the future is completely reasonable if doing so would
yield cleaner/better code overall.

Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
Link: https://lore.kernel.org/r/20240320001542.3203871-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
virt/kvm/pfncache.c