首页|期刊导航|集成电路与嵌入式系统|基于页表机制实现QEMU调用片外外设动态库的方法

基于页表机制实现QEMU调用片外外设动态库的方法OA

A method for implementing QEMU callback to off-chip peripheral dynamic libraries based on TLB mechanism

中文摘要英文摘要

通过研究QEMU虚拟机与宿主机映射的页表机制,并深入分析其页表填充原理以及读/写指令如何触发、区分对不同类型内存的操作流程原理.通过在页属性中增加新的标志位,并在页表填充和指令对内存读/写的helper函数中对该位进行对应的设置和判定,从而实现对具有某一属性地址的定位并进入特定的回调函数.参照QEMU自带leon3例程中添加外设的流程,设计了动态库的接口函数,包括设备创建、初始化、读/写回调函数等.分析了QEMU对 MMIO外设的读/写流程和传参特征,得出外设定位原理及回调函数所需的基本参数,在此基础上,设计并给出了对片外MMIO型外设的动态库中读/写回调函数的精确调用位置.最后通过实验对研究的正确性和速度敏感性进行了分析,证明文中方法能够很好地实现外设和QEMU代码的分离,运行结果正确,运行速度能达到外设源码与QEMU源码在一起编译时速度的97%以上,对于虚拟机开发人员以及QEMU开源使用者具有一定的借鉴意义.

This paper investigates the page table mechanism for address translation between the QEMU virtual machine and the host,providing an in-depth analysis of page table filling principles and how memory read/write instructions trigger distinct processing flows for different memory types.By introducing a new flag bit into page attributes and setting/checking this bit during page table population and in memory access helper functions,the method achieves recognition of addresses with specific attributes and invokes corresponding call-back functions.With reference to the peripheral addition process in the QEMU leon3 example,interface functions for dynamic libraries are designed,including device creation,initialization,and read/write callbacks.The read/write process and parameter transmission characteristics of QEMU for MMIO peripherals are analyzed to clarify the peripheral locating principle and the basic parameters required by callback functions.Based on this,precise call locations for read/write callback functions in off-chip MMIO peripheral dynamic libraries are designed and presented.Experiments verify the correctness and performance sensitivity of the proposed approach.Results demonstrate that this method effectively separates peripheral code from QEMU source code,ensures correct execution,and achieves over 97%of the performance compared to compiling peripheral source code directly with QEMU.This study offers valuable insights for virtual machine developers and QEMU open-source users.

LI Gen;WU Jin;ZHANG Yuyuan;CUI Hongwei;JI Hongxia

Beijing Xuanyu Information Technology Co.,Ltd.,Beijing 100190,ChinaBeijing Xuanyu Information Technology Co.,Ltd.,Beijing 100190,ChinaBeijing Xuanyu Information Technology Co.,Ltd.,Beijing 100190,ChinaBeijing Xuanyu Information Technology Co.,Ltd.,Beijing 100190,ChinaBeijing Institute of Control Engineering,Beijing 100094,China

信息技术与安全科学

内存分派仿真外设虚拟机QEMU动态库

memory dispatchsimulated peripheralsvirtual machineQEMUdynamic library

《集成电路与嵌入式系统》 2026 (1)

37-46,10

国家自然科学基金(No.2022YFB4501900)

10.20193/j.ices2097-4191.2025.0056

评论