Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1190005rwi; Mon, 10 Oct 2022 12:32:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM50RiGsPQhlQcEQ3KmCEu4iQ8sCl0/621iAGk3987FhP1QqftYCpbSWvz9+cWpl7q6MiOCf X-Received: by 2002:a17:906:ef8f:b0:77e:44be:790 with SMTP id ze15-20020a170906ef8f00b0077e44be0790mr15869008ejb.409.1665430334201; Mon, 10 Oct 2022 12:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665430334; cv=none; d=google.com; s=arc-20160816; b=sho7KWoPXTGqbzJmWg+YhCPEQwsAYfEfOQAnYi1ncQRmzBwm+mvh9ojgo1xtid/VGU sgiGRG5gxPE7wiI8QzhE0+1PLOR4rP2hq05hVWfUEkAlP9VggoxvKymdjDUdCDnaH3Gt RhPx5ngXoatrLwunsEnMuAPtWRJFxBybmqyF99Cj+WNLGirfGJ0nzMxNNEGEGV/Yosy5 hsKEw65ySz1SPNlKhnL6RegyP3BPG1sfp7Z0CtKcuHgkKhOxZ6UromwFWooy4uV6RT10 4f9jXS/eH96Mq0SNaVBT5FZHN+eOx9un0mWxPUsI3Q0Gi7eqyfOD1K736le3JlEYWXeJ UJuw== 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=sRtloaWjWBfahGs+pTmwPTB/m1+u657CnKAzpFkrBpA=; b=ZSoPeIswpD3K3gzs7ZV8U4+8x0rsLMMLuxgoKKxlxlh6wN/S8Y13y8iP+tYldzFaFR x2TiQIfe78VUNvuYZLnxuyaQwnla2YenSu1OOt/Hn/iZtlCAi1TjyGPLQSJ8gWwmUA2A 7OJ7Qa8zLIQB5uaR4g4aeP6IVi8XUerXWumdpIm8AITeBFJt1pm6EtDaogpkF2PSNoB+ 88tDxVDp8ppfDtb4QjFqzQ1CG+HXbOPCLJMh52r+AyJg9ZlNQ6jEDg+2q70qvz1kIQv7 BePh45ZN0NmcsgwqQrxWCUZ3ZbviGyqmqRTlcTALBZwIm6NT3kWyhBmpmWte/2dYki0p 3XCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hpn3hKrQ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx17-20020a0564020b5100b00458ff0764casi9561907edb.95.2022.10.10.12.31.35; Mon, 10 Oct 2022 12:32:14 -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=hpn3hKrQ; 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 S229880AbiJJTYA (ORCPT + 99 others); Mon, 10 Oct 2022 15:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbiJJTXw (ORCPT ); Mon, 10 Oct 2022 15:23:52 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9779760693 for ; Mon, 10 Oct 2022 12:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665429831; x=1696965831; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UDzg+9uANYdDBV+Ra3lQotFnvAmXOEkeoHs76rgla5s=; b=hpn3hKrQYc9pddwQOHPLGXhPHPQ2LwXEy0isutX4XzT34GSAX3cRTLzQ /idZjgPD2njUNXCWmkNIWvZbRdHJmTxFQe3/1pHiEFs/R2Dd+XnEwamLy wRlci3Ok4kE6nMs9RCzX2IJEbLBqc71TnAOhCsdOcW3325BK1Qivx1B23 rJ09ohX5541HChrH5qBXZslN64UESSoZTlGrqCWTXX8jpSCAlOEwduAuM 4nBpa7negTaJY2YpB+B4M1i64eGyxxy21SDAon+9mqAfMWTZKvFSxyLlY Zy7ITTwMuINW0BlVsEgCEtnNeruFTsURbTbKMmhDV3LJXVa2J0yGtb3mW Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10496"; a="284044528" X-IronPort-AV: E=Sophos;i="5.95,173,1661842800"; d="scan'208";a="284044528" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 12:23:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10496"; a="694762688" X-IronPort-AV: E=Sophos;i="5.95,173,1661842800"; d="scan'208";a="694762688" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga004.fm.intel.com with ESMTP; 10 Oct 2022 12:23:49 -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 Subject: [PATCH v2 1/6] x86/cpufeature: add cpu feature bit for LKGS Date: Mon, 10 Oct 2022 12:01:54 -0700 Message-Id: <20221010190159.11920-2-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221010190159.11920-1-xin3.li@intel.com> References: <20221010190159.11920-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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_PASS,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 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: Xin Li --- 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 ef4775c6db01..459fb0c21dd4 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..459fb0c21dd4 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 */ -- 2.34.1