From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751266AbdEESbn (ORCPT ); Fri, 5 May 2017 14:31:43 -0400 Received: from mga09.intel.com ([134.134.136.24]:29984 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751069AbdEESbl (ORCPT ); Fri, 5 May 2017 14:31:41 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,293,1491289200"; d="scan'208";a="1144196038" Message-ID: <1494009100.74182.13.camel@ranerica-desktop> Subject: Re: [v6 PATCH 06/21] x86/insn-eval: Add utility functions to get segment selector 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: Fri, 05 May 2017 11:31:40 -0700 In-Reply-To: <20170430171527.seipp3xnvhs2hlr7@pd.tnic> References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-7-ricardo.neri-calderon@linux.intel.com> <20170418094221.zamus5butw6yrfky@pd.tnic> <1493239483.36058.55.camel@ranerica-desktop> <20170430171527.seipp3xnvhs2hlr7@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 On Sun, 2017-04-30 at 19:15 +0200, Borislav Petkov wrote: > On Wed, Apr 26, 2017 at 01:44:43PM -0700, Ricardo Neri wrote: > > I regard that the role of this function is to obtain the the segment > > selector from either of the prefixes or inferred from the operands. It > > is the role of caller to determine if the segment selector should be > > ignored. > > No, this is wrong. The function is called resolve_seg_selector() and it > gives you the segment selector. CS, DS, ES, and SS in 64-bit mode are > treated as null segments and your function should return/signal exactly > that, i.e, saying that those should be ignored in that case. > > > I double-checked the latest version of the Intel Software Development > > manual [2], in the table 3-5 in section 3.7.4 mentions that DS is > > default segment for all data references, except string destinations. I > > tested this code with the UMIP-protected instructions and whenever I use > > %edi the default segment is %ds. > > Yes, all correct. Except that we're adding a more-or-less generic x86 > insn decoder so we should make it so... > > > Is this example valid? The documentation of MOVS specifies that it > > always moves DS:(E)SI to ES:(E)DI. > > ... that the decoder should do exactly that: > > if (MOVS and rDI) > return SEG_ES; > > And you're handing in struct insn * so you can easily check which insn > you're looking at. I see. I have submitted v7 of the series and I have implemented all the changes above. Now I am able to identify string instructions. Thanks and BR, Ricardo