[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Ze62bqgWhbReg9wl@yzhao56-desk.sh.intel.com>
Date: Mon, 11 Mar 2024 15:44:46 +0800
From: Yan Zhao <yan.y.zhao@...el.com>
To: Sean Christopherson <seanjc@...gle.com>
CC: Paolo Bonzini <pbonzini@...hat.com>, Lai Jiangshan
<jiangshanlai@...il.com>, "Paul E. McKenney" <paulmck@...nel.org>, "Josh
Triplett" <josh@...htriplett.org>, <kvm@...r.kernel.org>,
<rcu@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Kevin Tian
<kevin.tian@...el.com>, Yiwei Zhang <zzyiwei@...gle.com>
Subject: Re: [PATCH 1/5] KVM: x86: Remove VMX support for virtualizing guest
MTRR memtypes
On Fri, Mar 08, 2024 at 05:09:25PM -0800, Sean Christopherson wrote:
> index a67c28a56417..05490b9d8a43 100644
> --- a/arch/x86/kvm/mtrr.c
> +++ b/arch/x86/kvm/mtrr.c
> @@ -19,33 +19,21 @@
> #include <asm/mtrr.h>
>
> #include "cpuid.h"
"cpuid.h" is not required either.
> -#include "mmu.h"
>
..
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 7a74388f9ecf..66bf79decdad 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -7596,39 +7596,27 @@ static int vmx_vm_init(struct kvm *kvm)
>
> static u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio)
> {
> - /* We wanted to honor guest CD/MTRR/PAT, but doing so could result in
> - * memory aliases with conflicting memory types and sometimes MCEs.
> - * We have to be careful as to what are honored and when.
> - *
> - * For MMIO, guest CD/MTRR are ignored. The EPT memory type is set to
> - * UC. The effective memory type is UC or WC depending on guest PAT.
> - * This was historically the source of MCEs and we want to be
> - * conservative.
> - *
> - * 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.
> + /*
> + * Force UC for host MMIO regions, as allowing the guest to access MMIO
> + * with cacheable accesses will result in Machine Checks.
This does not always force UC. If guest PAT is WC, the effecitve one is WC.
> */
> -
> if (is_mmio)
> return MTRR_TYPE_UNCACHABLE << VMX_EPT_MT_EPTE_SHIFT;
>
Powered by blists - more mailing lists