KVM: x86: Reject loading KVM if host.PAT[0] != WB
authorSean Christopherson <seanjc@google.com>
Fri, 15 Jul 2022 23:00:13 +0000 (23:00 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 28 Jul 2022 17:22:20 +0000 (13:22 -0400)
commit94bda2f4cd868046094351b06b87d7d1053e990d
tree589bc00c4153f613d418ef544661f09b05fffbc4
parent01e69cef63f88d809181f62f03a01d7295f2d5a4
KVM: x86: Reject loading KVM if host.PAT[0] != WB

Reject KVM if entry '0' in the host's IA32_PAT MSR is not programmed to
writeback (WB) memtype.  KVM subtly relies on IA32_PAT entry '0' to be
programmed to WB by leaving the PAT bits in shadow paging and NPT SPTEs
as '0'.  If something other than WB is in PAT[0], at _best_ guests will
suffer very poor performance, and at worst KVM will crash the system by
breaking cache-coherency expecations (e.g. using WC for guest memory).

Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20220715230016.3762909-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c