From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751375AbdA3J6h (ORCPT ); Mon, 30 Jan 2017 04:58:37 -0500 Received: from mail-wj0-f194.google.com ([209.85.210.194]:34622 "EHLO mail-wj0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750977AbdA3J5d (ORCPT ); Mon, 30 Jan 2017 04:57:33 -0500 Date: Mon, 30 Jan 2017 10:57:28 +0100 From: Ingo Molnar To: Borislav Petkov Cc: linux-kernel@vger.kernel.org, Andrew Morton , Andy Lutomirski , Dave Hansen , Fenghua Yu , "H . Peter Anvin" , Linus Torvalds , Oleg Nesterov , Peter Zijlstra , Rik van Riel , Thomas Gleixner , Yu-cheng Yu Subject: Re: [PATCH 04/14] x86/fpu: Remove 'kbuf' parameter from the copy_xstate_to_user() APIs Message-ID: <20170130095728.GA26142@gmail.com> References: <1485426179-13681-1-git-send-email-mingo@kernel.org> <1485426179-13681-5-git-send-email-mingo@kernel.org> <20170127101656.r6djweg3snx4n7k2@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170127101656.r6djweg3snx4n7k2@pd.tnic> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Borislav Petkov wrote: > On Thu, Jan 26, 2017 at 11:22:49AM +0100, Ingo Molnar wrote: > > The 'kbuf' parameter is unused in the _user() side of the API, remove it. > > > > This simplifies the code and makes it easier to think about. > > ... > > > @@ -1010,10 +1010,7 @@ int copy_xstate_to_kernel(unsigned int pos, unsigned int count, void *kbuf, stru > > } > > > > static inline int > > -__copy_xstate_to_user(unsigned int pos, unsigned int count, > > - void *kbuf, void __user *ubuf, > > - const void *data, const int start_pos, > > - const int end_pos) > > +__copy_xstate_to_user(unsigned int pos, unsigned int count, void __user *ubuf, const void *data, const int start_pos, const int end_pos) > > That and similar lines are insanely long and could be broken. Yeah, so that's one point of the series: the interface was insanely complex (the original sin is that of the regset interfaces), and one symptom of that complexity are these overly long prototypes - the above one has 7 arguments (!!). Another, far more serious symptom of the complexity were the bugs that Rik found. The solution was not to break the prototype into multiple lines and thus paper over one symptom of complexity, but to _reduce_ complexity. So at the end of the series the basic copy_xstate_to_user() prototype looks like this: static inline int __copy_xstate_to_user(void __user *ubuf, const void *data, unsigned int offset, unsigned int size, unsigned int size_total) which is less complex and shorter as well. It could probably be shortened further: static inline int __copy_xstate_to_user(void __user *ubuf, const void *data, u32 offset, u32 size, u32 total) because our regset (and user-copy) APIs are intentionally 32-bit - but this would depart from the existing signature style so I'm not sure we want to do it unilaterally. Would anyone object to using u32 in these prototypes? Thanks, Ingo