KVM: vmx: rewrite the comment in vmx_get_mt_mask
Better reflect the structure of the code and metion why we could not always honor the guest. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Cc: Gurchetan Singh <gurchetansingh@chromium.org> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
244c6b6df9
commit
222f06e7cd
@ -6898,17 +6898,24 @@ static u64 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio)
|
|||||||
u8 cache;
|
u8 cache;
|
||||||
u64 ipat = 0;
|
u64 ipat = 0;
|
||||||
|
|
||||||
/* For VT-d and EPT combination
|
/* We wanted to honor guest CD/MTRR/PAT, but doing so could result in
|
||||||
* 1. MMIO: always map as UC
|
* memory aliases with conflicting memory types and sometimes MCEs.
|
||||||
* 2. EPT with VT-d:
|
* We have to be careful as to what are honored and when.
|
||||||
* a. VT-d without snooping control feature: can't guarantee the
|
*
|
||||||
* result, try to trust guest.
|
* For MMIO, guest CD/MTRR are ignored. The EPT memory type is set to
|
||||||
* b. VT-d with snooping control feature: snooping control feature of
|
* UC. The effective memory type is UC or WC depending on guest PAT.
|
||||||
* VT-d engine can guarantee the cache correctness. Just set it
|
* This was historically the source of MCEs and we want to be
|
||||||
* to WB to keep consistent with host. So the same as item 3.
|
* conservative.
|
||||||
* 3. EPT without VT-d: always map as WB and set IPAT=1 to keep
|
*
|
||||||
* consistent with host MTRR
|
* When there is no need to deal with noncoherent DMA (e.g., no VT-d
|
||||||
|
* or VT-d has snoop control), guest CD/MTRR/PAT are all ignored. The
|
||||||
|
* EPT memory type is set to WB. The effective memory type is forced
|
||||||
|
* WB.
|
||||||
|
*
|
||||||
|
* Otherwise, we trust guest. Guest CD/MTRR/PAT are all honored. The
|
||||||
|
* EPT memory type is used to emulate guest CD/MTRR.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (is_mmio) {
|
if (is_mmio) {
|
||||||
cache = MTRR_TYPE_UNCACHABLE;
|
cache = MTRR_TYPE_UNCACHABLE;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user