Hi Marc, On Fri, Aug 24, 2012 at 9:38 PM, Marc Zyngier <marc.zyngier@xxxxxxx> wrote: > On Fri, 24 Aug 2012 16:04:02 +0800, Lei Wen <adrian.wenl@xxxxxxxxx> wrote: >> On Thu, Aug 23, 2012 at 11:27 PM, Christoffer Dall >> <c.dall@xxxxxxxxxxxxxxxxxxxxxx> wrote: >>> On Thu, Aug 23, 2012 at 11:08 AM, Lei Wen <adrian.wenl@xxxxxxxxx> > wrote: >>>> Hi Christoffer, >>>> >>>> [snip] >>>> >>>>> diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S >>>>> index 1dc8926..4db26cb 100644 >>>>> --- a/arch/arm/kvm/init.S >>>>> +++ b/arch/arm/kvm/init.S >>>>> @@ -15,5 +15,135 @@ >>>>> * along with this program; if not, write to the Free Software >>>>> * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA >>>>> 02110-1301, USA. >>>>> */ >>>>> + >>>>> +#include <linux/linkage.h> >>>>> +#include <asm/unified.h> >>>>> #include <asm/asm-offsets.h> >>>>> #include <asm/kvm_asm.h> >>>>> +#include <asm/kvm_arm.h> >>>>> + >>>>> > +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ >>>>> +@ Hypervisor initialization >>>>> +@ - should be called with: >>>>> +@ r0 = Hypervisor pgd pointer >>>>> +@ r1 = top of Hyp stack (kernel VA) >>>>> > +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ >>>>> + .text >>>>> + .arm >>>>> + .pushsection .hyp.idmap.text,"ax" >>>>> + .align 12 >>>>> +__kvm_hyp_init: >>>>> + .globl __kvm_hyp_init >>>>> + >>>>> + @ Hyp-mode exception vector >>>>> + nop >>>>> + nop >>>>> + nop >>>>> + nop >>>>> + nop >>>>> + b __do_hyp_init >>>>> + nop >>>>> + nop >>>>> + >>>>> +__do_hyp_init: >>>>> + @ Set the sp to end of this page and push data for later use >>>>> + mov sp, pc >>>>> + bic sp, sp, #0x0ff >>>>> + bic sp, sp, #0xf00 >>>>> + add sp, sp, #0x1000 >>>>> + push {r0, r1, r2, r12} >>>> >>>> Is safe to use the stack here? Since our HYP memory mapping is >>>> gotten valid after the following HTTBR being set as I think. >>>> >>> >>> yes, as you can see in the end of this block we have a .align 12 >>> before __kvm_hyp_init_end giving us the stack space we need in this >>> page (as long as this init code doesn't grow beyond ~3K >> >> I know this area is already being mapped in hyp_init_static_idmap, >> however, due to the HTTBR is not being set up yet in the below code. >> So how the memory get mapped in the hyp mode? I mean what I could >> understand the hyp virtual address only could be seen after HTTBR >> being set up. > > Hint: look at HSCTLR, and when the M bit gets set. Until then, the words > "virtual address" have no meaning. I see. You means that when at the first push operation, it directly deal with physical memory, mapping is meaningless at that moment. After MMU on, for that piece of code being mapped as identical one, the sp operation also get no problem. Yep, that solve my confusion. Thanks, Lei -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html