All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Sean Christopherson <seanjc@google.com>
Cc: Fuad Tabba <fuad.tabba@linux.dev>,
	Paolo Bonzini <pbonzini@redhat.com>,
	 kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-doc@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Jonathan Corbet <corbet@lwn.net>,
	 Shuah Khan <skhan@linuxfoundation.org>,
	Isaku Yamahata <isaku.yamahata@intel.com>,
	 Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	 Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
	kvmarm@lists.linux.dev,  Wei-Lin Chang <weilin.chang@arm.com>,
	Will Deacon <will@kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] KVM: Stop KVM_PRE_FAULT_MEMORY when the vCPU's dirty ring is full
Date: Thu, 19 Nov 2026 11:20:38 +0000	[thread overview]
Message-ID: <av7bYb1geEGzaj8e@gremlin> (raw)
In-Reply-To: <av5CBjbeidUUWiLq@seanjc-mac.roam.internal>

On Wed, Nov 18, 2026 at 04:25:42PM -0800, Sean Christopherson wrote:
> On Tue, Nov 17, 2026, Fuad Tabba wrote:
> > > But the overflow bug only applies to x86 (see below), so is this something
> > > we should worry about at all?
> >
> > The ring overflows on arm64 too (below). As for exit_reason, I asked
> > Sean about the arm64 MMIO case on v1, and his answer was that a VMM
> > that pre-faults between a KVM_EXIT_MMIO return and the next KVM_RUN
> > "gets to deal with the fallout" [1]. I think the same goes for riscv's
> > exits.
> >
> > [...]
> > > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> > [...]
> > > >  The dirty ring can get full.  When it happens, the KVM_RUN of the
> > > > -vcpu will return with exit reason KVM_EXIT_DIRTY_RING_FULL.
> > > > +vcpu will return with exit reason KVM_EXIT_DIRTY_RING_FULL, and
> > > > +KVM_PRE_FAULT_MEMORY on the vcpu will process no more pages until the
> > > > +ring has been harvested and reset.
> > >
> > > Maybe worth mentioning the exit_reason thing if we keep this arch-generic?
> >
> > Sure, I'll document that userspace should complete a pending exit with
> > KVM_RUN before it pre-faults on that vCPU.
>
> If we're going to do a documentation update, I vote to keep it vague and scary,
> otherwise readers might think the exception proves the rule.  I.e. if we say
> that KVM_PRE_FAULT_MEMORY isn't supported, then userspace might think all other
> ioctls are safe, which is most definitely not the case.  E.g. something like

Yes definitely, like drivers, users can get up to all sorts of mischief if not
properly forewarned :>)

>
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index e95c9cda085d..45dc1e3c0b03 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -6971,10 +6971,13 @@ to the byte array.
>
>        The pending state of the operation is not preserved in state which is
>        visible to userspace, thus userspace should ensure that the operation is
> -      completed before performing a live migration.  Userspace can re-enter the
> -      guest with an unmasked signal pending or with the immediate_exit field set
> -      to complete pending operations without allowing any further instructions
> -      to be executed.
> +      completed before performing a live migration.  In general, userspace should
> +      exercise extreme caution when invoking ioctls other than KVM_RUN prior to
> +      completing the original operation.
> +
> +      Userspace can re-enter the guest with an unmasked signal pending or with
> +      the immediate_exit field set to complete pending operations without
> +      allowing any further instructions to be executed.
>
>  ::

--
Cheers, Lorenzo

  parent reply	other threads:[~2026-11-19 11:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  7:44 [PATCH v2 0/2] KVM: Bound KVM_PRE_FAULT_MEMORY by the vCPU's dirty ring Fuad Tabba
2026-11-17  7:44 ` [PATCH v2 1/2] KVM: Stop KVM_PRE_FAULT_MEMORY when the vCPU's dirty ring is full Fuad Tabba
2026-11-17 14:23   ` Lorenzo Stoakes (ARM)
2026-11-17 17:05     ` Fuad Tabba
2026-11-19  0:25       ` Sean Christopherson
2026-11-19  7:54         ` Fuad Tabba
2026-11-19 11:20         ` Lorenzo Stoakes (ARM) [this message]
2026-11-19 12:43           ` Fuad Tabba
2026-11-19 11:18       ` Lorenzo Stoakes (ARM)
2026-11-17  7:44 ` [PATCH v2 2/2] KVM: selftests: Test KVM_PRE_FAULT_MEMORY against a full dirty ring Fuad Tabba
2026-11-17 14:36   ` Lorenzo Stoakes (ARM)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=av7bYb1geEGzaj8e@gremlin \
    --to=ljs@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=corbet@lwn.net \
    --cc=fuad.tabba@linux.dev \
    --cc=isaku.yamahata@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=skhan@linuxfoundation.org \
    --cc=stable@vger.kernel.org \
    --cc=weilin.chang@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.