From patchwork Fri Nov 20 23:01:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 7671781 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8D48DBF90C for ; Fri, 20 Nov 2015 23:01:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0067204FF for ; Fri, 20 Nov 2015 23:01:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADFD520457 for ; Fri, 20 Nov 2015 23:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759930AbbKTXBQ (ORCPT ); Fri, 20 Nov 2015 18:01:16 -0500 Received: from mail.skyhub.de ([78.46.96.112]:37282 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759616AbbKTXBQ (ORCPT ); Fri, 20 Nov 2015 18:01:16 -0500 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (door.skyhub.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id d-7ev7zUhRKF; Sat, 21 Nov 2015 00:01:14 +0100 (CET) Received: from pd.tnic (p200300454B0FD3000A606EFFFE5584DC.dip0.t-ipconnect.de [IPv6:2003:45:4b0f:d300:a60:6eff:fe55:84dc]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id C86421DA2A2; Sat, 21 Nov 2015 00:01:13 +0100 (CET) Received: by pd.tnic (Postfix, from userid 1000) id C0A2F160E2A; Sat, 21 Nov 2015 00:01:11 +0100 (CET) From: Borislav Petkov To: KVM Cc: "Andreas Faerber" , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti Subject: [PATCH] target-i386: Do not set MCG_SER_P by default Date: Sat, 21 Nov 2015 00:01:11 +0100 Message-Id: <1448060471-14128-1-git-send-email-bp@alien8.de> X-Mailer: git-send-email 2.3.5 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Borislav Petkov Software Error Recovery, i.e. SER, is purely an Intel feature and it shouldn't be set by default. Enable it only on Intel. Signed-off-by: Borislav Petkov --- target-i386/cpu.c | 7 ------- target-i386/cpu.h | 9 ++++++++- target-i386/kvm.c | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 11e5e39a756a..8155ee94fbe1 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2803,13 +2803,6 @@ static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) } #endif - -#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 && \ - (env)->cpuid_vendor2 == CPUID_VENDOR_INTEL_2 && \ - (env)->cpuid_vendor3 == CPUID_VENDOR_INTEL_3) -#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && \ - (env)->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && \ - (env)->cpuid_vendor3 == CPUID_VENDOR_AMD_3) static void x86_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); diff --git a/target-i386/cpu.h b/target-i386/cpu.h index fc4a605d6a29..2605c564239a 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -283,7 +283,7 @@ #define MCG_CTL_P (1ULL<<8) /* MCG_CAP register available */ #define MCG_SER_P (1ULL<<24) /* MCA recovery/new status bits */ -#define MCE_CAP_DEF (MCG_CTL_P|MCG_SER_P) +#define MCE_CAP_DEF MCG_CTL_P #define MCE_BANKS_DEF 10 #define MCG_STATUS_RIPV (1ULL<<0) /* restart ip valid */ @@ -610,6 +610,13 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_MWAIT_IBE (1U << 1) /* Interrupts can exit capability */ #define CPUID_MWAIT_EMX (1U << 0) /* enumeration supported */ +#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 && \ + (env)->cpuid_vendor2 == CPUID_VENDOR_INTEL_2 && \ + (env)->cpuid_vendor3 == CPUID_VENDOR_INTEL_3) +#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && \ + (env)->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && \ + (env)->cpuid_vendor3 == CPUID_VENDOR_AMD_3) + #ifndef HYPERV_SPINLOCK_NEVER_RETRY #define HYPERV_SPINLOCK_NEVER_RETRY 0xFFFFFFFF #endif diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 2a9953b2d4b5..082d38d4838d 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -787,8 +787,13 @@ int kvm_arch_init_vcpu(CPUState *cs) if (banks > MCE_BANKS_DEF) { banks = MCE_BANKS_DEF; } + mcg_cap &= MCE_CAP_DEF; mcg_cap |= banks; + + if (IS_INTEL_CPU(env)) + mcg_cap |= MCG_SER_P; + ret = kvm_vcpu_ioctl(cs, KVM_X86_SETUP_MCE, &mcg_cap); if (ret < 0) { fprintf(stderr, "KVM_X86_SETUP_MCE: %s", strerror(-ret));