diff mbox series

[XEN,v2,25/25] arm: new VGIC: Improve MMIO handling

Message ID 86465b3762ed8c9cdd24752792d0ca0e19698d22.1699618395.git.mykyta_poturai@epam.com (mailing list archive)
State New, archived
Headers show
Series arm: Add GICv3 support to the New VGIC | expand

Commit Message

Mykyta Poturai Nov. 10, 2023, 12:56 p.m. UTC
Currently the full register address is used in VGIC MMIO handlers. This
can cause issues when VGIC_ADDR_TO_IRQ_MASK overlaps with the base address.
For example the current GUEST_GICV3_GICD_BASE overlaps with addr to irq
mask for 64 bit registers, causing intids to be calculated incorrectly.

This patch fixes the issue by subtracting the base address from the full
register address before passing it to the MMIO handlers. Thus giving the
MMIO handler only the relevant offset.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
 xen/arch/arm/vgic/vgic-mmio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/xen/arch/arm/vgic/vgic-mmio.c b/xen/arch/arm/vgic/vgic-mmio.c
index 7a28be53bc..abf7854af0 100644
--- a/xen/arch/arm/vgic/vgic-mmio.c
+++ b/xen/arch/arm/vgic/vgic-mmio.c
@@ -540,7 +540,7 @@  vgic_get_mmio_region(struct vcpu *vcpu, struct vgic_io_device *iodev,
 
     region = vgic_find_mmio_region(iodev->regions, iodev->nr_regions,
                                    addr - gfn_to_gaddr(iodev->base_fn));
-    if ( !region || !check_region(vcpu->domain, region, addr, len) )
+    if ( !region || !check_region(vcpu->domain, region, addr - gfn_to_gaddr(iodev->base_fn), len) )
         return NULL;
 
     return region;
@@ -565,13 +565,13 @@  static int dispatch_mmio_read(struct vcpu *vcpu, mmio_info_t *info,
     switch (iodev->iodev_type)
     {
     case IODEV_DIST:
-        data = region->read(vcpu, addr, len);
+        data = region->read(vcpu, addr - gfn_to_gaddr(iodev->base_fn), len);
         break;
     case IODEV_REDIST:
-        data = region->read(iodev->redist_vcpu, addr, len);
+        data = region->read(iodev->redist_vcpu, addr - gfn_to_gaddr(iodev->base_fn), len);
         break;
     case IODEV_ITS:
-        data = region->its_read(vcpu->domain, iodev->its, addr, len);;
+        data = region->its_read(vcpu->domain, iodev->its, addr - gfn_to_gaddr(iodev->base_fn), len);;
         break;
     }
 
@@ -596,13 +596,13 @@  static int dispatch_mmio_write(struct vcpu *vcpu, mmio_info_t *info,
     switch (iodev->iodev_type)
     {
     case IODEV_DIST:
-        region->write(vcpu, addr, len, data);
+        region->write(vcpu, addr - gfn_to_gaddr(iodev->base_fn), len, data);
         break;
     case IODEV_REDIST:
-        region->write(iodev->redist_vcpu, addr, len, data);
+        region->write(iodev->redist_vcpu, addr - gfn_to_gaddr(iodev->base_fn), len, data);
         break;
     case IODEV_ITS:
-        region->its_write(vcpu->domain, iodev->its, addr, len, data);
+        region->its_write(vcpu->domain, iodev->its, addr - gfn_to_gaddr(iodev->base_fn), len, data);
         break;
     }