public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Borislav Petkov <bp@alien8.de>, LKML <linux-kernel@vger.kernel.org>
Cc: X86 ML <x86@kernel.org>, KVM <kvm@vger.kernel.org>
Subject: Re: [RFC PATCH 3/3] x86/cpu/amd, kvm: Satisfy guest kernel reads of IC_CFG MSR
Date: Wed, 18 Nov 2015 12:11:18 +0100	[thread overview]
Message-ID: <564C5CD6.5060309@redhat.com> (raw)
In-Reply-To: <1447497436-26424-4-git-send-email-bp@alien8.de>



On 14/11/2015 11:37, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> The kernel accesses IC_CFG MSR (0xc0011021) on AMD because it checks
> whether the way access filter is enabled on some F15h models, and, if
> so, disables it.
> 
> kvm doesn't handle that MSR access and complains about it, which can
> get really noisy in dmesg when one starts kvm guests all the time for
> testing. And it is useless anyway - guest kernel shouldn't be doing such
> changes anyway so tell it that that filter is disabled.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/include/asm/msr-index.h |  1 +
>  arch/x86/kernel/cpu/amd.c        |  4 ++--
>  arch/x86/kvm/svm.c               | 17 +++++++++++++++++
>  3 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
> index 9f3905697f12..5384485f8569 100644
> --- a/arch/x86/include/asm/msr-index.h
> +++ b/arch/x86/include/asm/msr-index.h
> @@ -322,6 +322,7 @@
>  #define MSR_F15H_PERF_CTR		0xc0010201
>  #define MSR_F15H_NB_PERF_CTL		0xc0010240
>  #define MSR_F15H_NB_PERF_CTR		0xc0010241
> +#define MSR_F15H_IC_CFG			0xc0011021
>  
>  /* Fam 10h MSRs */
>  #define MSR_FAM10H_MMIO_CONF_BASE	0xc0010058
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index 4a70fc6d400a..1d76dcdf7e55 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -665,9 +665,9 @@ static void init_amd_bd(struct cpuinfo_x86 *c)
>  	 * Disable it on the affected CPUs.
>  	 */
>  	if ((c->x86_model >= 0x02) && (c->x86_model < 0x20)) {
> -		if (!rdmsrl_safe(0xc0011021, &value) && !(value & 0x1E)) {
> +		if (!rdmsrl_safe(MSR_F15H_IC_CFG, &value) && !(value & 0x1E)) {
>  			value |= 0x1E;
> -			wrmsrl_safe(0xc0011021, value);
> +			wrmsrl_safe(MSR_F15H_IC_CFG, value);
>  		}
>  	}
>  }
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 83a1c643f9a5..58b64c17c4a8 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -3053,6 +3053,23 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  	case MSR_IA32_UCODE_REV:
>  		msr_info->data = 0x01000065;
>  		break;
> +	case MSR_F15H_IC_CFG: {
> +
> +		int family, model;
> +
> +		family = guest_cpuid_family(vcpu);
> +		model  = guest_cpuid_model(vcpu);
> +
> +		if (family < 0 || model < 0)
> +			return kvm_get_msr_common(vcpu, msr_info);
> +
> +		msr_info->data = 0;
> +
> +		if (family == 0x15 &&
> +		    (model >= 0x2 && model < 0x20))
> +			msr_info->data = 0x1E;
> +		}
> +		break;
>  	default:
>  		return kvm_get_msr_common(vcpu, msr_info);
>  	}
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

      reply	other threads:[~2015-11-18 11:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-14 10:37 [RFC PATCH 0/3] x86, kvm: Unify CPUID computation and fix MSR accessing Borislav Petkov
2015-11-14 10:37 ` [RFC PATCH 1/3] x86/cpu: Unify CPU family, model, stepping calculation Borislav Petkov
2015-11-18 11:10   ` Paolo Bonzini
2015-11-18 11:28     ` Borislav Petkov
2015-11-18 11:35       ` Paolo Bonzini
2015-11-18 18:50         ` Borislav Petkov
2015-11-19  9:34           ` Paolo Bonzini
2015-11-19  9:47             ` Borislav Petkov
2015-11-14 10:37 ` [RFC PATCH 2/3] kvm: Add accessors for guest CPU's family, model, stepping Borislav Petkov
2015-11-18 11:10   ` Paolo Bonzini
2015-11-14 10:37 ` [RFC PATCH 3/3] x86/cpu/amd, kvm: Satisfy guest kernel reads of IC_CFG MSR Borislav Petkov
2015-11-18 11:11   ` Paolo Bonzini [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=564C5CD6.5060309@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@alien8.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox