Re: [PATCH 01/16] KVM: x86/mmu: Exit to userspace with -EFAULT if private fault hits emulation
From: Sean Christopherson
Date: Thu Apr 04 2024 - 12:39:53 EST
On Tue, Mar 12, 2024, Binbin Wu wrote:
>
> On 3/7/2024 8:52 PM, Gupta, Pankaj wrote:
> > > Exit to userspace with -EFAULT / KVM_EXIT_MEMORY_FAULT if a private fault
> > > triggers emulation of any kind, as KVM doesn't currently support
> > > emulating access to guest private memory. Practically speaking, private
> > > faults and emulation are already mutually exclusive, but there are edge
> > > cases upon edge cases where KVM can return RET_PF_EMULATE, and adding one
> > > last check
> >
> > edge cases upon edge cases?
> >
> > Just curious about the details of the edge cases scenarios?
>
> Same question out of curiosity.
Accesses that hit the APIC-access page and gfns that are write-tracked, are the
two most likely candidates. Even plain old emulated MMIO falls into this bucket,
e.g. if KVM botched things and generated a RSVD fault on a private mapping. I'll
reword that line to
faults and emulation are already mutually exclusive, but there are many
flows that can result in KVM returning RET_PF_EMULATE, and adding one last
check to harden against weird, unexpected combinations and/or KVM bugs is
inexpensive.
to make it sound less dramatic/hand-wavy.