Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754811AbbDJLe1 (ORCPT ); Fri, 10 Apr 2015 07:34:27 -0400 Received: from casper.infradead.org ([85.118.1.10]:33299 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751030AbbDJLe0 (ORCPT ); Fri, 10 Apr 2015 07:34:26 -0400 Date: Fri, 10 Apr 2015 13:34:12 +0200 From: Peter Zijlstra To: Ingo Molnar 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: <20150410113412.GB5029@twins.programming.kicks-ass.net> References: <20150409075311.GA4645@gmail.com> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150410111427.GA30477@gmail.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1325 Lines: 35 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? -- 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/