x86/p2m: fix p2m_finish_type_change()
PATCH v2 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 ). We also need to treat finish_type_change()'s return codes cumulatively in the success case (don't overwrite a 1 returned while processing the hostp2m if processing an altp2m returns 0).
The breakage was introduced by commit 0fb4b58c8b ("x86/altp2m: fix display frozen when switching to a new view early").
Properly indent the out: label while at it.
---
Changes since V1:
- Updated description.
- Now treating finish_type_change()'s return value cumulatively for the success case.
--- xen/arch/x86/mm/p2m.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
xen/arch/x86/mm/p2m.c +10 -4
@@ -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
@@ -1188,18 +1188,24 @@ int p2m_finish_type_change(struct domain *d,if ( d->arch.altp2m_eptp[i] !=mfn_x (INVALID_MFN ) ) {struct p2m_domain *altp2m = d->arch.altp2m_p2m[i]; +int rc1;p2m_lock (altp2m); - rc =finish_type_change (altp2m, first_gfn, max_nr); + rc1 =finish_type_change (altp2m, first_gfn, max_nr);p2m_unlock (altp2m); -if ( !rc ) +if ( rc1 <0 ) + { + rc = rc1; goto out; + } + + rc =max (rc, rc1); } }#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
Quoted 46 lines
Quoted 1 line
Quoted 1 line · On 09.01.19 at 13:24, <[email protected]> wrote:
finish_type_change()returns a negative int on error, but the current code checks if ( !rc ). We also need to treat finish_type_change()'s return codes cumulatively in the success case (don't overwrite a 1 returned while processing the hostp2m if processing an altp2m returns 0).The breakage was introduced by commit
0fb4b58c8b("x86/altp2m: fix display frozen when switching to a new view early").Properly indent the out: label while at it.
Signed-off-by Razvan Cojocaru <[email protected]>---
Changes since V1:
- Updated description.
- Now treating finish_type_change()'s return value cumulatively for the success case.--- xen/arch/x86/mm/p2m.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)xen/arch/x86/mm/p2m.c +3
-2@@ -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 @@ -1188,18 +1188,24 @@ int p2m_finish_type_change(struct domain *d,if ( d->arch.altp2m_eptp[i] !=mfn_x (INVALID_MFN ) ) {struct p2m_domain *altp2m = d->arch.altp2m_p2m[i]; +int rc1;p2m_lock (altp2m); - rc =finish_type_change (altp2m, first_gfn, max_nr); + rc1 =finish_type_change (altp2m, first_gfn, max_nr);
xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1203
Quoted 10 lines
xen/arch/x86/mm/p2m.c +6
-1p2m_unlock (altp2m); -if ( !rc ) +if ( rc1 <0 ) + { + rc = rc1; goto out; + } + + rc =max (rc, rc1);
"rc |= rc1" would likely be cheaper in terms of generated code. But functionally this is fine, and the change would be easy enough to make while committing, so
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 16 lines · Razvan Cojocaru
finish_type_change()returns a negative int on error, but the current code checks if ( !rc ). We also need to treat finish_type_change()'s return codes cumulatively in the success case (don't overwrite a 1 returned while processing the hostp2m if processing an altp2m returns 0).The breakage was introduced by commit
0fb4b58c8b("x86/altp2m: fix display frozen when switching to a new view early").Properly indent the out: label while at it.
Quoted 7 lines
Signed-off-by Razvan Cojocaru <[email protected]>---
Changes since V1:
- Updated description.
- Now treating finish_type_change()'s return value cumulatively for the success case.
Oh, I see you already did the more complicated thing. I’m slightly worried about the return value of the hypercall, but since that was the semantic before, I guess it shouldn’t cause any problems:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel