Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM

2009-02-13 Thread Matteo Frigo
Avi Kivity a...@redhat.com writes:

 - run a cygwin program in an infinite loop (while :; do :; done is
 sufficient)
 - 'info registers', look at gdt
 - 'x/28x 0x$GDT'

 I'm interested in offset 0x28, but please provide the whole thing for
 sanity checking.

Here it is.  This is with npt=1, but npt=0 shows exactly the
same GDT.

(qemu) info registers
EAX=0022dad8 EBX=0023 ECX=61108b28 EDX=0043fea7
ESI=0014 EDI= EBP=0022c518 ESP=0022c4f4
EIP=610935e2 EFL=0202 [---] CPL=3 II=0 A20=1 SMM=0 HLT=0
ES =002b   00c0f300
CS =0023   00c0fb00
SS =002b   00c0f300
DS =002b   00c0f300
FS =0053 7efdd000 0fff 0040f300
GS =002b 7efdb000  00c0f300
LDT=   
TR =0040 f84e8070 0068 8b00
GDT= f84e7000 006f
IDT= f84e7070 0fff
CR0=80050031 CR2=07ff7dd13000 CR3=2d62c000 CR4=06f8
DR0= DR1= DR2= 
DR3= 
DR6=0ff0 DR7=0400
FCW=037f FSW= [ST=0] FTW=00 MXCSR=
FPR0=  FPR1= 
FPR2=  FPR3= 
FPR4=  FPR5= 
FPR6=  FPR7= 
XMM00= XMM01=
XMM02= XMM03=
XMM04= XMM05=
XMM06=7ffe003000160014 XMM07=
(qemu) x/28x 0xf84e7000
f84e7000: 0x 0x 0x 0x
f84e7010: 0x 0x00209b00 0x 0x00cf9300
f84e7020: 0x 0x00cffb00 0x 0x00cff300
f84e7030: 0x 0x0020fb00 0x 0x
f84e7040: 0x80700068 0x8b4e 0xf800 0x
f84e7050: 0xdfff 0x7e40f3fd 0x 0x
f84e7060: 0x 0x00cf9b00 0x 0x
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM

2009-02-13 Thread Matteo Frigo
Avi Kivity a...@redhat.com writes:

 Can you rerun on AMD, but set add npt=0 as a kvm-amd module parameter?
 This will determine if this is an mmu bug or kvm-intel bug.

AMD works fine with npt=0, both cygwin and my setjmp()/longjmp() test
program.  dmesg confirms that nested paging is disabled.

Regards,
Matteo Frigo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM

2009-02-13 Thread Matteo Frigo
Avi Kivity a...@redhat.com writes:

 More questions:
 - is the bad 'mov gs' instruction reached on AMD?  or is it avoided
 somehow?  What about bare metal?

The instruction is indeed reached on amd, and gs is 0x2b after
the instruction.  I don't know about bare metal.

 - does the attached program fail when compiled and run in cygwin on an
 AMD host?

The program runs as follows:

w2k3-64:/cygdrive/v$ gcc -O gs.c
w2k3-64:/cygdrive/v$ ./a.exe 
gs: 2b
gs:0x30: 7efdb000
test

 - does setjmp()/longjmp() come from the Windows run-time library, or 
 from cygwin?

The setjmp()/longjmp() is in the cygwin library /bin/cygwin1.dll .
bash calls longjmp() at the end of the expr built-in, which causes the
problem reported by the original poster.

I should also mention that, as an experiment, I have replaced the mov
gs,ax instruction with a couple of no-ops in cygwin1.dll, and cygwin
runs fine on Intel with this patch.

Regards,
Matteo Frigo

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM

2009-02-13 Thread Matteo Frigo
Avi Kivity a...@redhat.com writes:

 Can you run the slightly modified gs.c (attached) and rerun on AMD?
 The is to see if the runtime somehow restores gs.

Crashes as follows:

w2k3-64:~$ ./a.exe 
gs: 2b
gs:0x30: 7efdb000
Segmentation fault (core dumped)
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM

2009-02-13 Thread Matteo Frigo
Matteo Frigo ath...@fftw.org writes:

 Avi Kivity a...@redhat.com writes:

 Can you run the slightly modified gs.c (attached) and rerun on AMD?
 The is to see if the runtime somehow restores gs.

 Crashes as follows:

 w2k3-64:~$ ./a.exe 
 gs: 2b
 gs:0x30: 7efdb000
 Segmentation fault (core dumped)

A little bit more information:

w2k3-64:~$ gdb a.exe
GNU gdb 6.8.0.20080328-cvs (cygwin-special)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as i686-pc-cygwin...
(no debugging symbols found)
(gdb) r
Starting program: /home/athena/a.exe 
[New thread 1620.0x6dc]
Error: dll starting at 0x77d4 not found.
Error: dll starting at 0x77d4 not found.
Error: dll starting at 0x77c2 not found.
Error while mapping shared library sections:
/cygdrive/c/WINDOWS/SysWOW64/ntdll32.dll: No such file or directory.
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New thread 1620.0x74c]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
0x0040109d in main ()
(gdb) x/i $pc
0x40109d main+77: mov%gs:0x30,%esi
(gdb) p/x $gs
$1 = 0x2b
(gdb) 
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM

2009-02-13 Thread Matteo Frigo
Avi Kivity a...@redhat.com writes:

 + vmx_load_host_state(vcpu);

Works here as well (on intel).  

(On kvm-83, gcc complains about passing argument 1 of
'vmx_load_host_state' from incompatible pointer type.)

Thanks for the terrific support.  kvm rocks!

Regards,
Matteo Frigo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM

2009-02-05 Thread Matteo Frigo
Avi Kivity a...@redhat.com writes:

 - add a watchpoint to break when the value of gs:[0x30] changes

It seems that the problem can be reproduced by compiling the following
simple program using cygwin's gcc.  The program crashes on w2k3-amd64
on kvm-83 on core2-duo, and it does not crash on the same w2k3-amd64
installation on kvm-83 on AMD Phenom.

  #include setjmp.h

  jmp_buf env;
  main()
  {
   if(setjmp(env)) return;
   longjmp(env, 1);
  }

The problem seems to be in the instruction ``mov gs,ax'' (Intel
syntax) in the longjmp() code.  If I let the virtual machine execute
the instruction, the program crashes.  However, if I step over the
instruction using the vs2008 debugger, the program completes without
crashing.  Thus, I think that this is the instruction that Avi is
looking for, but I don't know how to proceed from here.

Hope this helps.
Cheers,
Matteo Frigo

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html