When L1 activates VMCS shadowing for L2, associate an L0 shadow VMCS with vmcs02. It's not yet linked to vmcs02, since we don't have the appropriate VMREAD and VMWRITE bitmaps for it. Signed-off-by: Liran Alon <liran.alon@xxxxxxxxxx> Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx> --- arch/x86/kvm/vmx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index db9bb24ffc23..99576c2fa65a 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4441,7 +4441,10 @@ static void free_loaded_vmcs(struct loaded_vmcs *loaded_vmcs) loaded_vmcs->vmcs = NULL; if (loaded_vmcs->msr_bitmap) free_page((unsigned long)loaded_vmcs->msr_bitmap); - WARN_ON(loaded_vmcs->shadow_vmcs != NULL); + if (loaded_vmcs->shadow_vmcs) { + free_vmcs(loaded_vmcs->shadow_vmcs); + loaded_vmcs->shadow_vmcs = NULL; + } } static struct vmcs *alloc_vmcs(bool shadow) @@ -11354,6 +11357,11 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) if (nested_cpu_has_xsaves(vmcs12)) vmcs_write64(XSS_EXIT_BITMAP, vmcs12->xss_exit_bitmap); + + if (nested_cpu_has2(vmcs12, SECONDARY_EXEC_SHADOW_VMCS) && + enable_shadow_vmcs && alloc_shadow_vmcs(vcpu)) { + /* TODO: IMPLEMENT */ + } vmcs_write64(VMCS_LINK_POINTER, -1ull); if (cpu_has_vmx_posted_intr()) -- 1.9.1