public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Willy Tarreau <w@1wt.eu>
Cc: Pavel Machek <pavel@ucw.cz>, Avi Kivity <avi@redhat.com>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Matteo Croce <technoboy85@gmail.com>,
	Sven-Haegar Koch <haegar@sdinet.de>, Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org
Subject: Re: i686 quirk for AMD Geode
Date: Tue, 10 Nov 2009 14:15:55 -0800	[thread overview]
Message-ID: <4AF9E61B.5090407@zytor.com> (raw)
In-Reply-To: <20091110220652.GE26633@1wt.eu>

On 11/10/2009 02:06 PM, Willy Tarreau wrote:
> On Tue, Nov 10, 2009 at 01:19:30PM -0800, H. Peter Anvin wrote:
>> Willy, perhaps you can come up with a list of features you think should
>> be emulated, together with an explanation of why you opted for that list
>> of features and *did not* opt for others.
> 
> Well, the instructions I had to emulate were the result of failures
> to run standard distros on older machines. When I ran a 486 distro
> on my old 386, I found that almost everything worked except a few
> programs making use of BSWAP for htonl(), and a small group of other
> ones making occasional use of CMPXCHG for mutex handling. So I checked
> the differences between 386 and 486 and found that the last remaining
> one was XADD which I did not find in my binaries but which was really
> obvious to implement, so it made sense to complete the emulator. That
> said, a feature was missing with CMPXCHG. It was generally used with
> a LOCK prefix which could not be emulated. In practice, that wasn't
> an issue since I did not have any SMP i386 and I think we might only
> find them on some very specific industrial boards if any.
> 

Linux doesn't support 386 SMP anyway, and we really don't support 486
SMP either since noone relevant seems to have a board we can test on.

> But what I can say is that after emulating those instructions, I
> never got any illegal instruction anymore on my systems. Here
> Matteo reports an issue with NOPL, which might have been introduced
> with newer compilers. So if we get NOPL+CMOV, I think that every
> CPU starting from 486 will be able to execute all the applications
> I have been running on those machines. We can add the 486 ones if
> we think it's worth it.

NOPL was introduced with a recent binutils(!) change.  They might have
backed that one out.

> Once again, I have no argument against emulating more instructions.
> It's just that I never needed them, and I fear that doing so might
> render the code a lot more complex and slower. Maybe time will prove
> me wrong and I will have no problem with that. We can re-open this
> thread after the first report of a SIGILL with the patch applied.
> 
> So in my opinion, we should have :
>   - CMOV (for 486, Pentium, C3, K6, ...)
>   - NOPL (newcomer)
> 
> And if we want to extend down to i386 :
>   - BSWAP (=htonl)
>   - CMPXCHG (mutex)
>   - XADD (never encoutered but cheap)
> 
> I still have the 2.4 patch for BSWAP, CMPXCHG, CMOV and XADD lying
> around. I'm appending it to the end of this mail in case it can fuel
> the discussion. I've not ported it to 2.6 yet simply because my old
> systems are still on 2.4, but volunteers are welcome :-)
> 
>> Note: emulated FPU is a special subcase.  The FPU operations are
>> heavyweight enough that the overhead of trapping versus library calls is
>> relatively insignificant.
> 
> Agreed for most of them, though some cheap ones such as FADD can
> see a huge difference. In fact it's mostly that it's been common
> for a long time to see slow software FPU (till 386 & 486-SX), so
> it's been avoided for a long time.
> 
> Regards,
> Willy

I immediately note that you have absolutely no check on the code
segment, either in terms of code segment limits or even that we're in
the right mode.  Furthermore, you read user space -- code in user space
is still user space -- without get_user().  We also need NX protection
to be honoured, and the various special subtleties of the x86
instruction format (15-byte limit, for example) to be preserved: they
aren't just there randomly, but are there to protect against specific
failures.

*THIS* is the kind of complexity that makes me think that having a
single source for all interpretation done in the kernel is the preferred
option.

	-hpa

  reply	other threads:[~2009-11-10 22:23 UTC|newest]

