From patchwork Fri Feb 13 22:32:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 7092 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1DMWj9D018815 for ; Fri, 13 Feb 2009 22:32:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753297AbZBMWce (ORCPT ); Fri, 13 Feb 2009 17:32:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753338AbZBMWce (ORCPT ); Fri, 13 Feb 2009 17:32:34 -0500 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 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n1DMWU1c015491; Fri, 13 Feb 2009 17:32:30 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n1DMWTAp017911; Fri, 13 Feb 2009 17:32:30 -0500 Received: from mermaid.qumranet.com (vpn-13-161.rdu.redhat.com [10.11.13.161]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n1DMWPPY001939; Fri, 13 Feb 2009 17:32:26 -0500 Message-ID: <4995F516.6080603@redhat.com> Date: Sat, 14 Feb 2009 00:32:54 +0200 From: Avi Kivity User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: Matteo Frigo CC: kvm@vger.kernel.org Subject: Re: Cygwin bash's built-in test command crashes on Windows 2008 Server 64bit under KVM 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> In-Reply-To: <4995EEB4.4010602@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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. 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;