2008-08-31 18:22:25

by David Sanders

[permalink] [raw]
Subject: [BUG] x86 kenel won't boot under Virtual PC

I recently discovered that x86 kernels won't boot under Virtual PC. In this
case paravirt was not built into the kernel. The kernel just "hangs" on
attempted boot with no error messages. Git-bisect pinpointed the following
commit as the problem:

commit 32c464f5d9701db45bc1673288594e664065388e
Author: Jan Beulich <[email protected]>
Date: Wed Oct 17 18:04:41 2007 +0200

x86: multi-byte single instruction NOPs

Add support for and use the multi-byte NOPs recently documented to be
available on all PentiumPro and later processors.

This patch only applies cleanly on top of the "x86: misc.
constifications" patch sent earlier.

[ tglx: arch/x86 adaptation ]

Signed-off-by: Jan Beulich <[email protected]>
Signed-off-by: Andi Kleen <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>

arch/x86/kernel/alternative.c | 23 ++++++++++++++++++++++-
include/asm-x86/processor_32.h | 22 ++++++++++++++++++++++
include/asm-x86/processor_64.h | 22 ++++++++++++++++++++++
3 files changed, 66 insertions(+), 1 deletion(-)

:040000 040000 9226efb160ea180e8c419134b82e0a6938868c1a
12daabe81d9cda0d574815c0957a24c1028c8fb0 M arch
:040000 040000 7ab3918741abcb203bd25289d2c6e789bed64fc1
eb662fea6ed7904074c87dd004b9f6d23964c844 M include

Any suggestion on where to go from here would be appreciated.


2008-08-31 18:47:41

by Linus Torvalds

[permalink] [raw]
Subject: Re: [BUG] x86 kenel won't boot under Virtual PC



On Sun, 31 Aug 2008, David Sanders wrote:
>
> I recently discovered that x86 kernels won't boot under Virtual PC.

What CPU does Virtual PC emulate? As far as Wikipedia is concerned (not
that I'd take it on complete faith) it emulates a 32-bit Intel Pentium II.

And that commit makes the kernel use the "P6 nops" for such hardware.
Maybe Virtual PC doesn't support the newer intel nop things?

Intel docs say that it should be available on any intel CPU that has
CPUID.01H.EAX[11:8] = 0110B or 1111B. That's the "family ID", and Pentium
II should have a family ID of 6 (ie that 0110B case).

So it sounds like a Virtual PC bug, but I dunno. And maybe we should just
use the legcay nops for anything that isn't modern (ie P4+ or Core)?

Linus

2008-08-31 19:28:17

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [BUG] x86 kenel won't boot under Virtual PC

On Sun, 31 Aug 2008 11:47:04 -0700 (PDT)
Linus Torvalds <[email protected]> wrote:

>
>
> On Sun, 31 Aug 2008, David Sanders wrote:
> >
> > I recently discovered that x86 kernels won't boot under Virtual PC.
>
> What CPU does Virtual PC emulate? As far as Wikipedia is concerned
> (not that I'd take it on complete faith) it emulates a 32-bit Intel
> Pentium II.
>
> And that commit makes the kernel use the "P6 nops" for such hardware.
> Maybe Virtual PC doesn't support the newer intel nop things?
>
> Intel docs say that it should be available on any intel CPU that has
> CPUID.01H.EAX[11:8] = 0110B or 1111B. That's the "family ID", and
> Pentium II should have a family ID of 6 (ie that 0110B case).
>
> So it sounds like a Virtual PC bug, but I dunno. And maybe we should
> just use the legcay nops for anything that isn't modern (ie P4+ or
> Core)?

it's probably even a security bug in that I don't see what would be
stopping a ring 3 user process from executing these instructions...

2008-08-31 19:39:56

by Linus Torvalds

[permalink] [raw]
Subject: Re: [BUG] x86 kenel won't boot under Virtual PC



On Sun, 31 Aug 2008, Arjan van de Ven wrote:
>
> it's probably even a security bug in that I don't see what would be
> stopping a ring 3 user process from executing these instructions...

Well, it could be that Virtual PC raises a #UD exception in the virtual
machine. In user space, that would just cause the kernel to kill the poor
innocent victim. But when the kernel gets a #UD exception on what it
expects to be a nop, it just won't work.

Linus

2008-08-31 20:03:35

by David Sanders

[permalink] [raw]
Subject: Re: [BUG] x86 kenel won't boot under Virtual PC

On Sunday 31 August 2008 14:47, Linus Torvalds wrote:
> On Sun, 31 Aug 2008, David Sanders wrote:
> > I recently discovered that x86 kernels won't boot under Virtual PC.
>
> What CPU does Virtual PC emulate? As far as Wikipedia is concerned (not
> that I'd take it on complete faith) it emulates a 32-bit Intel Pentium II.
>
> And that commit makes the kernel use the "P6 nops" for such hardware.
> Maybe Virtual PC doesn't support the newer intel nop things?
>
> Intel docs say that it should be available on any intel CPU that has
> CPUID.01H.EAX[11:8] = 0110B or 1111B. That's the "family ID", and Pentium
> II should have a family ID of 6 (ie that 0110B case).
>
> So it sounds like a Virtual PC bug, but I dunno. And maybe we should just
> use the legcay nops for anything that isn't modern (ie P4+ or Core)?
>
> Linus

Virtual PC does not emulate a processor like it does with the motherboard,
video, NIC ,etc. What you see in the virtual machine is the actual
processor, except that Virtual PC looks at all of your instructions and
modifies ring 0 code and the like. It may be that Virtual PC was not
designed with an awareness of these nops that the commit added.

I would suggest an configuration option to select legacy-nops or newer-nops
and a kernel boot-time parameter so it can be disabled to allow installation
of a distribution for example.

I would be happy to submit such a patch if you agree (or I'll try to anyway).