Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1024464imm; Thu, 4 Oct 2018 07:08:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV61JLMeLUaAMubOojKcOXXf3TP0KaqY8hL5RbiKcZsARFWyZ7nkCwlT0S2E7aCzQENLRhjGC X-Received: by 2002:a17:902:4225:: with SMTP id g34-v6mr6839642pld.161.1538662087182; Thu, 04 Oct 2018 07:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538662087; cv=none; d=google.com; s=arc-20160816; b=MdT0KJyOAwGYRpT4s2FI8JHC7tazgt+QCwRq0cOW7V8eJD0I8CM7130R6RT8JMdn/d n/Nht6KOb+leWf3ZjZ/8/TuHNPTwc1yn939+N4+iz4q6DWtIwvmoipFlCN7iCLU2BbN3 tX9hEB363U2ukRIpZxRA068s8KtEhzfjV5OaAtJItZ+6BIcH53nX2MtN1DLfycWGObtu z6DRSTIJ4cOhiE0pLEr2fLM2AF4GJRzHenfyKOcnlAYQ3Zg4VW/gnCwDWVQS8J2zQp57 t3U5/v96yitNX+8ED3LfkC338kzXgjj5X244VTcaw6rhJ4z+cmVDJm47jNAt2Zd4l/p/ qW2g== 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=aE59DbpWgtx7h2LkhSGJfShjUFeqUKdIJr0ned3hLy+8XYTS6o12RnmNAZ0aUuqZta ck+q5mSj8Dv0rCsCsaARLaLxeep1QMkrqZQh/+/ueXxPpxfuLZNXlYClaewsAP+sXfVk EJiqOgyKXxSR8yBDdhYVYNAPWoQy+6B58dsyh63JhAQ9B8Jel4LaSTpBEixYvB7qxwTK TF7JuK/8pOxF52vNgkRo3/TBTMVZNSCIg12sNpVJTwPk6r2roX2agoDJ3OtaRlysWWtK JQLtnsHNYb2kIkv9UWdNbuuuon27B+AZ8IoidWgR6eSJbkvdB0TnLxTObigVEEfosW0P yXsQ== 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 d21-v6si5607988pfd.114.2018.10.04.07.07.51; Thu, 04 Oct 2018 07:08:07 -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 S1727672AbeJDU7d (ORCPT + 99 others); Thu, 4 Oct 2018 16:59:33 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:36270 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727380AbeJDU7c (ORCPT ); Thu, 4 Oct 2018 16:59:32 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1g84GO-0002ic-No; Thu, 04 Oct 2018 16:06:00 +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 , Dave Hansen , Sebastian Andrzej Siewior Subject: [PATCH 02/11] x86/fpu: add (__)make_fpregs_active helpers Date: Thu, 4 Oct 2018 16:05:38 +0200 Message-Id: <20181004140547.13014-3-bigeasy@linutronix.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181004140547.13014-1-bigeasy@linutronix.de> References: <20181004140547.13014-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