Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp209960rdb; Tue, 5 Dec 2023 03:23:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0cT97zUa17WbN8/xTk5KrZC3S2/sOwFDJ6zUb8J/QpeQkXW0HuADzpMe3jUoqx+np+UVP X-Received: by 2002:a17:90b:100d:b0:286:6cc0:cac2 with SMTP id gm13-20020a17090b100d00b002866cc0cac2mr885894pjb.57.1701775385066; Tue, 05 Dec 2023 03:23:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701775385; cv=none; d=google.com; s=arc-20160816; b=bdS/qgOb8fgLo1ANUO1JtYrNmBQOlbQTjvdF+1CYBXSuUWWpff47t50iiSx1Q/f46v Z8gG0NLaGpzOQd5rcUPk48eB9mCWKmKiTTLLrEITEN3rT2g8P5rDo5JYQZkroA/5xuff NSFQHeKTqMbcN81rAIWmw8l4nCdMJWjzwaRzyoCfDSN48OZTdSe1n4ENxdN0PjxJTthb ktzW/zCwUfdMK67ZcGgMycB4XAhAzqKxP0OmUgeKG9219Yyci2ICNMBBGCQ1PczdQncV YN+Itm8xtB8EGQq1dwLqtXNUNIw0t/Q5lNuE5Z9f2H6pI1YyKTN4v6rJEjuuzwxPnP2j jlSw== 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=ev0AS+62vNauLOXJPFpvl2iRWuwhBPS9q43Xn+eKMkQ=; fh=uCCWEUVpLc/xDP/D3WvGY/BxHU9d0NQYu/T71GEsNmA=; b=EJkIEtD3QwxmCqsZzaePgjrOnkoZbLKX34RPLNe0wUir4zXxNt2nztfMX6mEXmRSHW bSslM7QZK+BHxhldCGEA3/0k29F61l5kM9mA/3ZK3XP13rUZ7DHu/eNnpfnsW/d44+DV BHeManmklVNaFjtUIysg1vHCs0djxaieximo+GB+T5bdCwcjSKQJhJ4Cue0Ky8lxHLpV qniaThp8mcsVe7HNyvECImDlZe/3YDxiiZQg4f8dV4+0l4PNYoT3D7R2ATDxrukn9apr Z3tR9qjFRF+VlM6JsDOFWOG2Uiaeh6vxLrWYN6jU/T+8KerxfwVvKJyZ6OG3pXXbZz6P NqbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z5Tq47ey; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ft7-20020a17090b0f8700b002839be230b2si5508649pjb.44.2023.12.05.03.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 03:23:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z5Tq47ey; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 5F2B08225CB7; Tue, 5 Dec 2023 03:22:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442086AbjLELWS (ORCPT + 99 others); Tue, 5 Dec 2023 06:22:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442105AbjLELV0 (ORCPT ); Tue, 5 Dec 2023 06:21:26 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E43A1187; Tue, 5 Dec 2023 03:21:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701775290; x=1733311290; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hPsnAnmRCEio5pl6T3lxKlJogXHr45sRU/QYYYLaUzw=; b=Z5Tq47eyrDr7px0HUR8QJ/kdeHe4FPlpSIQsmaYVWUagXRI0BdbByvIq oy+sQ45WJeh6vfSAWHGANk5CfpJ8Np7dOJatmUPfZd37ikfMg76YVjuLy qM+LNt8E6yDHk1C4Zc2pNCONnJphCt4m2wWrIHq2nKyiwgfCLxD+5IpkY 1tYkVhCSx0eOTJca0d4Add/RzTiV0lChojtB9K5/r4hD4ZS5K0BR1v7ID K/KvRl28/1fiDspkHf2TS30ck8tb1ge9+BNw5KGl+OJC55kmmqU7fUIQP Apj8NOHYo/3nTG9+tLRxAuF2Q3m7VAyEcTxB+xrULoGY5dKgQ2gDo3CVJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="942530" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="942530" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 03:21:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="1018192965" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018192965" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 03:21:21 -0800 From: Xin Li To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, pbonzini@redhat.com, seanjc@google.com, peterz@infradead.org, jgross@suse.com, ravi.v.shankar@intel.com, mhiramat@kernel.org, andrew.cooper3@citrix.com, jiangshanlai@gmail.com, nik.borisov@suse.com, shan.kang@intel.com Subject: [PATCH v13 19/35] x86/fred: No ESPFIX needed when FRED is enabled Date: Tue, 5 Dec 2023 02:50:08 -0800 Message-ID: <20231205105030.8698-20-xin3.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205105030.8698-1-xin3.li@intel.com> References: <20231205105030.8698-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 03:22:53 -0800 (PST) From: "H. Peter Anvin (Intel)" Because FRED always restores the full value of %rsp, ESPFIX is no longer needed when it's enabled. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/espfix_64.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c index 16f9814c9be0..6726e0473d0b 100644 --- a/arch/x86/kernel/espfix_64.c +++ b/arch/x86/kernel/espfix_64.c @@ -106,6 +106,10 @@ void __init init_espfix_bsp(void) pgd_t *pgd; p4d_t *p4d; + /* FRED systems always restore the full value of %rsp */ + if (cpu_feature_enabled(X86_FEATURE_FRED)) + return; + /* Install the espfix pud into the kernel page directory */ pgd = &init_top_pgt[pgd_index(ESPFIX_BASE_ADDR)]; p4d = p4d_alloc(&init_mm, pgd, ESPFIX_BASE_ADDR); @@ -129,6 +133,10 @@ void init_espfix_ap(int cpu) void *stack_page; pteval_t ptemask; + /* FRED systems always restore the full value of %rsp */ + if (cpu_feature_enabled(X86_FEATURE_FRED)) + return; + /* We only have to do this once... */ if (likely(per_cpu(espfix_stack, cpu))) return; /* Already initialized */ -- 2.43.0