From: Simon Kagstrom Subject: Re: Etherboot problems Date: Fri, 10 Nov 2006 16:35:52 +0100 Message-ID: <87odrfgvqf.wl%simon.kagstrom@bth.se> References: <874pt8ip14.wl%simon.kagstrom@bth.se> <455354AB.8000908@qumranet.com> <45536A11.6050808@qumranet.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Fri_Nov_10_16:35:52_2006-1" Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Return-path: To: Avi Kivity In-Reply-To: <45536A11.6050808-atKUWr5tajBWk0Htik3J/w@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 --Multipart_Fri_Nov_10_16:35:52_2006-1 Content-Type: text/plain; charset=US-ASCII 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). // Simon --Multipart_Fri_Nov_10_16:35:52_2006-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="keep-segments.patch" Content-Transfer-Encoding: 7bit --- kvm-2/kernel/kvm_main.c 2006-11-09 12:16:43.000000000 +0100 +++ kvm-2-ska/kernel/kvm_main.c 2006-11-10 16:24:56.000000000 +0100 @@ -714,10 +714,6 @@ } FIX_PMODE_DATASEG(SS, vcpu->rmode.ss); - FIX_PMODE_DATASEG(ES, vcpu->rmode.es); - FIX_PMODE_DATASEG(DS, vcpu->rmode.ds); - FIX_PMODE_DATASEG(GS, vcpu->rmode.gs); - FIX_PMODE_DATASEG(FS, vcpu->rmode.fs); vmcs_write16(GUEST_CS_SELECTOR, vmcs_read16(GUEST_CS_SELECTOR) & ~SELECTOR_RPL_MASK); --Multipart_Fri_Nov_10_16:35:52_2006-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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 --Multipart_Fri_Nov_10_16:35:52_2006-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --Multipart_Fri_Nov_10_16:35:52_2006-1--