From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755782AbdKBLLM (ORCPT ); Thu, 2 Nov 2017 07:11:12 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:53589 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933322AbdKBLIC (ORCPT ); Thu, 2 Nov 2017 07:08:02 -0400 Date: Thu, 2 Nov 2017 12:07:13 +0100 (CET) From: Thomas Gleixner To: Ingo Molnar cc: Ricardo Neri , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , Borislav Petkov , Peter Zijlstra , Andrew Morton , Brian Gerst , Chris Metcalf , Dave Hansen , Paolo Bonzini , Masami Hiramatsu , Huang Rui , Jiri Slaby , Jonathan Corbet , "Michael S. Tsirkin" , Paul Gortmaker , Vlastimil Babka , Chen Yucong , "Ravi V. Shankar" , Shuah Khan , linux-kernel@vger.kernel.org, x86@kernel.org, ricardo.neri@intel.com, Adam Buchbinder , Colin Ian King , Lorenzo Stoakes , Qiaowei Ren , Arnaldo Carvalho de Melo , Adrian Hunter , Kees Cook , Thomas Garnier , Dmitry Vyukov Subject: Re: [PATCH v10 02/13] x86/insn-eval: Compute linear address in several utility functions In-Reply-To: <20171102085108.pgiem4kplrcmbzh6@gmail.com> Message-ID: References: <1509148310-30862-1-git-send-email-ricardo.neri-calderon@linux.intel.com> <1509148310-30862-3-git-send-email-ricardo.neri-calderon@linux.intel.com> <20171102085108.pgiem4kplrcmbzh6@gmail.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 Nov 2017, Ingo Molnar wrote: > * Ricardo Neri wrote: > > > + /* > > + * -EDOM means that we must ignore the address_offset. In such a case, > > + * in 64-bit mode the effective address relative to the RIP of the > > + * following instruction. > > + */ > > + if (*regoff == -EDOM) { > > + if (user_64bit_mode(regs)) > > + tmp = (long)regs->ip + insn->length; > > + else > > + tmp = 0; > > + } else if (*regoff < 0) { > > + return -EINVAL; > > + } else { > > + tmp = (long)regs_get_register(regs, *regoff); > > + } > > > + else > > + indx = (long)regs_get_register(regs, indx_offset); > > This and subsequent patches include a disgustly insane amount of type casts - why? > > For example here 'tmp' is 'long', while regs_get_register() returns > 'unsigned long', but no type cast is necessary for that. > > > + ret = get_eff_addr_modrm(insn, regs, &addr_offset, > > + &eff_addr); > > Also, please don't break lines slightly longer than 80 cols just to pacify > checkpatch (and this holds for other patches as well) - the cure is worse than the > illness! The right thing to do here is to split out stuff into a helper function which removes the indentation levels or restructure the code to avoid them. Thanks, tglx