On Mon, May 9, 2011 at 5:31 PM, Hollis Blanchard <hollis at penguinppc.org> wrote: > On Sun, May 8, 2011 at 7:00 AM, Christoffer Dall <cdall at cs.columbia.edu> wrote: >> Hi Catalin. >> >> This patch contains the KVM code including the simple version of the >> initialization API that we discussed. > > I missed the discussion, so I'm not really sure what the context is, > but just a quick question: The purpose of sending this patch now was to get a discussion going on how KVM should initialize itself. The background is that the Hypervisor mode only exists as sort of a "parent" mode to the privileged non-secure modes and doesn't exist in the secure world. Therefore, to initialize it, some values have to be configured by the Monitor mode, which has higher privilege than the Hypervisor mode. So, we came up with an API, so a non-secure kernel can gain access to the Hyp-mode by setting the Hypervisor exception vector base address through a secure monitor call ABI convention, which is what the proposed patch takes advantage of. Hope it makes sense. > >> +/* >> + * Change the current processor mode to Hyp mode. >> + * You should never return to user space or enable interrupts before calling >> + * kvm_arm_hyp_return. >> + */ >> +static inline void kvm_arm_hyp_mode(void) >> +{ >> + ? ? ? __asm__ ( >> + ? ? ? ? ? ? ? "push ? {lr}\n\t" >> + ? ? ? ? ? ? ? "hvc ? ?#0\n\t" >> + ? ? ? ? ? ? ? "pop ? ?{lr}\n\t"); >> +} >> + >> +/* >> + * Return from Hyp mode to Svc mode. >> + */ >> +static inline void kvm_arm_hyp_return(void) >> +{ >> + ? ? ? __asm__ ( >> + ? ? ? ? ? ? ? "push ? {lr}\n\t" >> + ? ? ? ? ? ? ? "hvc ? ?#0\n\t" >> + ? ? ? ? ? ? ? "pop ? ?{lr}\n\t"); >> +} > > Are these hypercalls that return in a new processor privilege level? > (Also, I don't see them being used anywhere.) > Yes, they are, but I am not sure they're going to look like this yet, as the world-switch code for A15 is not yet finished, so they're kind of stubs right now. I was working with the idea that since the entire kernel, with scheduling of other processes and jumps to user space, does not work in the Hyp mode, it might be convenient to be able to simply switch to Hyp mode with interrupts disabled, do some hardware manipuliation / querying, and then switch back. Another approach would be a way to call a function in Hyp mode through some macro or function pointer implementation. OTOH, it may be cleaner to just read anything that may be necessary when returning from a guest and store that on some data structures, which the kernel can manipulate in svc mode and likewise let the kernel manipulate data structures that Hyp-mode can use when switching to the guest. In the end it will come down to a trade-off between code readability and performance I think, but if anyone have opinions on this up front, please let me know. > Is the A15 ISA documentation available anywhere yet? > Yes, it's available on ARM's web site. If you register at http://infocenter.arm.com, you can download the LPAE specifications and the Virt. Extensions are part of those. > -Hollis >