[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2237d6b1-1c90-4acd-99e9-f051556dd6ac@intel.com>
Date: Fri, 1 Mar 2024 11:26:00 +1300
From: "Huang, Kai" <kai.huang@...el.com>
To: Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini
<pbonzini@...hat.com>
CC: <kvm@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Yan Zhao
<yan.y.zhao@...el.com>, Isaku Yamahata <isaku.yamahata@...el.com>, "Michael
Roth" <michael.roth@....com>, Yu Zhang <yu.c.zhang@...ux.intel.com>, "Chao
Peng" <chao.p.peng@...ux.intel.com>, Fuad Tabba <tabba@...gle.com>, "David
Matlack" <dmatlack@...gle.com>
Subject: Re: [PATCH 08/16] KVM: x86/mmu: WARN and skip MMIO cache on private,
reserved page faults
On 28/02/2024 3:41 pm, Sean Christopherson wrote:
> WARN and skip the emulated MMIO fastpath if a private, reserved page fault
> is encountered, as private+reserved should be an impossible combination
> (KVM should never create an MMIO SPTE for a private access).
>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
> arch/x86/kvm/mmu/mmu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index bd342ebd0809..9206cfa58feb 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -5866,7 +5866,8 @@ int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 err
> error_code |= PFERR_PRIVATE_ACCESS;
>
> r = RET_PF_INVALID;
> - if (unlikely(error_code & PFERR_RSVD_MASK)) {
> + if (unlikely((error_code & PFERR_RSVD_MASK) &&
> + !WARN_ON_ONCE(error_code & PFERR_PRIVATE_ACCESS))) {
> r = handle_mmio_page_fault(vcpu, cr2_or_gpa, direct);
> if (r == RET_PF_EMULATE)
> goto emulate;
It seems this will make KVM continue to call kvm_mmu_do_page_fault()
when such private+reserve error code actually happens (e.g., due to
bug), because @r is still RET_PF_INVALID in such case.
Is it better to just return error, e.g., -EINVAL, and give up?
Powered by blists - more mailing lists