Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp879848imm; Thu, 31 May 2018 11:00:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK6CfuikgQiXDx9ZAzsz1H0OTKQRDqst1ZBznNEq4wfZIy4XOeLw/spc34y6/7i80jU13lx X-Received: by 2002:a62:ecdb:: with SMTP id e88-v6mr7851933pfm.16.1527789648344; Thu, 31 May 2018 11:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527789648; cv=none; d=google.com; s=arc-20160816; b=CTLSoVdDlMkmmpjOwrszbG/c8zros/OR/SbwI0zq1qUQuUEr3Ij6koTSh2Y7Z0DnXc v7yISUJNV36wiRH26bxzK3nmdDyYuehsiR++/einhpHDaHqskb62bp2jgSTMjSQcnugK 472p0btkUqPcO1ix+QYV9SVXz5XT05EyAuQEg0myAE3uPG0iY4KkhIokITDoISsahZhm 7efVpVZDGqjm2hOHvED4OxUzJgY763Q+3Mn1Syzzvqp7tnV5AkdSYeh99mNLw256Xnri 60Ysis36uWPx5dtzf6bQYSVbzW7oDa0sCaIHW9a6q2ghCULXX7S4G8ErJ7V68q+Uad/p XODg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=DdHyoKL9hQF8o/NASq2gykaTmRZmDH4w68++yGiE3tQ=; b=oQHOCMis0mgFrflAcc3SvSET5MyX8cbOgTWB/etxPanVNojfwjlLJmvf/zpXw80Oty C0reP7nEMRkUfnuBPgMM0KzKReypa8AkJBBcH9LzhYMtaepJ4e01Y2PfX9mWaj4OKYM1 52GZx+N2UPnn23oTJXzVs0cNqNrhSIqEQ7CDbv17tVkl1zbHLzmCCB0OLzr6pR3xtXJC CTEaj3mYr5rhdu/smSkm0EKzqcuar96Slm3SCZyDtW5vudp/3NLzJLHpAPD14fWzeOin njDGHsOIp/qvTpIz+Rqr8L7HjBjtZM6ZwWMQ4wIJvfTTIMPYk0jb+5VQ1KMo7Tp4Gv7g qfQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11-v6si24066975pgp.331.2018.05.31.11.00.34; Thu, 31 May 2018 11:00:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756006AbeEaR7L (ORCPT + 99 others); Thu, 31 May 2018 13:59:11 -0400 Received: from mga01.intel.com ([192.55.52.88]:18552 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755933AbeEaR65 (ORCPT ); Thu, 31 May 2018 13:58:57 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2018 10:58:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,463,1520924400"; d="scan'208";a="60725507" Received: from chang-linux-2.sc.intel.com ([10.3.52.139]) by orsmga001.jf.intel.com with ESMTP; 31 May 2018 10:58:55 -0700 From: "Chang S. Bae" To: Andy Lutomirski , "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar Cc: Andi Kleen , Dave Hansen , Markus T Metzger , "Ravi V . Shankar" , "Chang S . Bae" , linux-kernel@vger.kernel.org Subject: [PATCH V2 04/15] x86/fsgsbase/64: Factor out load FS/GS segments from __switch_to Date: Thu, 31 May 2018 10:58:34 -0700 Message-Id: <1527789525-8857-5-git-send-email-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527789525-8857-1-git-send-email-chang.seok.bae@intel.com> References: <1527789525-8857-1-git-send-email-chang.seok.bae@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of open code, load_fsgs() will cleanup __switch_to and symmetric with FS/GS segment save. When FSGSBASE enabled, X86_FEATURE_FSGSBASE check will be incorporated. Signed-off-by: Chang S. Bae Reviewed-by: Andi Kleen Cc: Andy Lutomirski Cc: H. Peter Anvin Cc: Dave Hansen Cc: Thomas Gleixner Cc: Ingo Molnar --- arch/x86/kernel/process_64.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index e498671..cebf240 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -279,6 +279,15 @@ static __always_inline void load_seg_legacy(unsigned short prev_index, } } +static __always_inline void load_fsgs(struct thread_struct *prev, + struct thread_struct *next) +{ + load_seg_legacy(prev->fsindex, prev->fsbase, + next->fsindex, next->fsbase, FS); + load_seg_legacy(prev->gsindex, prev->gsbase, + next->gsindex, next->gsbase, GS); +} + static unsigned long task_seg_base(struct task_struct *task, unsigned short selector) { @@ -588,10 +597,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) if (unlikely(next->ds | prev->ds)) loadsegment(ds, next->ds); - load_seg_legacy(prev->fsindex, prev->fsbase, - next->fsindex, next->fsbase, FS); - load_seg_legacy(prev->gsindex, prev->gsbase, - next->gsindex, next->gsbase, GS); + load_fsgs(prev, next); switch_fpu_finish(next_fpu, cpu); -- 2.7.4