From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM Date: Fri, 13 Feb 2009 23:46:20 +0200 Message-ID: <4995EA2C.7060004@redhat.com> References: <40ddf2480901050654y268213d1jbf34f9d81d6faeb0@mail.gmail.com> <40ddf2480901050822q52a9c2b6x5d5d87d17dec4992@mail.gmail.com> <49788A80.2070403@redhat.com> <87bptgnykd.fsf@fftw.org> <4995D180.9000706@redhat.com> <878woaozu2.fsf@matteo.cilk.lan> <4995D7FD.9020609@redhat.com> <87eiy26ph9.fsf@cilk.com> <4995DFD6.7050605@redhat.com> <87ab8q6ngc.fsf@cilk.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080606090701080804020309" Cc: kvm@vger.kernel.org To: Matteo Frigo Return-path: Received: from mx2.redhat.com ([66.187.237.31]:47982 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753280AbZBMVrI (ORCPT ); Fri, 13 Feb 2009 16:47:08 -0500 In-Reply-To: <87ab8q6ngc.fsf@cilk.com> Sender: kvm-owner@vger.kernel.org List-ID: This is a multi-part message in MIME format. --------------080606090701080804020309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Matteo Frigo wrote: > Avi Kivity 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. > > That was going to be my next question :) Right now I don't understand how cygwin's longjmp() is supposed to work at all, given that it clobbers gs. Can you run the slightly modified gs.c (attached) and rerun on AMD? The is to see if the runtime somehow restores gs. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. --------------080606090701080804020309 Content-Type: text/x-csrc; name="gs.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gs.c" #include int main() { unsigned short gs; unsigned x; asm ("mov %%gs, %0\n" : "=g"(gs)); asm ("movl %%gs:0x30, %0\n" : "=r"(x)); printf("gs: %x\n", gs); printf("gs:0x30: %x\n", x); asm volatile ("mov %0, %%gs\n" : : "g"(gs)); asm volatile ("movl %%gs:0x30, %0\n" : "=r"(x)); printf("gs:0x30: %x\n", x); return 0; } --------------080606090701080804020309--