From patchwork Mon Nov 9 23:24:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Luck X-Patchwork-Id: 11892775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13AFBC5517A for ; Mon, 9 Nov 2020 23:24:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C64CA206ED for ; Mon, 9 Nov 2020 23:24:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731355AbgKIXYF (ORCPT ); Mon, 9 Nov 2020 18:24:05 -0500 Received: from mga09.intel.com ([134.134.136.24]:7001 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729740AbgKIXYE (ORCPT ); Mon, 9 Nov 2020 18:24:04 -0500 IronPort-SDR: ID0Hd7zq6ENP88mZc7V0tz9D0YDzA4YLVkszv6mgrxKfpJX+Js0e0v4Qy5pox5+D3lPx/5SCan PazxTL9ggC5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="170038978" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="170038978" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 15:24:03 -0800 IronPort-SDR: GpZbytWzBTV4P7UoNJU0CtTmo7uvwa2hvA0jdHPZGeGaba7dR/GNinokcc8VgiKXTCs/iFFDHk g3eGxblBjDOQ== X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="473180423" Received: from agluck-desk2.sc.intel.com (HELO agluck-desk2.amr.corp.intel.com) ([10.3.52.68]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 15:24:03 -0800 Date: Mon, 9 Nov 2020 15:24:02 -0800 From: "Luck, Tony" To: Borislav Petkov , Jim Mattson Cc: Qian Cai , "linux-kernel@vger.kernel.org" , "linux-tip-commits@vger.kernel.org" , Boris Petkov , Borislav Petkov , x86 , Paolo Bonzini , "kvm@vger.kernel.org" Subject: [PATCH] x86/mce: Check for hypervisor before enabling additional error logging Message-ID: <20201109232402.GA25492@agluck-desk2.amr.corp.intel.com> References: <20201030190807.GA13884@agluck-desk2.amr.corp.intel.com> <160431588828.397.16468104725047768957.tip-bot2@tip-bot2> <3f863634cd75824907e8ccf8164548c2ef036f20.camel@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Booting as a guest under KVM results in error messages about unchecked MSR access: [ 6.814328][ T0] unchecked MSR access error: RDMSR from 0x17f at rIP: 0xffffffff84483f16 (mce_intel_feature_init+0x156/0x270) because KVM doesn't provide emulation for random model specific registers. Check for X86_FEATURE_HYPERVISOR and skip trying to enable the mode (a guest shouldn't be concerned with corrected errors anyway). Reported-by: Qian Cai Fixes: 68299a42f842 ("x86/mce: Enable additional error logging on certain Intel CPUs") Signed-off-by: Tony Luck Nacked-by: Paolo Bonzini --- arch/x86/kernel/cpu/mce/intel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/intel.c b/arch/x86/kernel/cpu/mce/intel.c index b47883e364b4..7f7d863400b7 100644 --- a/arch/x86/kernel/cpu/mce/intel.c +++ b/arch/x86/kernel/cpu/mce/intel.c @@ -517,6 +517,9 @@ static void intel_imc_init(struct cpuinfo_x86 *c) { u64 error_control; + if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) + return; + switch (c->x86_model) { case INTEL_FAM6_SANDYBRIDGE_X: case INTEL_FAM6_IVYBRIDGE_X: