From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752990AbbCYBCB (ORCPT ); Tue, 24 Mar 2015 21:02:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53868 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752514AbbCYBBu (ORCPT ); Tue, 24 Mar 2015 21:01:50 -0400 Message-ID: <551208F8.1090806@redhat.com> Date: Tue, 24 Mar 2015 21:01:44 -0400 From: Rik van Riel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Andy Lutomirski , Dave Hansen CC: Thomas Gleixner , "linux-kernel@vger.kernel.org" , X86 ML , Dave Hansen , Suresh Siddha , Ingo Molnar , "H. Peter Anvin" , Fenghua Yu , Oleg Nesterov , Borislav Petkov Subject: Re: [PATCH 01/17] x86, fpu: wrap get_xsave_addr() to make it safer References: <1427235664-25318-1-git-send-email-dave.hansen@intel.com> <1427235664-25318-2-git-send-email-dave.hansen@intel.com> <5511F65A.5020505@intel.com> <5511FD59.3040503@intel.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/24/2015 08:18 PM, Andy Lutomirski wrote: > On Tue, Mar 24, 2015 at 5:12 PM, Dave Hansen wrote: >> I won't completely claim to understand what's going on with the FPU >> code, but I think your analysis is a bit off. >> >> unlazy_fpu() does __save_init_fpu() which (among other things) calls >> xsave to dump the CPU registers to memory. That doesn't make any sense >> to do if "The in-memory copy and the CPU regs match." >> >> IOW, unlazy_fpu() is called when the in-memory copy is garbage and takes >> us to a state where we can look at the in-memory copy. > > I think that __save_init_fpu (called by unlazy_fpu) does that, but > __thread_fpu_end calls __thread_clear_has_fpu, which, in turn, zaps > fpu_owner_task, which will force an unnecessary xrstor. Or maybe not > if we have further bugs. Indeed, __save_init_fpu (yeah, terrible name) will save the in-register state to memory for you, so you can inspect it. Is there any reason not to rename __save_init_fpu to save_fpu_state, or just save_fpu? -- All rights reversed