linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Pentium Pro - sysenter - doublefault
@ 2003-08-21 20:41 Jim Houston
  2003-08-21 21:32 ` Mikael Pettersson
  2003-08-25  4:05 ` Jamie Lokier
  0 siblings, 2 replies; 19+ messages in thread
From: Jim Houston @ 2003-08-21 20:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: jim.houston

Hi Everyone,

I upgraded my Pentium Pro system to Redhat 9, installed a
linux-2.6.0-test3 kernel, and it fails with a double-fault when
init starts.

The code which decides if it is o.k. to use sysenter is broken for
some Pentium Pro cpus ,in particular, this bit of code from
arch/i386/kernel/cpu/intel.c:

	/* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it */
	if ( c->x86 == 6 && c->x86_model < 3 && c->x86_mask < 3 )
		clear_bit(X86_FEATURE_SEP, c->x86_capability);

On my cpu model=1 and mask=9, it doesn't clear 86_FEATURE_SEP.
This results in a double-fault when init starts.  The double-fault
happens on the sysexit.  The new double-fault handler caught this
nicely, and I was able to debug this with kgdb.

The logic above is exactly what Intel says to do in "IA-32 Intel®
Architecture Software Developer's Manual, Volume 2: Instruction Set
Reference" on page 3-767.  It also says that sysenter was added to the
Pentium II.

I checked the Pentium Pro and Pentium II Specifications Update manuals
hoping to find the details to justify the "mask < 3" portion of the test
above. They both describe sysenter related errata but none which was
fixed in mask 3.

The attached patch avoids using sysenter on all Pentium Pro systems.

Jim Houston - Concurrent Computer Corp.


diff -urN linux-2.6.0-test3.orig/arch/i386/kernel/cpu/intel.c
linux-2.6.0-test3.new/arch/i386/kernel/cpu/intel.c
--- linux-2.6.0-test3.orig/arch/i386/kernel/cpu/intel.c	2003-08-20
10:30:14.000000000 -0400
+++ linux-2.6.0-test3.new/arch/i386/kernel/cpu/intel.c	2003-08-21
14:39:35.000000000 -0400
@@ -246,7 +246,7 @@
 	}
 
 	/* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it */
-	if ( c->x86 == 6 && c->x86_model < 3 && c->x86_mask < 3 )
+	if ( c->x86 == 6 && c->x86_model < 3)
 		clear_bit(X86_FEATURE_SEP, c->x86_capability);
 	
 	/* Names for the Pentium II/Celeron processors 





^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-21 20:41 [PATCH] Pentium Pro - sysenter - doublefault Jim Houston
@ 2003-08-21 21:32 ` Mikael Pettersson
  2003-08-22  2:18   ` [PATCH2] " Jim Houston
                     ` (2 more replies)
  2003-08-25  4:05 ` Jamie Lokier
  1 sibling, 3 replies; 19+ messages in thread
From: Mikael Pettersson @ 2003-08-21 21:32 UTC (permalink / raw)
  To: jim.houston; +Cc: linux-kernel

Jim Houston writes:
 > Hi Everyone,
 > 
 > I upgraded my Pentium Pro system to Redhat 9, installed a
 > linux-2.6.0-test3 kernel, and it fails with a double-fault when
 > init starts.
 > 
 > The code which decides if it is o.k. to use sysenter is broken for
 > some Pentium Pro cpus ,in particular, this bit of code from
 > arch/i386/kernel/cpu/intel.c:
 > 
 > 	/* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it */
 > 	if ( c->x86 == 6 && c->x86_model < 3 && c->x86_mask < 3 )
 > 		clear_bit(X86_FEATURE_SEP, c->x86_capability);
 > 
 > On my cpu model=1 and mask=9, it doesn't clear 86_FEATURE_SEP.
 > This results in a double-fault when init starts.  The double-fault
 > happens on the sysexit.  The new double-fault handler caught this
 > nicely, and I was able to debug this with kgdb.
 > 
 > The logic above is exactly what Intel says to do in "IA-32 Intel®
 > Architecture Software Developer's Manual, Volume 2: Instruction Set
 > Reference" on page 3-767.  It also says that sysenter was added to the
 > Pentium II.

I double-checked AP-485 (24161823.pdf, the "real" reference to CPUID),
and it says (section 3.4) that SEP is unsupported when the signature
as a whole is less that 0x633. This means all PPros, and PII Model 3s
with steppings less than 3.

The problem is that the kernel check you quoted above is buggy: the
c->x86_model < 3 && c->x86_mask < 3 part fails for late-stepping PPros
since c->x86_mask >= 3 for them. The test should be rewritten as:

        if (c->x86 == 6 && (c->x86_model < 3 ||
                            (c->x86_model == 3 && c->x86_mask < 3)))
                clear_bit(X86_FEATURE_SEP, c->x86_capability);

/Mikael

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH2] Pentium Pro - sysenter - doublefault
  2003-08-21 21:32 ` Mikael Pettersson
@ 2003-08-22  2:18   ` Jim Houston
  2003-08-25  5:56   ` [PATCH] " Jamie Lokier
  2003-08-25  6:09   ` Jamie Lokier
  2 siblings, 0 replies; 19+ messages in thread
From: Jim Houston @ 2003-08-22  2:18 UTC (permalink / raw)
  To: Mikael Pettersson, davej; +Cc: linux-kernel

On Thu, 2003-08-21 at 17:32, Mikael Pettersson wrote:
>  > The logic above is exactly what Intel says to do in "IA-32 Intel®
>  > Architecture Software Developer's Manual, Volume 2: Instruction Set
>  > Reference" on page 3-767.  It also says that sysenter was added to the
>  > Pentium II.
> 
> I double-checked AP-485 (24161823.pdf, the "real" reference to CPUID),
> and it says (section 3.4) that SEP is unsupported when the signature
> as a whole is less that 0x633. This means all PPros, and PII Model 3s
> with steppings less than 3.
> 

Hi Dave, Everyone,

This make sense. Here is Mikael's suggested code as a patch.

Dave, I picked your name from the maintainers list.  Please 
feed this patch up the chain.


Jim Houston - Concurrent Computer Corp. 


diff -urN linux-2.6.0-test3.orig/arch/i386/kernel/cpu/intel.c
linux-2.6.0-test3.new/arch/i386/kernel/cpu/intel.c
--- linux-2.6.0-test3.orig/arch/i386/kernel/cpu/intel.c	2003-08-20
10:30:14.000000000 -0400
+++ linux-2.6.0-test3.new/arch/i386/kernel/cpu/intel.c	2003-08-21
21:34:40.000000000 -0400
@@ -246,7 +246,8 @@
 	}
 
 	/* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it */
