From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754444AbcEBQo3 (ORCPT ); Mon, 2 May 2016 12:44:29 -0400 Received: from mga14.intel.com ([192.55.52.115]:43191 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752309AbcEBQoW (ORCPT ); Mon, 2 May 2016 12:44:22 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,568,1455004800"; d="scan'208";a="967070689" Subject: Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows correct xstates copy from kernel to user directly To: Yu-cheng Yu References: <5723BF63.2000100@linux.intel.com> <20160429224338.GA15757@test-lenovo> <5723FE20.7000906@linux.intel.com> <20160502155734.GA21577@test-lenovo> <57277B11.9080802@linux.intel.com> <20160502163410.GA21734@test-lenovo> Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, Andy Lutomirski , Borislav Petkov , Sai Praneeth Prakhya , "Ravi V. Shankar" , Fenghua Yu From: Dave Hansen Message-ID: <572783C3.8040907@linux.intel.com> Date: Mon, 2 May 2016 09:43:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160502163410.GA21734@test-lenovo> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/02/2016 09:34 AM, Yu-cheng Yu wrote: > On Mon, May 02, 2016 at 09:06:41AM -0700, Dave Hansen wrote: >> On 05/02/2016 08:57 AM, Yu-cheng Yu wrote: >>> On Fri, Apr 29, 2016 at 05:36:48PM -0700, Dave Hansen wrote: >>>> If may_copy_fpregs_to_sigframe() were called from a slightly different >>>> context, or if we change the call-site, what breaks? >>>> >>>> In other words. if we can still "may_copy_fpregs_to_sigframe()" no >>>> matter the state of fpu.fpstate_active, then I don't think we should be >>>> checking it in may_copy_fpregs_to_sigframe(). >>> >>> Do you mean, don't check fpu.fpstate_active here? >> >> Not really. I'm asking *why* the check is there. > > If (fpu.fpstate_active == 0), then the task does not use FPU; we don't > want to save these registers, right? No. It's possible to have fpstate_active=0 while fpregs_active=1. Such a task uses the FPU, but just hasn't done an XSAVE* to save the register content to the fpstate buffer. Note, this is just theoretical, and does not happen in this particular call path today.