Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751682AbdINSbI (ORCPT ); Thu, 14 Sep 2017 14:31:08 -0400 Received: from mga06.intel.com ([134.134.136.31]:47000 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751654AbdINSbH (ORCPT ); Thu, 14 Sep 2017 14:31:07 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,394,1500966000"; d="scan'208";a="135438206" Message-ID: <1505413847.8286.11.camel@linux.intel.com> Subject: Re: [PATCH v8 11/28] x86/insn-eval: Add utility function to identify string instructions 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 , "Ravi V. Shankar" , Shuah Khan , linux-kernel@vger.kernel.org, x86@kernel.org, Adam Buchbinder , Colin Ian King , Lorenzo Stoakes , Qiaowei Ren , Arnaldo Carvalho de Melo , Adrian Hunter , Kees Cook , Thomas Garnier , Dmitry Vyukov Date: Thu, 14 Sep 2017 11:30:47 -0700 In-Reply-To: <20170908135715.hoppz4j3abvu6j6g@pd.tnic> References: <20170819002809.111312-1-ricardo.neri-calderon@linux.intel.com> <20170819002809.111312-12-ricardo.neri-calderon@linux.intel.com> <20170908135715.hoppz4j3abvu6j6g@pd.tnic> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2169 Lines: 58 On Fri, 2017-09-08 at 15:57 +0200, Borislav Petkov wrote: > On Fri, Aug 18, 2017 at 05:27:52PM -0700, Ricardo Neri wrote: > > > > String instructions are special because, in protected mode, the > > linear > > address is always obtained via the ES segment register in operands > > that > > use the (E)DI register; the DS segment register in operands that > > use > > the (E)SI register. Furthermore, segment override prefixes are > > ignored > > when calculating a linear address involving the (E)DI register; > > segment > > override prefixes can be used when calculating linear addresses > > involving > > the (E)SI register. > > > > It follows that linear addresses are calculated differently for the > > case of > > string instructions. The purpose of this utility function is to > > identify > > such instructions for callers to determine a linear address > > correctly. > > > > Note that this function only identifies string instructions; it > > does not > > determine what segment register to use in the address computation. > > That is > > left to callers. A subsequent commmit introduces a function to > > determine > > the segment register to use given the instruction, operands and > > segment override prefixes. > > > > Cc: Dave Hansen > > Cc: Adam Buchbinder > > Cc: Colin Ian King > > Cc: Lorenzo Stoakes > > Cc: Qiaowei Ren > > Cc: Arnaldo Carvalho de Melo > > Cc: Masami Hiramatsu > > Cc: Adrian Hunter > > Cc: Kees Cook > > Cc: Thomas Garnier > > Cc: Peter Zijlstra > > Cc: Borislav Petkov > > Cc: Dmitry Vyukov > > Cc: Ravi V. Shankar > > Cc: x86@kernel.org > > Signed-off-by: Ricardo Neri > > --- > >  arch/x86/lib/insn-eval.c | 26 ++++++++++++++++++++++++++ > >  1 file changed, 26 insertions(+) > Reviewed-by: Borislav Petkov Thanks for your review! BR, Ricardo