Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2369147rdb; Tue, 10 Oct 2023 01:37:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHF1XquSF+MCqMdHdQ3aUYxKTIYHl1EdoM0zrC8dk6ylMZApzWExa7I1mhr+9jIHZXWRwao X-Received: by 2002:a05:6808:144d:b0:3ad:c5f3:36c6 with SMTP id x13-20020a056808144d00b003adc5f336c6mr21796313oiv.38.1696927026389; Tue, 10 Oct 2023 01:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696927026; cv=none; d=google.com; s=arc-20160816; b=m3LZW14hQXt6Wg8Plk6NX9LevDUaaFhbbgv+VSCTTGVGkhdc/PGFydkjyyRK8zI4nA 5Z5xtUWfeHK8UyDg/XcT/rKHuBWI3BB5/QWba76VniQsd22lHKD9n7RG/ArPAhyeTfCY gb8GKf/s3wVgeEKuLbdOS9M50X0pLQzS/qv5z00PlZgtDogUC0NV7M/7vNY5nu/OD3jL Rtb2xLMiS4QhUc0gnZgRGglVjptDMdJ1/9FRwmnnGwm/Eg+ILwqVRUJPJDpnC4idaNHi F00riE2srE1o34GslTeCEx2BXKtbRhoi8uVsoANOGCw5M166bjLlpp85MWXXpHdhn3K5 Mmdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eg8ccZ/J6xMWO90Wek5xkqt85zwH0uyL/5gnQGdl0Uc=; fh=qpQuS5DB8/tFQfmdgX1i3QvppRzkrzhfKx2/rzpwOaE=; b=XnCfskuuk/EKTpJd7Wi1rWZksyLMA3ver4d+HZfiqTnSNHPdH14tD2eiBEU4c+SnJ/ OeX5lBctfib5N5Otmhy43DpslaYsX3ULks3oiLjWwWVbcp0gZ+gpnwAF/ONxsdOSQlY1 tlY/mx81j4vGqvsU8tODEaiCf7bwtNZWLbt+z35+fvr19ddrawAciTBdw88o1g02KAqm 6EdCbBCpHZ1r9IT8ynOWQYPa76P3vPod/+MCSdS50wKQnRjiU6HNdBXq8yLMhG4Y32OC 0cn6DJTy8ycvadqvfb4wYg8cFyIuk0LyJIVEwmV1D28L3zibUPIDK4H0wtHdmEznAqrG mOqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="A/4c6uBG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m63-20020a632642000000b00578b40703bcsi11893032pgm.885.2023.10.10.01.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 01:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="A/4c6uBG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B8D8C8082873; Tue, 10 Oct 2023 01:36:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442947AbjJJIfs (ORCPT + 99 others); Tue, 10 Oct 2023 04:35:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442897AbjJJIfg (ORCPT ); Tue, 10 Oct 2023 04:35:36 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 990BA9F; Tue, 10 Oct 2023 01:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696926934; x=1728462934; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XRUCF/P5uKgDye69B2VNPFxzhkCFQCyWEdXoWuKd6KA=; b=A/4c6uBGxvJpTwMiDq1ASuH8uLoKBG+XDxMXAxfMBWGDeGTZaKoxzNIs ifRhrWEMMoK+vYRC8eF5bFd95nEz5SXoozqeq2nMmGDsxOmPpWTVS5jk1 3aIO1eF+XBUMYs6X3Qn5t4Hhj6ePD55RajVLCJepyVOOpCzg2Xf8N5SzO to2Dy8lz7ErcEIUUfrxD0ng8upzQkgLamx1PxmMdo3+hgTt3IAwup1ymn md5dCoBvd7DaLqxAcczdc6a24mWidEEF8Hwmrq1mDp7SuD/rmeBbFiLsQ MCU50FbCHgoR3aucDeyo2zpus4sgsLn8nQxnCdR7IlTIK4F62nUMRGtgI w==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="387176588" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="387176588" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 01:35:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="730001327" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="730001327" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 01:35:32 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Michael Roth , Paolo Bonzini , Sean Christopherson , linux-coco@lists.linux.dev, Chao Peng Subject: [PATCH 01/12] x86/mce: Fix hw MCE injection feature detection Date: Tue, 10 Oct 2023 01:35:09 -0700 Message-Id: <23c6fa20777498bccd486aedc435eef9af174748.1696926843.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 10 Oct 2023 01:36:17 -0700 (PDT) X-Spam-Level: ** From: Isaku Yamahata When initializing x86 MCE injection framework, it checks if hardware mce injection is available or not. When it's not available on AMD, set the boolean variable to false to not use it. The variable is on by default and the feature is AMD specific based on the code. Because the variable is default on, it is true on Intel platform (probably on other non-AMD x86 platform). It results in unchecked msr access of MSR_K7_HWCR=0xc0010015 when injecting MCE on Intel platform. (Probably on other x86 platform.) Make the variable of by default, and set the variable on when the hardware feature is usable. The procedure to produce on Intel platform. echo hw > /sys/kernel/debug/mce-inject/flags This succeeds. set other MCE parameters if necessary. echo 0 > /sys/kernel/debug/mce-inject/bank This triggers mce injection. The kernel accesses MSR_K7_HWCR=0xc0010015 resulting unchecked MSR access. Fixes: 891e465a1bd8 ("x86/mce: Check whether writes to MCA_STATUS are getting ignored") Signed-off-by: Isaku Yamahata --- arch/x86/kernel/cpu/mce/inject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index 4d8d4bcf915d..881898a1d2f4 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -33,7 +33,7 @@ #include "internal.h" -static bool hw_injection_possible = true; +static bool hw_injection_possible; /* * Collect all the MCi_XXX settings @@ -732,6 +732,7 @@ static void check_hw_inj_possible(void) if (!cpu_feature_enabled(X86_FEATURE_SMCA)) return; + hw_injection_possible = true; cpu = get_cpu(); for (bank = 0; bank < MAX_NR_BANKS; ++bank) { -- 2.25.1