From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753818AbbKXJeP (ORCPT ); Tue, 24 Nov 2015 04:34:15 -0500 Received: from terminus.zytor.com ([198.137.202.10]:55329 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753786AbbKXJeK (ORCPT ); Tue, 24 Nov 2015 04:34:10 -0500 Date: Tue, 24 Nov 2015 01:33:11 -0800 From: tip-bot for Borislav Petkov Message-ID: Cc: luto@amacapital.net, linux-kernel@vger.kernel.org, pbonzini@redhat.com, bp@suse.de, peterz@infradead.org, brgerst@gmail.com, mingo@kernel.org, tglx@linutronix.de, dvlasenk@redhat.com, hpa@zytor.com, torvalds@linux-foundation.org, bp@alien8.de Reply-To: luto@amacapital.net, linux-kernel@vger.kernel.org, bp@suse.de, pbonzini@redhat.com, peterz@infradead.org, dvlasenk@redhat.com, brgerst@gmail.com, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, bp@alien8.de, torvalds@linux-foundation.org In-Reply-To: <1448273546-2567-4-git-send-email-bp@alien8.de> References: <1448273546-2567-4-git-send-email-bp@alien8.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] x86/cpu/amd, kvm: Satisfy guest kernel reads of IC_CFG MSR Git-Commit-ID: ae8b787543d872cf89a7f9ef8aa302f3ef9bcbd7 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ae8b787543d872cf89a7f9ef8aa302f3ef9bcbd7 Gitweb: http://git.kernel.org/tip/ae8b787543d872cf89a7f9ef8aa302f3ef9bcbd7 Author: Borislav Petkov AuthorDate: Mon, 23 Nov 2015 11:12:23 +0100 Committer: Ingo Molnar CommitDate: Tue, 24 Nov 2015 09:15:54 +0100 x86/cpu/amd, kvm: Satisfy guest kernel reads of IC_CFG MSR 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 Reviewed-by: Paolo Bonzini Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1448273546-2567-4-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar --- 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 690b402..b05402e 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -321,6 +321,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 a8816b3..e229640 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -678,9 +678,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 83a1c64..58b64c1 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); }