From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755530AbdELCOB (ORCPT ); Thu, 11 May 2017 22:14:01 -0400 Received: from mga01.intel.com ([192.55.52.88]:62206 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbdELCN7 (ORCPT ); Thu, 11 May 2017 22:13:59 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,327,1491289200"; d="scan'208";a="86627657" Message-ID: <1494555237.118905.54.camel@ranerica-desktop> Subject: Re: [v6 PATCH 07/21] x86/insn-eval: Add utility function to get segment descriptor From: Ricardo Neri To: Borislav Petkov Cc: Andy Lutomirski , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , 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:13:57 -0700 In-Reply-To: <20170504110213.guyhxsomgu4iaurj@pd.tnic> References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-8-ricardo.neri-calderon@linux.intel.com> <20170419102636.chx5fwofysehy3yx@pd.tnic> <1493243515.36058.63.camel@ranerica-desktop> <20170504110213.guyhxsomgu4iaurj@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 Thu, 2017-05-04 at 13:02 +0200, Borislav Petkov wrote: > On Wed, Apr 26, 2017 at 02:51:56PM -0700, Ricardo Neri wrote: > > > > + seg >= current->active_mm->context.ldt->size)) { > > > > > > ldt->size is the size of the descriptor table but you've shifted seg by > > > 3. That selector index is shifted by 3 (to the left) to form an offset > > > into the descriptor table because the entries there are 8 bytes. > > > > I double-checked the ldt code and it seems to me that size refers to the > > number of entries in the table; it is always multiplied by > > LDT_ENTRY_SIZE [1], [2]. Am I missing something? > > No, you're not. I fell into that wrongly named struct member trap. > > So ldt_struct.size should actually be called ldt_struct.n_entries or > similar. Because what's in there is now is not "size". > > And then code like > > new_ldt->size * LDT_ENTRY_SIZE > > would make much more sense if written like this: > > new_ldt->n_entries * LDT_ENTRY_SIZE > > Would you fix that in a prepatch pls? > Sure I can. Would this trigger a v8 of my series? I was hoping v7 series could be merged and then start doing incremental work on top of it. Does it make sense? Thanks and BR, Ricardo From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Neri Subject: Re: [v6 PATCH 07/21] x86/insn-eval: Add utility function to get segment descriptor Date: Thu, 11 May 2017 19:13:57 -0700 Message-ID: <1494555237.118905.54.camel@ranerica-desktop> References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-8-ricardo.neri-calderon@linux.intel.com> <20170419102636.chx5fwofysehy3yx@pd.tnic> <1493243515.36058.63.camel@ranerica-desktop> <20170504110213.guyhxsomgu4iaurj@pd.tnic> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170504110213.guyhxsomgu4iaurj@pd.tnic> Sender: linux-msdos-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Borislav Petkov Cc: Andy Lutomirski , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , 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 Thu, 2017-05-04 at 13:02 +0200, Borislav Petkov wrote: > On Wed, Apr 26, 2017 at 02:51:56PM -0700, Ricardo Neri wrote: > > > > + seg >= current->active_mm->context.ldt->size)) { > > > > > > ldt->size is the size of the descriptor table but you've shifted seg by > > > 3. That selector index is shifted by 3 (to the left) to form an offset > > > into the descriptor table because the entries there are 8 bytes. > > > > I double-checked the ldt code and it seems to me that size refers to the > > number of entries in the table; it is always multiplied by > > LDT_ENTRY_SIZE [1], [2]. Am I missing something? > > No, you're not. I fell into that wrongly named struct member trap. > > So ldt_struct.size should actually be called ldt_struct.n_entries or > similar. Because what's in there is now is not "size". > > And then code like > > new_ldt->size * LDT_ENTRY_SIZE > > would make much more sense if written like this: > > new_ldt->n_entries * LDT_ENTRY_SIZE > > Would you fix that in a prepatch pls? > Sure I can. Would this trigger a v8 of my series? I was hoping v7 series could be merged and then start doing incremental work on top of it. Does it make sense? Thanks and BR, Ricardo