Hi guys,
  I think I figure some of this out. The Wikipedia page on CPUID (
http://en.wikipedia.org/wiki/CPUID) indicates that xsave is bit 26 of ECX.
Unsetting this bit allowed me to successfully boot these older versions of
Linux. For anyone running into the same issue, here is the patch for that
change:

------------------------------------------------------------------
diff --git a/src/arch/x86/cpuid.cc b/src/arch/x86/cpuid.cc
--- a/src/arch/x86/cpuid.cc
+++ b/src/arch/x86/cpuid.cc
@@ -154,7 +154,7 @@
                 break;
               case FamilyModelStepping:
                 result = CpuidResult(0x00020f51, 0x00000805,
-                                     0xe7dbfbff, 0x04000209);
+                                     0xe7dbfbff, 0x00000209);
                 break;
               default:
                 warn("x86 cpuid: unimplemented function %u", funcNum);
------------------------------------------------------------------

  I also discovered that the reason Linux falls into this kernel panic is
that it executes a CPUID operation that is not currently implemented in
gem5 (src/arch/x86/cpuid.cc). Specifically, the cpuid_count function call
(here:
http://lxr.free-electrons.com/source/arch/x86/kernel/xsave.c?v=2.6.32#L319)
tries to execute CPUID function EAX=0xd (13), EAX=0x0. gem5 prints a
warning saying that this function is unimplemented, and does not update any
registers, causing the resulting EAX to be incorrect.

  It looks like more recent Linux versions contain more checks, and so may
not reach this cpuid_count call:
http://lxr.free-electrons.com/source/arch/x86/kernel/xsave.c#L618


  Joel




On Fri, Feb 20, 2015 at 2:17 PM, Joel Hestness <jthestn...@gmail.com> wrote:

> Hey Gabe,
>   When I try to boot older versions of Linux (2.6.28.4, 2.6.22.9), I'm
> running into a kernel panic related to xsave (
> http://lxr.free-electrons.com/source/arch/x86/kernel/xsave.c?v=2.6.32#L323
> ):
>
> *FP/SSE not shown under xsave features 0xd*
> ------------[ cut here ]------------
> kernel BUG at arch/x86/kernel/xsave.c:323!
> invalid opcode: 0000 [#1] SMP
> last sysfs file:
> CPU 0
> Modules linked in:
> Pid: 0, comm: swapper Tainted: G        W  2.6.28-rc4-dirty #5
> RIP: 0010:[<ffffffff808d69e7>]  [<ffffffff808d69e7>]
> xsave_cntxt_init+0x35/0x130
> RSP: 0018:ffffffff808c3f18  EFLAGS: 000000b8
> RAX: 000000000000002d RBX: ffffffff808c3f48 RCX: 00000000ffffffff
> RDX: ffffffff807c3c38 RSI: 0000000000000074 RDI: ffffffff8094a5f4
> RBP: 0000000000000000 R08: 00000000ffffffff R09: 00000000000003fd
> R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff807a8340
> R13: 0000000000000005 R14: 00000000ffff8800 R15: ffff88000101f000
> FS:  0000000000000000(0000) GS:ffffffff808bd980(0000)
> knlGS:0000000000000000
> CS:  0010 DS: 0018 ES: 0018 CR0: 0000000080050033
> CR2: 0000000000000000 CR3: 0000000000201000 CR4: 00000000000006a0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000000
> Process swapper (pid: 0, threadinfo ffffffff808c2000, task
> ffffffff807a8340)
> Stack:
>  ffffffff808c3f48 ffffffff8060e2b1 0000000000000010 ffffffff8060fa3f
>  0000000000000020 fffffff000000000 0100890239802087 00000000ffff8800
>  ffffffff808c3f88 ffffffffffffffff 0000000000000040 ffffffff808f7700
> Call Trace:
>  [<ffffffff8060e2b1>] fpu_init+0x4a/0x97
>  [<ffffffff8060fa3f>] cpu_init+0x319/0x33f
>  [<ffffffff808cdab5>] start_kernel+0x1b2/0x321
>  [<ffffffff808cd405>] x86_64_start_kernel+0xd9/0xdd
> Code: 48 c1 e2 20 89 c0 48 8d 34 02 48 89 f0 48 89 35 90 96 05 00 83 e0 03
> 48 83 f8 03 74 12 48 c7 c7 10 82 71 80 31 c0 e8 4d e6 d3 ff <0f> 0b eb fe
> f6 05 b5 70 fe ff 04 48 c7 05 63 96 05 00 03 00 00
> RIP  [<ffffffff808d69e7>] xsave_cntxt_init+0x35/0x130
>  RSP <ffffffff808c3f18>
> ---[ end trace 4eaa2a86a8e2da22 ]---
> Kernel panic - not syncing: Attempted to kill the idle task!
> ------------[ cut here ]------------
> WARNING: at kernel/smp.c:333 smp_call_function_mask+0x1de/0x250()
> Modules linked in:
> Pid: 0, comm: swapper Tainted: G      D W  2.6.28-rc4-dirty #5
> Call Trace:
>  [<ffffffff8023af92>] warn_on_slowpath+0x62/0xa0
>  [<ffffffff803a4159>] vsnprintf+0x449/0x6b0
>  [<ffffffff803a3a84>] string+0x34/0xf0
>  [<ffffffff803a4118>] vsnprintf+0x408/0x6b0
>  [<ffffffff802547dd>] up+0xd/0x40
>  [<ffffffff8023b6de>] release_console_sem+0x1ae/0x200
>  [<ffffffff8021ef40>] stop_this_cpu+0x0/0x30
>  [<ffffffff8025db9e>] smp_call_function_mask+0x1de/0x250
>  [<ffffffff803a3f78>] vsnprintf+0x268/0x6b0
>  [<ffffffff80615074>] printk+0x40/0x45
>  [<ffffffff8021ef30>] native_smp_send_stop+0x20/0x30
>  [<ffffffff80614f8d>] panic+0x82/0x129
>  [<ffffffff8023ecae>] do_exit+0x7de/0x890
>  [<ffffffff80615074>] printk+0x40/0x45
>  [<ffffffff806184ba>] oops_end+0x7a/0xc0
>  [<ffffffff8020d3d4>] do_invalid_op+0x84/0xa0
>  [<ffffffff808d69e7>] xsave_cntxt_init+0x35/0x130
>  [<ffffffff8023b6de>] release_console_sem+0x1ae/0x200
>  [<ffffffff802547dd>] up+0xd/0x40
>  [<ffffffff806178e9>] error_exit+0x0/0x51
>  [<ffffffff808d69e7>] xsave_cntxt_init+0x35/0x130
>  [<ffffffff808d69e7>] xsave_cntxt_init+0x35/0x130
>  [<ffffffff8060e2b1>] fpu_init+0x4a/0x97
>  [<ffffffff8060fa3f>] cpu_init+0x319/0x33f
>  [<ffffffff808cdab5>] start_kernel+0x1b2/0x321
>  [<ffffffff808cd405>] x86_64_start_kernel+0xd9/0xdd
> ---[ end trace 4eaa2a86a8e2da22 ]---
>
>   Based on the commit message, it looks like this patch might have enabled
> Linux boot features through the xsave setting. Can you please let me know
> which of the bits in the CpuidResult vector I should disable to test if
> xsave is the problem?
>
>   Thanks!
>   Joel
>
>
>
> On Wed, Jan 7, 2015 at 12:06 AM, Gabe Black via gem5-dev <
> gem5-dev@gem5.org> wrote:
>
>> changeset 5d119a460f15 in /z/repo/gem5
>> details: http://repo.gem5.org/gem5?cmd=changeset;node=5d119a460f15
>> description:
>>         x86: Enable three bits in the FamilyModelStepping ECX CPUID
>> bitfield.
>>
>>         These are for the monitor/mwait instructions, SSSE3, and XSAVE.
>>
>> diffstat:
>>
>>  src/arch/x86/cpuid.cc |  2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diffs (12 lines):
>>
>> diff -r e9bc4cde5d8e -r 5d119a460f15 src/arch/x86/cpuid.cc
>> --- a/src/arch/x86/cpuid.cc     Tue Jan 06 22:13:56 2015 -0800
>> +++ b/src/arch/x86/cpuid.cc     Tue Jan 06 22:15:00 2015 -0800
>> @@ -154,7 +154,7 @@
>>                  break;
>>                case FamilyModelStepping:
>>                  result = CpuidResult(0x00020f51, 0x00000805,
>> -                                     0xe7dbfbff, 0x00000001);
>> +                                     0xe7dbfbff, 0x04000209);
>>                  break;
>>                default:
>>                  warn("x86 cpuid: unimplemented function %u", funcNum);
>> _______________________________________________
>> gem5-dev mailing list
>> gem5-dev@gem5.org
>> http://m5sim.org/mailman/listinfo/gem5-dev
>>
>
>
>
> --
>   Joel Hestness
>   PhD Candidate, Computer Architecture
>   Dept. of Computer Science, University of Wisconsin - Madison
>   http://pages.cs.wisc.edu/~hestness/
>



-- 
  Joel Hestness
  PhD Candidate, Computer Architecture
  Dept. of Computer Science, University of Wisconsin - Madison
  http://pages.cs.wisc.edu/~hestness/
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to