memory: avoid pointless continuation in xenmem_add_to_physmap()
authorJan Beulich <jbeulich@suse.com>
Thu, 14 Jan 2021 12:00:26 +0000 (13:00 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 14 Jan 2021 12:00:26 +0000 (13:00 +0100)
Adjust so we uniformly avoid needlessly arranging for a continuation on
the last iteration.

Fixes: 5777a3742d88 ("IOMMU: hold page ref until after deferred TLB flush")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/common/memory.c

index b21b6c452d52248a0f0e9cf60bf2fba85ee5783e..ccb4d49fc6e192d921e5e8d939c65c251ac891d1 100644 (file)
@@ -858,8 +858,9 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,
             ++extra.ppage;
 
         /* Check for continuation if it's not the last iteration. */
-        if ( (++done >= ARRAY_SIZE(pages) && extra.ppage) ||
-             (xatp->size > done && hypercall_preempt_check()) )
+        if ( xatp->size > ++done &&
+             ((done >= ARRAY_SIZE(pages) && extra.ppage) ||
+              hypercall_preempt_check()) )
         {
             rc = start + done;
             break;