From patchwork Thu Mar 2 05:25:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 63234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4063948wrd; Wed, 1 Mar 2023 21:54:43 -0800 (PST) X-Google-Smtp-Source: AK7set80gfHUcEK+mRlHe9RYynz/iPM41uZjZxKt2zCr1TQfJTJsegvEdw5kb1+XwfFdUXajq3YZ X-Received: by 2002:a17:907:7e82:b0:8ab:4c4:d0f6 with SMTP id qb2-20020a1709077e8200b008ab04c4d0f6mr12478906ejc.56.1677736483186; Wed, 01 Mar 2023 21:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677736483; cv=none; d=google.com; s=arc-20160816; b=m7KIrymuBjw1uwPD2cGJglYTnVEjkG2dtVFtNMkCTsvptghS0nFxwZsz0tDYrrumX4 xqz6ICIGLwd4QwZcUAE3HMvyWutKubCP33Svarb6FkXyxMAXh2AJ/7id+0gcYfRrEoib tt2NMsxBsIsv5Q9RDzXWrZlYBo8cpWrhZvAKibKfd95CttobGXGQ+ykK8TPvRkXP2n1H awgl/2UGc2i8eV+laNJ0qUB9dtgHJDIS8ikp3zY3c8/uUZ69hLu8LAFgrLWrY3gv1P0o +il8pd9vDTQ1WGSLx2FsbLCwgA7D3KxPngtFNH/3MpvvaKrHVMOVO5xD4ICRXDxQZh2Y iHEw== 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=vxjy11Tsv/mgkUj27ibhp2UA7uqHHL7WLXhaKKIvcCY=; b=b37DfR3WVKiPJcRwEYsQbE1kCGZRR5ETunOazv2CkcHuiAK3aF3rnaUY34bBnKstK4 KLM6o1ltKOmyYZjtv6nlAc7XiwyuQZ8aruFO14FSiPpo1gw27VBbqHZwZu8YTg0/YjMn v/cqcGQPiMrd/YveLWf4x95YDMVqDxP+/U5txVPoHk9qDBsFlrWFAxxSKhugZY8vCfXJ e0x3w861e6NLyir5Fm157O+wj5LJ0u+mKWEJLnyzcD+2T/07EaPHyk0/TY2erfRB3Uuv 3IhMatEIJNdlk7S5ydUKU04icjETzG5JapvFwRUp8Wx1dnfSYTHbGrDOj5vRfbsB5CJc F38Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HOuaorGB; 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 gg17-20020a170906e29100b008ceead154e9si1122787ejb.942.2023.03.01.21.54.18; Wed, 01 Mar 2023 21:54:43 -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=HOuaorGB; 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 S230166AbjCBFwx (ORCPT + 99 others); Thu, 2 Mar 2023 00:52:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbjCBFwT (ORCPT ); Thu, 2 Mar 2023 00:52:19 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25EA351F9E; Wed, 1 Mar 2023 21:51:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677736283; x=1709272283; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YTgEgmA3f1uzY8PacyZ6XmpZcGIgDW5/dB0vDrivilc=; b=HOuaorGBemCaZyBXmXxjQ3em0xKDFzaWI+0p/xIwjLYNrEyXINVbyvd/ V2k0p2wWGDZ909PSei7r4WXqq5jbtyCz3MDF+BxALl4p36ltvJ9/+iu0V 222gcU1HdYCOGedxtzc9L4AHP/c6Z+vEbRMXMg9dY2llo1hTI3cFLgTiM lnC8Ijk/rlC1fqD+z6j/zNgrO92pabtw6ZoHzdn+wpKm5oUhTB2Z0YGVT dyO20vr4uZQnB0sHpNUnezsUs1kbsFH+nuR+aPzCYlPj7ba4X+U416u/W 0aAdRHGolS0+xHULy4k9NyEuUjQUJGILmIyBhJLBYOF3007R7YDKZ/awP g==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="420887268" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="420887268" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 21:50:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="920530958" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="920530958" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 01 Mar 2023 21:50:50 -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: [PATCH v4 26/34] x86/fred: no ESPFIX needed when FRED is enabled Date: Wed, 1 Mar 2023 21:25:03 -0800 Message-Id: <20230302052511.1918-27-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302052511.1918-1-xin3.li@intel.com> References: <20230302052511.1918-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, 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?1759234210533899596?= X-GMAIL-MSGID: =?utf-8?q?1759234210533899596?= 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..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 */