From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754828AbdELCGE (ORCPT ); Thu, 11 May 2017 22:06:04 -0400 Received: from mga06.intel.com ([134.134.136.31]:39209 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750708AbdELCGC (ORCPT ); Thu, 11 May 2017 22:06:02 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,327,1491289200"; d="scan'208";a="1168074868" Message-ID: <1494554760.118905.50.camel@ranerica-desktop> Subject: Re: [v6 PATCH 08/21] x86/insn-eval: Add utility function to get segment descriptor base address 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: Thu, 11 May 2017 19:06:00 -0700 In-Reply-To: <20170505172847.x3i2kca2xdb735ca@pd.tnic> References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-9-ricardo.neri-calderon@linux.intel.com> <20170420082533.hwc6eon3aom43qzo@pd.tnic> <1493247161.36058.77.camel@ranerica-desktop> <20170505172847.x3i2kca2xdb735ca@pd.tnic> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 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 On Fri, 2017-05-05 at 19:28 +0200, Borislav Petkov wrote: > On Wed, Apr 26, 2017 at 03:52:41PM -0700, Ricardo Neri wrote: > > Probably insn_get_seg_base() itself can verify if there are segment > > override prefixes in the struct insn. If yes, use them except for > > specific cases such as CS. > > ... and depending on whether in long mode or not. Yes, in my v7 I ignore the segment register if we are in long mode [1]. > > > On an unrelated note, I still have the problem of using DS vs ES for > > string instructions. Perhaps instead of a use_default_seg flag, a > > string_instruction flag that indicates how to determine the default > > segment. > > ... or you can look at the insn opcode directly. AFAICT, you need > to check whether the opcode is 0xa4 or 0xa5 and that the insn is a > single-byte opcode, i.e., not from the secondary map escaped with 0xf or > some of the other multi-byte opcode maps. In my v7, I have added a section my function resolve_seg_register() that ignores segment overrides if it sees string instructions and the register EDI and defaults to ES. If the register is EIP, it defaults to CS. To determine if an instruction is a string instruction I do check for the size of the opcode and the opcodes that you mention plus others based on the Intel Software Development Manual[2]. [1]. https://lkml.org/lkml/2017/5/5/405 [2]. https://lkml.org/lkml/2017/5/5/410 Thanks and BR, Ricardo > > -- > Regards/Gruss, > Boris. > > SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)