From patchwork Fri Feb 24 07:01:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 61170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp760727wrd; Thu, 23 Feb 2023 23:42:49 -0800 (PST) X-Google-Smtp-Source: AK7set+fiARWaepajqTb/M8lI858vT06G5en2Yal0QwrrFuXAkjOxR9cqnfxI0DROhucUNCSYg4G X-Received: by 2002:a17:902:f68f:b0:19c:1433:5fba with SMTP id l15-20020a170902f68f00b0019c14335fbamr16457830plg.0.1677224569242; Thu, 23 Feb 2023 23:42:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677224569; cv=none; d=google.com; s=arc-20160816; b=ZOYk70lqS+09dgiQ5InPMgFj9jbmUUKJ3b4vaVd35mMB2n3zpF3HK1IJPOiAxqQ7QA QbEeTqTympSrbbSrHIDsTtNFLauuRI806fyiuX7eXPl1JarkeFXbpfK9NImn/qo+DehW pE4gs02QiVf0W5/iK3UVyorYv7mTiDL4HCC4KQTYWxtbhpUJwlcfjmxvTij8hTr38d2B 5ZLYWd9vlIkyFnwyRGDknFFw9LHRLWhlYDYp1E64JwGniv676xWq0r2j0ujNJ+kFZiiq Lo/926ZEDOA1kywQdUu5/0E2qQPKEmIejfVfL/9ebMrgLPHYkzL9zVdNZ/w4+fdN0EWV t4qQ== 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=iRGgmcjQkZMZW9bKfKAkn4GXA2qpm3VlLlQn9hSIZ8o=; b=zwHMgE29jVf5hhNeIPaPmLWeAF1gbM41yIiM8i0fylNzJGou/RTqm+XNDwZcUi4w+e 82xDqWhkuUvpZ2J+kV0fTxE6Y81mRPRR+5lbO3Aup0BCDzResrW5yvM8lTgX5DwxBlVl hKvmM01Ay0mVKnQqmgiwnPW4VOO2ug3hpJb44xs2ifJ7fw9XLdfLgtbFZJFHFWJJJrE8 nmaLUzXC9nShrsvgz9/DUGaKo0PqAGPH4OR+yR2Tl+PNWc8SwIL6kV5THIoZkOLsgizt rRkQua43lgE6sYw/vkAZpJgQa7FDN49O+mjtJm4XqUWgeRXuHBPPnty1zRLt6itGxU8W KpgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ug298TNc; 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 q125-20020a632a83000000b004a4eae7c943si10873630pgq.535.2023.02.23.23.42.34; Thu, 23 Feb 2023 23:42:49 -0800 (PST) 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=Ug298TNc; 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 S229871AbjBXH3n (ORCPT + 99 others); Fri, 24 Feb 2023 02:29:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbjBXH3N (ORCPT ); Fri, 24 Feb 2023 02:29:13 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D578363542; Thu, 23 Feb 2023 23:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677223702; x=1708759702; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dKcGYBnXHQiTsBcKqxrhALysREBc36cYC8m/4NUk9CA=; b=Ug298TNcLjq/0dhk0ArWPlm/WgutFcIs9CJ3s0zTSKcEzYUC6tXrS6HE 9foXwpe3vCdFzKHDvsuU5qDETfe+Dsd7wmlQgu7/eSbURy7livKMGE0dr upyShuMRWSIXohF9H3LdcIVmstYTyW6D1DX5xMs2tH79Z3NE6+tLvYrHL k1RxVUB+jOAa/gGK49EEYSVE19pljvRs7bw+9tNrIPbAeXM0EQxlcam0T eLL0bvIJ9oQhLfit72ll3CtTJW+sbyIkHVVuMS9XdyXpldPB1vaWZzldg 0v6iAh+Z0y0bXqwh5EEqtjP1e0fBqt4XI4BfHUa53CXC0A0XLiEh/AIMv A==; X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="334836143" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="334836143" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2023 23:27:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="815639271" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="815639271" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga001.fm.intel.com with ESMTP; 23 Feb 2023 23:27:25 -0800 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 Subject: [RFC PATCH v3 26/32] x86/fred: no ESPFIX needed when FRED is enabled Date: Thu, 23 Feb 2023 23:01:39 -0800 Message-Id: <20230224070145.3572-27-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230224070145.3572-1-xin3.li@intel.com> References: <20230224070145.3572-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758697429546271498?= X-GMAIL-MSGID: =?utf-8?q?1758697429546271498?= 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) 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..48d133a54f45 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 don't need ESPFIX */ + 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 don't need ESPFIX */ + 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 */