快速模擬器QEMU為廣為大家所使用的嵌入式系統模擬器,除可進行單一應用程式模擬(Application Simulation),更可進行全系統的系統模擬(System Simulation),但在全系統的模擬速度表現上,與Desktop PC大約會有10倍左右的slow down,在過去較為重視的是模擬結果正確性,但在現今嵌入式平台已邁入多核心處理器應用和處理器頻率仍不斷往上攀升的情況,提升模擬器速度,減少與真實機器間的模擬速度差異,已成為極需重視的議題。 在真實系統運行中,記憶體存取指令碼佔有很重的比例,約佔整體執行指令碼的20%~40%,但記憶體的存取速度遠比不上處理器的執行速度,因此為能加速記憶體存取速度,硬體設計上使用MMU(Memory Management Unit)來加速記憶體位址轉換,同時處理器內部也有TLB(Translation Lookaside Buffer)作為記憶體位址轉換的快取。QEMU在全系統模擬上,以軟體方式實作了MMU和TLB的支援,稱為Soft-MMU和Soft-TLB,但在全系統模擬的指令碼翻譯上,卻大幅增加了記憶體存取指令碼與其他指令碼間的數量差異,造成了約5倍的指令碼數量差異,這5倍的指令碼數量差異,讓記憶體存取指令碼所佔整體比例,由20%~40%推升至56%~77%。 因此為能加速QEMU原有的記憶體存取效率,減少各指令的執行時間差異,本論文分別就Soft-MMU、Soft-TLB提出改善方法。本論文是以x86-64bit平台對映ARM-32bit平台進行觀察測試和全系統模擬,預設兩邊平台的作業系統分為Linux-64bit和Linux-32bit,這也是目前在Android系統平台開發上,使用QEMU進行全系統模擬時,最為大家普遍使用的設定。
QEMU is a fast and popular emulator for on embedded systems. Not only have ability for Application Simulations, but also support System Simulations. Unfortunately, 10 times slowdown was observed in System Simulation speed tests, as Simulation being focused on correctness. Nowadays, embedded systems step forward to multi-core application, while CPU frequencies get higher, speeding up the emulator and emulating differentiate instruction with more reasonable time is a noticeable issue. This paper described a method to improve Soft-MMU and Soft-TLB. This paper is targeted on x86-64 bit platform, and emulating arm-32 bit platform system. These two configurations are the most widely used when developing Android applications.