Sunday, July 19, 2020

QEMU TCG

[I'm not sure what's the best title to describe this blog. So just use those two words. If you arrive here, that means either this title or something below has the keywords that you care about.]


Recently I had a need to touch TCG code in QEMU to fix something. I have been using QEMU for years and even longer with VirtualBox and VMWare. But at most time, the virtualization of CPU is done in kernel by real CPU, via KVM in QEMU. I heard about the user mode emulation, and even read the VBox's doc which has some detailed explanation on how they do it, and of course some fancy PPTs, but I have never had a chance to really dig into the source code to know how exactly it's done.

So after countless days and nights I finally had a roughly deep understanding. I feel that I'd better record it somewhere because it's so complex and hard to remember the details even just after couple months.

I'll describe the steps bellow about how to analyze its execution flow.

I've never been a real virtualization guy untill last year when I needed to fix something deeply inside the virtualized CPU. So if some terms or concepts below are wrong, please forgive me and just use whatever names that you think they are correct.