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: 81408 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1758130vqo; Mon, 10 Apr 2023 01:44:49 -0700 (PDT) X-Google-Smtp-Source: AKy350auaM5orzJuAYiGqAuPwJQXkHnppCpvipN4rKxwQTZPyoimCi4OfQ9b7WwnHc4caIK59xPO X-Received: by 2002:aa7:955b:0:b0:639:f1da:9fa4 with SMTP id w27-20020aa7955b000000b00639f1da9fa4mr501983pfq.13.1681116288830; Mon, 10 Apr 2023 01:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681116288; cv=none; d=google.com; s=arc-20160816; b=aWlD5HcvRWyQvFIW+PWu8+Y/qCrjwfWOooVS5pyGHm7S76IYjfX7MsM8Z05z/YlJKc x/0uB3DZZ+L3Yi3m4U4BvmmfR+svnECBXtKLZ6qgVqMzK7qpp1E4Zic4koIW676fDLx2 tf5kx/8f5rEbbL2hBfDlEoCAk94Rf+2QWtBAfn2xlyVdJf1dZw9nawakKoEwawZAv0F9 zToQBhoLAxLfOl/jHRYVpBXotgFULsmaMiIjrxW1YONWZkktLFK1P4t4R2Ke+t2GM0cY M3QB4tZaWzRoEQkHLLKCFDO0LTzFT7o+sXVleYH76IU1KcNsHp6dKFpY7wWMdu9Nt0d1 DL+A== 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=fTC3wHoilVdfSrxaAuTGwj59tELEUHMxSkJME6+yttw=; b=wu6uAKi/ykVJjElxaGIYy4g7BohXMiob5J5FCi5Yx39+aYXc/h5tx+HYi4c4hXGYt9 t/bGbO/xBgdl+d3Ao0KeTg/1sZiOPtHPNXjsKum34vo9WZ59FgdUHfcgrG0K90Jy+ft0 vKuVCFicSKsHdyhsfyBIKaIC3G2sZdSaA2HfRzSDSYNku39T58PZpfnjkhcUw4X03OY4 Ba1lphSL196/93DJwmOk9BRM/SS9etHClhtWmePKybi7Bkr/Goh2D3N8dINTx8LG1J4k WV2+IDT08wD8+PJnG875Bqy2FRMdKH4eyVdx8JOTNsXkPpOP6dbwPCkuxIGbBaYPwQ8u 0Nrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RRNe0xKR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l70-20020a638849000000b00519d96ec174si2398794pgd.411.2023.04.10.01.44.36; Mon, 10 Apr 2023 01:44:48 -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=RRNe0xKR; 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 S229886AbjDJInN (ORCPT + 99 others); Mon, 10 Apr 2023 04:43:13 -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 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762778193403959489?= X-GMAIL-MSGID: =?utf-8?q?1762778193403959489?= 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) |