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: Sat, 14 Feb 2009 00:32:54 +0200 Message-ID: <4995F516.6080603@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> <4995EA51.20805@redhat.com> <8763je6m8i.fsf@cilk.com> <87y6wa57j2.fsf@cilk.com> <4995EEB4.4010602@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040901020205010105060604" Cc: kvm@vger.kernel.org To: Matteo Frigo Return-path: Received: from mx2.redhat.com ([66.187.237.31]:51749 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297AbZBMWcd (ORCPT ); Fri, 13 Feb 2009 17:32:33 -0500 In-Reply-To: <4995EEB4.4010602@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is a multi-part message in MIME format. --------------040901020205010105060604 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Avi Kivity wrote: > Matteo Frigo wrote: >> Matteo Frigo writes: >> >> >>> Avi Kivity 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 >> >> 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 0x77d40000 not found. >> Error: dll starting at 0x77d40000 not found. >> Error: dll starting at 0x77c20000 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 : mov %gs:0x30,%esi >> (gdb) p/x $gs >> $1 = 0x2b >> (gdb) > > Okay, at least this makes some little bit of sense. On both Intel and > AMD, 'mov gs' clobbers gs.base as expected. On AMD, something further > down the line (some syscall likely) restores gs.base, but on Intel it > doesn't. When we avoid the syscall, we get a crash on AMD as well. > The attached patch fixes it for me. Without this, rdmsr(KERNEL_GS_BASE) reads a stale value, which presumably Windows later writes back. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. --------------040901020205010105060604 Content-Type: text/x-patch; name="cygwin-fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cygwin-fix.patch" diff --git a/kernel/x86/vmx.c b/kernel/x86/vmx.c index 7507ce2..048460d 100644 --- a/kernel/x86/vmx.c +++ b/kernel/x86/vmx.c @@ -910,6 +910,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata) data = vmcs_readl(GUEST_SYSENTER_ESP); break; default: + vmx_load_host_state(vcpu); msr = find_msr_entry(to_vmx(vcpu), msr_index); if (msr) { data = msr->data; --------------040901020205010105060604--