From patchwork Wed Nov 11 00:39:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Luck X-Patchwork-Id: 11895921 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.7 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 C4077C5517A for ; Wed, 11 Nov 2020 00:40:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89F7820679 for ; Wed, 11 Nov 2020 00:40:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732090AbgKKAj7 (ORCPT ); Tue, 10 Nov 2020 19:39:59 -0500 Received: from mga04.intel.com ([192.55.52.120]:12588 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727275AbgKKAj7 (ORCPT ); Tue, 10 Nov 2020 19:39:59 -0500 IronPort-SDR: pfxbqvZBzCS9LxdlzFXr1gnXMzqCfGtrBmiAOeht8KeiN2C9HYOYsWwJEmv0pesSolnRdvnbeD dSmxwayl4qFQ== X-IronPort-AV: E=McAfee;i="6000,8403,9801"; a="167489223" X-IronPort-AV: E=Sophos;i="5.77,468,1596524400"; d="scan'208";a="167489223" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2020 16:39:57 -0800 IronPort-SDR: yxsyaDteDfcShgJDHe25SY8PLDJkrEfTHmRI7swP+/uvKoOvYh33CH3Zx0r8pzvBKXTdO1wOly JUW3MbeEmqxw== X-IronPort-AV: E=Sophos;i="5.77,468,1596524400"; d="scan'208";a="356389564" Received: from agluck-desk2.sc.intel.com (HELO agluck-desk2.amr.corp.intel.com) ([10.3.52.68]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2020 16:39:56 -0800 Date: Tue, 10 Nov 2020 16:39:54 -0800 From: "Luck, Tony" To: Paolo Bonzini Cc: Borislav Petkov , Jim Mattson , Qian Cai , "linux-kernel@vger.kernel.org" , "linux-tip-commits@vger.kernel.org" , x86 , "kvm@vger.kernel.org" Subject: [PATCH v2] x86/mce: Use "safe" MSR functions when enabling additional error logging Message-ID: <20201111003954.GA11878@agluck-desk2.amr.corp.intel.com> References: <20201109232402.GA25492@agluck-desk2.amr.corp.intel.com> <20201110063151.GB7290@nazgul.tnic> <094c2395-b1b3-d908-657c-9bd4144e40ac@redhat.com> <20201110095615.GB9450@nazgul.tnic> <20201110155013.GE9857@nazgul.tnic> <1b587b45-a5a8-2147-ae53-06d1b284ea11@redhat.com> <7bd98718-f800-02ef-037a-4dfc5a7d1a54@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7bd98718-f800-02ef-037a-4dfc5a7d1a54@redhat.com> 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. Switch to using rdmsrl_safe()/wrmsrl_safe() to avoid the message. Reported-by: Qian Cai Fixes: 68299a42f842 ("x86/mce: Enable additional error logging on certain Intel CPUs") Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/mce/intel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/intel.c b/arch/x86/kernel/cpu/mce/intel.c index b47883e364b4..42e60ef16c3a 100644 --- a/arch/x86/kernel/cpu/mce/intel.c +++ b/arch/x86/kernel/cpu/mce/intel.c @@ -521,9 +521,10 @@ static void intel_imc_init(struct cpuinfo_x86 *c) case INTEL_FAM6_SANDYBRIDGE_X: case INTEL_FAM6_IVYBRIDGE_X: case INTEL_FAM6_HASWELL_X: - rdmsrl(MSR_ERROR_CONTROL, error_control); + if (rdmsrl_safe(MSR_ERROR_CONTROL, &error_control)) + return; error_control |= 2; - wrmsrl(MSR_ERROR_CONTROL, error_control); + wrmsrl_safe(MSR_ERROR_CONTROL, error_control); break; } }