From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752557AbcJDDDI (ORCPT ); Mon, 3 Oct 2016 23:03:08 -0400 Received: from mail-ua0-f170.google.com ([209.85.217.170]:34929 "EHLO mail-ua0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbcJDDDG (ORCPT ); Mon, 3 Oct 2016 23:03:06 -0400 MIME-Version: 1.0 In-Reply-To: <1475549273.21644.51.camel@redhat.com> References: <1475353895-22175-1-git-send-email-riel@redhat.com> <1475353895-22175-3-git-send-email-riel@redhat.com> <1475366900.21644.8.camel@redhat.com> <1475529679.4622.27.camel@redhat.com> <1475544579.21644.37.camel@redhat.com> <1475549273.21644.51.camel@redhat.com> From: Andy Lutomirski Date: Mon, 3 Oct 2016 20:02:45 -0700 Message-ID: Subject: Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace To: Rik van Riel Cc: Dave Hansen , "linux-kernel@vger.kernel.org" , X86 ML , Thomas Gleixner , Paolo Bonzini , Ingo Molnar , Andrew Lutomirski , "H. Peter Anvin" , Borislav Petkov Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 3, 2016 at 7:47 PM, Rik van Riel wrote: > On Mon, 2016-10-03 at 19:09 -0700, Andy Lutomirski wrote: > >> > Having two separate status booleans for "registers valid" >> > and "memory valid" may make more sense. >> >> I have no problem with the concept of "owner_ctx", and I think it's a >> perfectly reasonable data structure. My problem with it is that it's >> subtle and knowledge of it is spread all over the place. Just going >> with "registers valid" in a variable won't work, I think, because >> there's nowhere to put it. We need to be able to delete a struct fpu >> while that struct fpu might have a valid copy in a different cpu's >> registers. >> >> Anyway, feel free to tell me that I'm making this too difficult :) > > How about we rename fpu_want_lazy_restore to > fpu_registers_valid()? Problem solved :) > > Then we can rename __cpu_disable_lazy_restore > to fpu_invalidate_registers(), and call that > before we modify any in-memory FPU state. Sounds good to me. > >> > We can get rid of fpu.counter, since nobody uses it >> > any more. >> >> We should definitely do this. >> >> Maybe getting in some cleanups first (my lazy fpu deletion, >> fpu.counter removal, etc) first is the way to go. > > Sounds good. I will keep my patch 1/4 as part of the > cleanup series, and will not move on to the harder > stuff until after the cleanups. > > Any other stuff I should clean up while we're there? Almost certainly, but nothing I'm thinking of right now :) > >> > > > > >> > You are right, read_pkru() and write_pkru() can only deal with >> > the pkru state being present in registers. Is this because of an >> > assumption in the code, or because of a hardware requirement? > > read_pkru and write_pkru would be candidates for using > fpu_registers_valid, and potentially a fpu_make_registers_valid, > which restores the contents of the fpu registers from memory, > if fpu_registers_valid is not true. > > Likewise, we can have an fpu_make_memory_valid to ensure the > in kernel memory copy of the FPU registers is valid, potentially > a _read and _write version that do exactly what the pstate code > wants today. > > Would that make sense as an API? > > -- > All Rights Reversed. -- Andy Lutomirski AMA Capital Management, LLC