Thread overview: 135+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-03  2:12 i686 quirk for AMD Geode Matteo Croce
2009-10-03  2:34 ` H. Peter Anvin
2009-10-03  3:08   ` Matteo Croce
2009-10-03  2:35 ` H. Peter Anvin
2009-10-03  7:21 ` Ingo Molnar
2009-10-03  9:53   ` Matteo Croce
2009-10-03 14:12     ` H. Peter Anvin
2009-10-03 14:56       ` Matteo Croce
2009-11-06 14:59   ` Matteo Croce
2009-11-06 16:44     ` H. Peter Anvin
2009-11-06 22:18       ` Matteo Croce
2009-11-07  0:49         ` Alan Cox
2009-11-08 17:37         ` Pavel Machek
2009-11-08 17:40           ` Matteo Croce
2009-11-08 18:10             ` Pavel Machek
2009-11-08 18:13               ` Matteo Croce
2009-11-08 19:29               ` Sven-Haegar Koch
2009-11-08 19:36                 ` Pavel Machek
2009-11-08 19:47                   ` Matteo Croce
2009-11-08 19:51                     ` Pavel Machek
2009-11-08 20:08                       ` Alan Cox
2009-11-10  5:27                         ` Willy Tarreau
2009-11-10  6:02                           ` H. Peter Anvin
2009-11-10 10:41                             ` Avi Kivity
2009-11-10 10:56                               ` Alan Cox
2009-11-10 17:08                                 ` H. Peter Anvin
2009-11-10 17:24                                   ` Alan Cox
2009-11-10 18:49                                     ` H. Peter Anvin
2009-11-10 19:50                                       ` Avi Kivity
2009-11-10 20:01                                         ` H. Peter Anvin
2009-11-10 20:16                                           ` Willy Tarreau
2009-11-10 20:25                                             ` H. Peter Anvin
2009-11-10 20:34                                               ` Willy Tarreau
2009-11-10 20:54                                             ` Pavel Machek
2009-11-10 21:12                                               ` Willy Tarreau
2009-11-10 21:19                                                 ` H. Peter Anvin
2009-11-10 22:06                                                   ` Willy Tarreau
2009-11-10 22:15                                                     ` H. Peter Anvin [this message]
2009-11-10 22:20                                                       ` Ingo Molnar
2009-11-10 22:42                                                         ` Willy Tarreau
2009-11-10 22:47                                                           ` H. Peter Anvin
2009-11-11  5:52                                                             ` Willy Tarreau
2009-11-11  6:15                                                               ` H. Peter Anvin
2009-11-11  6:36                                                                 ` Willy Tarreau
2009-11-11  7:57                                                                   ` H. Peter Anvin
2009-11-11  9:32                                                                     ` Willy Tarreau
2009-11-12  2:23                                                                       ` Matt Thrailkill
2009-11-12  5:27                                                                         ` Willy Tarreau
2009-11-12  5:31                                                                           ` H. Peter Anvin
2009-11-12  5:40                                                                             ` Willy Tarreau
2009-11-23 19:27                                                                               ` Eric W. Biederman
2009-11-23 19:35                                                                                 ` H. Peter Anvin
2009-11-23 20:03                                                                                   ` Eric W. Biederman
2009-11-11 10:03                                                                 ` Alan Cox
2009-11-11  8:17                                                               ` Pavel Machek
2009-11-10 22:21                                                       ` Willy Tarreau
2009-11-11 10:21                                                     ` Alan Cox
2009-11-11 10:43                                                       ` Willy Tarreau
2009-11-11 16:15                                                         ` H. Peter Anvin
2009-11-10 22:27                                                   ` Lennart Sorensen
2009-11-10 22:29                                                     ` H. Peter Anvin
2009-11-10 22:34                                                       ` Lennart Sorensen
2009-11-10 22:38                                                         ` H. Peter Anvin
2009-11-10 22:54                                                           ` Lennart Sorensen
2009-11-11  8:03                                                 ` Pavel Machek
2009-11-11  9:35                                                   ` Willy Tarreau
2009-11-10 21:21                                               ` Matt Thrailkill
2009-11-10 21:26                                                 ` H. Peter Anvin
2009-11-10 22:01                                               ` Matteo Croce
2009-11-10 22:10                                                 ` Willy Tarreau
2009-11-11 10:54                                               ` Bernd Petrovitsch
2009-11-12  0:51                                       ` Daniel Pittman
2009-11-12  1:00                                         ` H. Peter Anvin
2009-11-10 16:29                               ` H. Peter Anvin
2009-11-08 19:46                 ` Matteo Croce
2009-11-08 19:50                   ` Pavel Machek
2009-11-08 20:41                 ` Krzysztof Halasa
2009-11-08 18:42       ` Matteo Croce
2009-11-09 20:16         ` Lennart Sorensen
2009-11-09 21:03           ` Matteo Croce
2009-11-09 21:17           ` H. Peter Anvin
2009-11-09 21:23             ` Lennart Sorensen
2009-11-12 12:18               ` Pavel Machek
2009-11-13  2:03                 ` Andres Salomon
2009-11-13 10:50                 ` Alan Cox
2009-11-13 16:23                 ` Lennart Sorensen
2009-11-13 16:57                   ` Alan Cox
2009-11-13 19:24                     ` Lennart Sorensen
2009-11-13 21:21                       ` Alan Cox
2009-11-16 17:50                         ` Lennart Sorensen
2009-11-17 11:59                           ` Alan Cox
2009-11-17 14:34                             ` Lennart Sorensen
2009-11-17 16:43                               ` H. Peter Anvin
2009-11-17 17:10                                 ` Lennart Sorensen
2009-11-17 16:48                             ` Valdis.Kletnieks
2009-11-17 17:25                               ` Lennart Sorensen
2009-11-17 17:33                                 ` H. Peter Anvin
2009-11-17 18:33                                   ` Lennart Sorensen
2009-11-18 20:21                                     ` Lennart Sorensen
2009-11-18 20:59                                       ` H. Peter Anvin
2009-11-18 21:11                                         ` Lennart Sorensen
2009-11-19  0:41                                           ` Lennart Sorensen
2009-11-13  5:55               ` Yuhong Bao
2009-11-13 16:24                 ` Lennart Sorensen
2009-11-13 13:33               ` Pádraig Brady
2009-11-13 16:25                 ` Lennart Sorensen
2009-11-08 17:35     ` Pavel Machek
2009-10-03 18:05 ` Arjan van de Ven
2009-10-03 22:04   ` Matteo Croce
2009-10-03 22:32     ` Gabor Gombas
2009-10-03 22:54       ` Matteo Croce
2009-10-04  7:29         ` Gabor Gombas
2009-10-04  2:25     ` Arjan van de Ven
2009-10-04 14:58       ` Alan Cox
2009-11-09 21:14         ` H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2009-11-06 15:49 Martin Schleier
2009-11-06 15:59 ` Alan Cox
2009-11-06 16:42   ` Matteo Croce
2009-11-06 16:57   ` Martin Schleier
2009-11-06 18:22     ` Alan Cox
2009-11-06 20:06       ` Martin Schleier
     [not found]         ` <20091106210259.290b281a@lxorguk.ukuu.org.uk>
2009-11-06 22:33           ` Martin Schleier
2009-11-06 23:05         ` Krzysztof Halasa
2009-11-07  0:05           ` Martin Schleier
2009-11-07 10:37             ` Krzysztof Halasa
2009-11-07 11:11             ` Matteo Croce
2009-11-08  2:14               ` H. Peter Anvin
2009-11-08 16:05               ` Andres Salomon
2009-11-08 18:04                 ` Matteo Croce
2009-11-08 18:46                   ` Andres Salomon
2009-11-08 18:22                 ` Matteo Croce
2009-11-08 18:47                   ` Andres Salomon
2009-11-10  5:58                     ` Willy Tarreau
2009-11-08 22:10 H. Peter Anvin
2009-11-09  0:22 ` Alan Cox

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=4AF9E61B.5090407@zytor.com \
    --to=hpa@zytor.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=avi@redhat.com \
    --cc=haegar@sdinet.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=pavel@ucw.cz \
    --cc=technoboy85@gmail.com \
    --cc=w@1wt.eu \
    /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