All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: vgic: fix wrong loop condition in scan_its_table()
@ 2022-10-12 16:59 ` Eric Ren
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Ren @ 2022-10-12 16:59 UTC (permalink / raw)
  To: kvm, kvmarm; +Cc: marc.zyngier, cdall

Reproducer hints:
1. Create ARM virt VM with pxb-pcie bus which adds
   extra host bridges, with qemu command like:

```
  -device pxb-pcie,bus_nr=8,id=pci.x,numa_node=0,bus=pcie.0 \
  -device pcie-root-port,..,bus=pci.x \
  ...
  -device pxb-pcie,bus_nr=37,id=pci.y,numa_node=1,bus=pcie.0 \
  -device pcie-root-port,..,bus=pci.y \
  ...

```
2. Perform VM migration which calls save/restore device tables.

In that setup, we get a big "offset" between 2 device_ids (
one is small, another is big), which makes unsigned "len" round
up a big positive number, causing loop to continue exceptionally.

Signed-off-by: Eric Ren <renzhengeek@gmail.com>
---
 arch/arm64/kvm/vgic/vgic-its.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c
index 24d7778d1ce6..673554ef02f9 100644
--- a/arch/arm64/kvm/vgic/vgic-its.c
+++ b/arch/arm64/kvm/vgic/vgic-its.c
@@ -2141,7 +2141,7 @@ static int scan_its_table(struct vgic_its *its, gpa_t base, int size, u32 esz,
 			  int start_id, entry_fn_t fn, void *opaque)
 {
 	struct kvm *kvm = its->dev->kvm;
-	unsigned long len = size;
+	ssize_t len = size;
 	int id = start_id;
 	gpa_t gpa = base;
 	char entry[ESZ_MAX];
-- 
2.19.1.6.gb485710b

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-10-15 11:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-12 16:59 [PATCH] KVM: arm64: vgic: fix wrong loop condition in scan_its_table() Eric Ren
2022-10-12 16:59 ` Eric Ren
2022-10-12 18:33 ` Marc Zyngier
2022-10-12 18:33   ` Marc Zyngier
2022-10-13 16:42   ` Eric Auger
2022-10-13 16:42     ` Eric Auger
2022-10-14 14:28     ` Marc Zyngier
2022-10-14 14:28       ` Marc Zyngier
2022-10-15  2:41       ` Eric Ren
2022-10-15  2:41         ` Eric Ren
2022-10-12 20:14 ` Eric Auger
2022-10-12 20:14   ` Eric Auger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.