Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2585529rwn; Fri, 9 Sep 2022 16:44:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VgtqfCUDC049VzdERgF7bhKg2OfBxvxt4ASllwtA4fBvmWV3WbSiTsjcBWUfWqInWZbNz X-Received: by 2002:a05:6a00:e8a:b0:535:cc5c:3d87 with SMTP id bo10-20020a056a000e8a00b00535cc5c3d87mr16554177pfb.24.1662767090237; Fri, 09 Sep 2022 16:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662767090; cv=none; d=google.com; s=arc-20160816; b=foYGXT4Xly+8knzTk6+isiPUBH3lLD4etL+UVKxCGgJg2vx4C2QyhnR1nxv1DRH/mL WeS2mKAcPcB4QJTQ88YFoePrz8DdW7bNgNxs2G8wZXIBXjiHGIqN3Ucq6BnqeM3zunN8 ahrPDg+4+WotJR8YD8isAS166YrMdIVBz63kIIr3M6nWtqnNzSIEDXiwWQfekvvnPh4z pUYcoF+0VbZlByiyjYmDox/Of8p24dV/cDqECbSfW68iQqD11BpmnU2hvsNGwQpdumZq IthluKxHaA00qyGyWCXo8yoV2xTx43wzstFw6UloGG136QCnM/tQiirtP9R1RrWsO6sl pi6A== 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=/58GS3WSRazCzDxw1WAdvzdJxgrnxOblzeNRg+q0CWc=; b=rA4im3yal0BbXTUz1TzP+n3yaxttiiQE8s3NXEf+aq6YELxBo427qyqeKgs8uIy3DW N66GL4fGcmb0rIpl9anrOAglCJi3pt91YWmEQDWDO5EYexI4HFGy3DeNnST+nEAnTBGw ZPauX0iwYH7Fb2/orNjEQiAnrOl722eddySQ8PGavwQwCUkcFAXavmaIBR8lqGTafcYR XjlrFS76z74WhCEij8zyWsMFjbvFLR+Spm452AKuGmzKpJvAGMGToSRlHSU10T5Vi6dC uAud1jI99DSo7O9EbzdC4kaPRQbg6Ud98O8aP/2BIc28d2FYwMcHKtQxGuDvarb2PzpL B7ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Sc7GrvPp; 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 i1-20020a170902e48100b00176e226934csi1633751ple.270.2022.09.09.16.44.38; Fri, 09 Sep 2022 16:44: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=Sc7GrvPp; 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 S232056AbiIIXH7 (ORCPT + 99 others); Fri, 9 Sep 2022 19:07:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231494AbiIIXGs (ORCPT ); Fri, 9 Sep 2022 19:06:48 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39E50115CE1 for ; Fri, 9 Sep 2022 16:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662764800; x=1694300800; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=uWhlQiKfFlJ133UzVFaeiIrxWqUY0rEMtrX3JgRUHEg=; b=Sc7GrvPpXtwGL2S+wQAoH4Sjo3KLojt1iUzuZ1i27Qfzr+eiKSSA2xpp V85HkyjKX0aqOhPHxCkIAT/v2MtQ+PUy3/wdZao2MmSHPxr/IJnb/r22x dxhVs47VycBw9aq2RzJ4078BRmo3exKsJl5009fok61F7SfaUfyc11Kk1 GEJ/ILfT92fQEs3BIP0d2UTmJMwLbctHPtin2p1i4lzR1+oozqMbvkLC6 59+2j72+haz4kuBRHJmV8kLLfUm7B3ZtDc2i5tHo10+dE9TJ4plSCTf2o s6StVcZV+40nkLWc0+oowLAnwRWQHECB2cTLiQZD2IxVO12bgTJRLlpV4 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10465"; a="298386930" X-IronPort-AV: E=Sophos;i="5.93,304,1654585200"; d="scan'208";a="298386930" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2022 16:06:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,304,1654585200"; d="scan'208";a="677355058" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga008.fm.intel.com with ESMTP; 09 Sep 2022 16:06:36 -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 , x86@kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , "Tim C . Chen" Subject: [RFC PATCH 22/23] x86/hreset: Configure history reset Date: Fri, 9 Sep 2022 16:12:04 -0700 Message-Id: <20220909231205.14009-23-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220909231205.14009-1-ricardo.neri-calderon@linux.intel.com> References: <20220909231205.14009-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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: Len Brown Cc: Mel Gorman Cc: Rafael J. Wysocki Cc: Srinivas Pandruvada Cc: Steven Rostedt Cc: Tim C. Chen Cc: Valentin Schneider Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ricardo Neri --- arch/x86/kernel/cpu/common.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 3e508f239098..108642fe6761 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -411,6 +411,28 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c) cr4_clear_bits(X86_CR4_UMIP); } +static u32 hardware_history_features __read_mostly; + +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); + + pr_info_once("x86/cpu: Intel History Reset (HRESET) activated\n"); +} + /* 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 | @@ -1823,10 +1845,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