Skip to contentSkip to conversation

x86/p2m: fix p2m_finish_type_change()

PATCH Superseded Razvan Cojocaru 3 participants 4 messages Jan 9, 2019 – Jan 10, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/p2m: fix p2m_finish_type_change()

finish_type_change() returns a negative int on error, but the current code checks if ( !rc ). Also properly indent the out:
label while at it.

---
 xen/arch/x86/mm/p2m.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/x86/mm/p2m.c +3 -3
index 5451f16..e08f6b1 100644
@@ -1176,7 +1176,7 @@ int p2m_finish_type_change(struct domain *d,
 
     rc = finish_type_change(hostp2m, first_gfn, max_nr);
 
-    if ( !rc )
+    if ( rc < 0 )
         goto out;
 
 #ifdef CONFIG_HVM
@@ -1193,13 +1193,13 @@ int p2m_finish_type_change(struct domain *d,
                 rc = finish_type_change(altp2m, first_gfn, max_nr);
                 p2m_unlock(altp2m);
 
-                if ( !rc )
+                if ( rc < 0 )
                     goto out;
             }
     }
 #endif
 
-out:
+ out:
     p2m_unlock(hostp2m);
 
     return rc;
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 09.01.19 at 11:41, <[email protected]> wrote:

finish_type_change() returns a negative int on error, but the current code checks if ( !rc ).

For the purpose of determining the backporting scope (none here) it would be nice if in such a case you could point out the commit introducing the breakage.

Quoted 12 lines
xen/arch/x86/mm/p2m.c +1 -1
@@ -1176,7 +1176,7 @@ int p2m_finish_type_change(struct domain *d,
 
     rc = finish_type_change(hostp2m, first_gfn, max_nr);
 
-    if ( !rc )
+    if ( rc < 0 )
         goto out;
 
 #ifdef CONFIG_HVM

xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1200

Quoted 9 lines
xen/arch/x86/mm/p2m.c +1 -1
@@ -1193,13 +1193,13 @@ int p2m_finish_type_change(struct domain *d,
                 rc = finish_type_change(altp2m, first_gfn, max_nr);
                 p2m_unlock(altp2m);
 
-                if ( !rc )
+                if ( rc < 0 )
                     goto out;
             }
     }
 #endif

May I ask that you also fix the other return value issue here: Either we mean to indicate to the caller the 0/1 distinction (in which case it should be correct, i.e. cumulative across all finish_type_change() calls made here), which was the behavior before 0fb4b58c8b ("x86/altp2m: fix display frozen when switching to a new view early"), or we mean to signal success to the caller only by handing back zero.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 26 lines · Jan Beulich
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines · On 09.01.19 at 11:41, <[email protected]> wrote:

finish_type_change() returns a negative int on error, but the current code checks if ( !rc ).

For the purpose of determining the backporting scope (none here) it would be nice if in such a case you could point out the commit introducing the breakage.

Quoted 15 lines
xen/arch/x86/mm/p2m.c +1 -1
@@ -1176,7 +1176,7 @@ int p2m_finish_type_change(struct domain *d,
 
    rc = finish_type_change(hostp2m, first_gfn, max_nr);
 
-    if ( !rc )
+    if ( rc < 0 )
        goto out;
 
 #ifdef CONFIG_HVM
@@ -1193,13 +1193,13 @@ int p2m_finish_type_change(struct domain *d,
                rc = finish_type_change(altp2m, first_gfn, max_nr);
                p2m_unlock(altp2m);
 
Quoted 13 lines

xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1200

Quoted 6 lines
xen/arch/x86/mm/p2m.c +1 -1
-                if ( !rc )
+                if ( rc < 0 )
                    goto out;
            }
    }
 #endif

May I ask that you also fix the other return value issue here: Either we mean to indicate to the caller the 0/1 distinction (in which case it should be correct, i.e. cumulative across all finish_type_change() calls made here), which was the behavior before 0fb4b58c8b ("x86/altp2m: fix display frozen when switching to a new view early"), or we mean to signal success to the caller only by handing back zero.

The “root” caller of p2m_finish_type_change() is XEN_DMOP_map_mem_type_to_ioreq_server; It doesn’t look like it does anything useful with positive values, and it’s not clear from an interface perspective that returning a positive value from that hypercall makes any sense.

Perhaps it would be best to just discard the positive values for now.

-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/1
#3 lore raw
In reply to Razvan Cojocaru
Quoted 9 lines · Razvan Cojocaru

finish_type_change() returns a negative int on error, but the current code checks if ( !rc ). Also properly indent the out:
label while at it.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel