Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2840560pxj; Sun, 23 May 2021 12:40:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlG7OTKhhp6sorwOjq60pqz4WrvlLEDyiVZFk7uI5GSmaDueJ31YC9egJ6hMHInmwFEblj X-Received: by 2002:a05:6e02:1b87:: with SMTP id h7mr12165555ili.185.1621798857144; Sun, 23 May 2021 12:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621798857; cv=none; d=google.com; s=arc-20160816; b=JW88iie/KtAN6Hh2gsi2sKlKyxoqrOwnZ0A6E0tK6b86wCoZRVGgwbDadkC97S27Zn PCSc8LP4qAtO5VBTggUMLeUkj5v8u7ldPyHCPF27Emp8jxBI401CMsH7il03XEEinWW+ uRfsI+3Z5pQ0dXSLm22c2ADOdG0KjTwSx2JZ8K+Y+VK2I38ctFvX23RZ7jp2ovaZjbRr Xmo/CGOfiQs2if8KM7PtSyBjFKUDAP6fUp+ulnq06kjMmKHKxlmi82SYrKLeA97C2tqe pygAJhEZyIdiyz/5U5yJAIhnPgOAlFKYD7ZV4ExULleA2S+4KwnkUBW8MHRjjAUXfC3v suAA== 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=ReaLDPQMplJqOu4bRUkPG7ENwzNInHAjgIbZ5KUfiwc=; b=EynekegRYIgrhvPIp0TbEhIUloz6xO+mlGbkuoqFfNcn8yGemSQc3sDXGekubJpBK7 gknxlRlIkUT9GsNIUVpxJ6RsJgqKdcYipf7fH10lzge+cFwvomzy+jKbplAa8jrbu+V5 bHsjQBOTF6VeobvgmoaUwJpztERWjdynK9fJEDq3DSWJ7jQrHVFbwqMcicqwdEH6eBdG SAfbc9W6XAZwCXYslaP+lrHSZTvS9r/eJNi+04qcQ3AaAdGcv7XLW8d9hdUwifR9DMYU k2yPp7C4Zh2JbwvQjkp9qcFLa5qAYeWZtIr0job6pmZxXyP++F8GHF8jTHa4DHfjPYnY H/xg== 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 n8si11879663jam.34.2021.05.23.12.40.44; Sun, 23 May 2021 12:40:57 -0700 (PDT) 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 S232039AbhEWTkF (ORCPT + 99 others); Sun, 23 May 2021 15:40:05 -0400 Received: from mga11.intel.com ([192.55.52.93]:31998 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbhEWTj4 (ORCPT ); Sun, 23 May 2021 15:39:56 -0400 IronPort-SDR: P90B+WqNbH42NA0G0PbdcM5R0eU9XH+dGPcOjDPufQo6gFI/IUQxmhGb+zV+bDg3ndOnxhC9E3 iDQwKwtG8NNQ== X-IronPort-AV: E=McAfee;i="6200,9189,9993"; a="198740676" X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="198740676" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2021 12:38:28 -0700 IronPort-SDR: 2jr+pu/3oLl32YbNsPXiZ3PO24/Gh7icBbiRYnzLURXa5e8PjH8re1gppUtFntsYHer6nVAo1a if1gFeb624tA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="407467070" Received: from chang-linux-3.sc.intel.com ([172.25.66.175]) by fmsmga007.fm.intel.com with ESMTP; 23 May 2021 12:38:27 -0700 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 v5 04/28] x86/fpu/xstate: Modify the context restore helper to handle both static and dynamic buffers Date: Sun, 23 May 2021 12:32:35 -0700 Message-Id: <20210523193259.26200-5-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210523193259.26200-1-chang.seok.bae@intel.com> References: <20210523193259.26200-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 of 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 52f886477b07..830b1bc75ed4 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); } } @@ -258,7 +258,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 01c8642cb56c..b428ff496bca 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -9649,7 +9649,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