[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Date: Fri, 10 Nov 2023 12:56:24 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Essb1Ld/1j1kT+sD5meqRu42KXbfpKOnx9aVBNLbuT0=; b=JHqFEL3swVJGriUuAufGagmNbwJHARD27sO97vBV0IVNmOAeWTdP9esqyKaII2xRx77q7N8skwm3lkxt21Nw9GFCtdW9AM1OhmYdd64T0wIgBMYqalwuWv9riYEvwsVqaTUiRaDzp/+69D0nUL0D9ga7jM+22lW3ky+LeRu5mj+tUMGeCzvfeXaXVEUDg17ALTPjKVV1aixY+XcboFYZuhlL4BqrKvkcSEPnaEywWw7MYhJd1iuZ9oBFXGiMPof35DME3Tk9YqMscEmCni4ZKxXgiIsYOZjuvvOQZzzdKXCyrV+aAruIDmDo0v4Rp+15P7psDZjVj3KJTTb2vR30Og==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c63QVfsZewcF1pWl26rSCmI8aikPmmNMdhmvOPBfUUhQeeXO5k/WuMsCcmYwTxXpCfO/AmLrnH1b5O8eNfbEfjCyjd5/+VzvpSUSTitAvfGwhVS9o+nu3IS7nEm3Kn5IsE8I7elEtd1bmLNUtP0as2boFaLyDVAOtZ+PiMjplVGbv8xpEl0QSjTgfROA91oxOhNpz8o7DQ50RxbxO5nHVwM4u4qILMBf+sjHrIvc7qQ3zpnELrCSyQMu0AhB845S7A/+TqcBGthZ5dPV6qtworo8wJNmmcF/AvL+udSqVI/jmH1KWPhTQmjvkZwSVjPJdlGvAXLwbeUdD11lSkBdlQ==
  • Cc: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Fri, 10 Nov 2023 12:56:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHaE9VPvUK8VLpzMkyL6GJ3SfoYcA==
  • Thread-topic: [XEN PATCH v2 25/25] arm: new VGIC: Improve MMIO handling

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@xxxxxxxx>
---
 xen/arch/arm/vgic/vgic-mmio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

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;
     }
 
-- 
2.34.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.