From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796467306; b=o7tlGdLLU/JiN43NMrckwUExVpdH4Kk9MJwoBnCDdubMeIa1lzbkAFpn9tGJvQo8Qy/h KGB4b8wbll+wAphzFLKj3XNOQpaoJOAaqq9wpUsDcDlLfj4CX9+CW9DzyOZ/+dgzKGYAW kRPMpDWkG04OWgAJepN1bCgpWemClalAsk/59K+UiyGT/tOoplD3lI7UviVUOIFalvl7P lAJ3ThEYYND3qFnCMBqoZmDtv18+Kgw0tEcuAb0LakeB819cXeZJ32pZLAf5MiH0HTIv7 Knd2iYL8dymtjazEkGvOKqdPE5CwlrpsSv8Q2BljmJjR+82HttmJbydWIfuXbmCIOkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796467306; h=Received:DKIM-Signature:Received:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-SA-Exim-Connect-IP:X-SA-Exim-Rcpt-To: X-SA-Exim-Mail-From:X-SA-Exim-Scanned; bh=J130X/W0OscUrsqMYKmDWvIUE1R6B00Iy5z9ZFe/7lg=; b=WD0P+CdwW8/YygdOQRVueXFZPbInsxAatEk9o0XsU2U2hK+kZsPjeXCUnAyxWpT+JiNW 6YUgy6TICjTgou/9xQPsC86WrLym/fGzAHzJ1H6yT7DiNxZtGmP+0ehhDWURiMx/g5Poe n7AzA6It1MrubW7w1x0poQZ4mKnL4cm/4Zb0XosaXtQLuu78oAYivGTMY2cp1IOQtZ/lR mBbDKj0ZxyfREpWj/JXYyT/O46FoQaFxdpda2c8oEOyu/raorzMm7Bz3f3U8jckuTUCr6 l9+GMitrU/GzU1vZCd146ONhAaJ4XNH5qW7ebKbSOM5hoa/plif4/aX4qwt4QF9Uueg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e0GqUTCs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EDC8606A6AB; Sat, 5 Dec 2026 10:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e0GqUTCs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4065A1F00A10; Sat, 5 Dec 2026 10:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796467306; bh=J130X/W0OscUrsqMYKmDWvIUE1R6B00Iy5z9ZFe/7lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=e0GqUTCs2GiYNFkr2YQAIkXcn2g1xkt2hF5lsEtfCLrH7QYbTZ07ihIM7cgZlysrt rkoG9/eVEBeKMCVhMO6TITd+y5mdQ7dVS/OEyi1XyyGLFicmMCmA3B0SeDVk+dxuVg e2y1ccNScTNl2DtIcNzNwW086NpGAyLhejonCygFvKI9psxU3fUQEvX52kuPcx+/7E VwAIS/M/vNgOLQbl3yW/bhYH3SWBq92HJuQ5IuWyr/6iST8RpC09Mpu4Dia7A+BkJI 45Tkh30EYIoh3o+ZgvLHQn0Sb5HCbz5rEmPgpgiFOiAxpsLUr1LCrJY8xh5lMYrX8S bKKs0Sbx9NhIw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xZnD6-00000007UWT-26IV; Sat, 05 Dec 2026 10:41:44 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Steffen Eiden , Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Fuad Tabba , Paolo Bonzini , stable@vger.kernel.org, Raghavendra Rao Ananta , Stefan Teodorescu , Damiano Melotti Subject: [PATCH 6.6.y 4/5] KVM: arm64: vgic-its: Add signal checks in scan_its_table() Date: Sat, 5 Dec 2026 10:41:37 +0000 Message-ID: <20261205104138.1432063-5-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261205104138.1432063-1-maz@kernel.org> References: <20261205104138.1432063-1-maz@kernel.org> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, seiden@linux.ibm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com, fuad.tabba@linux.dev, pbonzini@redhat.com, stable@vger.kernel.org, rananta@google.com, fane@google.com, melotti@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false From: Raghavendra Rao Ananta commit 0403edd7fc1c8d1263e179e85d0e987dcc838193 upstream. During ITS table restore (KVM_DEV_ARM_ITS_RESTORE_TABLES), scan_its_table() walks guest RAM to restore Device Table Entries (DTEs) and Interrupt Translation Tables (ITTs) while holding kvm->lock, all vCPU mutexes, kvm->arch.config_lock, and its->its_lock. Because a guest can plant valid DTEs with num_eventid_bits = 16 (size = 15, or 65,536 EventIDs per device) pointing to zeroed/sparse ITT memory (!lpi_id), vgic_its_restore_ite() returns +1 for each unmapped entry. This forces scan_its_table() to scan up to 65,536 entries per device (up to 4.30B reads for a 1-level flat table or 21.48B reads for a 2-level indirect table). Because scan_its_table() lacks signal checks, executing KVM_DEV_ARM_ITS_RESTORE_TABLES monopolizes the host CPU in kernel space for tens to hundreds of seconds. Fix this by checking signal_pending(current) at the start of the scan_its_table() loop to allow immediate cancellation (-EINTR) if a VMM timeout or termination signal arrives. Fixes: 920a7a8fa92a ("KVM: arm64: vgic-its: Add infrastructure for table lookup") Reported-by: Stefan Teodorescu Cc: stable@vger.kernel.org Signed-off-by: Raghavendra Rao Ananta Signed-off-by: Damiano Melotti [maz: added cond_resched() for non PREEMPT_LAZY capable versions] Signed-off-by: Marc Zyngier --- arch/arm64/kvm/vgic/vgic-its.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index 122e0da104a1c..62e2e33d87443 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -2263,6 +2263,9 @@ static int scan_its_table(struct vgic_its *its, gpa_t base, int size, u32 esz, int next_offset; size_t byte_offset; + if (signal_pending(current)) + return -EINTR; + ret = kvm_read_guest_lock(kvm, gpa, entry, esz); if (ret) return ret; @@ -2278,6 +2281,8 @@ static int scan_its_table(struct vgic_its *its, gpa_t base, int size, u32 esz, id += next_offset; gpa += byte_offset; len -= byte_offset; + + cond_resched(); } return 1; } -- 2.47.3