From nobody Tue Dec 16 13:35:29 2025 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 B1D0E280A58 for ; Fri, 16 May 2025 21:35:46 +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=1747431348; cv=none; b=NRIni7CkJhzYhZlUar2BFuJ07UO8dF0sfZG7oVwHbDb79p/HKYVw8qaC2SMBU9aTjur7jLtAmxWBB+kK3pei1Vs5bZxWyRv4pL9rQz8Dq7Ij8oOPIqwoH0YQclwYJAwS3trg6PNTfzpa6SWoKTwiwlaOvrqvU3Mv9OBiRTwYgyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747431348; c=relaxed/simple; bh=RrZIIikij6DmitW6dz05NLZuqphJeOs9Ps1ePqojGbE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=e2eFG71PBoNdwaX0Mz0FD7DlSnUqlHlACPWqX2/GBvrYj9acq7ne3tQo11y81IxQ8x8CSeXt4Y2xUGM19MO7RkpW6j/CmTOlriw2eb3bL+7Z/v/L8IMUSC3hl0+sfHhdXZQ5RAgBnYduyvuGXl7Hr3aEz7SL3N9iaKHNxn4dowk= 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=F3jW5aK8; 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="F3jW5aK8" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-30a29af28d1so2123407a91.0 for ; Fri, 16 May 2025 14:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1747431346; x=1748036146; 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=G9wmHetGMkK5ECrcXO3NqdUKVr+Bbfy2OeQR2kTh+6U=; b=F3jW5aK8hS9KEX1vtOHIcreyHVASXmaxPtKg5/Oygiu5GwtIUGdEXGrJnE6gP7I/L3 JnlQP2oGA6uFUmSlTfq4zt3CSs4/3lkeMF1c7RhAVL4xeimdbEhT6jswq8UbmT08lYtY izRBSoBrO9sG6k/Fc7v/NE6ErPJ3n3KEdndH6OR1PYHfOpilP0tnY4dCXAmfClcu34Ga Q3OmW76oJglaYZZPT8tE6y+oNrXzT4oSXROKN4cfy38Z2ZaFoyS1bEnmKYjtEZdHwH// /0WEh/Fu9h0QVlFQnJa/rzOPeuPztu+Xpy1QdsiJ80KdG8s8brnYIX1mBhxDVx/o7wN2 mVQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747431346; x=1748036146; 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=G9wmHetGMkK5ECrcXO3NqdUKVr+Bbfy2OeQR2kTh+6U=; b=Z7hHLKOdQD3mvIb1UZ/SrnhQTntNVE7GDvIDXe4WsvXoEKY97PFzN0Bv7bCLgBrqgR kUnFat+q1q7q5iDeHV4ig7mMULL4qwsZEdQ5Nxb/u5y6G6knivS+WJOGnctFbgBg0feu N2p2TLl2QP1j2nI4TltiivNeTRxvktZDieeT3qID4IsnrR33kqCR5BXrrLgcSqdOdbUH nAka657Kpe0ZUmZeBUD4ln/JPCICQc5Frg4ciZXxQaQEICAoNZlQxAWA7JYtOhfFcZz0 PUqggtBO6Gxw84Yewgr2lhb6IZ9q00TEhHB45geq5TEaoPUzwpQodNmnfxaeLu3+1Mvi IFwg== X-Forwarded-Encrypted: i=1; AJvYcCU+QKuSqz4mJ8xqbPEJXLtnT+5T/SDuB4h5+GcFxKlhQpI+RH70pQm8qD9vl2UhnPfwEEQwhgbdKp8x7ks=@vger.kernel.org X-Gm-Message-State: AOJu0YyUWfHHWvOfLSNPI6BwCw/ucr0x7qrfSrzQpQPbFB2Sncza8K/p oP9TW6KZRTlJ0turDNN2tYaqk2m4tzUO2U8e1lUo1sReRhg1bw4ilc3egljmVMIqwvuKEYpIhVu tiDn6Cw== X-Google-Smtp-Source: AGHT+IFa21w7PEBxGuke+jG4g4hQIIBprIgWw+tC2Qp349rJsk36zh/R3cXUzcky2fs51sE1Hx6oGfXmwC8= X-Received: from pjbsn4.prod.google.com ([2002:a17:90b:2e84:b0:2ef:7af4:5e8e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3e8e:b0:30e:54be:37cc with SMTP id 98e67ed59e1d1-30e7d5a93a3mr6251597a91.23.1747431346001; Fri, 16 May 2025 14:35:46 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 16 May 2025 14:35:36 -0700 In-Reply-To: <20250516213540.2546077-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: <20250516213540.2546077-1-seanjc@google.com> X-Mailer: git-send-email 2.49.0.1112.g889b7c5bd8-goog Message-ID: <20250516213540.2546077-3-seanjc@google.com> Subject: [PATCH v3 2/6] 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 , Binbin Wu , James Houghton , Sean Christopherson , Pankaj Gupta 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") Reviewed-by: James Houghton Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- 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 77986f34eff8..e844e869e8c7 100644 --- a/virt/kvm/dirty_ring.c +++ b/virt/kvm/dirty_ring.c @@ -118,6 +118,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.49.0.1112.g889b7c5bd8-goog