From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Etherboot problems Date: Fri, 10 Nov 2006 18:11:43 +0200 Message-ID: <4554A4BF.5020409@qumranet.com> References: <874pt8ip14.wl%simon.kagstrom@bth.se> <455354AB.8000908@qumranet.com> <45536A11.6050808@qumranet.com> <87odrfgvqf.wl%simon.kagstrom@bth.se> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Return-path: To: Simon Kagstrom In-Reply-To: <87odrfgvqf.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Simon Kagstrom wrote: > At Thu, 09 Nov 2006 19:49:05 +0200, > Avi Kivity wrote: > >> Very likely this is due to VT's inability to virtualize real mode >> correctly. Is anyone in the mood to extend x86_emulate.c to support >> real mode? >> > > I found what caused the problems for the etherboot startup and it now > works fine (well, I've not tested downloading anything over the > network, but at least it gets that far). I've started grub as well, > and that works as before even with this fix. > > However, I'm not sure what the correct solution to the problem is. > > The crash occurs after etherboot has switched to protected mode and > does a long jump to the new code segment: > > /* Load GDT */ > 1: DATA32 lgdt %ds:(r2p_gdt-1b)(%bx) /* Load GDT */ > > /* Switch to protected mode */ > 2: movl %cr0, %eax > 3: orb $CR0_PE, %al > 4: movl %eax, %cr0 > > /* flush prefetch queue, and reload %cs:%eip */ > 5: DATA32 ljmp %ds:*(r2p_paddr-1b)(%bx) > .code32 > > The problem is that KVM zeroes all segment registers directly on a > switch to protected mode (i.e., on instruction 4 above) - and %ds > being zero causes a crash on the ljmp above. > > What I've done is to remove the zeroing of all segment registers > except %ss, which is shown in the trivial patch below. I don't > remember enough of transfer-to-protected-mode assembly to know the > correct solution to this (the %ss zeroing needs to be kept for > example, not sure why). > VT does a lot of checks when entering guest mode. These checks are stricter than what the processor can handle, and stricter than what some software expects. The upshot is that virtualizing real mode and the transition between modes can't be made to work 100%. The long term solution is to emulate rather than virtualize while in these states. Short term, I'll see if there's some workaround we can apply here (your patch probably makes other guests fail; I'll check this though). -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642