Skip to contentSkip to conversation

x86/mm: set_p2m_entry() should return 0 on error

PATCH In review Kouya Shimura 3 participants 3 messages Nov 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: set_p2m_entry() should return 0 on error

set_p2m_entry() ignores halfway errors.
It should return 0 on error, shouldn't it?

xen/arch/x86/mm/p2m.c +3 -2
diff -r ba68bb0d229c xen/arch/x86/mm/p2m.c
@@ -1497,7 +1497,7 @@ int set_p2m_entry(struct domain *d, unsi
 {
     unsigned long todo = 1ul << page_order;
     unsigned int order;
-    int rc = 0;
+    int rc = 1;
 
     while ( todo )
     {
@@ -1506,7 +1506,8 @@ int set_p2m_entry(struct domain *d, unsi
                 9 : 0;
         else
             order = 0;
-        rc = d->arch.p2m->set_entry(d, gfn, mfn, order, p2mt);
+        if ( !d->arch.p2m->set_entry(d, gfn, mfn, order, p2mt) )
+            rc = 0;
         gfn += 1ul << order;
         if ( mfn_x(mfn) != INVALID_MFN )
             mfn = _mfn(mfn_x(mfn) + (1ul << order));

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

Acked-by on v1 1/1
#2 lore raw
In reply to Kouya Shimura
Quoted 2 lines · Kouya Shimura

set_p2m_entry() ignores halfway errors.
It should return 0 on error, shouldn't it?

Since all of its callers discard the return value, it hardly matters. :( But yes, this patch makes the semantics more sensible.

Quoted 1 line
Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]