Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.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>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Oliver Upton <oupton@kernel.org>,
	kvmarm@lists.linux.dev, Wei-Lin Chang <weilin.chang@arm.com>,
	Anup Patel <anup@brainfault.org>,
	Atish Patra <atish.patra@linux.dev>,
	kvm-riscv@lists.infradead.org, Will Deacon <will@kernel.org>,
	Fuad Tabba <tabba@google.com>
Subject: Re: [PATCH v3 0/3] KVM: Bound KVM_PRE_FAULT_MEMORY by the vCPU's dirty ring
Date: Mon, 23 Nov 2026 14:23:11 +0000	[thread overview]
Message-ID: <86fqwrzkxc.wl-maz@kernel.org> (raw)
In-Reply-To: <20261123113435.1170711-1-fuad.tabba@linux.dev>

On Mon, 23 Nov 2026 11:34:32 +0000,
Fuad Tabba <fuad.tabba@linux.dev> wrote:
> 
> Hi folks,
> 
> Changes since v2 [1]:
>   - Added patch 2, which warns in api.rst against calling ioctls other
>     than KVM_RUN while an exit is pending. (Sean)
>   - Mentioned riscv as well as arm64 in patch 1's exit_reason
>     paragraph. (Lorenzo)
>   - Collected Lorenzo's Acked-by on patch 3. (thanks!)
> 
> KVM_PRE_FAULT_MEMORY never checks the vCPU's dirty ring, so one call
> over a large enough range of populated, dirty-logged pages overflows
> it. The first patch stops the loop at the soft limit, as KVM_RUN does.
> The second warns userspace against calling ioctls other than
> KVM_RUN while an exit is pending. The third adds the case to
> pre_fault_memory_test.
> 
> Pre-faulting isn't the only ioctl that can push past the ring's
> reserve. On x86, KVM_SET_MSRS does too when it writes the wall clock or
> the Hyper-V hypercall page. A guest can also push past the reserve
> within one exit, for example through the arm64 ITS. What those paths
> should do when the ring fills is an open question for the dirty ring
> API, which I don't think belongs in this series.
> 
> I didn't include the kvm_dirty_ring_check_request() rewrite that Sean
> sketched on v1, since I think it can lose a request. It tests the
> request first and clears it afterwards. If the vCPU is scheduled out in
> between, loongarch sets the PV preempted flag in guest memory and x86
> updates a Xen guest's runstate area, either of which pushes an entry.
> When that push makes the ring soft full, the request it makes is then
> cleared, and the vCPU runs with the ring soft full until its next push.
> Clearing first and re-setting, as the code does now, doesn't have that
> window.
> 
> Based on Linux 7.4-rc2 (7475ea8b58616; also applies to kvm-x86/next
> cbe54fc3462b3 with git am -3).
> 
> Cheers,
> /fuad
> 
> [1] https://lore.kernel.org/all/20261117074428.7544-1-fuad.tabba@linux.dev/
> 
> Fuad Tabba (3):
>   KVM: Stop KVM_PRE_FAULT_MEMORY when the vCPU's dirty ring is full
>   KVM: Warn userspace against ioctls while an exit is pending
>   KVM: selftests: Test KVM_PRE_FAULT_MEMORY against a full dirty ring
> 
>  Documentation/virt/kvm/api.rst                |  20 ++--
>  include/linux/kvm_dirty_ring.h                |   5 +
>  .../selftests/kvm/pre_fault_memory_test.c     | 102 ++++++++++++++++++
>  virt/kvm/kvm_main.c                           |   5 +
>  4 files changed, 126 insertions(+), 6 deletions(-)
> 
> 
> base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

      parent reply	other threads:[~2026-11-23 14:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 11:34 [PATCH v3 0/3] KVM: Bound KVM_PRE_FAULT_MEMORY by the vCPU's dirty ring Fuad Tabba
2026-11-23 11:34 ` [PATCH v3 1/3] KVM: Stop KVM_PRE_FAULT_MEMORY when the vCPU's dirty ring is full Fuad Tabba
2026-11-23 11:34 ` [PATCH v3 2/3] KVM: Warn userspace against ioctls while an exit is pending Fuad Tabba
2026-11-23 11:34 ` [PATCH v3 3/3] KVM: selftests: Test KVM_PRE_FAULT_MEMORY against a full dirty ring Fuad Tabba
2026-11-23 14:23 ` Marc Zyngier [this message]

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=86fqwrzkxc.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=anup@brainfault.org \
    --cc=atish.patra@linux.dev \
    --cc=corbet@lwn.net \
    --cc=fuad.tabba@linux.dev \
    --cc=isaku.yamahata@intel.com \
    --cc=kvm-riscv@lists.infradead.org \
    --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=ljs@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=tabba@google.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox