From 76838c25d5037eb6a1ddfeaaee78aee67f4cd759 Mon Sep 17 00:00:00 2001 From: Yu Zhang Date: Wed, 27 Dec 2023 15:21:17 +0800 Subject: [PATCH] KVM: x86/mmu: Allocate pml4_root for guest PAE mode shadowing Intel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I8UBIZ CVE: NA ---------------------------------------------------------------------- Add the missing allocation for pml4_root. Current mmu_alloc_special_roots() is broken, when - L0 host is an AMD CPU, running in 64-bit mode && - L1 VMM is running in 32-bit/PAE mode && - L1 VMM is trying to create L2 guest using NPT. The error is caused by a mistake when trying to solve the conflict, to backport the upstreaming commit 748e52b9b736 ("KVM: x86/mmu: Allocate pae_root and lm_root pages in dedicated helper"). Fix it by adding the missing allocation of pml4_root. Note: this error shall NOT affect any Intel platform, because an Intel host does not need any special root: - when EPT is disabled/un-supported, 64-bit host will use PAE shadow page table for 32-bit guest; - when EPT is enabled, its level is either 4-level or 5-level, regardless of the guest/host paging mode, no need to allocate any special root either. Fixes: cd414417fdf6 ("KVM: x86/mmu: Allocate pae_root and lm_root pages in dedicated helper") Signed-off-by: Yu Zhang --- arch/x86/kvm/mmu/mmu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 891dc122b69d..37c07278d488 100755 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3464,6 +3464,7 @@ static int mmu_alloc_special_roots(struct kvm_vcpu *vcpu) return -ENOMEM; #ifdef CONFIG_X86_64 + pml4_root = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT); if (!pml4_root) goto err_pml4; -- Gitee