Skip to content

Commit 7484289

Browse files
Kunkun Jianggregkh
Kunkun Jiang
authored andcommitted
KVM: arm64: vgic-its: Clear DTE when MAPD unmaps a device
commit e964912 upstream. vgic_its_save_device_tables will traverse its->device_list to save DTE for each device. vgic_its_restore_device_tables will traverse each entry of device table and check if it is valid. Restore if valid. But when MAPD unmaps a device, it does not invalidate the corresponding DTE. In the scenario of continuous saves and restores, there may be a situation where a device's DTE is not saved but is restored. This is unreasonable and may cause restore to fail. This patch clears the corresponding DTE when MAPD unmaps a device. Cc: [email protected] Fixes: 57a9a11 ("KVM: arm64: vgic-its: Device table save/restore") Co-developed-by: Shusen Li <[email protected]> Signed-off-by: Shusen Li <[email protected]> Signed-off-by: Kunkun Jiang <[email protected]> [Jing: Update with entry write helper] Signed-off-by: Jing Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2a4ec24 commit 7484289

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,9 +1215,11 @@ static int vgic_its_cmd_handle_mapd(struct kvm *kvm, struct vgic_its *its,
12151215
bool valid = its_cmd_get_validbit(its_cmd);
12161216
u8 num_eventid_bits = its_cmd_get_size(its_cmd);
12171217
gpa_t itt_addr = its_cmd_get_ittaddr(its_cmd);
1218+
int dte_esz = vgic_its_get_abi(its)->dte_esz;
12181219
struct its_device *device;
1220+
gpa_t gpa;
12191221

1220-
if (!vgic_its_check_id(its, its->baser_device_table, device_id, NULL))
1222+
if (!vgic_its_check_id(its, its->baser_device_table, device_id, &gpa))
12211223
return E_ITS_MAPD_DEVICE_OOR;
12221224

12231225
if (valid && num_eventid_bits > VITS_TYPER_IDBITS)
@@ -1238,7 +1240,7 @@ static int vgic_its_cmd_handle_mapd(struct kvm *kvm, struct vgic_its *its,
12381240
* is an error, so we are done in any case.
12391241
*/
12401242
if (!valid)
1241-
return 0;
1243+
return vgic_its_write_entry_lock(its, gpa, 0, dte_esz);
12421244

12431245
device = vgic_its_alloc_device(its, device_id, itt_addr,
12441246
num_eventid_bits);

0 commit comments

Comments
 (0)