Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754858AbbDJSE7 (ORCPT ); Fri, 10 Apr 2015 14:04:59 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:34618 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756013AbbDJSEw (ORCPT ); Fri, 10 Apr 2015 14:04:52 -0400 Date: Fri, 10 Apr 2015 20:04:48 +0200 From: Ingo Molnar To: Peter Zijlstra Cc: "Paul E. McKenney" , Linus Torvalds , Jason Low , Davidlohr Bueso , Tim Chen , Aswin Chandramouleeswaran , LKML Subject: Re: [PATCH] x86/uaccess: Implement get_kernel() Message-ID: <20150410180448.GD6563@gmail.com> References: <20150409175652.GI6464@linux.vnet.ibm.com> <20150409183926.GM6464@linux.vnet.ibm.com> <20150410090051.GA28549@gmail.com> <20150410091252.GA27630@gmail.com> <20150410092152.GA21332@gmail.com> <20150410111427.GA30477@gmail.com> <20150410113412.GB5029@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150410113412.GB5029@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1464 Lines: 44 * Peter Zijlstra wrote: > On Fri, Apr 10, 2015 at 01:14:27PM +0200, Ingo Molnar wrote: > > +/* > > + * Simple copy-from-possibly-faulting-kernel-addresses method that > > + * avoids the STAC/CLAC SMAP overhead. > > + * > > + * NOTE: this does not propagate the error code of faulting kernel > > + * addresses properly. You can recover it via uaccess_catch() > > + * if you really need to. > > + */ > > +#define get_kernel(dst, src) \ > > +do { \ > > + typeof(*(src)) __val; \ > > Should we make that: > > typeof(*(src)) __val = (dst); > > > + \ > > + switch (sizeof(__val)) { \ > > + case 1: __get_kernel_asm_ex(__val, src, "b", "b", "=q"); break; \ > > + case 2: __get_kernel_asm_ex(__val, src, "w", "w", "=r"); break; \ > > + case 4: __get_kernel_asm_ex(__val, src, "l", "k", "=r"); break; \ > > + case 8: __get_kernel_asm_ex(__val, src, "q", " ", "=r"); break; \ > > + default: __get_kernel_BUILD_ERROR(); \ > > + } \ > > + (dst) = __val; \ > > +} while (0) > > Such that when we fault, the value is unmodified? The way it is we'll > assign whatever was on stack for __val, which seems undesirable, no? Yes, indeed. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/