[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] Re: [PATCH][RFC] Emulating real mode with x86_emulate



Hi Anthony,
  I tried your patch at my end with snapshot of xen-unstable on 20070326. And here are my findings.
   - The --emulate-16bit option for qemu did not work. qemu is not accepting this as an valid command line option.
   - I tried hardcoding this to 1 in the qemu code, and found that the port x595 is not reflecting it correctly to hvmloader.
   - Then I tried forcing in the hvmloader to use the emulator instead of vmxassit, and I see the the emulator is not getting the right context. Following is the console log at this point.

(XEN) HVM3: HVM Loader                                                         
(XEN) HVM3: Detected Xen v3.0-unstable                                         
(XEN) HVM3: Writing SMBIOS tables ...                                          
(XEN) HVM3: Loading ROMBIOS ...                                                
(XEN) irq.c:210: Dom3 PCI link 0 changed 0 -> 5                                
(XEN) HVM3: PCI-ISA link 0 routed to IRQ5                                      
(XEN) irq.c:210: Dom3 PCI link 1 changed 0 -> 7                                
(XEN) HVM3: PCI-ISA link 1 routed to IRQ7                                      
(XEN) irq.c:210: Dom3 PCI link 2 changed 0 -> 10                               
(XEN) HVM3: PCI-ISA link 2 routed to IRQ10                                     
(XEN) irq.c:210: Dom3 PCI link 3 changed 0 -> 11                               
(XEN) HVM3: PCI-ISA link 3 routed to IRQ11                                     
(XEN) HVM3: pci dev 01:1 bar 20 size 00000010: 0000c001                        
(XEN) HVM3: pci dev 01:2 INTA->IRQ7                                            
(XEN) HVM3: pci dev 02:0 bar 10 size 02000000: f0000008                        
(XEN) HVM3: pci dev 02:0 bar 14 size 00001000: f2000000                        
(XEN) HVM3: pci dev 03:0 bar 10 size 00000100: 0000c101                        
(XEN) HVM3: pci dev 03:0 bar 14 size 01000000: f3000008                        
(XEN) HVM3: pci dev 03:0 INTA->IRQ11                                           
(XEN) HVM3: pci dev 04:0 bar 10 size 00000100: 0000c201                        
(XEN) HVM3: pci dev 04:0 bar 14 size 00000100: f4000000                        
(XEN) HVM3: pci dev 04:0 INTA->IRQ5                                            
(XEN) HVM3: Creating MP tables ...                                             
(XEN) HVM3: Loading Cirrus VGABIOS ...                                         
(XEN) HVM3: Loading ACPI ...                                                   
(XEN) HVM3: Not Loading VMXAssist ... ffffffff                                 
(XEN) HVM3: foo                                                                
(XEN) hvmop_emulate_realmode                                                   
(XEN) guest requests real mode emulation                                       
(XEN) foo 221                                                                  
(XEN) HVM3: Invoking ROMBIOS ...                                               
(XEN) Transfering control to x86_emulate %eip 0x0                              
(XEN) hvm.c:446:d3 Triple fault on VCPU0 - invoking HVM system reset.   

The log shows that emulator is not getting the right cpu context.
How much of testing have you done with this code? I am not able to proceed to emulation of 1 instruction with the patch. How many instruction could you emulate with the patch?

Thanks & Regards,
Nitin
Open Source Technology Center, Intel Corporation.
-------------------------------------------------------------------------
The mind is like a parachute; it works much better when it's open.
On Sun, 2007-03-25 at 16:35 -0700, Anthony Liguori wrote:
Howdy,

Attached is a patch that begins to lay down the infrastructure for
emulating real mode with x86_emulate().  With a little more refactoring,
I think it could also replace the SVM emulator.

The patch introduces an HVMOP hypercall to set a flag in the hvm vcpu
struct to signal that real mode should be emulated with x86_emulate
instead of using vm86.  This is to make development a little bit easier
since x86_emulate is not quite there yet wrt 16 bit emulation.  It can
be enabled by passing -emulate-16bit to qemu-dm (I use a wrapper script
similar to qemu-dm.debug).

The VT code keeps track of the whether it's in the emulator and loops on
the do_resume path in x86_emulate.  I think this code probably should be
refactored into the common HVM code although this would require changing
some of the HVM ops.  This would allow SVM to use the x86_emulate to
handle individual instructions.

There are some issues to work out.  Namely, x86_emulate appears to want
blocking PIO calls which isn't conducive to the wait PIO works today in
HVM.  This is only a problem for instructions at the moment.  I'm also a
bit confused about how to properly loop in the emulator.  schedule_tail
is not meant to return so perhaps we should loop on emulating == 1
instead of hypercall_preempt_check?  I didn't think the hypervisor was
preemptable though.

The current code doesn't handle non-flat segments as I don't think
hvm_copy_from/to_guest handles it (which I assume it would need to).

However, it is enough to start running instructions in x86_emulate so
it's enough to start working on enhancing that.

Regards,

Anthony Liguori



Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.