From patchwork Thu Oct 13 20:01:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 2357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp465467wrs; Thu, 13 Oct 2022 13:25:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qwdGFlu6I0RfXh85wRnAMYV1qvIQqta47eiaeFtNqKFzqiMdlSl487lsP6qyKdQDT8HFK X-Received: by 2002:a17:90b:3892:b0:20d:4bb5:91fe with SMTP id mu18-20020a17090b389200b0020d4bb591femr1714250pjb.31.1665692730565; 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=pf9E17wiupegvI2RyHtxruXPNm/EmRzwZiVqWqCB7osFjMPKBfoXrJmoXYHNR/x1ou /gsJ9F0LMcT9NuGL4YCr0+piJPp4Jki6uRvOKJhTZr48yJ8WczDNP7AEKqQ3DK00GUlz Ti8yYO+OpTSNoWfAMKNaChv33uCkjC55t21YWVSnYiPkWYz4LvemP3f3wzueQ8fQn7Bp DLye6EF0veCWOjJHgIJjjfhACtXE1FIMQKtcXyxu3/UA+tVVLYsc6FS+P+I2Tj1W9jJQ X27yaP22X2gtTaJU8ZjoCOkSkbiYFdJHUDbG+2dSfEwTqgkzV2rOVNx9obxoCjby6Al6 YgJg== 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=pZm/kyqoGIWzVOoMvTkc5/EE4DN9bg8f556Rl51v5Cs=; b=HubmbfQDzujLNB8CWC/Yrhw2P7QImGYCfXj804eD3ohXrIcLplSXuqnqcc1kWpLCP7 GUhioMGP7F4aBkBH9tplCXIETegjlid993dhLgHYiNHDsEKBhm4On8Y+tQ8HTmv47GLB XGyiA0AeV6RUGT0YrfBhJ2IPstH2KXaiQ3K+fxGB8CyG0WJOGJdYqqD44VgsvcfraR/6 QDeoepBDv1K4lD4swmRAkQtazKgXMva7eh55oQ4MmGGrQURmot6IJy8gt+Azrp2+7jLa SMTs/LJmiYdKtJvumH69LCSkwEopRd5spdr5aI/hOzhLG4VhvK+jGcGLarl4Tj3/xjaG +UWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AIgriEcA; 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 e128-20020a636986000000b00460a5961827si344004pgc.651.2022.10.13.13.25.10; 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=AIgriEcA; 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 S229913AbiJMUXx (ORCPT + 99 others); Thu, 13 Oct 2022 16:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbiJMUXc (ORCPT ); Thu, 13 Oct 2022 16:23:32 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F905159D51 for ; Thu, 13 Oct 2022 13:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665692611; x=1697228611; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=juR16UITaT3MxswvlHsDaympRivW8hA0yaAGOHpwels=; b=AIgriEcAIKcaPZQ9w+sCBIVNwWtdvVmxgPbSm6YZejMgp383TsY9q3ms nDOwxkaO25BSZIdyr08va/vlBv7K0Vf4VGpSu8VQQ1nsT/p996EKL2ouz QoHSFVLWE+KJVJ8MOt1oSg6VcyCcEHcXej4xfzKYSguf1wEd2y/xfKvKQ K/HbzUMyONCtHXCrFBuqSOkghZ9SwPAkWPOrpATVKwlBQvCcL5qtpM3d6 SXXEST7KgnXiT3+4xBSTry9pSzWgpR/0W1zCHOh8IBPcisXZksvYtSFht TrLtJ4BoLX9hqIxtYhpLNve3Yl61a60tINmNuQcKBIPDR/cR9PS3uvHkp g==; X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="302808963" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="302808963" 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="690271051" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="690271051" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga008.fm.intel.com with ESMTP; 13 Oct 2022 13:23:28 -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 5/6] x86/gsseg: move load_gs_index() to its own header file Date: Thu, 13 Oct 2022 13:01:33 -0700 Message-Id: <20221013200134.1487-6-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?1746605420605888313?= X-GMAIL-MSGID: =?utf-8?q?1746605420605888313?= From: "H. Peter Anvin (Intel)" depends on , so in order to be able to use alternatives in native_load_gs_index(), factor it out into a separate header file. Signed-off-by: H. Peter Anvin (Intel) Signed-off-by: Xin Li --- arch/x86/ia32/ia32_signal.c | 1 + arch/x86/include/asm/gsseg.h | 32 ++++++++++++++++++++++++++++ arch/x86/include/asm/mmu_context.h | 1 + arch/x86/include/asm/special_insns.h | 17 --------------- arch/x86/kernel/paravirt.c | 1 + arch/x86/kernel/tls.c | 1 + 6 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 arch/x86/include/asm/gsseg.h diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index c9c3859322fa..14c739303099 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c @@ -34,6 +34,7 @@ #include #include #include +#include static inline void reload_segments(struct sigcontext_32 *sc) { diff --git a/arch/x86/include/asm/gsseg.h b/arch/x86/include/asm/gsseg.h new file mode 100644 index 000000000000..5e3b56a17098 --- /dev/null +++ b/arch/x86/include/asm/gsseg.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_X86_GSSEG_H +#define _ASM_X86_GSSEG_H + +#include +#include + +#ifdef CONFIG_X86_64 + +extern asmlinkage void asm_load_gs_index(u16 selector); + +static inline void native_load_gs_index(unsigned int selector) +{ + asm_load_gs_index(selector); +} + +#endif /* CONFIG_X86_64 */ + +#ifndef CONFIG_PARAVIRT_XXL + +static inline void load_gs_index(unsigned int selector) +{ +#ifdef CONFIG_X86_64 + native_load_gs_index(selector); +#else + loadsegment(gs, selector); +#endif +} + +#endif /* CONFIG_PARAVIRT_XXL */ + +#endif /* _ASM_X86_GSSEG_H */ diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index b8d40ddeab00..e01aa74a6de7 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -12,6 +12,7 @@ #include #include #include +#include extern atomic64_t last_mm_ctx_id; diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h index 6de00dec6564..cfd9499b617c 100644 --- a/arch/x86/include/asm/special_insns.h +++ b/arch/x86/include/asm/special_insns.h @@ -120,13 +120,6 @@ static inline void native_wbinvd(void) asm volatile("wbinvd": : :"memory"); } -extern asmlinkage void asm_load_gs_index(u16 selector); - -static inline void native_load_gs_index(unsigned int selector) -{ - asm_load_gs_index(selector); -} - static inline unsigned long __read_cr4(void) { return native_read_cr4(); @@ -180,16 +173,6 @@ static inline void wbinvd(void) native_wbinvd(); } - -static inline void load_gs_index(unsigned int selector) -{ -#ifdef CONFIG_X86_64 - native_load_gs_index(selector); -#else - loadsegment(gs, selector); -#endif -} - #endif /* CONFIG_PARAVIRT_XXL */ static inline void clflush(volatile void *__p) diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 7ca2d46c08cc..00f6a92551d2 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -32,6 +32,7 @@ #include #include #include +#include /* * nop stub, which must not clobber anything *including the stack* to diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c index 3c883e064242..3ffbab0081f4 100644 --- a/arch/x86/kernel/tls.c +++ b/arch/x86/kernel/tls.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "tls.h"