Skip to contentSkip to conversation

gnttab: adjust unmap checking of dev_bus_addr

PATCH In review Jan Beulich 2 participants 2 messages Aug 30, 2021 – Sep 6, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gnttab: adjust unmap checking of dev_bus_addr

There's no point checking ->dev_bus_addr when GNTMAP_device_map isn't set (and hence the field isn't going to be consumed). And if there is a mismatch, use the so far unused GNTST_bad_dev_addr error indicator - if not here, where else would this (so far unused) value be used?

xen/common/grant_table.c +2 -2
@@ -1450,9 +1450,9 @@ unmap_common(
 
     op->mfn = act->mfn;
 
-    if ( op->dev_bus_addr &&
+    if ( op->dev_bus_addr && (flags & GNTMAP_device_map) &&
          unlikely(op->dev_bus_addr != mfn_to_maddr(act->mfn)) )
-        PIN_FAIL(act_release_out, GNTST_general_error,
+        PIN_FAIL(act_release_out, GNTST_bad_dev_addr,
                  "Bus address doesn't match gntref (%"PRIx64" != %"PRIpaddr")\n",
                  op->dev_bus_addr, mfn_to_maddr(act->mfn));
 
Acked-by on v1 1/1
#1 lore raw

Hi Jan,

Quoted 6 lines · Jan Beulich

There's no point checking ->dev_bus_addr when GNTMAP_device_map isn't set (and hence the field isn't going to be consumed). And if there is a mismatch, use the so far unused GNTST_bad_dev_addr error indicator - if not here, where else would this (so far unused) value be used?

Quoted 6 lines
xen/common/grant_table.c +0 -0
@@ -1450,9 +1450,9 @@ unmap_common(
 

xen/common/grant_table.c unmap_common( · line 1458

Quoted 10 lines
xen/common/grant_table.c +2 -2
      op->mfn = act->mfn;
 
-    if ( op->dev_bus_addr &&
+    if ( op->dev_bus_addr && (flags & GNTMAP_device_map) &&
           unlikely(op->dev_bus_addr != mfn_to_maddr(act->mfn)) )
-        PIN_FAIL(act_release_out, GNTST_general_error,
+        PIN_FAIL(act_release_out, GNTST_bad_dev_addr,
                   "Bus address doesn't match gntref (%"PRIx64" != %"PRIpaddr")\n",
                   op->dev_bus_addr, mfn_to_maddr(act->mfn));
 

Cheers,

Signature · 1 line
Julien Grall