From: Bandan Das <bsd@redhat.com>
To: Ben Serebrin <serebrin@google.com>
Cc: kvm@vger.kernel.org, stable@vger.kernel.org, luto@amacapital.net,
pbonzini@redhat.com, jan.kiszka@siemens.com
Subject: Re: [PATCH] vt-x: Preserve host CR4.MCE value while in guest mode.
Date: Thu, 16 Apr 2015 14:44:54 -0400 [thread overview]
Message-ID: <jpgfv7zgbfd.fsf@redhat.com> (raw)
In-Reply-To: <1429208106-11759-1-git-send-email-serebrin@google.com> (Ben Serebrin's message of "Thu, 16 Apr 2015 11:15:06 -0700")
Ben Serebrin <serebrin@google.com> writes:
I suggest changing the subject to
KVM: VMX: Preserve host CR4.MCE value while in guest mode
That keeps it consistent with the $SUBJECT naming convention KVM
follows.
If Paolo is ok with changing it in his tree directly, that's fine too.
Bandan
> The host's decision to enable machine check exceptions should remain
> in force during non-root mode. KVM was writing 0 to cr4 on VCPU reset
> and passed a slightly-modified 0 to the vmcs.guest_cr4 value.
>
> Tested: Built.
> On earlier version, tested by injecting machine check
> while a guest is spinning.
>
> Before the change, if guest CR4.MCE==0, then the machine check is
> escalated to Catastrophic Error (CATERR) and the machine dies.
> If guest CR4.MCE==1, then the machine check causes VMEXIT and is
> handled normally by host Linux. After the change, injecting a machine
> check causes normal Linux machine check handling.
>
> Signed-off-by: Ben Serebrin <serebrin@google.com>
> ---
> arch/x86/kvm/vmx.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index f5e8dce..f7b6168 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3622,8 +3622,16 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
>
> static int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
> {
> - unsigned long hw_cr4 = cr4 | (to_vmx(vcpu)->rmode.vm86_active ?
> - KVM_RMODE_VM_CR4_ALWAYS_ON : KVM_PMODE_VM_CR4_ALWAYS_ON);
> + /*
> + * Pass through host's Machine Check Enable value to hw_cr4, which
> + * is in force while we are in guest mode. Do not let guests control
> + * this bit, even if host CR4.MCE == 0.
> + */
> + unsigned long hw_cr4 =
> + (cr4_read_shadow() & X86_CR4_MCE) |
> + (cr4 & ~X86_CR4_MCE) |
> + (to_vmx(vcpu)->rmode.vm86_active ?
> + KVM_RMODE_VM_CR4_ALWAYS_ON : KVM_PMODE_VM_CR4_ALWAYS_ON);
>
> if (cr4 & X86_CR4_VMXE) {
> /*
prev parent reply other threads:[~2015-04-16 18:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 16:41 [PATCH] vt-x: Preserve host CR4.MCE value while in guest mode Benjamin Serebrin
2015-04-16 17:00 ` Jan Kiszka
2015-04-16 18:15 ` Ben Serebrin
2015-04-16 18:44 ` Bandan Das [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=jpgfv7zgbfd.fsf@redhat.com \
--to=bsd@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=pbonzini@redhat.com \
--cc=serebrin@google.com \
--cc=stable@vger.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