Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1089648pxb; Sun, 21 Feb 2021 11:04:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQrTMnfw6FwbGNDo1gVuvQOEoErhXtGMWO2PqhmQ87UwSumdhsb8CjLQZzLsj3sLIEJWtg X-Received: by 2002:a17:906:c455:: with SMTP id ck21mr18192665ejb.354.1613934262161; Sun, 21 Feb 2021 11:04:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613934262; cv=none; d=google.com; s=arc-20160816; b=ODC8aijEDoyVDKqVCS0s9t45oeCYDk7hPZA/yT6wAx5r1CYCyOrZCaMhrKjQpHcWwf 5EInlcv8bzVHCJ+tEuTSdP5bjhram3FYaz+WS6G8kkWi6dIhTnPl94sA9qUMEC1hg0z9 a9IoEtmpU/GXZX3+3bbYBsx26a6BDu2D5+ijCO0igTBm9FNlr3bDfhvrCX/SqX9Qy7Aq YWUXU7x+VLbbJ84T3nt2Wm9iUjz2JtQGlw60vbQwh3lo9KzRs/Dnk/jVfuap3k28B/fc JOpDQMNNaRHaM6Nmerg6/tieTdZdSPjA1ZIYfJ0wcDbFh1+8228PGD0k5+Lyjj0+bROf lDiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=1axhngAj2EVtD6e42qb9eA+IblHs6zdgPXmAJDhUJqI=; b=deM+lKDeVAcotBGcyBF9ILNcn0gI1zqco6K4Z3W7Icdrp9cLsNQGMwUAa7AXSPrgw+ bpalZPYKXlhe9fUp1vq5Qg5tiNXiqBy5EZ01fvEiCKsJPcti8Jvq36zVC2FjFk2KtNPz haee+ZEvD8vIJNvtV6rfp9XugrI/5G0RUR829faMgkuywPwsosC3Bl63lhMCVSWHfV9+ JagLGGo4753UJcGdceto8xnB4jUe4DgjbAbL6pkmf8GHtTx3kCKZ+rbtZ2QwTCplSjmA HMZJK4dpo3+eJ9Cn4BXsIWZp/5S2967wfsY6+MScepYLzXA4PdNxbhQWmxoaYUPvxv0F wSyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id g15si10128645edr.180.2021.02.21.11.03.59; Sun, 21 Feb 2021 11:04:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230349AbhBUTCO (ORCPT + 99 others); Sun, 21 Feb 2021 14:02:14 -0500 Received: from mga09.intel.com ([134.134.136.24]:2043 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbhBUTCH (ORCPT ); Sun, 21 Feb 2021 14:02:07 -0500 IronPort-SDR: QGSWx0DRrz3Lfv5P3X+rMwbzXIfxk6SLPgJo4zAvBGVsXdLu2XTx/TLgfDi94Bfc5WopKuhaMb RncTBvvmSnNA== X-IronPort-AV: E=McAfee;i="6000,8403,9902"; a="184382822" X-IronPort-AV: E=Sophos;i="5.81,195,1610438400"; d="scan'208";a="184382822" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2021 11:01:27 -0800 IronPort-SDR: Ysf2RZIskvNXoH8suu3ScNj3GRZjUQEmezzxdcQt9tI7P014yLuA6EC214DzBs/xjpMvlHsuQU RFmXEtBoxWaA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,195,1610438400"; d="scan'208";a="429792089" Received: from chang-linux-3.sc.intel.com ([172.25.66.175]) by FMSMGA003.fm.intel.com with ESMTP; 21 Feb 2021 11:01:26 -0800 From: "Chang S. Bae" To: bp@suse.de, luto@kernel.org, tglx@linutronix.de, mingo@kernel.org, x86@kernel.org Cc: len.brown@intel.com, dave.hansen@intel.com, jing2.liu@intel.com, ravi.v.shankar@intel.com, linux-kernel@vger.kernel.org, chang.seok.bae@intel.com, kvm@vger.kernel.org Subject: [PATCH v4 04/22] x86/fpu/xstate: Modify the context restore helper to handle both static and dynamic buffers Date: Sun, 21 Feb 2021 10:56:19 -0800 Message-Id: <20210221185637.19281-5-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210221185637.19281-1-chang.seok.bae@intel.com> References: <20210221185637.19281-1-chang.seok.bae@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Have the function restoring xstate take a struct fpu * pointer in preparation for dynamic state buffer support. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org --- Changes from v3: * Updated the changelog. (Borislav Petkov) * Reverted the change on the copy_kernel_to_xregs_err() function as not needed. Changes from v2: * Updated the changelog with task->fpu removed. (Borislav Petkov) --- arch/x86/include/asm/fpu/internal.h | 6 ++++-- arch/x86/kernel/fpu/core.c | 4 ++-- arch/x86/kvm/x86.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index 0153c4d4ca77..b34d0d29e4b8 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -425,8 +425,10 @@ static inline void __copy_kernel_to_fpregs(union fpregs_state *fpstate, u64 mask } } -static inline void copy_kernel_to_fpregs(union fpregs_state *fpstate) +static inline void copy_kernel_to_fpregs(struct fpu *fpu) { + union fpregs_state *fpstate = &fpu->state; + /* * AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception is * pending. Clear the x87 state here by setting it to fixed values. @@ -511,7 +513,7 @@ static inline void __fpregs_load_activate(void) return; if (!fpregs_state_valid(fpu, cpu)) { - copy_kernel_to_fpregs(&fpu->state); + copy_kernel_to_fpregs(fpu); fpregs_activate(fpu); fpu->last_cpu = cpu; } diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index d43661d309ab..5775e64b0172 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -173,7 +173,7 @@ void fpu__save(struct fpu *fpu) if (!test_thread_flag(TIF_NEED_FPU_LOAD)) { if (!copy_fpregs_to_fpstate(fpu)) { - copy_kernel_to_fpregs(&fpu->state); + copy_kernel_to_fpregs(fpu); } } @@ -251,7 +251,7 @@ int fpu__copy(struct task_struct *dst, struct task_struct *src) memcpy(&dst_fpu->state, &src_fpu->state, fpu_kernel_xstate_size); else if (!copy_fpregs_to_fpstate(dst_fpu)) - copy_kernel_to_fpregs(&dst_fpu->state); + copy_kernel_to_fpregs(dst_fpu); fpregs_unlock(); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index cc3b604ddcd2..dd9565d12d81 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -9313,7 +9313,7 @@ static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) if (vcpu->arch.guest_fpu) kvm_save_current_fpu(vcpu->arch.guest_fpu); - copy_kernel_to_fpregs(&vcpu->arch.user_fpu->state); + copy_kernel_to_fpregs(vcpu->arch.user_fpu); fpregs_mark_activate(); fpregs_unlock(); -- 2.17.1