From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752630AbdKCCrp (ORCPT ); Thu, 2 Nov 2017 22:47:45 -0400 Received: from mga14.intel.com ([192.55.52.115]:20743 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751507AbdKCCro (ORCPT ); Thu, 2 Nov 2017 22:47:44 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,336,1505804400"; d="scan'208";a="1239096725" Date: Thu, 2 Nov 2017 19:46:20 -0700 From: Ricardo Neri To: Thomas Gleixner Cc: Ingo Molnar , 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 Message-ID: <20171103024620.GB24896@voyager> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Thu, Nov 02, 2017 at 12:07:13PM +0100, Thomas Gleixner wrote: > 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. This patch introduce this several helper function. Perhaps I can add some more. For this particular case, I think that using shorter variable names will avoid this problem. Thanks and BR, Ricardo