Skip to contentSkip to conversation

VT-d: fix off-by-one error in RMRR validation

PATCH In review Jan Beulich 2 participants 2 messages Sep 21, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 VT-d: fix off-by-one error in RMRR validation

(base_addr,end_addr) is an inclusive range, and hence there shouldn't be a subtraction of 1 in the second invocation of page_is_ram_type(). For RMRRs covering a single page that actually resulted in the immediately preceding page to get checked (which could have resulted in a false warning).

xen/drivers/passthrough/vtd/dmar.c +1 -1
@@ -520,7 +520,7 @@ acpi_parse_one_rmrr(struct acpi_dmar_ent
      * inform the user
      */
     if ( (!page_is_ram_type(paddr_to_pfn(base_addr), RAM_TYPE_RESERVED)) ||
-         (!page_is_ram_type(paddr_to_pfn(end_addr) - 1, RAM_TYPE_RESERVED)) )
+         (!page_is_ram_type(paddr_to_pfn(end_addr), RAM_TYPE_RESERVED)) )
     {
         dprintk(XENLOG_WARNING VTDPREFIX,
                 "  RMRR address range not in reserved memory "

(base_addr,end_addr) is an inclusive range, and hence there shouldn't be a subtraction of 1 in the second invocation of page_is_ram_type(). For RMRRs covering a single page that actually resulted in the immediately preceding page to get checked (which could have resulted in a false warning).

xen/drivers/passthrough/vtd/dmar.c +1 -1
@@ -520,7 +520,7 @@ acpi_parse_one_rmrr(struct acpi_dmar_ent
      * inform the user
      */
     if ( (!page_is_ram_type(paddr_to_pfn(base_addr), RAM_TYPE_RESERVED)) ||
-         (!page_is_ram_type(paddr_to_pfn(end_addr) - 1, RAM_TYPE_RESERVED)) )
+         (!page_is_ram_type(paddr_to_pfn(end_addr), RAM_TYPE_RESERVED)) )
     {
         dprintk(XENLOG_WARNING VTDPREFIX,
                 "  RMRR address range not in reserved memory "

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Agree, it should not have subtracted 1 here. Good catch. Thanks!

Allen

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, September 21, 2011 4:10 AM
To: [email protected]
Cc: Kay, Allen M
Subject: [PATCH] VT-d: fix off-by-one error in RMRR validation

(base_addr,end_addr) is an inclusive range, and hence there shouldn't be a subtraction of 1 in the second invocation of page_is_ram_type(). For RMRRs covering a single page that actually resulted in the immediately preceding page to get checked (which could have resulted in a false warning).

xen/drivers/passthrough/vtd/dmar.c +2 -1
@@ -520,7 +520,7 @@ acpi_parse_one_rmrr(struct acpi_dmar_ent
      * inform the user
      */
     if ( (!page_is_ram_type(paddr_to_pfn(base_addr), RAM_TYPE_RESERVED)) ||
-         (!page_is_ram_type(paddr_to_pfn(end_addr) - 1, RAM_TYPE_RESERVED)) )
+         (!page_is_ram_type(paddr_to_pfn(end_addr), RAM_TYPE_RESERVED)) 
+ )
     {
         dprintk(XENLOG_WARNING VTDPREFIX,

" RMRR address range not in reserved memory "