On Thu, Jul 15, 2021, harry harry wrote: > Hi Sean, > > Thanks for the explanations. Please see my comments below. Thanks! > > > When TDP (EPT) is used, the hardware MMU has two parts: the TDP PTEs that > > are controlled by KVM, and the IA32 PTEs that are controlled by the guest. > > And there's still a KVM MMU for the guest; the KVM MMU in that case knows > > how to connfigure the TDP PTEs in hardware _and_ walk the guest IA32 PTEs, > > e.g. to handle memory accesses during emulation. > > Sorry, I could not understand why the emulated MMU is still needed > when TDP (e.g., Intel EPT) is used? > In particular, in what situations, we need the emulated MMU to > configure the TDP PTEs in hardware and walk the guest IA32 PTEs? Ignoring some weird corner cases that blur the lines between emulation and hardware configuration, the emulated IA32 MMU isn't used to configure TDP PTEs in hardware, it's only used to walk the the guest page tables. > Why do we need the emulated MMU in these situations? For emulation of any instruction/flow that starts with a guest virtual address. On Intel CPUs, that includes quite literally any "full" instruction emulation, since KVM needs to translate CS:RIP to a guest physical address in order to fetch the guest's code stream. KVM can't avoid "full" emulation unless the guest is heavily enlightened, e.g. to avoid string I/O, among many other things.