On Fri, Nov 22, 2013 at 02:33:55PM -0500, Zhuoqun Cheng wrote: > Hi Christoffer, > > Thank you! > > 1. Yeah, you are right. Right now i am just picking some stuffs from native > kvm tool and pasting to my own code. But my ultimate goal is to build a > process sandbox based on KVM/ARM, it hosts process rather than kernel, > though i even don't know if it is possible, like those syscall relay > stuffs. Anyway, yet to find better things to do for my research... :) > > 2. I checked the return value of mmap. Just being lazy and abbreviated the > code. Sorry. > > 3. Actually i had an hvc instruction after "add r2, r1, r0", which should > have caused a vm_exit. But since it didn't make any difference, i just got > rid of it and thought the problem should be my guest image not getting run > at all. well, so if that injects an undefined exception and you don't have anything mapped at the exception vectors, that would also cause what you're seeing. > > 4. I asked how to detect a VM shutdown several days ago. And it seems that > it involves power management devices emulation, which is complicated for me > now. So the guest now just keeps executing... Any suggestion to let the > guest exit itself? the only sensible and quick thing to do here is just to reserve an IO address for a shutdown command, write some value to that address and check the return value in your user space tool and just exit the process. Note this is a giant hack. You may benefit from seeing some of the similar hacks we did int the kvm-selftest here: https://github.com/columbia/linux-kvm-arm/tree/kvm-selftest > > 5. I will definitely look into how to use KVM tracepoints and when you say > printks, do you mean to insert some to kvm source code? > Yes, tracepoints should give you the basic info, but you can instrument the KVM code further to see more details of what is going on. -Christoffer > > > > On Fri, Nov 22, 2013 at 2:05 PM, Christoffer Dall < > christoffer.dall@xxxxxxxxxx> wrote: > > > On Fri, Nov 22, 2013 at 01:47:17PM -0500, Zhuoqun Cheng wrote: > > > Hi friends, > > > > > > I am working on a user level kvm tool based on KVM/ARM. Right now it is > > > quite primitive. It creates a vm and loads a binary image to the address > > > space of the vm, then runs the vcpu. > > > > one question would be why? You know there are already two such things > > available right: kvm tool and qemu :) > > > > > > > > But the* problem* is it gets into KVM_RUN ioctl and is never able to get > > > out of it. > > > I use ftrace to trace the function calls and I see what is happening is: > > > > > > kvm_arch_vcpu_ioctl_run-> > > > handle_exit-> > > > exit_handler (which is kvm_handle_guest_abort)-> > > > kvm_inject_pabt */* Prefetch Abort on I/O address */ (this is the comment > > > in that if condition)* > > > > > > Then it keeps returning 1 until back to kvm_arch_vcpu_ioctl, where there > > is > > > a while loop checking if the return value is greater than 0. And since it > > > is 1, it just keeps doing the* above loop*. > > > > > > I don't how it ended up *prefetching instructions from an I/O address*. > > > > > > The *arguments i used when calling ioctl*(KVM_SET_USER_MEMORY_REGION) is: > > > .guest_phys_addr = 0x0000000080000000UL > > > .memory_size = 1024 * 1024 > > > .userspace_addr = mmap(NULL, ram_size, PROT_READ | PROT_WRITE, > > > MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE, -1, 0); > > > > you probably want to check the return value of mmap. > > > > > > > > When *loading image*, i read a binary image to userspace address mapped > > to > > > 0x0000000080000000UL. What the binary image does it just: > > > mov r0, #5 > > > mov r1, #4 > > > add r2, r1, r0 > > > > yeah well, after this instruction who knows what happens.... > > > > > > > > And before running, i *set pc* to 0x0000000080000000UL. Then i run it. > > > > > > What did i do wrong? Can you offer me some hints? > > > > > It means that you're not setting the PC properly or that the code you > > end up executing quickly jumps to some location outside your VM RAM > > region. > > > > I cannot speculate as to what you're doing wrong, but if you look at the > > tracepoints that KVM gives you it will tell you which address it is > > entering for the VCPU and which address it exits on. That should give > > you some hints as to what's going on. > > > > printks will also be helpful - trace the execution of your code. > > > > -Christoffer > > _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm