From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Haozhong Zhang <haozhong.zhang@intel.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Gleb Natapov <gleb@kernel.org>, Boris Petkov <bp@suse.de>,
Tony Luck <tony.luck@intel.com>, Ashok Raj <ashok.raj@intel.com>,
Andi Kleen <andi.kleen@intel.com>
Subject: Re: [PATCH v1] KVM: VMX: enable guest access to LMCE related MSRs
Date: Fri, 3 Jun 2016 17:34:33 +0200 [thread overview]
Message-ID: <20160603153433.GA20152@potion> (raw)
In-Reply-To: <20160603060851.17018-2-haozhong.zhang@intel.com>
2016-06-03 14:08+0800, Haozhong Zhang:
> On Intel platforms, this patch adds LMCE to KVM MCE supported
> capabilities and handles guest access to LMCE related MSRs.
>
> Signed-off-by: Ashok Raj <ashok.raj@intel.com>
> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
> ---
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> @@ -2863,6 +2863,11 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
> return 0;
> }
>
> +static inline bool vmx_feature_control_msr_required(struct kvm_vcpu *vcpu)
I'd call it "present", rather than "required". SDM does so for other
MSRs and it is easier to understand in the condition that returns #GP if
this function is false.
> +{
> + return nested_vmx_allowed(vcpu) || (vcpu->arch.mcg_cap & MCG_LMCE_P);
> +}
> @@ -2904,8 +2909,15 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> case MSR_IA32_FEATURE_CONTROL:
> - if (!nested_vmx_allowed(vcpu))
> + if (!vmx_feature_control_msr_required(vcpu))
> return 1;
> msr_info->data = to_vmx(vcpu)->nested.msr_ia32_feature_control;
(MSR_IA32_FEATURE_CONTROL does not depend only on nested anymore, so
moving msr_ia32_feature_control from struct nested_vmx to struct
vcpu_vmx would make sense.)
> break;
> @@ -2997,8 +3009,17 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> + case MSR_IA32_MCG_EXT_CTL:
> + if (!(vcpu->arch.mcg_cap & MCG_LMCE_P) ||
> + !(to_vmx(vcpu)->nested.msr_ia32_feature_control &
> + FEATURE_CONTROL_LMCE))
(This check is used twice and could be given a name too,
"vmx_mcg_ext_ctl_msr_present()"?)
> + return 1;
> + if (data && data != 0x1)
(data & ~MCG_EXT_CTL_LMCE_EN)
is a clearer check for reserved bits.
> + return -1;
> + vcpu->arch.mcg_ext_ctl = data;
> + break;
> case MSR_IA32_FEATURE_CONTROL:
> - if (!nested_vmx_allowed(vcpu) ||
> + if (!vmx_feature_control_msr_required(vcpu) ||
> (to_vmx(vcpu)->nested.msr_ia32_feature_control &
> FEATURE_CONTROL_LOCKED && !msr_info->host_initiated))
> return 1;
Does hardware throw #GP when FEATURE_CONTROL_LMCE is set without
MCG_LMCE_P?
(We could emulate that by having a mask of valid bits and also use that
mask in place of vmx_feature_control_msr_required(). I don't think
there is a reason to have only vmx_feature_control_msr_required() if
the hardware can #GP on individual bits too.)
Thanks.
next prev parent reply other threads:[~2016-06-03 15:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 6:08 [PATCH v1] Add KVM support for Intel local MCE Haozhong Zhang
2016-06-03 6:08 ` [PATCH v1] KVM: VMX: enable guest access to LMCE related MSRs Haozhong Zhang
2016-06-03 15:34 ` Radim Krčmář [this message]
2016-06-05 15:09 ` Haozhong Zhang
2016-06-04 11:01 ` Boris Petkov
2016-06-05 15:14 ` Haozhong Zhang
2016-06-05 19:43 ` Borislav Petkov
2016-06-06 0:12 ` Haozhong Zhang
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=20160603153433.GA20152@potion \
--to=rkrcmar@redhat.com \
--cc=andi.kleen@intel.com \
--cc=ashok.raj@intel.com \
--cc=bp@suse.de \
--cc=gleb@kernel.org \
--cc=haozhong.zhang@intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.