Skip to content

Commit 7602ffd

Browse files
Kunkun Jiangoupton
authored andcommitted
KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITE
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: eff484e ("KVM: arm64: vgic-its: ITT save and restore") Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com> [Jing: Update with entry write helper] Signed-off-by: Jing Zhang <jingzhangos@google.com> Link: https://lore.kernel.org/r/20241107214137.428439-6-jingzhangos@google.com Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent e964912 commit 7602ffd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/arm64/kvm/vgic/vgic-its.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,9 @@ static int vgic_its_cmd_handle_discard(struct kvm *kvm, struct vgic_its *its,
782782

783783
ite = find_ite(its, device_id, event_id);
784784
if (ite && its_is_collection_mapped(ite->collection)) {
785+
struct its_device *device = find_its_device(its, device_id);
786+
int ite_esz = vgic_its_get_abi(its)->ite_esz;
787+
gpa_t gpa = device->itt_addr + ite->event_id * ite_esz;
785788
/*
786789
* Though the spec talks about removing the pending state, we
787790
* don't bother here since we clear the ITTE anyway and the
@@ -790,7 +793,8 @@ static int vgic_its_cmd_handle_discard(struct kvm *kvm, struct vgic_its *its,
790793
vgic_its_invalidate_cache(its);
791794

792795
its_free_ite(kvm, ite);
793-
return 0;
796+
797+
return vgic_its_write_entry_lock(its, gpa, 0, ite_esz);
794798
}
795799

796800
return E_ITS_DISCARD_UNMAPPED_INTERRUPT;

0 commit comments

Comments
 (0)