From patchwork Thu Oct 13 20:01:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 2358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp465469wrs; Thu, 13 Oct 2022 13:25:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41h9sFpqwjx1KWPpqg1zKraOptIatqMTrhfKQ0wUGKZiKcTKsZSaqpDPDl1sV/vGZgzLV/ X-Received: by 2002:a17:90b:3ecd:b0:20d:9ddb:f287 with SMTP id rm13-20020a17090b3ecd00b0020d9ddbf287mr8293506pjb.167.1665692730832; Thu, 13 Oct 2022 13:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665692730; cv=none; d=google.com; s=arc-20160816; b=JzO2pGu5k176OS4aVLgq/7KBbt/e4JQ3wN6z28OKi0h4pkb6aDWpK99HsHt3c2PngR y+/VgX+jYGY0PSGRtswXg7lf6wG5KQrN/GyY7QdWsccqN/nYH3bu9R7RJT0GXCCybJuX fUqlV3ZL/GadedJ1Uk0OKkErLajQURWwJWFeJTAhrvGoLYgSZQGE2pTA9ik5I56dn38J KofZvWFBBnSUx5kRFzyGsA4W8ZVkPXaA2DIXxufvG8ijv0Zj9+zrRwb6PLjyPqHDOVEg qFHsIQi/knqEXsfM77R76SepPMJmjG+uOSrlN9PEJzHBuxVoy+nwjAgw7SZtCi/B+EdF 307Q== 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=Cb8BtZdMSgiPx6gQlGIIHdDI30Su0G3adph+QJNDvSg=; b=nKNau9HmwAuCLizCNLqiZOT8ZdtszKKunM8u+3pMsIxYYWtgOpdX8WS3rWkO8UTFPa 0f6VFW5R2hPQzGaiOfWPLPMNJf8DdN7WrXvDR8/wr9Dze2j8ODFSkMctR18IIU9cm9dH 1hOPAVLtAofRT6av4XZjqjGJOshXavgy6Vg6gO344A4Kfv+VHcZBQVIHQitNuzDrYUOH 3EtqAiAaWSkYAhw+4rfm/9dgJ6NYiiIOjkQAHiEOxbpPKvoQOEYpnIWRVL+7yIcjtuZI X1fzcE9NVXN3dzADtJpjhHaJWJAvn/Ifn7t7jbB1FmWCzvsJJ9KOnNeXkQpVPCAfXkbv 5lmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T2jo2jPY; 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 n15-20020a170902f60f00b0017f8290fcf0si728873plg.272.2022.10.13.13.25.08; Thu, 13 Oct 2022 13:25:30 -0700 (PDT) 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=T2jo2jPY; 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 S229850AbiJMUXt (ORCPT + 99 others); Thu, 13 Oct 2022 16:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbiJMUXb (ORCPT ); Thu, 13 Oct 2022 16:23:31 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88B67159D4B for ; Thu, 13 Oct 2022 13:23:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665692610; x=1697228610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8RCzjNFiyTPAxja/GnLMgLgcV2ZImlmdTYbAFnTLKSI=; b=T2jo2jPYSGKBo149pgoWpiFM20creK0j/M1nT1o7lNOG0g3x3+RQVtMG ya0V45VnvkCAcqtWQXRMeP2wvaMjAcKM1eyaWxrn9FEl05vsp9PT3kUvV WaK9ssyed3dsWGOyl7/cnar3LkqYLrDTxJLTGg9HRfPClj7zXmoOpscoG cMXj7kqpnBDa8ycoMa3GPqg80ImsBYl0ao+eOdSdoJR5zCqxlNpgSWV4Z 0hVO/qtBuB+vcl46rrJ9lBwxTyi0Z6Lh+qjdyfJswr6Ym3lnIJbH7Wuoi OBqXMEwpTZL1ZZR+tmJ/Dt7TeTgjiuCh45eSSn5vCvxtM6ZatxKdzAUhf w==; X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="302808955" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="302808955" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2022 13:23:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="690271039" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="690271039" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga008.fm.intel.com with ESMTP; 13 Oct 2022 13:23:27 -0700 From: Xin Li To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, peterz@infradead.org, brgerst@gmail.com, chang.seok.bae@intel.com Subject: [PATCH v3 1/6] x86/cpufeature: add cpu feature bit for LKGS Date: Thu, 13 Oct 2022 13:01:29 -0700 Message-Id: <20221013200134.1487-2-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221013200134.1487-1-xin3.li@intel.com> References: <20221013200134.1487-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1746605420808099110?= X-GMAIL-MSGID: =?utf-8?q?1746605420808099110?= From: "H. Peter Anvin (Intel)" Add the CPU feature bit for LKGS (Load "Kernel" GS). LKGS instruction is introduced with Intel FRED (flexible return and event delivery) specificaton https://cdrdv2.intel.com/v1/dl/getContent/678938. LKGS behaves like the MOV to GS instruction except that it loads the base address into the IA32_KERNEL_GS_BASE MSR instead of the GS segment’s descriptor cache, which is exactly what Linux kernel does to load a user level GS base. Thus, with LKGS, there is no need to SWAPGS away from the kernel GS base. Signed-off-by: H. Peter Anvin (Intel) Signed-off-by: Chang S. Bae Signed-off-by: Xin Li Link: https://lkml.org/lkml/2022/10/11/1139 --- arch/x86/include/asm/cpufeatures.h | 1 + tools/arch/x86/include/asm/cpufeatures.h | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index b71f4f2ecdd5..3dc1a48c2796 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -308,6 +308,7 @@ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ #define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */ +#define X86_FEATURE_LKGS (12*32+ 18) /* "" Load "kernel" (userspace) gs */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h index ef4775c6db01..9d45071d1730 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h @@ -308,6 +308,7 @@ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ #define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */ +#define X86_FEATURE_LKGS (12*32+ 18) /* "" Load "kernel" (userspace) gs */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */