[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About two-dimensional page translation (e.g., Intel EPT) and shadow
From: |
Sean Christopherson |
Subject: |
Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM |
Date: |
Thu, 15 Jul 2021 22:24:22 +0000 |
On Thu, Jul 15, 2021, harry harry wrote:
> Hi Sean,
>
> > No, each vCPU has its own MMU instance, where an "MMU instance" is (mostly)
> > a KVM
> > construct. Per-vCPU MMU instances are necessary because each vCPU has its
> > own
> > relevant state, e.g. CR0, CR4, EFER, etc..., that affects the MMU instance
> > in
> > some way. E.g. the MMU instance is used to walk guest page tables when
> > translating GVA->GPA for emulation, so per-vCPU MMUs are necessary even when
> > using TDP.
> >
> > However, shadow/TDP PTEs are shared between compatible MMU instances. E.g.
> > in
> > the common case where all vCPUs in a VM use identical settings, there will
> > effectively be a single set of TDP page tables shared by all vCPUs.
>
> What do you mean by "MMU instance"? Do you mean VMCS? MMU is hardware.
No, an MMU is not a hardware-exclusive term, e.g. a software emulator will have
an MMU to emulate the MMU of the target hardware.
The terminology we use in KVM is roughly that a KVM MMU is KVM's presentation of
a hardware MMU to the guest. E.g. when shadow paging is used, there is both the
hardware MMU that is stuffed with KVM's shadow PTEs, and the KVM MMU that models
the guest's MMU (the guest thinks its configuring a hardware MMU, but in reality
KVM is intercepting (some) guest PTE modifications). 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.
Even more fun, when nested TDP is used, there is a KVM MMU for L1, a KVM MMU for
L1's EPT for L2, a KVM MMU for L2 (L2's legacy page tables), and the hardware
MMU.
> Could you please share me the code of the MMU instance in KVM? Thanks!
struct kvm_mmu, and generally speaking everything under arch/x86/kvm/mmu/.
- About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, harry harry, 2021/07/11
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, Maxim Levitsky, 2021/07/12
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, harry harry, 2021/07/12
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, Maxim Levitsky, 2021/07/12
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, Sean Christopherson, 2021/07/12
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, harry harry, 2021/07/14
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, Sean Christopherson, 2021/07/14
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, harry harry, 2021/07/15
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM,
Sean Christopherson <=
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, harry harry, 2021/07/15
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, Sean Christopherson, 2021/07/21
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, harry harry, 2021/07/28
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, Sean Christopherson, 2021/07/28
- Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM, harry harry, 2021/07/14