-	if ( c->x86 == 6 && c->x86_model < 3 && c->x86_mask < 3 )
+	if ( c->x86 == 6 && ((c->x86_model < 3) ||
+				(c->x86_model == 3 && c->x86_mask < 3)))
 		clear_bit(X86_FEATURE_SEP, c->x86_capability);
 	
 	/* Names for the Pentium II/Celeron processors 





^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-21 20:41 [PATCH] Pentium Pro - sysenter - doublefault Jim Houston
  2003-08-21 21:32 ` Mikael Pettersson
@ 2003-08-25  4:05 ` Jamie Lokier
  2003-08-25  4:14   ` Jakob Oestergaard
  2003-08-26 12:26   ` Richard Curnow
  1 sibling, 2 replies; 19+ messages in thread
From: Jamie Lokier @ 2003-08-25  4:05 UTC (permalink / raw)
  To: Jim Houston; +Cc: linux-kernel, jim.houston

Jim Houston wrote:
> On my cpu model=1 and mask=9, it doesn't clear 86_FEATURE_SEP.
> This results in a double-fault when init starts.  The double-fault
> happens on the sysexit.  The new double-fault handler caught this
> nicely, and I was able to debug this with kgdb.

Does anyone know what the syenter & sysexit instructions do on these
early PPro CPUs?

The Intel documentation is vague, saying only to avoid using them.
I'd like to know what happens if userspace does "sysenter" on one of
these systems.  Does it issue Invalid Opcode, General Protection
fault, or something else?

Jim you can answer this as you have such a Ppro.  Could you please run
this very simple userspace program for me, and report the result?

	int main() { __asm__ ("sysenter"); return 0; }

I expect it to die with SIGILL on Pentium and earlier chips, and
SIGSEGV on "good" PPro and later chips running kernels which don't
enable the sysenter instruction.

But what does it do on your early Intel PPro, the one which is the
subject of this thread?

Thanks,
-- Jamie

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-25  4:05 ` Jamie Lokier
@ 2003-08-25  4:14   ` Jakob Oestergaard
  2003-08-25  5:50     ` Jamie Lokier
  2003-08-26 12:26   ` Richard Curnow
  1 sibling, 1 reply; 19+ messages in thread
From: Jakob Oestergaard @ 2003-08-25  4:14 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Jim Houston, linux-kernel, jim.houston

On Mon, Aug 25, 2003 at 05:05:14AM +0100, Jamie Lokier wrote:
...
> Jim you can answer this as you have such a Ppro.  Could you please run
> this very simple userspace program for me, and report the result?
> 
> 	int main() { __asm__ ("sysenter"); return 0; }

I tested on two boxes:

Stepping 1 ppro:  SIGSEGV
Stepping 7 ppro:  SIGSEGV

If you need additional info, please just ask.

-- 
................................................................
:   jakob@unthought.net   : And I see the elder races,         :
:.........................: putrid forms of man                :
:   Jakob Østergaard      : See him rise and claim the earth,  :
:        OZ9ABN           : his downfall is at hand.           :
:.........................:............{Konkhra}...............:

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-25  4:14   ` Jakob Oestergaard
@ 2003-08-25  5:50     ` Jamie Lokier
  2003-08-25  6:29       ` Jamie Lokier
  0 siblings, 1 reply; 19+ messages in thread
From: Jamie Lokier @ 2003-08-25  5:50 UTC (permalink / raw)
  To: Jakob Oestergaard, Jim Houston, linux-kernel, jim.houston

Jakob Oestergaard wrote:
> > Jim you can answer this as you have such a Ppro.  Could you please run
> > this very simple userspace program for me, and report the result?
> > 
> > 	int main() { __asm__ ("sysenter"); return 0; }
> 
> I tested on two boxes:
> 
> Stepping 1 ppro:  SIGSEGV
> Stepping 7 ppro:  SIGSEGV

Thank you!

So that means the sysenter instruction _does_ exist on the PPro and
early Pentium II, but it isn't usable.

It's safe so long as it is disabled, but as you found, when you enable
and use it, it doesn't work as expected.  (I wonder what the actual
behaviour of sysenter/sysexit are on these CPUs.)

-- Jamie

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-21 21:32 ` Mikael Pettersson
  2003-08-22  2:18   ` [PATCH2] " Jim Houston
@ 2003-08-25  5:56   ` Jamie Lokier
  2003-08-25  6:09   ` Jamie Lokier
  2 siblings, 0 replies; 19+ messages in thread
From: Jamie Lokier @ 2003-08-25  5:56 UTC (permalink / raw)
  To: Mikael Pettersson; +Cc: jim.houston, linux-kernel

Mikael Pettersson wrote:
>  > The logic above is exactly what Intel says to do in "IA-32 Intel®
>  > Architecture Software Developer's Manual, Volume 2: Instruction Set
>  > Reference" on page 3-767.  It also says that sysenter was added to the
>  > Pentium II.
> 
> I double-checked AP-485 (24161823.pdf, the "real" reference to CPUID),
> and it says (section 3.4) that SEP is unsupported when the signature
> as a whole is less that 0x633. This means all PPros, and PII Model 3s
> with steppings less than 3.

So (double-checking) the pseudo-code in "IA-32: Intel Architecture
Software Development Manual, Volume 2: Instruction Set Reference" is buggy?

Oh my!  Perhaps there are other bugs in that behemoth of a manual, too :/

-- Jamie

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-21 21:32 ` Mikael Pettersson
  2003-08-22  2:18   ` [PATCH2] " Jim Houston
  2003-08-25  5:56   ` [PATCH] " Jamie Lokier
@ 2003-08-25  6:09   ` Jamie Lokier
  2003-09-03 12:50     ` Pavel Machek
  2 siblings, 1 reply; 19+ messages in thread
From: Jamie Lokier @ 2003-08-25  6:09 UTC (permalink / raw)
  To: Mikael Pettersson; +Cc: jim.houston, linux-kernel

Mikael Pettersson wrote:
> I double-checked AP-485 (24161823.pdf, the "real" reference to CPUID),
> and it says (section 3.4) that SEP is unsupported when the signature
> as a whole is less that 0x633. This means all PPros, and PII Model 3s
> with steppings less than 3.

"SEP is unsupported".  It's interesting that Pentium Pro erratum #82
is "SYSENTER/SYSEXIT instructions can implicitly load 'null segment
selector' to SS and CS registers", implying that SYSENTER does
_something_ useful on PPros.

-- Jamie

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-25  5:50     ` Jamie Lokier
@ 2003-08-25  6:29       ` Jamie Lokier
  2003-08-25  7:49         ` Jakob Oestergaard
  2003-08-25 18:15         ` Jim Houston
  0 siblings, 2 replies; 19+ messages in thread
From: Jamie Lokier @ 2003-08-25  6:29 UTC (permalink / raw)
  To: Jakob Oestergaard, Jim Houston, linux-kernel, jim.houston

Jamie Lokier wrote:
> So that means the sysenter instruction _does_ exist on the PPro and
> early Pentium II, but it isn't usable.

If anyone has information on what the SYSENTER and SYSEXIT
instructions actually do on Intel Pentium Pro or stepping<3 Pentium II
processors, I am very interested.

I'm intrigued to know if the buggy behaviour of these instructions is
really unsafe, or simply hard to use so Intel changed the behaviour.
(An example of hard to use would be SYSENTER not disabling
interrupts).  If they are safe but hard to use, perhaps the ingenuity
of kernel hackers can work around the hardness >:)

Does anyone have a contact at Intel for this question?

Thanks,
-- Jamie

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-25  6:29       ` Jamie Lokier
@ 2003-08-25  7:49         ` Jakob Oestergaard
  2003-08-25 18:15         ` Jim Houston
  1 sibling, 0 replies; 19+ messages in thread
From: Jakob Oestergaard @ 2003-08-25  7:49 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Jim Houston, linux-kernel, jim.houston

On Mon, Aug 25, 2003 at 07:29:05AM +0100, Jamie Lokier wrote:
> Jamie Lokier wrote:
> > So that means the sysenter instruction _does_ exist on the PPro and
> > early Pentium II, but it isn't usable.
> 
> If anyone has information on what the SYSENTER and SYSEXIT
> instructions actually do on Intel Pentium Pro or stepping<3 Pentium II
> processors, I am very interested.

I dug up a little more from the archeological site (machine room -
sigh)...

-------------------------------------------
model name      : Pentium II (Deschutes)
stepping        : 2
$ ./syse 
Segmentation fault
-------------------------------------------
model name      : Celeron (Mendocino)
stepping        : 0
cpu MHz         : 334.097
$ ./syse
Segmentation fault
-------------------------------------------
CPU: Pentium II/Pentium II Xeon/Celeron (299.94-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x651  Stepping = 1
$ ./syse
Bus error (core dumped)
-------------------------------------------

The last one is a FreeBSD box.


-- 
................................................................
:   jakob@unthought.net   : And I see the elder races,         :
:.........................: putrid forms of man                :
:   Jakob Østergaard      : See him rise and claim the earth,  :
:        OZ9ABN           : his downfall is at hand.           :
:.........................:............{Konkhra}...............:

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-25  6:29       ` Jamie Lokier
  2003-08-25  7:49         ` Jakob Oestergaard
@ 2003-08-25 18:15         ` Jim Houston
  1 sibling, 0 replies; 19+ messages in thread
From: Jim Houston @ 2003-08-25 18:15 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: linux-kernel

On Mon, 2003-08-25 at 02:29, Jamie Lokier wrote:
> Jamie Lokier wrote:
> > So that means the sysenter instruction _does_ exist on the PPro and
> > early Pentium II, but it isn't usable.
> 
> If anyone has information on what the SYSENTER and SYSEXIT
> instructions actually do on Intel Pentium Pro or stepping<3 Pentium II
> processors, I am very interested.
> 
> I'm intrigued to know if the buggy behaviour of these instructions is
> really unsafe, or simply hard to use so Intel changed the behaviour.
> (An example of hard to use would be SYSENTER not disabling
> interrupts).  If they are safe but hard to use, perhaps the ingenuity
> of kernel hackers can work around the hardness >:)

Hi Jamie,

I tried your test on my machine.  It fails with a segmentation
fault.  I noticed that the Pentium II specifications update manual
starts with rev C0 stepping (ignoring mask rev < 3).
I'm inclined to forgive Intel for not publishing the scary errata that
goes with the first few mask revs, particularly for an old product.

When I was chasing the original problem, I added tracing code 
(compiling the kernel with finstrument-functions) so that when I
got into kgdb after the double-fault I could see that it had just
completed a umask system call.  I'm assuming that it failed on
the sysexit.

I keep the old Pentium Pro around because it has an NMI interrupt
button.

I'm happy that Linus has merged the fix to disable correctly
disable sysenter for these machines.

Jim Houston - Concurrent Computer Corp


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-25  4:05 ` Jamie Lokier
  2003-08-25  4:14   ` Jakob Oestergaard
@ 2003-08-26 12:26   ` Richard Curnow
  2003-08-27 14:01     ` Jamie Lokier
  1 sibling, 1 reply; 19+ messages in thread
From: Richard Curnow @ 2003-08-26 12:26 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Jim Houston, linux-kernel, jim.houston

* Jamie Lokier <jamie@shareable.org> [2003-08-26]:
> Could you please run this very simple userspace program for me, and
> report the result?
> 
> 	int main() { __asm__ ("sysenter"); return 0; }
> 
> I expect it to die with SIGILL on Pentium and earlier chips, and
> SIGSEGV on "good" PPro and later chips running kernels which don't
> enable the sysenter instruction.

OK, since I get something different to the other reports I saw:

 1:20PM-malvern-0-534-% ./sysenter
 1:20PM-malvern-STKFLT-535-% echo $?
144

/proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 5
model name      : Pentium II (Deschutes)
stepping        : 0
cpu MHz         : 333.495
cache size      : 512 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr
bogomips        : 657.40

uname -a:
Linux malvern 2.6.0-test2-mm5 #2 Fri Aug 8 12:06:50 BST 2003 i686 unknown

HTH

-- 
Richard \\\ SuperH Core+Debug Architect /// .. At home ..
  P.    /// richard.curnow@superh.com  ///  rc@rc0.org.uk
Curnow  \\\ http://www.superh.com/    ///  www.rc0.org.uk

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-26 12:26   ` Richard Curnow
@ 2003-08-27 14:01     ` Jamie Lokier
  2003-08-27 14:23       ` Richard Curnow
                         ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Jamie Lokier @ 2003-08-27 14:01 UTC (permalink / raw)
  To: Jim Houston, linux-kernel, jim.houston

Richard Curnow wrote:
> OK, since I get something different to the other reports I saw:
> 
>  1:20PM-malvern-0-534-% ./sysenter
>  1:20PM-malvern-STKFLT-535-% echo $?
> 144

Hi Richard,

That's because you ran it on a 2.5/2.6 kernel, right?  The test code
is meant for 2.4 kernels and earlier :)

Here is a more universal test:

	int main () {
		asm ("movl %%esp,%%ebp;sysenter" : : "a" (1), "b" (0));
		return 0;
	}

I expect it to do the first of these which is applicable:

	- raise SIGILL on Pentium and earlier Intel CPUs
	- raise SIGILL on non-Intel CPUs which don't have the SEP capability
	- raise SIGSEGV on Pentium Pro CPUs
	- raise SIGSEGV on Pentium II CPUs with model == 3 and stepping < 3
	- raise SIGSEGV on 2.4 kernels
	- exit with status 0 on 2.6 kernels

Enjoy,
-- Jamie

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-27 14:01     ` Jamie Lokier
@ 2003-08-27 14:23       ` Richard Curnow
  2003-08-27 14:25       ` dl-ipaddr
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Richard Curnow @ 2003-08-27 14:23 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Jim Houston, linux-kernel, jim.houston

* Jamie Lokier <jamie@shareable.org> [2003-08-27]:
> Here is a more universal test:
> 
[snip]

> 	- exit with status 0 on 2.6 kernels

Yes, confirmed, that's what it did on 2.6.0-test2-mm5 here.  Sorry, I
can't try 2.4 right now.

-- 
Richard \\\ SuperH Core+Debug Architect /// .. At home ..
  P.    /// richard.curnow@superh.com  ///  rc@rc0.org.uk
Curnow  \\\ http://www.superh.com/    ///  www.rc0.org.uk

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-27 14:01     ` Jamie Lokier
  2003-08-27 14:23       ` Richard Curnow
@ 2003-08-27 14:25       ` dl-ipaddr
  2003-08-27 15:15       ` Stan Bubrouski
  2003-08-27 16:02       ` Pasi Savolainen
  3 siblings, 0 replies; 19+ messages in thread
From: dl-ipaddr @ 2003-08-27 14:25 UTC (permalink / raw)
  To: linux-kernel

did you notice the announcement from www.apache.org and www.debian.org?

-----Original Message-----
From: linux-kernel-owner@vger.kernel.org
[mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Jamie Lokier
Sent: Wednesday, August 27, 2003 10:01 PM
To: Jim Houston; linux-kernel@vger.kernel.org; jim.houston@ccur.com
Subject: Re: [PATCH] Pentium Pro - sysenter - doublefault


Richard Curnow wrote:
> OK, since I get something different to the other reports I saw:
> 
>  1:20PM-malvern-0-534-% ./sysenter  1:20PM-malvern-STKFLT-535-% echo 
> $? 144

Hi Richard,

That's because you ran it on a 2.5/2.6 kernel, right?  The test code is
meant for 2.4 kernels and earlier :)

Here is a more universal test:

	int main () {
		asm ("movl %%esp,%%ebp;sysenter" : : "a" (1), "b" (0));
		return 0;
	}

I expect it to do the first of these which is applicable:

	- raise SIGILL on Pentium and earlier Intel CPUs
	- raise SIGILL on non-Intel CPUs which don't have the SEP
capability
	- raise SIGSEGV on Pentium Pro CPUs
	- raise SIGSEGV on Pentium II CPUs with model == 3 and stepping
< 3
	- raise SIGSEGV on 2.4 kernels
	- exit with status 0 on 2.6 kernels

Enjoy,
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel"
in the body of a message to majordomo@vger.kernel.org More majordomo
info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-27 14:01     ` Jamie Lokier
  2003-08-27 14:23       ` Richard Curnow
  2003-08-27 14:25       ` dl-ipaddr
@ 2003-08-27 15:15       ` Stan Bubrouski
  2003-08-27 16:02       ` Pasi Savolainen
  3 siblings, 0 replies; 19+ messages in thread
From: Stan Bubrouski @ 2003-08-27 15:15 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Jim Houston, linux-kernel, jim.houston

Jamie Lokier wrote:

<SNIP>

> I expect it to do the first of these which is applicable:
> 
> 	- raise SIGILL on Pentium and earlier Intel CPUs
> 	- raise SIGILL on non-Intel CPUs which don't have the SEP capability
> 	- raise SIGSEGV on Pentium Pro CPUs
> 	- raise SIGSEGV on Pentium II CPUs with model == 3 and stepping < 3
> 	- raise SIGSEGV on 2.4 kernels
> 	- exit with status 0 on 2.6 kernels
> 
> Enjoy,
> -- Jamie

As expected I get a SIGILL on P166 with 2.4.22

-sb
-----------------------------------------------
The price of freedom? Ask your Senator how much
the RIAA gave him for his Lexus.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-27 14:01     ` Jamie Lokier
                         ` (2 preceding siblings ...)
  2003-08-27 15:15       ` Stan Bubrouski
@ 2003-08-27 16:02       ` Pasi Savolainen
  3 siblings, 0 replies; 19+ messages in thread
From: Pasi Savolainen @ 2003-08-27 16:02 UTC (permalink / raw)
  To: linux-kernel

* Jamie Lokier <jamie@shareable.org>:
> Richard Curnow wrote:
>> OK, since I get something different to the other reports I saw:
>> 
>>  1:20PM-malvern-0-534-% ./sysenter
>>  1:20PM-malvern-STKFLT-535-% echo $?
>> 144
> 
> Hi Richard,
> 
> That's because you ran it on a 2.5/2.6 kernel, right?  The test code
> is meant for 2.4 kernels and earlier :)

If this is of any help..

- -
pvsavola@a11a:~/code$ cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 1
model name      : Pentium Pro
stepping        : 6
cpu MHz         : 199.312
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov
bogomips        : 397.31

pvsavola@a11a:~/code$ ./sysent ; echo $?
Segmentation fault
139
pvsavola@a11a:~/code$ uname -a
Linux a11a 2.4.19-ck3-rmap #1 Mon Aug 26 21:38:49 EEST 2002 i686 GNU/Linux
- -

-- 
   Psi -- <http://www.iki.fi/pasi.savolainen>


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-08-25  6:09   ` Jamie Lokier
@ 2003-09-03 12:50     ` Pavel Machek
  2003-09-08 14:05       ` Jamie Lokier
  0 siblings, 1 reply; 19+ messages in thread
From: Pavel Machek @ 2003-09-03 12:50 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Mikael Pettersson, jim.houston, linux-kernel

Hi!

> > I double-checked AP-485 (24161823.pdf, the "real" reference to CPUID),
> > and it says (section 3.4) that SEP is unsupported when the signature
> > as a whole is less that 0x633. This means all PPros, and PII Model 3s
> > with steppings less than 3.
> 
> "SEP is unsupported".  It's interesting that Pentium Pro erratum #82
> is "SYSENTER/SYSEXIT instructions can implicitly load 'null segment
> selector' to SS and CS registers", implying that SYSENTER does
> _something_ useful on PPros.

Well, with CS==0 machine is not going to survive too long.
If it only happens sometimes you might catch the double fault
and fixup, but....
				Pavel
-- 
				Pavel
Written on sharp zaurus, because my Velo1 broke. If you have Velo you don't need...


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Pentium Pro - sysenter - doublefault
  2003-09-03 12:50     ` Pavel Machek
@ 2003-09-08 14:05       ` Jamie Lokier
  0 siblings, 0 replies; 19+ messages in thread
From: Jamie Lokier @ 2003-09-08 14:05 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Mikael Pettersson, jim.houston, linux-kernel

Pavel Machek wrote:
> > "SEP is unsupported".  It's interesting that Pentium Pro erratum #82
> > is "SYSENTER/SYSEXIT instructions can implicitly load 'null segment
> > selector' to SS and CS registers", implying that SYSENTER does
> > _something_ useful on PPros.
> 
> Well, with CS==0 machine is not going to survive too long.
> If it only happens sometimes you might catch the double fault
> and fixup, but....

The erratum only applies when you load CS==0 _deliberately_, by setting
the MSR to that.

I'm wondering what happens when you don't do silly things - what is
the undocumented behaviour of SYSENTER/SYSEXIT on those chips?

I vaguely recall reading details about the behaviour change made by
Intel, around the time it was done, but I can't see to find it
anywhere.

-- Jamie

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2003-09-08 14:06 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-21 20:41 [PATCH] Pentium Pro - sysenter - doublefault Jim Houston
2003-08-21 21:32 ` Mikael Pettersson
2003-08-22  2:18   ` [PATCH2] " Jim Houston
2003-08-25  5:56   ` [PATCH] " Jamie Lokier
2003-08-25  6:09   ` Jamie Lokier
2003-09-03 12:50     ` Pavel Machek
2003-09-08 14:05       ` Jamie Lokier
2003-08-25  4:05 ` Jamie Lokier
2003-08-25  4:14   ` Jakob Oestergaard
2003-08-25  5:50     ` Jamie Lokier
2003-08-25  6:29       ` Jamie Lokier
2003-08-25  7:49         ` Jakob Oestergaard
2003-08-25 18:15         ` Jim Houston
2003-08-26 12:26   ` Richard Curnow
2003-08-27 14:01     ` Jamie Lokier
2003-08-27 14:23       ` Richard Curnow
2003-08-27 14:25       ` dl-ipaddr
2003-08-27 15:15       ` Stan Bubrouski
2003-08-27 16:02       ` Pasi Savolainen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).