Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5478183imm; Wed, 12 Sep 2018 06:38:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY9mHTG+bKLEiX1hdI87cMuUCfbQxZXNERwcXn2cf+lfx80DybD8mctSIOciwhGkz/7OGRH X-Received: by 2002:a63:904a:: with SMTP id a71-v6mr2343935pge.339.1536759489969; Wed, 12 Sep 2018 06:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536759489; cv=none; d=google.com; s=arc-20160816; b=xRvVVC7dnUSek6prdO6ssYeQX/kGV6LC3XX+bLPzAH2+J2fD+y3vamxofFNGZqNlK+ kH1B9KPI+lYb4fecHe0IqRvhM1LO4K3WWy/CA/MSdSZqbBA4QMWFdIzoyv91Z1bNmiLC LsJs2Q4YAwo6raMBurhFLEFPjDqNG/L7nEq2GYVQUdRAzAtF+Vc0y1syp5Bcl0zLKM0X JBxHDxjVsKEOF1G9Hj7cPlc/1Uzp/383I0Ti3IXEaiRr8thCvuXE+0Ll3OZfWn/w6MnO bew4wBkGPzUNutofHjgAzTqVkTxkqP0T6l1QXAHdmdfPucLBFtfVQHTxNu9Ksl+4sSqk zFsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=MD2yukOCLz6mrZlE2Y/gsZ+aD8S/zeqzXQ8K8DSTsrg=; b=fKwOaOAJrNdKBSZnWlxExHQA2rODssbwxMVQac/9rqHB1A3KiJuQSpuQqMjZjedVNj E8GmUX3HOM/GYqMc7tX7JYUcM5Jtee8Ux8NKAFY4r+4HA2NhbfIXIqF9ExCfQbQxoTiv WydmDzP+5MjBVez2Kz+Wg7Zk6ActzLXSEPweXH87tID7p01FzJn9DnAI6/L0D3+jKBLw 6krSYTMYqd2U/pHQ2OmDrS6d4DfiImUDF+EIpV1j5tUMlNAtPN/x0Y9vnNpxVBzFbWPP CTjNUXpu1mK3l8wDMVTeqG0Dpke1Vz4QcZC0hSqPElmWkO/fO4Cym9OgUxOHPl9dBb8s O1/Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15-v6si1077925pfg.124.2018.09.12.06.37.42; Wed, 12 Sep 2018 06:38:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbeILSkc (ORCPT + 99 others); Wed, 12 Sep 2018 14:40:32 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:43885 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726980AbeILSkb (ORCPT ); Wed, 12 Sep 2018 14:40:31 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1g05JC-0001Ap-6f; Wed, 12 Sep 2018 15:35:54 +0200 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Andy Lutomirski , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel , Sebastian Andrzej Siewior Subject: [RFC PATCH 03/10] x86/fpu: add (__)make_fpregs_active helpers Date: Wed, 12 Sep 2018 15:33:46 +0200 Message-Id: <20180912133353.20595-4-bigeasy@linutronix.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180912133353.20595-1-bigeasy@linutronix.de> References: <20180912133353.20595-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rik van Riel Add helper function that ensures the floating point registers for the current task are active. Use with preemption disabled. Signed-off-by: Rik van Riel Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/include/asm/fpu/internal.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index a38bf5a1e37ad..16c4077ffc945 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -514,6 +514,26 @@ static inline void fpregs_activate(struct fpu *fpu) trace_x86_fpu_regs_activated(fpu); } +/* + * Load the FPU state for the current task. Call with preemption disabled. + */ +static inline void __fpregs_load_activate(struct fpu *fpu, int cpu) +{ + if (!fpregs_state_valid(fpu, cpu)) + copy_kernel_to_fpregs(&fpu->state); + fpregs_activate(fpu); +} + +static inline void __fpregs_changes_begin(void) +{ + preempt_disable(); +} + +static inline void __fpregs_changes_end(void) +{ + preempt_enable(); +} + /* * FPU state switching for scheduling. * @@ -553,11 +573,8 @@ static inline void switch_fpu_finish(struct fpu *new_fpu, int cpu) bool preload = static_cpu_has(X86_FEATURE_FPU) && new_fpu->initialized; - if (preload) { - if (!fpregs_state_valid(new_fpu, cpu)) - copy_kernel_to_fpregs(&new_fpu->state); - fpregs_activate(new_fpu); - } + if (preload) + __fpregs_load_activate(new_fpu, cpu); } /* -- 2.19.0