Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947784AbdDZCGP (ORCPT ); Tue, 25 Apr 2017 22:06:15 -0400 Received: from mga01.intel.com ([192.55.52.88]:58712 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1434621AbdDZCGE (ORCPT ); Tue, 25 Apr 2017 22:06:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,252,1488873600"; d="scan'208";a="253502611" Message-ID: <1493172353.36058.27.camel@ranerica-desktop> Subject: Re: [v6 PATCH 04/21] x86/mpx, x86/insn: Relocate insn util functions to a new insn-kernel From: Ricardo Neri To: Borislav Petkov Cc: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Andy Lutomirski , 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 , Alexandre Julliard , Stas Sergeev , Fenghua Yu , "Ravi V. Shankar" , Shuah Khan , linux-kernel@vger.kernel.org, x86@kernel.org, linux-msdos@vger.kernel.org, wine-devel@winehq.org, Adam Buchbinder , Colin Ian King , Lorenzo Stoakes , Qiaowei Ren , Arnaldo Carvalho de Melo , Adrian Hunter , Kees Cook , Thomas Garnier , Dmitry Vyukov Date: Tue, 25 Apr 2017 19:05:53 -0700 In-Reply-To: <20170412100308.uuai3hf3l2fsavhb@pd.tnic> References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-5-ricardo.neri-calderon@linux.intel.com> <20170412100308.uuai3hf3l2fsavhb@pd.tnic> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1274 Lines: 38 On Wed, 2017-04-12 at 12:03 +0200, Borislav Petkov wrote: > > + * If mod is 0 and register R/EBP (regno=5) is > indicated in the > > + * base part of the SIB byte, the value of such > register should > > + * not be used in the address computation. Also, a > 32-bit > > + * displacement is expected in this case; the > instruction > > + * decoder takes care of it. This is true for both R13 > and > > + * R/EBP as REX.B will not be decoded. > > + */ > > + if (regno == 5 && X86_MODRM_MOD(insn->modrm.value) == > 0) > > + return -EDOM; > > + > > + if (X86_REX_B(insn->rex_prefix.value)) > > + regno += 8; > > + break; > > + > > + default: > > + pr_err("invalid register type"); > > + BUG(); > > WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code > rather than BUG() or BUG_ON() > #211: FILE: arch/x86/lib/insn-eval.c:90: > + BUG(); > > And checkpatch is kinda right. We need to warn here, not explode. Oh > and > that function returns negative values on error... > > Please change that with a patch ontop of the move. Sure, I will change it.