2009-10-26 03:56:07

by Rusty Russell

[permalink] [raw]
Subject: Re: [Lguest] 2.6.32-rc5 guest crash

On Mon, 26 Oct 2009 04:25:21 am Johannes Stezenbach wrote:
> Hi,
>
> I'm using linux-2.6.32-rc5-81-g964fe08 as both host and guest,
> and the guest crashes on boot:
>
> Calibrating delay loop...
> general protection fault: 0000 [#1] PREEMPT SMP
> last sysfs file:
> Modules linked in:
>
> Pid: 0, comm: swapper Not tainted (2.6.32-rc5 #1)
> EIP: 0061:[<c11f915d>] EFLAGS: 00010046 CPU: 0
> EIP is at cmpxchg8b_emu+0x1/0x12

OK, it's the non-paravirt "cli" we're breaking on (the pushfl is bad too).

This is because alternatives haven't been subbed yet. The Right Thing is to
make this asm code paravirt aware. The Easy Thing is to fix this code to
only get included when we're actually compiling for a 386 or 486 (this was
introduced with the original pentium AFAICT).

How's this Ingo, Arjan?

Subject: x86: sidestep lguest problem by only building cmpxchg8b_emu for pre-Pentium

Arjen's 79e1dd05d1a22 "x86: Provide an alternative() based cmpxchg64()" broke
lguest, even on systems which have cmpxchg8b support. The emulation code
gets used until alternatives get run, but it contains native instructions,
not their paravirt alternatives.

The simplest fix is to turn this code off except for 386 and 486 builds.

Reported-by: Johannes Stezenbach <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>

diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -400,7 +400,7 @@ config X86_TSC

config X86_CMPXCHG64
def_bool y
- depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
+ depends on !M386 && !M486

# this should be set for all -march=.. options where the compiler
# generates cmov.



2009-10-26 11:39:49

by Rusty Russell

[permalink] [raw]
Subject: [tip:x86/urgent] x86: Side-step lguest problem by only building cmpxchg8b_emu for pre-Pentium

Commit-ID: ae1b22f6e46c03cede7cea234d0bf2253b4261cf
Gitweb: http://git.kernel.org/tip/ae1b22f6e46c03cede7cea234d0bf2253b4261cf
Author: Rusty Russell <[email protected]>
AuthorDate: Mon, 26 Oct 2009 14:26:04 +1030
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 26 Oct 2009 12:33:02 +0100

x86: Side-step lguest problem by only building cmpxchg8b_emu for pre-Pentium

Commit 79e1dd05d1a22 "x86: Provide an alternative() based
cmpxchg64()" broke lguest, even on systems which have cmpxchg8b
support. The emulation code gets used until alternatives get
run, but it contains native instructions, not their paravirt
alternatives.

The simplest fix is to turn this code off except for 386 and 486
builds.

Reported-by: Johannes Stezenbach <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Acked-by: H. Peter Anvin <[email protected]>
Cc: [email protected]
Cc: Arjan van de Ven <[email protected]>
Cc: Jeremy Fitzhardinge <[email protected]>
Cc: Linus Torvalds <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/Kconfig.cpu | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index f2824fb..2649840 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -400,7 +400,7 @@ config X86_TSC

config X86_CMPXCHG64
def_bool y
- depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
+ depends on !M386 && !M486

# this should be set for all -march=.. options where the compiler
# generates cmov.

2009-10-26 19:10:43

by Johannes Stezenbach

[permalink] [raw]
Subject: Re: [Lguest] 2.6.32-rc5 guest crash

On Mon, Oct 26, 2009 at 02:26:04PM +1030, Rusty Russell wrote:
>
> Subject: x86: sidestep lguest problem by only building cmpxchg8b_emu for pre-Pentium
>
> Arjen's 79e1dd05d1a22 "x86: Provide an alternative() based cmpxchg64()" broke
> lguest, even on systems which have cmpxchg8b support. The emulation code
> gets used until alternatives get run, but it contains native instructions,
> not their paravirt alternatives.
>
> The simplest fix is to turn this code off except for 386 and 486 builds.
>
> Reported-by: Johannes Stezenbach <[email protected]>
> Signed-off-by: Rusty Russell <[email protected]>
>
> diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
> --- a/arch/x86/Kconfig.cpu
> +++ b/arch/x86/Kconfig.cpu
> @@ -400,7 +400,7 @@ config X86_TSC
>
> config X86_CMPXCHG64
> def_bool y
> - depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
> + depends on !M386 && !M486


FWIW, I've tested it both with original host kernel (only used recompiled
kernel as guest), and after reboot, the guest works in both cases and
the host kernel still boots with the patch applied.


Thanks,
Johannes