Emulation progress

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

 



Hi Guys,
    I committed to the main branch "working" translation/emulation 
code.  Working, currently means it can handle translating a block of 
code, running the block as guest, regaining control and emulating 
conditional and unconditional branches (basically what it did before, 
but now a lot more happens under the covers).  The next step for me is 
to create tests that will drive the emulation of all sensitive 
instructions.   If your fooling around with running guest code in guest 
privileged mode, the instructions to NOT use are defined in 
kvmarm_translate.h.  Note some are only sensitive when R15 is used,  and 
some are always sensitive.  I will send updates as I confirm each is 
working.   Here is a high level rundown of the changes I made, if you 
have any questions don't hesitate to ask.

kvm.h
    Updated kvm_regs to include all banked registers.  This is needed 
once I get to testing the instructions that load/store from user regs.  
This is also necessary if we can get userspace kvm up and running.

kvmtest.c
    Updated to set the cpsr before executing.  Note if you set the CPSR 
to user mode no translatation or emulation will occur.  Also sets R6 to 
10, the example.s function was modified to find the nth fib number, n 
being in R6.  Finally, the output will print out all registers (cpsr, 
spsr, gprs, banked, unbanked).  This has been committed to the svn repo.

kvm_host.h
    Added a guest_regs (of type pt_regs) section.  This is used as the 
interface between arm_interrupts.S and any of our interrupt handlers 
(currently only swi).

asm-offset.c
    Changed VCPU_GPR to VCPU_REGS, this points to the new guest_regs.

arm.c
    Created prepareSwitchToGuest function.  This should be the last 
thing called before transferring control to arm_interrupts.S (context 
switch to guest).  It's purpose is to:
      1) translate any sensitve instructions in the current block of 
code to SWI instructions if psr mode isn't user mode.
      2) move guest's GPR registers (vcpu) and a "guestified" CPSR into 
guest_regs. A guestified CPSR basically ensures the guest will run in 
user mode with interrupts enabled, regardless of what the guest sees his 
state as.

    Created prepareSwitchFromGuest function. This should be the first 
thing called after receiving control from arm_interrupts.S (context 
switch from guest).  It's purpose is to:
      1) untranslate the current block of code back to what it was, if 
it was translated
      2) setup the guest's GPR registers (vcpu) and an "unguestified" 
CPSR from guest_regs.
  
    Modified kvmarm_handle_swi function so it emulates an instruction 
when it should (the instruction was translated), and exits when it 
shouldn't (currently, if the guest instruction was an SWI, this 
indicates end of run).


arm_interrupts.S
    Modified swi handler to:
       1) save state on the stack in "pt_regs" format
       2) determine if the interrupt is because of the guest process, if 
it isn't pass interrupt to kernel
       3) if it is, move state from stack into guest_regs (VCPU_REGS)
       4) enable for interrupts
       5) call handle_swi, which does its stuff, and puts updated state 
back into guest_regs
       6) run the guest using guest_regs state


Brian


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux