From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2993700AbdDZIHO (ORCPT ); Wed, 26 Apr 2017 04:07:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:50745 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1956776AbdDZIGB (ORCPT ); Wed, 26 Apr 2017 04:06:01 -0400 Date: Wed, 26 Apr 2017 10:05:42 +0200 From: Borislav Petkov To: Ricardo Neri 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 , Nathan Howard , Adan Hawthorn , Joe Perches Subject: Re: [v6 PATCH 03/21] x86/mpx: Do not use R/EBP as base in the SIB byte with Mod = 0 Message-ID: <20170426080542.pannewbvzeqn5kj6@pd.tnic> References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-4-ricardo.neri-calderon@linux.intel.com> <20170411220816.2u3o72qnwcwq7jzc@pd.tnic> <1493172260.36058.26.camel@ranerica-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1493172260.36058.26.camel@ranerica-desktop> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 25, 2017 at 07:04:20PM -0700, Ricardo Neri wrote: > For the specific case of ModRM.mod being 0, I feel I need to clarify > that REX.B is not decoded and if SIB.base is %r13 the base is also 0. Well, that all doesn't matter. The rule is this: ModRM.mod == 00b and ModRM.r/m == 101b -> effective address: disp32 See Table 2-2. "32-Bit Addressing Forms with the ModR/M Byte" in the SDM. So the base register is not used. How that base register is specified then doesn't matter (undecoded REX bits or not). > This comment adds clarity because REX.X is decoded when determining > SIB.index. Well, that's a different thing. The REX bits participating in the SIB fields don't matter about this particular case. We only want to say that we're returning a disp32 without a base register and the comment should keep it simple without extraneous information. I know, you want to mention what Table 2-5. "Special Cases of REX Encodings" says but we should avoid unnecessary content in the comment. People who want details can stare at the manuals - the comment should only document what that particular case is. Btw, you could write it even better: if (!X86_MODRM_MOD(insn->modrm.value) && X86_MODRM_RM(insn->modrm.value) == 5) and then it is basically a 1:1 copy of the rule from Table 2-2. -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) -- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Borislav Petkov Subject: Re: [v6 PATCH 03/21] x86/mpx: Do not use R/EBP as base in the SIB byte with Mod = 0 Date: Wed, 26 Apr 2017 10:05:42 +0200 Message-ID: <20170426080542.pannewbvzeqn5kj6@pd.tnic> References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-4-ricardo.neri-calderon@linux.intel.com> <20170411220816.2u3o72qnwcwq7jzc@pd.tnic> <1493172260.36058.26.camel@ranerica-desktop> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: <1493172260.36058.26.camel@ranerica-desktop> Sender: linux-kernel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="utf-8" To: Ricardo Neri 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 On Tue, Apr 25, 2017 at 07:04:20PM -0700, Ricardo Neri wrote: > For the specific case of ModRM.mod being 0, I feel I need to clarify > that REX.B is not decoded and if SIB.base is %r13 the base is also 0. Well, that all doesn't matter. The rule is this: ModRM.mod == 00b and ModRM.r/m == 101b -> effective address: disp32 See Table 2-2. "32-Bit Addressing Forms with the ModR/M Byte" in the SDM. So the base register is not used. How that base register is specified then doesn't matter (undecoded REX bits or not). > This comment adds clarity because REX.X is decoded when determining > SIB.index. Well, that's a different thing. The REX bits participating in the SIB fields don't matter about this particular case. We only want to say that we're returning a disp32 without a base register and the comment should keep it simple without extraneous information. I know, you want to mention what Table 2-5. "Special Cases of REX Encodings" says but we should avoid unnecessary content in the comment. People who want details can stare at the manuals - the comment should only document what that particular case is. Btw, you could write it even better: if (!X86_MODRM_MOD(insn->modrm.value) && X86_MODRM_RM(insn->modrm.value) == 5) and then it is basically a 1:1 copy of the rule from Table 2-2. -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --