Message ID | 20230307023946.14516-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 v21csp2209939wrd; Mon, 6 Mar 2023 19:08:19 -0800 (PST) X-Google-Smtp-Source: AK7set/nCwHClVaVGIfGvjrYvPggRZ3P7oMkHQP/BOkKh8I7W3dVwUHuUucmi+ntp1wWFtLLJYWP X-Received: by 2002:a05:6a20:656:b0:cb:a22e:d33b with SMTP id 22-20020a056a20065600b000cba22ed33bmr9454371pzm.42.1678158499028; Mon, 06 Mar 2023 19:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678158499; cv=none; d=google.com; s=arc-20160816; b=jdG4hTWOzhXuBqJnIK1bTYlbpsNjQAJEUnZOFO9XfyR1VdQ36ERxKE7KyCwfGeeZjI YPfqesu/XhcvoVzmKxa1EpM2hj16UeIpPjCE4mG+w5zbmWb0xrJuYxQpABYj42SINvTR WeXaqacmvlaNr+Jht7KcL77MRHLeon7XPJ0k9noG/OwGSkNDQe+47I4C9dBG85rUJff+ 1wSp/zDqn0yezEesgLuaS3mW07AVLznc7Z3ScSr7GMeI1BuKoyv9ReAXbyDtgctNzg7V ICb6BvqjOoJ4LYkpMivrfh6ngHCUJW35WgbUmi5GlzOV2hODTxNaWV3y/uro4+sB1Kna WOcA== 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=CAwwHxdmySeTwUiXJxBjwIE6ec+fx+NkUFLB6oSL6+I=; b=wgLTjeuIL8ffy/4JBHZXi+XKFqjPtzRPhXjHA3zNyQbLL8Cb3S9PqOM1RygWTXNjK1 DGYxqUsVOczxgD6Omue29xShNNjoDvjiuA88BrKIMr34jsmjTVEO03PMyHjOxT+Ez2uY bN1g1tIjEmuTOdOMmwcz8ndcQqR6GCBpZYFofZrX2/sfnG8+cv329hp1lBf/+ElZWcKX HwsjcjmIrTgMehWE1rVh2FE3QAnXmAx7Gw4RBlupqPgsu0fhKqh1P7AIKTdDLnnPNYTE 3gxDbB93qmDIGdMsmNjZ+5NZ2TmTdu3PE0dlBRdUtJiI0LSOb9u1wkc2u9GefrvpNorH j2Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hNiJvt5C; 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 x26-20020aa7957a000000b005a8adc698casi10178149pfq.189.2023.03.06.19.08.06; Mon, 06 Mar 2023 19:08:19 -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=hNiJvt5C; 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 S230508AbjCGDHY (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 22:07:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230216AbjCGDGl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 22:06:41 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEE4D7C9F0; Mon, 6 Mar 2023 19:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678158336; x=1709694336; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JCKu4lASdy4fofKGHW4gy5ePwfNi7YQxHJ13+kwlv3k=; b=hNiJvt5CUHaZqkc2NNqWSVDWOOpAS3RE4qJ3csDtOu+a/RtIoK3BAL0d bCxiaqxPJwkveCoV6cABaOSytOHRNhMVY96mAeDFtpH68GN0mZ+VMbBod XXEI3p4VgTMQUid00FnsOpWJVK8smeodNxX5uoWXkNKSA/Fa92RCU+Tee q1/nJWEy+1tbnmWdpJ9bjuwp8NKyZwSv8pWYrw3Ow/jhywkFgnI7BGquD OYm92CJ02tdL7CDiH8hXlC5O5XWEzR+riJd6M2XEnW3JxvjopomjTWxBw UXOZ4ui9XJ/toqNN3Y/yt7GH2BZGi+0B7GZZwyWpSpGGWaGpdTT7bh1k8 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="338072548" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="338072548" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 19:05:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="676409897" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="676409897" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga002.jf.intel.com with ESMTP; 06 Mar 2023 19:05:20 -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: [PATCH v5 25/34] x86/fred: disallow the swapgs instruction when FRED is enabled Date: Mon, 6 Mar 2023 18:39:37 -0800 Message-Id: <20230307023946.14516-26-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307023946.14516-1-xin3.li@intel.com> References: <20230307023946.14516-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, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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?1759676726540614920?= X-GMAIL-MSGID: =?utf-8?q?1759676726540614920?= |
Series |
x86: enable FRED for x86-64
|
|
Commit Message
Li, Xin3
March 7, 2023, 2:39 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> Tested-by: Shan Kang <shan.kang@intel.com> Signed-off-by: Xin Li <xin3.li@intel.com> --- arch/x86/kernel/process_64.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On Mon, Mar 06, 2023 at 06:39:37PM -0800, Xin Li wrote: > 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. ^^^ --- new word :-)
> > 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. > ^^^ --- new word :-) My stupid fingers...
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();