From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753427AbdL1QjX (ORCPT ); Thu, 28 Dec 2017 11:39:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:57848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750959AbdL1QjU (ORCPT ); Thu, 28 Dec 2017 11:39:20 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E1D9218B1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Thu, 28 Dec 2017 11:39:15 -0500 From: Steven Rostedt To: Ard Biesheuvel Cc: Linux Kernel Mailing List , "H. Peter Anvin" , Ralf Baechle , Arnd Bergmann , Heiko Carstens , Kees Cook , Will Deacon , Michael Ellerman , Thomas Garnier , Thomas Gleixner , "Serge E. Hallyn" , Bjorn Helgaas , Benjamin Herrenschmidt , Russell King , Paul Mackerras , Catalin Marinas , "David S. Miller" , Petr Mladek , Ingo Molnar , James Morris , Andrew Morton , Nicolas Pitre , Josh Poimboeuf , Martin Schwidefsky , Sergey Senozhatsky , Linus Torvalds , Jessica Yu , linux-arm-kernel@lists.infradead.org, linux-mips , linuxppc-dev , linux-s390 , sparclinux@vger.kernel.org, "the arch/x86 maintainers" Subject: Re: [PATCH v6 8/8] x86/kernel: jump_table: use relative references Message-ID: <20171228113915.47838609@gandalf.local.home> In-Reply-To: References: <20171227085033.22389-1-ard.biesheuvel@linaro.org> <20171227085033.22389-9-ard.biesheuvel@linaro.org> <20171228111926.28e82877@gandalf.local.home> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 28 Dec 2017 16:26:07 +0000 Ard Biesheuvel wrote: > On 28 December 2017 at 16:19, Steven Rostedt wrote: > > On Wed, 27 Dec 2017 08:50:33 +0000 > > Ard Biesheuvel wrote: > > > >> static inline jump_label_t jump_entry_code(const struct jump_entry *entry) > >> { > >> - return entry->code; > >> + return (jump_label_t)&entry->code + entry->code; > > > > I'm paranoid about doing arithmetic on abstract types. What happens in > > the future if jump_label_t becomes a pointer? You will get a different > > result. > > > > In general, I share your concern. In this case, however, jump_label_t > is typedef'd three lines up and is never used anywhere else. I would agree if this was in a .c file, but it's in a header file, which causes me to be more paranoid. > > > Could we switch these calculations to something like: > > > > return (jump_label_t)((long)&entrty->code + entry->code); > > > > jump_label_t is local to this .h file, so it can be defined as u32 or > u64 depending on the word size. I don't mind adding the extra cast, > but I am not sure if your paranoia is justified in this particular > case. Perhaps we should just use 'unsigned long' throughout? Actually, that may be better. Have the return value be jump_label_t, but the cast be "unsigned long". That way it should always work. static inline jump_label_t jump_entry_code(...) { return (unsigned long)&entry->code + entry->code; } -- Steve