kvm: Nested KVM MMUs need PAE root too
authorJiří Paleček <jpalecek@web.de>
Sat, 22 Jun 2019 17:42:04 +0000 (19:42 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 11 Sep 2019 16:02:25 +0000 (18:02 +0200)
commit1cfff4d9a5d01fa61e5768a6afffc81ae1c8ecb9
treead001f9f8d93352135c5ff979ce09cd9db301dbc
parentc8848cee74ff05638e913582a476bde879c968ad
kvm: Nested KVM MMUs need PAE root too

On AMD processors, in PAE 32bit mode, nested KVM instances don't
work. The L0 host get a kernel OOPS, which is related to
arch.mmu->pae_root being NULL.

The reason for this is that when setting up nested KVM instance,
arch.mmu is set to &arch.guest_mmu (while normally, it would be
&arch.root_mmu). However, the initialization and allocation of
pae_root only creates it in root_mmu. KVM code (ie. in
mmu_alloc_shadow_roots) then accesses arch.mmu->pae_root, which is the
unallocated arch.guest_mmu->pae_root.

This fix just allocates (and frees) pae_root in both guest_mmu and
root_mmu (and also lm_root if it was allocated). The allocation is
subject to previous restrictions ie. it won't allocate anything on
64-bit and AFAIK not on Intel.

Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=203923
Fixes: 14c07ad89f4d ("x86/kvm/mmu: introduce guest_mmu")
Signed-off-by: Jiri Palecek <jpalecek@web.de>
Tested-by: Jiri Palecek <jpalecek@web.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c