All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@suse.de>, Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	X86 ML <x86@kernel.org>,
	linux-msdos@vger.kernel.org, wine-devel@winehq.org,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Adam Buchbinder <adam.buchbinder@gmail.com>,
	Colin Ian King <colin.king@canonical.com>,
	Lorenzo Stoakes <lstoakes@gmail.com>,
	Qiaowei Ren <qiaowei.ren@intel.com>,
	"Ravi V . Shankar" <ravi.v.shankar@intel.com>
Subject: Re: [v2 1/7] x86/mpx: Do not use SIB index if index points to R/ESP
Date: Tue, 27 Dec 2016 14:29:18 -0800	[thread overview]
Message-ID: <1482877758.106950.7.camel@ranerica-desktop> (raw)
In-Reply-To: <CALCETrWpo2Sydy1q1i4SLLmT-m8oGUj_j79cW0NZyr2dSs1qJw@mail.gmail.com>

On Fri, 2016-12-23 at 17:57 -0800, Andy Lutomirski wrote:
> On Fri, Dec 23, 2016 at 5:37 PM, Ricardo Neri
> <ricardo.neri-calderon@linux.intel.com> wrote:
> > Section 2.2.1.2 of the Intel 64 and IA-32 Architectures Software
> > Developer's Manual volume 2A states that when memory addressing is used
> > (i.e., mod part of ModR/M is not 3), a SIB byte is used and the index of
> > the SIB byte points to the R/ESP (i.e.,index = 4), the index should not be
> > used in the computation of the memory address.
> >
> > An example of such instruction could be
> >
> >     insn -0x80(%rsp)
> >
> > This is represented as:
> >
> >      [opcode] 4c 24 80
> >
> >       ModR/M: mod: 1, reg: 1: r/m: 4 (R/ESP)
> >       SIB 24: sc: 0, index: 100 (R/ESP), base(R/ESP): 100
> >       Displacement -0x80
> >
> > The correct address is (base) + displacement; no index is used.
> >
> > Care is taken to allow R12 to be used as index, which is a valid scenario.
> 
> Since I have no idea what this patch has to do with the rest of the
> series, I'll ask a question:

Thanks for your feedback! I saw in a previous e-mail that you read the
cover-letter. :)
> 
> Why isn't this code in the standard x86 instruction decoder?  Is the
> decoder similarly buggy?

I did not find any bug in the instruction decoder. I think the reason
this code is not in the decoder is that the decoder only gives you the
bytes of the instructions without any meaning. For instance, it gives
you the ModRM byte but it does not tell you what register or addressing
mode is used.

To fully emulate the UMIP instructions I need to give meaning to the
ModRM and SIB bytes. Since I was trying many operand combinations, I ran
into this issue.

Thanks and BR,
Ricardo

  reply	other threads:[~2016-12-27 22:29 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-24  1:37 [v2 0/7] x86: enable User-Mode Instruction Prevention Ricardo Neri
2016-12-24  1:37 ` Ricardo Neri
2016-12-24  1:37 ` [v2 1/7] x86/mpx: Do not use SIB index if index points to R/ESP Ricardo Neri
2016-12-24  1:37   ` Ricardo Neri
2016-12-24  1:57   ` Andy Lutomirski
2016-12-27 22:29     ` Ricardo Neri [this message]
2016-12-24  1:37 ` [v2 2/7] x86/mpx: Fail when implicit zero-displacement is used along with R/EBP Ricardo Neri
2016-12-24  1:37   ` Ricardo Neri
2016-12-24  1:58   ` Andy Lutomirski
2016-12-27 22:33     ` Ricardo Neri
2017-01-03 16:41       ` Dave Hansen
2017-01-04  1:31         ` Ricardo Neri
2016-12-24  1:37 ` [v2 3/7] x86/mpx, x86/insn: Relocate insn util functions to a new insn-utils Ricardo Neri
2016-12-24  1:37   ` Ricardo Neri
2016-12-24  2:34   ` kbuild test robot
2016-12-24  2:34     ` kbuild test robot
2016-12-25  6:17   ` Masami Hiramatsu
2016-12-25  6:17     ` Masami Hiramatsu
2016-12-27 22:36     ` Ricardo Neri
2017-01-03 16:44   ` Dave Hansen
2017-01-04  1:31     ` Ricardo Neri
2016-12-24  1:37 ` [v2 4/7] x86/cpufeature: Add User-Mode Instruction Prevention definitions Ricardo Neri
2016-12-24  1:37   ` Ricardo Neri
2016-12-24  1:37 ` [v2 5/7] x86: Add emulation code for UMIP instructions Ricardo Neri
2016-12-24  1:37   ` Ricardo Neri
2016-12-24  2:11   ` Andy Lutomirski
2016-12-24  2:11     ` Andy Lutomirski
2016-12-28  0:39     ` Ricardo Neri
2016-12-28  0:39       ` Ricardo Neri
2016-12-28  0:48       ` Andy Lutomirski
2016-12-28  0:48         ` Andy Lutomirski
2016-12-30  5:23         ` Ricardo Neri
2016-12-30  5:23           ` Ricardo Neri
2016-12-31  2:07           ` Andy Lutomirski
2016-12-31  2:07             ` Andy Lutomirski
2017-01-04  1:30             ` Ricardo Neri
2017-01-04  1:30               ` Ricardo Neri
2016-12-25 15:49   ` Masami Hiramatsu
2016-12-25 15:49     ` Masami Hiramatsu
2016-12-28  0:40     ` Ricardo Neri
2016-12-28  0:40       ` Ricardo Neri
2016-12-24  1:37 ` [v2 6/7] x86/traps: Fixup general protection faults caused by UMIP Ricardo Neri
2016-12-24  1:37   ` Ricardo Neri
2016-12-24  2:11   ` Andy Lutomirski
2016-12-24  2:11     ` Andy Lutomirski
2016-12-27 22:34     ` Ricardo Neri
2016-12-27 22:34       ` Ricardo Neri
2016-12-24  4:22   ` kbuild test robot
2016-12-24  4:22     ` kbuild test robot
2016-12-24  1:37 ` [v2 7/7] x86: Enable User-Mode Instruction Prevention Ricardo Neri
2016-12-24  1:37   ` Ricardo Neri
2016-12-24  3:15   ` kbuild test robot
2016-12-24  3:15     ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482877758.106950.7.camel@ranerica-desktop \
    --to=ricardo.neri-calderon@linux.intel.com \
    --cc=adam.buchbinder@gmail.com \
    --cc=bp@suse.de \
    --cc=colin.king@canonical.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-msdos@vger.kernel.org \
    --cc=lstoakes@gmail.com \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=qiaowei.ren@intel.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=tglx@linutronix.de \
    --cc=wine-devel@winehq.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.