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

Re: [PATCH v2 1/2] xen/arm: fix iomem permissions cfg in map_range_to_domain()


  • To: Julien Grall <julien@xxxxxxx>, Grygorii Strashko <gragst.linux@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Tue, 11 Mar 2025 13:31:17 +0200
  • 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=arcselector10001; 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=X3G/o5aj+YPdppb8CyOOCrUi6lyaBkvp2EFrk0XcZgY=; b=pvUWe+7umYPvRG8xm0K4mjHGwKgy7dEa8WzFqEZ/J3yf6Q1N22AZZoTVvcusxywzTCdcFylNCp9glQ/VaFV53mH2dNTUKWmInITmpDIdtwJBknUNGBJFlaCJlYSVFeCP7SpkmU0tS70q5qIKDAFo6Gw5wabqJGvYGYHAnbuWdmIZrLIKwDdPnp5S42fYdK6fsxXbItFyD8PeZMWveiTbtBhbu32BMFunA0ydNRBYMunNvvx010gtltDpcKMAHpfVPQ7HuOHVtXqtqb5YbEoPGQce5D4vC0rlwKrFJWj9mX5CStOPRBIz1ZPqD2AIWQnuYWiO2JLOiRde2lwvz4AUkw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=suERWYgbKc3U8i0SerpkUkCKby0atXAhXfmZvXr2hqT9uhPHRAgFcekCKfsuX7Ib5o0ys+s43EU20JWroPpgcKXdpIVsPldBEmLpaRCxrBtQUCPzFvZ3Yr6ZkvT5hsV4bbwrjYVy0dYeVslTFzI076BRGKvveQhd/pVKhAf6x15oklL0vg+ixHrjxCnXhHrHgf8lDV0IqFVDOxj5i7cNnP8RW/x0jfxkt0TNB8BftBF3Ex8cO7lbep14XjOExMxaWh7o52E0NEyd9OKl/+R2vNh56TsPzlEi8cn3zzDfBn28cIjFNNUxnoGIElgxempiUJ0O0JtcU0QwdpUYMT/Hmg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Tue, 11 Mar 2025 11:31:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi

On 19.02.25 13:25, Julien Grall wrote:
Hi Grygorii,

On 18/02/2025 11:22, Grygorii Strashko wrote:
Now the following code in map_range_to_domain()

     res = iomem_permit_access(d, paddr_to_pfn(addr),
                     paddr_to_pfn(PAGE_ALIGN(addr + len - 1)));

calculates the iomem range end address by rounding it up to the next Xen
page with incorrect assumption that iomem range end address passed to
iomem_permit_access() is exclusive, while it is expected to be inclusive.
It gives Control domain (Dom0) access to manage incorrect MMIO range with
one additional page.

For example, if requested range is [00e6140000:00e6141004] then it expected
to add [e6140:e6141] range (num_pages=2) to the domain iomem_caps rangeset,
but will add [e6140:e6142] (num_pages=3) instead.

To fix it, drop PAGE_ALIGN() from the iomem range end address calculation
formula.

Fixes: 33233c2758345 ("arch/arm: domain build: let dom0 access I/O memory
of mapped devices")
Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx>

Sorry, that I'm disturbing you, but do i need to perform any additional actions 
here?


Cheers,

---
  xen/arch/arm/device.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 5610cddcba8e..97e613e06afa 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -71,7 +71,7 @@ int map_range_to_domain(const struct dt_device_node *dev,
                       strlen("/reserved-memory/")) != 0 )
      {
          res = iomem_permit_access(d, paddr_to_pfn(addr),
-                paddr_to_pfn(PAGE_ALIGN(addr + len - 1)));
+                                  paddr_to_pfn(addr + len - 1));
          if ( res )
          {
              printk(XENLOG_ERR "Unable to permit to dom%d access to"


Best regards,
-grygorii



 


Rackspace

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