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