From nobody Mon Feb 9 01:16:50 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3E502033A for ; Sat, 11 Jan 2025 01:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736557457; cv=none; b=LHscUBe3wGjMVe7iVrjshlrpAMzBxdcLb4mfBzr8h5Q4CBaHzQIZsogvgexz8cfgBiUJkS4uZ+wjC6zNLveXTJXZT3yYmD53sCb2PV+ZskjSmoXmDhtB6NyIITXCXfm4Iyn6vL0yUHdeyxhO/LsjDSWc84hobKUgB6VCnRI7GVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736557457; c=relaxed/simple; bh=xIq2EpqRyA2AXMVcTKTfGnLziwxJNZwMY0SpruaP6dQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fHgcBV8gpZ+YhEEMzq9zI5a/IZ64ZrTV65ZR+cEzFloR3/xfDUD7BFKXrY4COATYVrOTLXD+hx4VkgxhF/EwcqCu6icqPfbyQ+AGioxcMif3/Ft6XOJtJYZCMrjNf7A0G5g7IkPRLzwnVXLYrXxOMiiP4v6gXSNWO80IKIRqjE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4qs5oJlp; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4qs5oJlp" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ee46799961so6714185a91.2 for ; Fri, 10 Jan 2025 17:04:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736557455; x=1737162255; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=qLONhXo3aW3WBH6fEqaAtaxz8PcaBZClYQxjCE2fW5k=; b=4qs5oJlp1NssvfORJ4Fz8n0E7/9Q9YF6XBJ3KFSFnXvaaAWsBWw1SVWB7aW1eRxyck Wn65+z/O5Lf/+namTAQj9Lb95a2TFGMpZNE+B93P4SwWgV9s1ytC2WTpktBQTUrDjuWu MRDtshiYsP7ay+wgdPVxE/xxIpU6kTv6pzGbAo2N+Ys1aETlClp+FqZrchyifISTaZiZ /H+lxtQByZMBz6nbxJ2OFA69N9NanXwdSR8CdNFKfjuT3GqGAVhtI7/HD3MzZsFzNqsQ TWBQ2RB7ojnF3/PIp7AR5JEFoKOc4mjiiCKKwq9gasQ1lBQgF0R0448AUghuwSc+uVEP YSGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736557455; x=1737162255; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qLONhXo3aW3WBH6fEqaAtaxz8PcaBZClYQxjCE2fW5k=; b=EM3N35SwW04CdUsRUHcMqLnCGpZU62H8CtEUiUXYHRxFHH4UW5/LcRXB4vYM35e17s p9Te6l4BQQp0xmqGpSsDmcFP3RFadZ3ZDZJ/XVqfkobTKeAS6ppe3/J5/eV0pO2ESNpU M/hecEouaqi8rveikl98i8mud8TWq7XNirOmGE0IhOvRXHG5+LVj+miGdwWBCFKW8Uu6 5fihoBJPeo61c+w55Z3Apdk+/0QRRezz9SA+36tcEpEl7hrY5tyO+TsIxhohFdmo4o74 YKNEu4b2fmOzMUZ081F/5LeHnTTy8w+NrYiC7uFRks6RNmWI5/O1FrUg+aIPK8g3Cne2 nINA== X-Forwarded-Encrypted: i=1; AJvYcCXFvyHlu4/7MvvCP9DwY44jsMYO6UhOYbhfGQc+xn4Yook65NyIIXWSegtI6KUhGPCcPXW68hrCfpCTW7o=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn7i5ga24G+Z4bRdy8QnnryW0AEYYPMPopXrvMS8sJu318vfpP o9ohzB4m9msIqhLvbG49rE4w6o53xNn6jN2A0an0dpjgpPZCICYwt9oHmrjyV5w9FczyfrgBC9t zTA== X-Google-Smtp-Source: AGHT+IHH0Fmds1PmmVVZr37IVwKQmveAAVRjINELYisNKzj4RspyqLxQGG7qVO+G/iH8KfvqVTQcx1AsZ7I= X-Received: from pjbqi17.prod.google.com ([2002:a17:90b:2751:b0:2ea:5084:5297]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2b8e:b0:2ee:d433:7c54 with SMTP id 98e67ed59e1d1-2f548eceae7mr17545829a91.19.1736557455348; Fri, 10 Jan 2025 17:04:15 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 10 Jan 2025 17:04:06 -0800 In-Reply-To: <20250111010409.1252942-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250111010409.1252942-1-seanjc@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250111010409.1252942-3-seanjc@google.com> Subject: [PATCH 2/5] KVM: Bail from the dirty ring reset flow if a signal is pending From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Xu , Yan Zhao , Maxim Levitsky , Sean Christopherson Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Abort a dirty ring reset if the current task has a pending signal, as the hard limit of INT_MAX entries doesn't ensure KVM will respond to a signal in a timely fashion. Fixes: fb04a1eddb1a ("KVM: X86: Implement ring-based dirty memory tracking") Signed-off-by: Sean Christopherson --- virt/kvm/dirty_ring.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virt/kvm/dirty_ring.c b/virt/kvm/dirty_ring.c index 2faf894dec5a..a81ad17d5eef 100644 --- a/virt/kvm/dirty_ring.c +++ b/virt/kvm/dirty_ring.c @@ -117,6 +117,9 @@ int kvm_dirty_ring_reset(struct kvm *kvm, struct kvm_di= rty_ring *ring, cur_slot =3D cur_offset =3D mask =3D 0; =20 while (likely((*nr_entries_reset) < INT_MAX)) { + if (signal_pending(current)) + return -EINTR; + entry =3D &ring->dirty_gfns[ring->reset_index & (ring->size - 1)]; =20 if (!kvm_dirty_gfn_harvested(entry)) --=20 2.47.1.613.gc27f4b7a9f-goog