All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Fix 64 bit mmio handle
@ 2022-06-30 16:12 ` Schspa Shi
  0 siblings, 0 replies; 27+ messages in thread
From: Schspa Shi @ 2022-06-30 16:12 UTC (permalink / raw)
  To: maz, james.morse, alexandru.elisei, suzuki.poulose,
	catalin.marinas, will
  Cc: Schspa Shi, kvmarm, linux-arm-kernel, linux-kernel

If the len is 8 bytes, we can't get the correct sign extend for
be system.

Fix the mask type len and the comparison of length.

Signed-off-by: Schspa Shi <schspa@gmail.com>
---
 arch/arm64/kvm/mmio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kvm/mmio.c b/arch/arm64/kvm/mmio.c
index 3dd38a151d2a6..0692f8b18f35c 100644
--- a/arch/arm64/kvm/mmio.c
+++ b/arch/arm64/kvm/mmio.c
@@ -81,8 +81,8 @@ unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len)
 int kvm_handle_mmio_return(struct kvm_vcpu *vcpu)
 {
 	unsigned long data;
+	unsigned long mask;
 	unsigned int len;
-	int mask;
 
 	/* Detect an already handled MMIO return */
 	if (unlikely(!vcpu->mmio_needed))
@@ -97,7 +97,7 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu)
 		data = kvm_mmio_read_buf(run->mmio.data, len);
 
 		if (kvm_vcpu_dabt_issext(vcpu) &&
-		    len < sizeof(unsigned long)) {
+		    len <= sizeof(unsigned long)) {
 			mask = 1U << ((len * 8) - 1);
 			data = (data ^ mask) - mask;
 		}
-- 
2.37.0

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

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

end of thread, other threads:[~2022-07-06 11:44 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-30 16:12 [PATCH] KVM: arm64: Fix 64 bit mmio handle Schspa Shi
2022-06-30 16:12 ` Schspa Shi
2022-06-30 16:12 ` Schspa Shi
2022-06-30 16:23 ` Marc Zyngier
2022-06-30 16:23   ` Marc Zyngier
2022-06-30 16:23   ` Marc Zyngier
2022-06-30 16:50   ` Schspa Shi
2022-06-30 16:50     ` Schspa Shi
2022-06-30 16:50     ` Schspa Shi
2022-07-01 10:50     ` Marc Zyngier
2022-07-01 10:50       ` Marc Zyngier
2022-07-01 10:50       ` Marc Zyngier
2022-07-01 12:22       ` Schspa Shi
2022-07-01 12:22         ` Schspa Shi
2022-07-01 12:22         ` Schspa Shi
2022-07-01 13:48         ` Marc Zyngier
2022-07-01 13:48           ` Marc Zyngier
2022-07-01 13:48           ` Marc Zyngier
2022-07-01 14:22           ` Schspa Shi
2022-07-01 14:22             ` Schspa Shi
2022-07-01 14:22             ` Schspa Shi
2022-07-06  7:11             ` Marc Zyngier
2022-07-06  7:11               ` Marc Zyngier
2022-07-06  7:11               ` Marc Zyngier
2022-07-06 11:29               ` Schspa Shi
2022-07-06 11:29                 ` Schspa Shi
2022-07-06 11:29                 ` Schspa Shi

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.