Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5476828imm; Wed, 12 Sep 2018 06:36:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ4X5AxW4FdI3slvEDMNktg7qZTMcsIo7YefLT5rpA9d5bMQQ7xO95/mUnuxVzAvRmWStyg X-Received: by 2002:a17:902:f209:: with SMTP id gn9mr2305097plb.173.1536759414487; Wed, 12 Sep 2018 06:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536759414; cv=none; d=google.com; s=arc-20160816; b=NoZjoLAIuva8bNaS7TLeR99fKlwqn9qECY23jp67o7Rg52HD7ctoU78FSe4Txin4E4 y4bScHx7cy9AVtKbDW5rxiEjPLN/s5VzCRcZ72C8hAtfptGJaZ96yGIlcEGTeFd71Dl9 ZNgE+pFNI1J3uTNae//lNv1AA5uPwx48tzcQ+nOesg+s8hMtevaWalOcd4nBAxM8OprO aWEo3IjjV9u7IzFSrZ6ZWZdIpIr/2NNzVG/EIkXDSg+qppEh1f+cEF8gv6tBOs+jHJTb CRpn55/pBlWVZd3ZR7DBvkSB3w9U4nL2QMopjDHhiv3CRldJr915T7zUc9wgue1Uy3+t us+w== 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=GBiAsakdcdXgaws2GDJWqeVcSSnUwCGh3fz/RwCNpOA=; b=pQy0+bym3o6dsKzXZtH1uKlp9WrMWXc7XPo1sCq5UHeOp9qqSTixV3v4+rBPtN95v/ fFnTSXzN3VEDWlVneFv3GJ9ZyAEpoMesL1NTW+vY/mlVoYiMHNb35YrUYp18nUWqx1xO hevObcK1khsVu8+MKluPjmS6LsZ6SYFIABSPbgZBgvLlQ8FH9A0Z+dYaU9XJivj3Gt0j rDWcr3sDtdOXX9e0+6g9SdfxShGhkywbTGtLNA4dximSlh1mhk8O0Kpc7HNduOe/Sg3V mHif/Wa1cvQFFKNsIstqrC6xCulBMn8bVeL6hbIqHaniOrQYHb7KjCMIqRZGDRpa4VPT hvrg== 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 z2-v6si1095726pgn.494.2018.09.12.06.36.38; Wed, 12 Sep 2018 06:36:54 -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 S1728147AbeILSkt (ORCPT + 99 others); Wed, 12 Sep 2018 14:40:49 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:43918 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbeILSkf (ORCPT ); Wed, 12 Sep 2018 14:40:35 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1g05JG-0001Ap-7u; Wed, 12 Sep 2018 15:35:58 +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 09/10] x86/fpu: copy non-resident FPU state at fork time Date: Wed, 12 Sep 2018 15:33:52 +0200 Message-Id: <20180912133353.20595-10-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 If the FPU state is not loaded in registers at fork time, memcpy the fpstate from the parent task to the child task. Signed-off-by: Rik van Riel Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/kernel/fpu/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 2ea85b32421a0..8564086c217fc 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -210,11 +210,14 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) * ( The function 'fails' in the FNSAVE case, which destroys * register contents so we have to copy them back. ) */ - if (!copy_fpregs_to_fpstate(dst_fpu)) { + __fpregs_changes_begin(); + if (test_thread_flag(TIF_LOAD_FPU)) { + memcpy(&src_fpu->state, &dst_fpu->state, fpu_kernel_xstate_size); + } else if (!copy_fpregs_to_fpstate(dst_fpu)) { memcpy(&src_fpu->state, &dst_fpu->state, fpu_kernel_xstate_size); copy_kernel_to_fpregs(&src_fpu->state); } - + __fpregs_changes_end(); trace_x86_fpu_copy_src(src_fpu); trace_x86_fpu_copy_dst(dst_fpu); -- 2.19.0