Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2569769imu; Thu, 29 Nov 2018 07:03:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/XEijstZMJH30cCy2NXo+NleEZ48F+UguuPomj7hrAcN8FfoFt8P6/RuIeKi/g+7Efgzif6 X-Received: by 2002:a17:902:5ac2:: with SMTP id g2mr1784156plm.313.1543503802974; Thu, 29 Nov 2018 07:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543503802; cv=none; d=google.com; s=arc-20160816; b=Hzp1k7gJWy4ipZXADkzQITfyiK35ERTJ7VzkI5sJBKTavYpz99808xVrnng86W5Vw2 2wyL6la4NZuKX6D8Lx8sw23sN15nNCvogQQFXafL6Ggw1kfq5/gplHPT/V/3P6VXQ0Xr ddY9tPq+OfsIy5WQL4Rn5fZ3pEjLSm+u9yMb4HWbC3DZdzVW+NH3dKD79b0agQW2OKxf uyF77ZyXvFeIvlxcYV0PIzG4lQvSuk/OVMhWw442+u8E7WE4+cglP+yMsLtxw8RKFfiE gOZHoYgJdBpqPpH9kL8AihYI7E5KCN3YYvkVQ6UZFSehUukFJ61nYQrcB28bjToSifli +dQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rMrmhpnQjbAPVpfMfNban09cnhz84kRtryqIP/5XugA=; b=QTFpJU7RqqZOKozzxNyNMMF4i3KfLrc7xQfmMTsLiovC1lIJ3xtSr+l7ArWNKcAvIm Lu4GvRGD89hlUZMEf1ktpzPorbWj2L5Jnvku9IFXuAvNMUkLxcWIgDejhnA267liZFmt 0bV1jI7LwYhtuoTclrzp6qzqcbgsOJ7sM+LndC9PUETHkSiujThN5CZcVNEycptKIM0d ivhjJ0hBVPL/ANED1BxMTQpciNp3mKZd5rRPhZtgUEfQhD5XlJYzR7W6C4pWAXqU2elv VxXoPkvjObiRMV4BR4OrvJc9TLnSp/Dd1cA5CFyPhwI4t9H6Gv8sMRhgJ1aeJhzDZ49j aCLQ== 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 e7si2375549pfh.147.2018.11.29.07.02.55; Thu, 29 Nov 2018 07:03:22 -0800 (PST) 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 S1730185AbeK3CF7 (ORCPT + 99 others); Thu, 29 Nov 2018 21:05:59 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:34981 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729410AbeK3CF7 (ORCPT ); Thu, 29 Nov 2018 21:05:59 -0500 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1gSNnc-0008Ia-H6; Thu, 29 Nov 2018 16:00:16 +0100 Date: Thu, 29 Nov 2018 16:00:16 +0100 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Andy Lutomirski , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel , Dave Hansen Subject: Re: [PATCH 29/29] x86/fpu: Defer FPU state load until return to userspace Message-ID: <20181129150016.bqjgc5t5qcafdplz@linutronix.de> References: <20181128222035.2996-1-bigeasy@linutronix.de> <20181128222035.2996-30-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181128222035.2996-30-bigeasy@linutronix.de> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-11-28 23:20:35 [+0100], To linux-kernel@vger.kernel.org wrote: > diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c > index fb16d0da71bca..f552b1d6c6958 100644 > --- a/arch/x86/kernel/fpu/signal.c > +++ b/arch/x86/kernel/fpu/signal.c > @@ -292,43 +295,51 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) > u64 init_bv = xfeatures_mask & ~xfeatures; > > if (using_compacted_format()) { > - ret = copy_user_to_xstate(&state->xsave, buf_fx); > + ret = copy_user_to_xstate(&fpu->state.xsave, buf_fx); > } else { > - ret = __copy_from_user(&state->xsave, buf_fx, state_size); > + ret = __copy_from_user(&fpu->state.xsave, buf_fx, state_size); > > if (!ret && state_size > offsetof(struct xregs_state, header)) > - ret = validate_xstate_header(&state->xsave.header); > + ret = validate_xstate_header(&fpu->state.xsave.header); > } > if (ret) > goto err_out; > > - sanitize_restored_xstate(state, envp, xfeatures, fx_only); > + sanitize_restored_xstate(&fpu->state, envp, xfeatures, fx_only); > > + __fpregs_changes_begin(); > if (unlikely(init_bv)) > copy_kernel_to_xregs(&init_fpstate.xsave, init_bv); > - ret = copy_users_to_xregs(&state->xsave, xfeatures); > + ret = copy_users_to_xregs(&fpu->state.xsave, xfeatures); > > } else if (use_fxsr()) { > - ret = __copy_from_user(&state->fxsave, buf_fx, state_size); > - if (ret) > + ret = __copy_from_user(&fpu->state.fxsave, buf_fx, state_size); > + if (ret) { > + err = -EFAULT; > goto err_out; > + } > > - sanitize_restored_xstate(state, envp, xfeatures, fx_only); > + sanitize_restored_xstate(&fpu->state, &env, xfeatures, fx_only); This should have remained `envp' and not become `&env'. Sebastian