From patchwork Mon Apr 10 08:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 13206191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7692C76196 for ; Mon, 10 Apr 2023 08:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230006AbjDJInM (ORCPT ); Mon, 10 Apr 2023 04:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbjDJIm3 (ORCPT ); Mon, 10 Apr 2023 04:42:29 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAD6059C4; Mon, 10 Apr 2023 01:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681116079; x=1712652079; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QC9Fb9BemsHiUNjBHn3W5WBw0HzwzGI557xdvOqcS00=; b=RRNe0xKRbIB0aHoNakq5TU7W37L8rvd3huu84a1+ibxnoU83RAx80wyI eJMd8uZybQhWu5Uju1z7RcpBZCvHRyNg8hHniW5ga+SojwaW/Yh1pkZUR mPx4zjUDD58UaAFJxgawYIgEkB4O1dAjAXfYiprA8uH+VePz7tWESMGRZ o4S2XOJH580po5Ml8cAXw4lvA4LK6yHa82jrwFssWkClfWBHpZdMK/QF2 wh+BPBSeAPCrwtP2zKRG2t3sMIqIllarUAJGMdhycAGEDxItbuEvYNwJK ABceX7/2DFmK7RK3zhFH5oV480UKkVDSfzWN6YqMsLl1FkfbIRnIGOhxn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10675"; a="342078216" X-IronPort-AV: E=Sophos;i="5.98,333,1673942400"; d="scan'208";a="342078216" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2023 01:41:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10675"; a="799436368" X-IronPort-AV: E=Sophos;i="5.98,333,1673942400"; d="scan'208";a="799436368" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga002.fm.intel.com with ESMTP; 10 Apr 2023 01:41:08 -0700 From: Xin Li To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, peterz@infradead.org, andrew.cooper3@citrix.com, seanjc@google.com, pbonzini@redhat.com, ravi.v.shankar@intel.com, jiangshanlai@gmail.com, shan.kang@intel.com Subject: [PATCH v8 32/33] x86/fred: disable FRED by default in its early stage Date: Mon, 10 Apr 2023 01:14:37 -0700 Message-Id: <20230410081438.1750-33-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230410081438.1750-1-xin3.li@intel.com> References: <20230410081438.1750-1-xin3.li@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Disable FRED by default in its early stage. To enable FRED, a new kernel command line option "fred" needs to be added. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v7: * Add a log message when FRED is enabled. --- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kernel/fred.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 6221a1d057dd..c55ea60e1a0c 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1498,6 +1498,10 @@ Warning: use of this parameter will taint the kernel and may cause unknown problems. + fred + Forcefully enable flexible return and event delivery, + which is otherwise disabled by default. + ftrace=[tracer] [FTRACE] will set and start the specified tracer as early as possible in order to facilitate early diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index eea41cb8722e..4db5e619fc97 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1467,6 +1467,9 @@ static void __init cpu_parse_early_param(void) char *argptr = arg, *opt; int arglen, taint = 0; + if (!cmdline_find_option_bool(boot_command_line, "fred")) + setup_clear_cpu_cap(X86_FEATURE_FRED); + #ifdef CONFIG_X86_32 if (cmdline_find_option_bool(boot_command_line, "no387")) #ifdef CONFIG_MATH_EMULATION diff --git a/arch/x86/kernel/fred.c b/arch/x86/kernel/fred.c index 8d6dda8c8e71..f4d48f4f06b4 100644 --- a/arch/x86/kernel/fred.c +++ b/arch/x86/kernel/fred.c @@ -11,6 +11,9 @@ */ void cpu_init_fred_exceptions(void) { + /* When FRED is enabled by default, this log message may not needed */ + pr_info("Initialize FRED on CPU%d\n", smp_processor_id()); + wrmsrl(MSR_IA32_FRED_CONFIG, FRED_CONFIG_REDZONE | /* Reserve for CALL emulation */ FRED_CONFIG_INT_STKLVL(0) |