免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2033 | 回复: 0
打印 上一主题 下一主题

[虚拟化] 请教kvm_call_hyp到底干了什么事 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-09-26 16:24 |只看该作者 |倒序浏览
找到一篇文章,说kvm_call_hyp()函数是为了在HYP mode下执行代码。例如,执行在SVC mode下的KVM/ARM代码可以通过下面的调用在HYP mode下无效TLB条目(第一个参数是要执行的函数名,后面的是该函数的参数)

    kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa);

但是我看这个函数的实现似乎只是通过hvc指令切换到HYP mode,然后就返回了,什么都没调用

    ENTRY(kvm_call_hyp)
         hvc        #0
         bx        lr

而且在__cpu_init_hyp_mode函数里面也两次调用kvm_call_hyp,调用的第一个参数分别是null和栈指针,并不是一个函数指针。按照PCS规则,kvm_call_hyp的三个参数分别存入r0,r1和r2,显然在函数实现中并未用到这些寄存器。

因为下面的函数涉及到KVM下的一些关键数据存储的位置,所以一直想把它搞清楚,不知哪位可以指点一下。谢谢

    static inline void __cpu_init_hyp_mode(phys_addr_t boot_pgd_ptr,
                                       phys_addr_t pgd_ptr,
                                       unsigned long hyp_stack_ptr,
                                       unsigned long vector_ptr)
    {
        /*
         * Call initialization code, and switch to the full blown HYP
         * code. The init code doesn't need to preserve these
         * registers as r0-r3 are already callee saved according to
         * the AAPCS.
         * Note that we slightly misuse the prototype by casing the
         * stack pointer to a void *.
         *
         * We don't have enough registers to perform the full init in
         * one go.  Install the boot PGD first, and then install the
         * runtime PGD, stack pointer and vectors. The PGDs are always
         * passed as the third argument, in order to be passed into
         * r2-r3 to the init code (yes, this is compliant with the
         * PCS!).
         */

        kvm_call_hyp(NULL, 0, boot_pgd_ptr);

        kvm_call_hyp((void*)hyp_stack_ptr, vector_ptr, pgd_ptr);
    }
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP