From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8C014223C5E; Thu, 12 Dec 2024 17:35:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734024933; cv=none; b=P0VJUJ64B+PEjveI/vtNPhJFt3sX+HgcJxIMVg5k+dcUJ0qHDrA5cv3M/l/q8WOhJRf72bF2ce9hqo2oMYoWI+3pj3Qq5uADBf01jRqzXJlADZfTmU0igkNppxUZviX0Tu5fzILtWA8QOy0Kv/fMHqmMupXQRSjSdG5PWo2QQ0Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734024933; c=relaxed/simple; bh=0Rm3Jg4WX7w5R6GmMet7KViLqzAR0smIqKuGKHxtFYg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W7IE4oavGG0laJKVJOIwcWb8UhmkyXNdDzpGVUvGQ4TDLQizA1YBFWqVc5D6oHXSD5AEG5WU8rFAVpsN680HuNQc2AEwvqcjBK2HD5hVeH0UygHj1dUAEziNFITip6mP8rvsrqU8cQoEWRwvirHNZfz2U84+/6Fsph1FH39PaTk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Yxgs69RM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Yxgs69RM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15C5AC4CECE; Thu, 12 Dec 2024 17:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734024933; bh=0Rm3Jg4WX7w5R6GmMet7KViLqzAR0smIqKuGKHxtFYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yxgs69RMJ4lU66eEnjYQ01EJEXQGEvfq+JJ8aAqma5WFwgAO6eZahiQpejsqEp7bb F7kHas8RfZCEao2C9cYw9Y9aRwe8Wm0opTSyl/GZ7uDw4532Tq4/W4EwvGf5W8bDbO 3EJJA0uc5WXJLoS02rl8Awfwdv1x9P5D3D00jHrk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kunkun Jiang , Jing Zhang , Oliver Upton Subject: [PATCH 5.10 445/459] KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITE Date: Thu, 12 Dec 2024 16:03:03 +0100 Message-ID: <20241212144311.350452297@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144253.511169641@linuxfoundation.org> References: <20241212144253.511169641@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kunkun Jiang commit 7602ffd1d5e8927fadd5187cb4aed2fdc9c47143 upstream. When DISCARD frees an ITE, it does not invalidate the corresponding ITE. In the scenario of continuous saves and restores, there may be a situation where an ITE is not saved but is restored. This is unreasonable and may cause restore to fail. This patch clears the corresponding ITE when DISCARD frees an ITE. Cc: stable@vger.kernel.org Fixes: eff484e0298d ("KVM: arm64: vgic-its: ITT save and restore") Signed-off-by: Kunkun Jiang [Jing: Update with entry write helper] Signed-off-by: Jing Zhang Link: https://lore.kernel.org/r/20241107214137.428439-6-jingzhangos@google.com Signed-off-by: Oliver Upton Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/vgic/vgic-its.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -855,6 +855,9 @@ static int vgic_its_cmd_handle_discard(s ite = find_ite(its, device_id, event_id); if (ite && its_is_collection_mapped(ite->collection)) { + struct its_device *device = find_its_device(its, device_id); + int ite_esz = vgic_its_get_abi(its)->ite_esz; + gpa_t gpa = device->itt_addr + ite->event_id * ite_esz; /* * Though the spec talks about removing the pending state, we * don't bother here since we clear the ITTE anyway and the @@ -863,7 +866,8 @@ static int vgic_its_cmd_handle_discard(s vgic_its_invalidate_cache(kvm); its_free_ite(kvm, ite); - return 0; + + return vgic_its_write_entry_lock(its, gpa, 0, ite_esz); } return E_ITS_DISCARD_UNMAPPED_INTERRUPT;