Re: [PATCH] Add MCE support to KVM

From: Huang Ying
Date: Sun Apr 12 2009 - 22:41:55 EST


On Sat, 2009-04-11 at 20:04 +0800, Avi Kivity wrote:
> >> Why not always allocate it on vcpu setup?
> >>
> >
> > Because the MCE bank number is not fixed, it is based on mcg_cap from
> > user space.
> >
>
> Right, but we can allocate the maximum number, no? it's a fairly small
> amount of memory.

OK. If you are OK with 8k extra memory usage.

> >
> >>> + case KVM_X86_SETUP_MCE: {
> >>> + u64 mcg_cap;
> >>> +
> >>> + r = -EFAULT;
> >>> + if (copy_from_user(&mcg_cap, argp, sizeof mcg_cap))
> >>> + goto out;
> >>> + /*
> >>> + * extended machine-check state registers and CMCI are
> >>> + * not supported.
> >>> + */
> >>> + mcg_cap &= ~(MCG_EXT_P|MCG_CMCI_P);
> >>>
> >>>
> >> Instead of silently dropping, should return an error.
> >>
> >>
> >>> + if (copy_to_user(argp, &mcg_cap, sizeof mcg_cap))
> >>> + goto out;
> >>>
> >>>
> >> And not copy.
> >>
> >
> > This is designed as some kind of feature negotiating. Use space request
> > MCE features via mcg_cap, kernel space remove un-supported features and
> > return the resulting mcg_cap.
> >
>
> kvm does feature negotiation (really, feature advertising) using
> KVM_CAP_... and KVM_CHECK_EXTENSION. So there's no need for this.

It is not only feature advertising, but also something like CPUID. Based
on CPU type specified in command line (qemu -cpu ?), different mcg_cap
can be used to determine number of MCE banks and various features of MCE
(MCG_CTL_P, MCG_TES_P, MCG_CMCI, etc) for specified CPU type. With KVM
feature advertising, we can only check whether MCE simulation is
supported, but can not set parameters of MCE simulation.

Maybe this interface can be changed to KVM_SET_MSRS, with
MSR_IA32_MCG_CAP be set by kvm-qemu. But MSR_IA32_MCG_CAP is read-only
by spec, and current interface can not distinguishes between MSR set
from guest system and MSR setup from kvm-qemu. I think there should be
other read-only MSRs need to be setup during guest system
creation/setup. How about add a interface such as KVM_SETUP_MSRS to
setup the value of read-only MSRs?

Best Regards,
Huang Ying

Attachment: signature.asc
Description: This is a digitally signed message part