Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp721555rwd; Mon, 12 Jun 2023 22:22:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zAEO9guMLL5rdogv3Stam55fNCTGJNunFB9R07S29C2iIrSIq8ljkkqLxvcvAd1jhWKAN X-Received: by 2002:a17:90a:7d01:b0:256:2526:2de5 with SMTP id g1-20020a17090a7d0100b0025625262de5mr17254309pjl.13.1686633770607; Mon, 12 Jun 2023 22:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686633770; cv=none; d=google.com; s=arc-20160816; b=I8GUVXZ3WOsZ8yCdDmYcYO08vqnLesatUt4rJ+lkUHIzpGBNb5/RHfdMsMOx/dSyx/ Wp/UFDOy7TFqXY8XC5Xrdk47ZH0w7FbrCv9ZUSDX4k4aw8y76XRiHH830+K5zjvb5XPh JqPIdV/fyeGjGXK6DHLTIeF0pivtpktVthlumbe3Jq4+2TyQACZRIzyOuiPVXi4kekkj u+8SoAcEJJN75ujXFUDx7j0th5FD59MWwiIsRD3hzaDEGYcwVnsY2yzlACshgtUA5qAp Xc4H47Ru5ZzBvwDLMShCNzY/yf0Fa2pRH6AhaGJPvKEmuS0zlHr4f0XMMPqHjhsZLmod Sisg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=LpFJ758ownMaHE2mKnKFNobK7BVlUCI1EKGq3JooEEk=; b=HR2kpUdgBM/JO294XO2jfZ3Z8t2dnJHnr8Y1c4fXhorUkRNpVtjTp43BzKe+quJ8AN ThQ544/bLqi5v3TnvZTo+S8nGOflgLEM+JkEa5a1tbp+xt+b1RIhN+9nkt2fDE7huSa/ FGJ+Lvf+IO7022HPONGw54KVk0tRg6GLL6HEQZJcbaIZsUrIOc4SaEC6LV9XqwXJPfoB xDFTDEPX98lS9RtH3PwpTX06keV2kcsI4Nn3+drianIYGR9W4PgCw94FIYsZcYZuZXUe K1tJs6511k+dYWsEvNEzdNtHfqZ7QQEz04yQRnl1B5Bm1+zN/LDEg5Rv7v9dgaWlPiXk jdKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nYXJYymD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a17090ad34e00b0025691c00096si8205286pjx.140.2023.06.12.22.22.39; Mon, 12 Jun 2023 22:22:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nYXJYymD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239883AbjFME0N (ORCPT + 99 others); Tue, 13 Jun 2023 00:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239830AbjFMEZf (ORCPT ); Tue, 13 Jun 2023 00:25:35 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0516E170E; Mon, 12 Jun 2023 21:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686630172; x=1718166172; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=RwlWd28vqHXWXzvO+9M6hWVcHHCuXEVs+/JBdj0y9xA=; b=nYXJYymDEFL//J7FXryfDQkNqSC76YxUMo1Z7JsnefLeH5zYy2T3Uqvn C4V1JqXDNaw8/ELmJp1xXaQinUy6TQe0POZIMYAy0Ng2afZ2QRVXp0Pdq RqzOT35DDUz96zE4s54ITqL0j90PLdEXRfDPRe1byy08jbdqos5TWoPhn Hmn0ZnrIzbzPTumIj5jWGJxPZBSaAKkeBcWB9/PUkASlfat5urlXsWyPK a8uc5ua8/5eGgjzhIZF/cBypmmCO5k4hTe/GK+hKQQaQRHBYdNbf7RfmM Ok11sekR+wiXuj810xXTynmqDF+tQucfJ34pHnXCBd3c2RWfRIjas4o5b w==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="358222301" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="358222301" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 21:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="661855006" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="661855006" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga003.jf.intel.com with ESMTP; 12 Jun 2023 21:22:04 -0700 From: Ricardo Neri To: "Peter Zijlstra (Intel)" , Juri Lelli , Vincent Guittot Cc: Ricardo Neri , "Ravi V. Shankar" , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Len Brown , Mel Gorman , "Rafael J. Wysocki" , Srinivas Pandruvada , Steven Rostedt , Tim Chen , Valentin Schneider , Lukasz Luba , Ionela Voinescu , Zhao Liu , "Yuan, Perry" , x86@kernel.org, "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ricardo Neri , "Tim C . Chen" , Zhao Liu Subject: [PATCH v4 23/24] x86/hreset: Configure history reset Date: Mon, 12 Jun 2023 21:24:21 -0700 Message-Id: <20230613042422.5344-24-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230613042422.5344-1-ricardo.neri-calderon@linux.intel.com> References: <20230613042422.5344-1-ricardo.neri-calderon@linux.intel.com> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Configure the MSR that controls the behavior of HRESET on each logical processor. Cc: Ben Segall Cc: Daniel Bristot de Oliveira Cc: Dietmar Eggemann Cc: Ionela Voinescu Cc: Joel Fernandes (Google) Cc: Len Brown Cc: Lukasz Luba Cc: Mel Gorman Cc: Perry Yuan Cc: Rafael J. Wysocki Cc: Srinivas Pandruvada Cc: Steven Rostedt Cc: Tim C. Chen Cc: Valentin Schneider Cc: Zhao Liu Cc: x86@kernel.org Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ricardo Neri --- Changes since v3: * None Changes since v2: * None Changes since v1: * Marked hardware_history_features as __ro_after_init instead of __read_mostly. (PeterZ) --- arch/x86/kernel/cpu/common.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8f284e185aea..d47a442900ad 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -396,6 +396,26 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c) cr4_clear_bits(X86_CR4_UMIP); } +static u32 hardware_history_features __ro_after_init; + +static __always_inline void setup_hreset(struct cpuinfo_x86 *c) +{ + if (!cpu_feature_enabled(X86_FEATURE_HRESET)) + return; + + /* + * Use on all CPUs the hardware history features that the boot + * CPU supports. + */ + if (c == &boot_cpu_data) + hardware_history_features = cpuid_ebx(0x20); + + if (!hardware_history_features) + return; + + wrmsrl(MSR_IA32_HW_HRESET_ENABLE, hardware_history_features); +} + /* These bits should not change their value after CPU init is finished. */ static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP | @@ -1834,10 +1854,11 @@ static void identify_cpu(struct cpuinfo_x86 *c) /* Disable the PN if appropriate */ squash_the_stupid_serial_number(c); - /* Set up SMEP/SMAP/UMIP */ + /* Set up SMEP/SMAP/UMIP/HRESET */ setup_smep(c); setup_smap(c); setup_umip(c); + setup_hreset(c); /* Enable FSGSBASE instructions if available. */ if (cpu_has(c, X86_FEATURE_FSGSBASE)) { -- 2.25.1