linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Babu Moger <babu.moger@amd.com>
Cc: wanpengli@tencent.com, kvm@vger.kernel.org, seanjc@google.com,
	joro@8bytes.org, x86@kernel.org, linux-kernel@vger.kernel.org,
	mingo@redhat.com, bp@alien8.de, hpa@zytor.com,
	vkuznets@redhat.com, tglx@linutronix.de, jmattson@google.com
Subject: Re: [PATCH] KVM: SVM: Clear the CR4 register on reset
Date: Tue, 2 Mar 2021 20:39:28 +0100	[thread overview]
Message-ID: <454cb7d4-9f50-42e1-6908-d659491ba140@redhat.com> (raw)
In-Reply-To: <161471109108.30811.6392805173629704166.stgit@bmoger-ubuntu>

On 02/03/21 19:51, Babu Moger wrote:
> 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@amd.com>
> ---
>   arch/x86/kvm/svm/svm.c |    1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index c636021b066b..baee91c1e936 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -1200,6 +1200,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, X86_EFLAGS_FIXED);
> 

Queued, thanks.

Paolo


      parent reply	other threads:[~2021-03-02 22:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 18:51 [PATCH] KVM: SVM: Clear the CR4 register on reset Babu Moger
2021-03-02 19:20 ` Sean Christopherson
2021-03-02 19:29   ` Babu Moger
2021-03-02 19:39 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=454cb7d4-9f50-42e1-6908-d659491ba140@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).