Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp30060imm; Mon, 4 Jun 2018 12:25:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKb9V/kcgjSwnyYDVuwTODaWIRxqXzPw8LbfJ79iwuHzczk0NnAK1D4ZJ0P5iyWTsj9Kg+n X-Received: by 2002:a63:304:: with SMTP id 4-v6mr18038979pgd.290.1528140358990; Mon, 04 Jun 2018 12:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528140358; cv=none; d=google.com; s=arc-20160816; b=zgKh8noHKexlkJSVnb66MX6ttwvdCDtAr7ovmoc7/Xduu12N67Jn6HTyPMObvCVhdI U8ExFKjoe+Z+jWbxoNKaWinFX06ssfarRQPwCwjFciiVoC/UB+wfBfGM3ii39+TBmR+P zvUGclRoYnkgOyNATDUQH1yOnMNREnj8pPml/nJB3+eFym+/u/7hH2OCzgscSFnxmBnX O7AO1gzQvMUWujBL4AOCfrEUQnFLsuVzXh0i3Bga4jfqIWBwiQXFgHD69KzqZXm3UTbZ a8jkmzEV9aWRKls+RlN1MDc3Q+jSt5/YC8xgmFarkQ2WLJZZ/6iwZrlOgiR1jXgg19v3 MXmA== 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=gfIx9uOmTpCUcUhKcSkYKie2LUjnC9Q+p5/wXgq6OUA=; b=rvyflTLr6O/7huspnRw/PsR7yzgW/f5bqqOS9Wb8U5wo/tk/oS7jllcVdQAvowBpeS dlYvQVH0int3VbCtMor6cQ8AgLStoKaV98hvl3/L5T+Cozo7l8Qar3KtCsZOLJS4ophm C0Y6UIEMUGLBbg/Ji7sYCfj0WBwI7CpQKpsELIHc/mVXPec4A+27nLZX6dhbR5OAY8uk fuIjF6N9oVXNeyBZB8oK7ET5waPC6y2MRmwtmyYli9etoriPmQwg9IMU9qCH1zejLTGe mzgCLVob04+k0l2+v0mYWmP1PvpQIZsDHjFEWTwEJRul1CsXlvJETA5EpC0MbLQzsT8S XERQ== 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 c10-v6si27591407plz.190.2018.06.04.12.25.44; Mon, 04 Jun 2018 12:25:58 -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 S1751379AbeFDTYy (ORCPT + 99 others); Mon, 4 Jun 2018 15:24:54 -0400 Received: from mga05.intel.com ([192.55.52.43]:40504 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751164AbeFDTYq (ORCPT ); Mon, 4 Jun 2018 15:24:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2018 12:24:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,476,1520924400"; d="scan'208";a="64240688" Received: from chang-linux-2.sc.intel.com ([10.3.52.139]) by orsmga002.jf.intel.com with ESMTP; 04 Jun 2018 12:24:45 -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" , LKML Subject: [PATCH 4/6] x86/fsgsbase/64: Factor out load FS/GS segments from __switch_to Date: Mon, 4 Jun 2018 12:24:27 -0700 Message-Id: <1528140269-26205-5-git-send-email-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528140269-26205-1-git-send-email-chang.seok.bae@intel.com> References: <1528140269-26205-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 Reviewed-by: Andy Lutomirski --- 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