* [PATCH] KVM: svm: virtualize MSR reads from MC4_MISC1
@ 2014-06-26 12:22 Matthias Lange
2014-06-26 12:22 ` Matthias Lange
0 siblings, 1 reply; 5+ messages in thread
From: Matthias Lange @ 2014-06-26 12:22 UTC (permalink / raw)
To: kvm
When running Linux as a guest with KVM on an AMD CPU, the guest Linux kernel
tries to read the MC4_MISC1 MSR from its MCE code. Because this MSR is not
virtualized within KVM a GPE is injected into the guest. This patch adds
support to virtualize the MC4_MSR.
Matthias Lange (1):
KVM: svm: virtualize MSR reads from MC4_MISC1
arch/x86/kvm/x86.c | 3 +++
1 file changed, 3 insertions(+)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] KVM: svm: virtualize MSR reads from MC4_MISC1
2014-06-26 12:22 [PATCH] KVM: svm: virtualize MSR reads from MC4_MISC1 Matthias Lange
@ 2014-06-26 12:22 ` Matthias Lange
2014-07-09 16:26 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: Matthias Lange @ 2014-06-26 12:22 UTC (permalink / raw)
To: kvm
Linux' AMD MCE code tries to read from the MC4_MISC1 (0xc0000408) MSR. Because
this read is not virtualized within KVM, a GPE is injected into the guest.
This patch handles guest reads from MC4_MISC and returns 0 to the guest.
Signed-off-by: Matthias Lange <matthias.lange@kernkonzept.com>
---
arch/x86/kvm/x86.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 24d70d4..d5a305b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2530,6 +2530,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
return 1;
data = vcpu->arch.osvw.status;
break;
+ case 0xc0000408: /* MC4_MISC1 */
+ data = 0;
+ break;
default:
if (kvm_pmu_msr(vcpu, msr))
return kvm_pmu_get_msr(vcpu, msr, pdata);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: svm: virtualize MSR reads from MC4_MISC1
2014-06-26 12:22 ` Matthias Lange
@ 2014-07-09 16:26 ` Paolo Bonzini
2014-07-10 9:31 ` Matthias Lange
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2014-07-09 16:26 UTC (permalink / raw)
To: Matthias Lange, kvm, Gleb Natapov
Il 26/06/2014 14:22, Matthias Lange ha scritto:
> Linux' AMD MCE code tries to read from the MC4_MISC1 (0xc0000408) MSR. Because
> this read is not virtualized within KVM, a GPE is injected into the guest.
> This patch handles guest reads from MC4_MISC and returns 0 to the guest.
>
> Signed-off-by: Matthias Lange <matthias.lange@kernkonzept.com>
> ---
> arch/x86/kvm/x86.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 24d70d4..d5a305b 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2530,6 +2530,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
> return 1;
> data = vcpu->arch.osvw.status;
> break;
> + case 0xc0000408: /* MC4_MISC1 */
> + data = 0;
> + break;
> default:
> if (kvm_pmu_msr(vcpu, msr))
> return kvm_pmu_get_msr(vcpu, msr, pdata);
>
Why don't you have to do the same with MC4_MISC0?
Is your kernel compiled with or without CONFIG_PARAVIRT? Paravirt does
.read_msr = native_read_msr_safe,
.write_msr = native_write_msr_safe,
so you shouldn't get these #GP exceptions.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: svm: virtualize MSR reads from MC4_MISC1
2014-07-09 16:26 ` Paolo Bonzini
@ 2014-07-10 9:31 ` Matthias Lange
2014-07-11 7:14 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: Matthias Lange @ 2014-07-10 9:31 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, Gleb Natapov
On Wed, Jul 09, 2014 at 06:26:23PM +0200, Paolo Bonzini wrote:
> Il 26/06/2014 14:22, Matthias Lange ha scritto:
> >Linux' AMD MCE code tries to read from the MC4_MISC1 (0xc0000408) MSR. Because
> >this read is not virtualized within KVM, a GPE is injected into the guest.
> >This patch handles guest reads from MC4_MISC and returns 0 to the guest.
> >
> >Signed-off-by: Matthias Lange <matthias.lange@kernkonzept.com>
> >---
> > arch/x86/kvm/x86.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> >diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> >index 24d70d4..d5a305b 100644
> >--- a/arch/x86/kvm/x86.c
> >+++ b/arch/x86/kvm/x86.c
> >@@ -2530,6 +2530,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
> > return 1;
> > data = vcpu->arch.osvw.status;
> > break;
> >+ case 0xc0000408: /* MC4_MISC1 */
> >+ data = 0;
> >+ break;
> > default:
> > if (kvm_pmu_msr(vcpu, msr))
> > return kvm_pmu_get_msr(vcpu, msr, pdata);
> >
>
> Why don't you have to do the same with MC4_MISC0?
MC4_MISC0 (0x413) is handled in kvm_get_msr_common by this statement
case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1:
return get_msr_mce(vcpu, msr, pdata);
and get_msr_mce returns a sane value from the vcpu mce_banks.
> Is your kernel compiled with or without CONFIG_PARAVIRT? Paravirt does
>
> .read_msr = native_read_msr_safe,
> .write_msr = native_write_msr_safe,
>
> so you shouldn't get these #GP exceptions.
I used the default i386_defconfig to build the guest kernel. CONFIG_PARAVIRT
is disabled in this setup.
Matthias.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: svm: virtualize MSR reads from MC4_MISC1
2014-07-10 9:31 ` Matthias Lange
@ 2014-07-11 7:14 ` Paolo Bonzini
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2014-07-11 7:14 UTC (permalink / raw)
To: kvm, Gleb Natapov
Il 10/07/2014 11:31, Matthias Lange ha scritto:
> MC4_MISC0 (0x413) is handled in kvm_get_msr_common by this statement
>
> case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1:
> return get_msr_mce(vcpu, msr, pdata);
>
> and get_msr_mce returns a sane value from the vcpu mce_banks.
>
Can you please add the MSR name to a .h file instead, and handle it in
get_msr_mce?
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-07-11 7:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-26 12:22 [PATCH] KVM: svm: virtualize MSR reads from MC4_MISC1 Matthias Lange
2014-06-26 12:22 ` Matthias Lange
2014-07-09 16:26 ` Paolo Bonzini
2014-07-10 9:31 ` Matthias Lange
2014-07-11 7:14 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox