Message ID | 20230224070145.3572-26-xin3.li@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp758019wrd; Thu, 23 Feb 2023 23:34:23 -0800 (PST) X-Google-Smtp-Source: AK7set+xZy1sYWVuq3c1QqC6VO/H5vyZczn+N1wVDtFG7sfRCfnFz6PbhIwDs7Rz/ZCzAsf5Zdrk X-Received: by 2002:a17:907:1623:b0:8b1:76dd:f5f6 with SMTP id hb35-20020a170907162300b008b176ddf5f6mr37487939ejc.50.1677224063205; Thu, 23 Feb 2023 23:34:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677224063; cv=none; d=google.com; s=arc-20160816; b=JG3INlZjm8PuesC7OvG1jlrmQQv5JHA5i5ZrVnQqUhb2lCI8+FyUeDhpKCpDsPKEjZ dAXH149kCxpsOre8niXtDGPMag6uedrzXBb2SXWkC+hc0xoGF9RSKSMzdo4v3e+gLPYF upvK2T7heE34M5zghbneN+Pgbmmi/pMqY5sFroY4CY/OaUl6pfx0jhEQnxr5vCdnAXms ZYANqqYumfdCaroYnxkdBXh8413ny71Xa+3FFsP1k1HwtIlvuY/NFL+FXtFqoY4gmBXG +8Nq7HDJ2gDY3XZKKhtPv7Tlzwo+q1LIUnmJ5Ms6JQVZo19yhWAhW46eZ2BJc+bS/mag ZoRQ== 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=gbCpSh6dFq5mTQGnLVcVJyqbvvBDE6ZceL50I5wGNa4=; b=HEJYzAndkD4esZv7hvM+AVrIej5hn0PGR9xP4g+ekBF9mKydmOF7aVTVZnu2nhN+sz t+nDqluv5sPqoGEnE78sztJijQDqxnWDdPehUaxQEjrHdeGe2WxnQXaqfa+BLP74ZDLH PP213sayL6HOjZpvRXPm6EPOTWmWNAiRHuVE0hyTaLHqST3eRtDcScbM9KHW/s8+nzjc 1zxIpnRCFZaj9CaMhnZbNx5FlQXpz5p4RGaV4JxBg6dQ1AfVfMijHF6ydCdqoSmjK2R6 k21SmWoGL5pycMf4S00xf92oAc4cyw/PR94jm/9GpKt8dEoLfEcfx8fqjz/ogI5RBfvY xSFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dF19NyBl; 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 zy24-20020a17090734d800b008dc8bcebff0si12082896ejb.341.2023.02.23.23.33.55; Thu, 23 Feb 2023 23:34:23 -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=dF19NyBl; 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 S229510AbjBXH3g (ORCPT <rfc822;jeff.pang.chn@gmail.com> + 99 others); Fri, 24 Feb 2023 02:29:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbjBXH3E (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 24 Feb 2023 02:29:04 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243CA93C9; Thu, 23 Feb 2023 23:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677223697; x=1708759697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IYVs/dNGzaWmYDt7WgVNUnSvBB8Ri3wL5GZJW6QmAc8=; b=dF19NyBlwnjYt1fISsvRlKjJE2K/srB3R6aGGkXaFTq0CkkQHzBimVc8 LErz/Vwsld5FxdVlm+B7negN6kvOVOqliErTqzMWa1o6ZLYtELMTdG4wy jyuy+2IGuTq9U5d1jr5SAhcKd/sUOIB99McZzJeF2DnblyVjzYHOb0k3l 6v0YzigsCBFHRhl6F1fBhT4JvdTjoCgzUjNPW0KLqePzlj6nkyfuYk1vp m5QsXHESJCN6ctfxU1o3PiCoyGtMJ5PuR+w0LBS3OteWIYTJMaeDOxJpT FiPP+DccddIFUm9YK+yf8FcMKhAIoMkuXZGPUq0dX6eHLpzNZKbZsz957 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="334836126" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="334836126" 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="815639268" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="815639268" 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 <xin3.li@intel.com> 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 25/32] x86/fred: disallow the swapgs instruction when FRED is enabled Date: Thu, 23 Feb 2023 23:01:38 -0800 Message-Id: <20230224070145.3572-26-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 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758696899132873531?= X-GMAIL-MSGID: =?utf-8?q?1758696899132873531?= |
Series |
x86: enable FRED for x86-64
|
|
Commit Message
Li, Xin3
Feb. 24, 2023, 7:01 a.m. UTC
From: "H. Peter Anvin (Intel)" <hpa@zytor.com> The FRED architecture establishes the full supervisor/user through: 1) FRED event delivery swaps the value of the GS base address and that of the IA32_KERNEL_GS_BASE MSR. 2) ERETU swaps the value of the GS base address and that of the IA32_KERNEL_GS_BASE MSR. Thus, the swapgs instruction is disallowed when FRED is enabled, otherwise it cauess #UD. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Signed-off-by: Xin Li <xin3.li@intel.com> --- arch/x86/kernel/process_64.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 57de166dc61c..ff6594dbea4a 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -165,7 +165,8 @@ static noinstr unsigned long __rdgsbase_inactive(void) lockdep_assert_irqs_disabled(); - if (!cpu_feature_enabled(X86_FEATURE_XENPV)) { + if (!cpu_feature_enabled(X86_FEATURE_FRED) && + !cpu_feature_enabled(X86_FEATURE_XENPV)) { native_swapgs(); gsbase = rdgsbase(); native_swapgs(); @@ -190,7 +191,8 @@ static noinstr void __wrgsbase_inactive(unsigned long gsbase) { lockdep_assert_irqs_disabled(); - if (!cpu_feature_enabled(X86_FEATURE_XENPV)) { + if (!cpu_feature_enabled(X86_FEATURE_FRED) && + !cpu_feature_enabled(X86_FEATURE_XENPV)) { native_swapgs(); wrgsbase(gsbase); native_swapgs();