From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Haozhong Zhang <haozhong.zhang@intel.com>
Subject: Re: [PATCH 1/2] KVM: x86: move MSR_IA32_FEATURE_CONTROL handling to x86.c
Date: Fri, 8 Jul 2016 14:59:29 +0200 [thread overview]
Message-ID: <20160708125929.GA10741@potion> (raw)
In-Reply-To: <1467979301-19376-2-git-send-email-pbonzini@redhat.com>
2016-07-08 14:01+0200, Paolo Bonzini:
> Because the MSR is listed in msrs_to_save, it is exported to userspace
> for both AMD and Intel processors. However, on AMD currently getting
> it will fail.
>
> vmx_set_msr must keep the case label in order to handle the "exit
> nested on reset by writing 0" case.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> @@ -3081,18 +3062,18 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> case MSR_IA32_FEATURE_CONTROL:
> - if (!vmx_feature_control_msr_valid(vcpu, data) ||
> - (to_vmx(vcpu)->msr_ia32_feature_control &
> + if (!feature_control_msr_valid(vcpu, data) ||
> + (vcpu->arch.msr_ia32_feature_control &
> FEATURE_CONTROL_LOCKED && !msr_info->host_initiated))
> return 1;
> - vmx->msr_ia32_feature_control = data;
> + vcpu->arch.msr_ia32_feature_control = data;
> if (msr_info->host_initiated && data == 0)
> vmx_leave_nested(vcpu);
> break;
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> @@ -2097,6 +2097,13 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> + case MSR_IA32_FEATURE_CONTROL:
> + if (!feature_control_msr_valid(vcpu, data) ||
> + (vcpu->arch.msr_ia32_feature_control &
> + FEATURE_CONTROL_LOCKED && !msr_info->host_initiated))
> + return 1;
> + vcpu->arch.msr_ia32_feature_control = data;
I'd avoid code duplication. Either with
kvm_x86_ops->msr_ia32_feature_control_write_trap(vcpu);
here, or with (simpler, but slightly harder to untangle)
ret = kvm_set_msr_common(vcpu, msr_info);
in before vmx_leave_nested() in vmx_set_msr().
> + break;
next prev parent reply other threads:[~2016-07-08 12:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-08 12:01 [PATCH 0/2] Small fixes for IA32_FEATURE_CONTROL Paolo Bonzini
2016-07-08 12:01 ` [PATCH 1/2] KVM: x86: move MSR_IA32_FEATURE_CONTROL handling to x86.c Paolo Bonzini
2016-07-08 12:41 ` Haozhong Zhang
2016-07-08 13:24 ` Paolo Bonzini
2016-07-08 12:59 ` Radim Krčmář [this message]
2016-07-08 12:01 ` [PATCH 2/2] KVM: x86: zero MSR_IA32_FEATURE_CONTROL on reset Paolo Bonzini
2016-07-08 12:52 ` 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=20160708125929.GA10741@potion \
--to=rkrcmar@redhat.com \
--cc=haozhong.zhang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/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