[Devel] (no subject)

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 20 15:26:31 MSK 2022


<161471109108.30811.6392805173629704166.stgit at bmoger-ubuntu>
Subject: [PATCH RHEL7 COMMIT] ms/KVM: SVM: Clear the CR4 register on reset

The commit is pushed to "branch-rh7-3.10.0-1160.62.1.vz7.187.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.62.1.vz7.187.4
------>
commit 850dd056ef60b7cf2ebace62e28fde4d0831a2f8
Author: Babu Moger <babu.moger at amd.com>
Date:   Mon Jun 20 11:33:07 2022 +0300

    ms/KVM: SVM: Clear the CR4 register on reset
    
    This problem was reported on a SVM guest while executing kexec.
    Kexec fails to load the new kernel when the PCID feature is enabled.
    
    When kexec starts loading the new kernel, it starts the process by
    resetting the vCPU's and then bringing each vCPU online one by one.
    The vCPU reset is supposed to reset all the register states before the
    vCPUs are brought online. However, the CR4 register is not reset during
    this process. If this register is already setup during the last boot,
    all the flags can remain intact. The X86_CR4_PCIDE bit can only be
    enabled in long mode. So, it must be enabled much later in SMP
    initialization.  Having the X86_CR4_PCIDE bit set during SMP boot can
    cause a boot failures.
    
    Fix the issue by resetting the CR4 register in init_vmcb().
    
    Signed-off-by: Babu Moger <babu.moger at amd.com>
    Message-Id: <161471109108.30811.6392805173629704166.stgit at bmoger-ubuntu>
    Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
    (cherry-picked from ms commit 9e46f6c6c959d9bb45445c2e8f04a75324a0dfd0)
    
    Fixes https://jira.sw.ru/browse/PSBM-139465
    Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
    
    khorenko@ note: we also noticed another sympthom of this issue:
    CPU hotplug in a VM running on a vz7 Node gets rebooted.
---
 arch/x86/kvm/svm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 01192c742eb4..65746fc5d8af 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -345,6 +345,7 @@ static DECLARE_BITMAP(avic_vm_id_bitmap, AVIC_VM_ID_NR);
 static DEFINE_SPINLOCK(avic_vm_id_lock);
 
 static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);
+static int svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4);
 static void svm_flush_tlb(struct kvm_vcpu *vcpu);
 static void svm_complete_interrupts(struct vcpu_svm *svm);
 
@@ -1451,6 +1452,7 @@ static void init_vmcb(struct vcpu_svm *svm)
 	init_sys_seg(&save->ldtr, SEG_TYPE_LDT);
 	init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16);
 
+	svm_set_cr4(&svm->vcpu, 0);
 	svm_set_efer(&svm->vcpu, 0);
 	save->dr6 = 0xffff0ff0;
 	kvm_set_rflags(&svm->vcpu, 2);


More information about the Devel mailing list