mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gabriel Paubert <paubert@iram.es>
To: "David S. Miller" <davem@davemloft.net>
Cc: Zachary Amsden <zach@vmware.com>,
	linux-kernel@vger.kernel.org, davej@codemonkey.org.uk,
	hpa@zytor.com, bgerst@didntduck.org, Riley@Williams.Name
Subject: Re: PROBLEM: x86 alignment check bug
Date: Wed, 8 Sep 2004 14:12:36 +0200	[thread overview]
Message-ID: <20040908121236.GA5283@iram.es> (raw)
In-Reply-To: <20040907170807.2e8bba1d.davem@davemloft.net>

On Tue, Sep 07, 2004 at 05:08:07PM -0700, David S. Miller wrote:
> On Tue, 07 Sep 2004 16:51:41 -0700
> Zachary Amsden <zach@vmware.com> wrote:
> 
> > Clearly, this is not correct.  Considering how difficult the fix is (the 
> > kernel must disassemble the faulting instruction and use register 
> > information to determine the faulting address),
> 
> While it is more difficult to disassemble x86 opcodes,
> what you describe is exactly how we handle this on
> sparc64.  In fact we do opcode decoding for most fault
> types.

For page faults, cr2 gives you the linear address, i.e., after
adding the base of the segment, which you can only find
by looking up the GDT and/or LDT for the correct segment.

Of course, the address decoding depends also of the size
attributes of the code segment (16 or 32 bits for i386, 
64 bits for x86_64) which needs also a lookup of CS in the
segment tables, and of a possible address prefix which 
affects the decoding. Of course this is fraught with race
if another thread modifies the LDT at the same time.

Then most instructions use a standard memory address
encoding, but there are a few exceptions which implicitly
use ESI and/or EDI. For the ones that use two memory 
addresses (movs/cmps), you'd have to even compute both 
addresses and decide which one is the unaligned one. 

I somehow suspect that Sparc is somewhat simpler to decode
than i386/x86_64 ;-)

Don't bloat the kernel with decoding this mess, please.
A helper library in user space, why not?

	Regards,
	Gabriel

  reply	other threads:[~2004-09-08 12:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-07 23:51 Zachary Amsden
2004-09-08  0:08 ` David S. Miller
2004-09-08 12:12   ` Gabriel Paubert [this message]
2004-09-08 18:26     ` David S. Miller
2004-09-08 13:26 ` Alan Cox
2004-09-09 16:29 Petr Vandrovec

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=20040908121236.GA5283@iram.es \
    --to=paubert@iram.es \
    --cc=Riley@Williams.Name \
    --cc=bgerst@didntduck.org \
    --cc=davej@codemonkey.org.uk \
    --cc=davem@davemloft.net \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zach@vmware.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome