From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 264CE3A83A9; Sat, 8 Aug 2026 08:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786176549; cv=none; b=u88EP7eBMflRO6cdhNGw3hL/RLnekPvUa2f6HHItHHSGnYzY8ZWmdHTXGv5oz1HNXmKfPSw2JDoX0Q458CmNKx7mtMH46sgpF/CyDs4p4KDsiBiNaobi+VKAFvlztcAfXK8cv4SK8yqoGdzDYkycuwd8qoUAV1HoTZTjo8jQegI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786176549; c=relaxed/simple; bh=EEtL0ADvMgRx6jV9x6sIrhuX4M2qKYjaS2dS6bZhE9Y=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=ru9NeH49iMvS8UBl31dfmel19BgoAqho8LWFgC84vs0wMEmvCq3H/INwMYT8Tf7eZh9iZaA2macunHv+IonE1uYZ4+7eD9FJ3yLIW7wmBGt5UPufbPxSjo7CtmH/Jy9CA6h6p1G9IYsXgmp/1WuKs8rLtUq3Gan5b4LZaaxyeLU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TokhsMIs; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TokhsMIs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4FA11F000E9; Sat, 8 Aug 2026 08:09:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786176547; bh=XtFxe7lTSkyr2Cg+Wnox9DL2CC/sLeXegVl9950TLyA=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=TokhsMIsIsjXaK+crrDB0+vAhOAD0Pv519ZF1AofRnBHHlLlww6Pk7Ug8gQnkSVJh a29OUCpEEDGqDnXn67E/vQ+VSPSIQvvwHEDUWtx52Mmz9/piF3DEVQYAAjSrFXiyJc NnlLXtuW7ivW4PJ/fm4tJFiioSUY62GA+6XVKXTBgxT2aguMwZuhJIUUJ66XmZDeGl EpCVgqso62YzhvRxxoLiKaM6dTWXxdyTq+SATnDajxPodNgaimAKyxkntJ4tNI6m5Z 7/cD+wOQM/LwSH6gGtCMFnVoWLe2pmz2enl9EO26WkDoPmz5XBxY19Xp7J7RgGS/rM 6+CYcytLv69Ww== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-girl.misterjones.org) 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 1wsc77-0000000DcX6-1h5a; Sat, 08 Aug 2026 08:09:05 +0000 Date: Sat, 08 Aug 2026 09:10:29 +0100 Message-ID: <87ecg9owwa.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: Oliver Upton , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Will Deacon , Sascha Bischoff , Sebastian Ene , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] KVM: arm64: vgic-its: Don't save collections the table cannot hold In-Reply-To: <20260807104102.2410744-4-fuad.tabba@linux.dev> References: <20260807104102.2410744-1-fuad.tabba@linux.dev> <20260807104102.2410744-4-fuad.tabba@linux.dev> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: fuad.tabba@linux.dev, oupton@kernel.org, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, will@kernel.org, sascha.bischoff@arm.com, sebastianene@google.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 07 Aug 2026 11:41:01 +0100, Fuad Tabba wrote: > > A guest that disables the ITS and rewrites GITS_BASER with fewer pages, > VALID still set, keeps every collection it mapped against the larger > table: KVM stores the new BASER unconditionally and frees the list only > when VALID is cleared. But isn't that the *real* problem? Shouldn't we instead nuke the collections entirely and go through a reload sequence? > vgic_its_save_collection_table() then walks the > whole list, writing up to 448K past the end of the table, and saves > collection IDs that vgic_its_restore_cte() rejects, so the save succeeds > and the restore fails with -EINVAL on the destination. The overrun stays > in guest memory, as vgic_write_guest_lock() validates every gfn. > > Validate each collection against the current table with > vgic_its_check_id() and return -EINVAL, as vgic_its_save_device_tables() > does for devices. Collection IDs are unique and the collection table is > never indirect, so the check also bounds the walk. I think returning -EINVAL here was a mistake, as it aborts the save procedure that userspace should be able to issue reliably, even if that means the state is crap. I don't think we should expand that behaviour any further. M. -- Jazz isn't dead. It just smells funny.