From nobody Sat May 4 22:17:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1587560903; cv=none; d=zohomail.com; s=zohoarc; b=m7n2BLugpJSXvTOHT67CXxTRoZXO/CJOfeuQp+1FFMrV4I4guCyuNPbvzfMCB7oRw0lIQXQkrZ7yQ8+BvFskijAkvP6YOowQZ5UI8MftVE7qnTc6Q3e4EeRP1pL8mYMuXKO/6XH0kmBRr+rwIdQaIFNRe3uUpcgn44mPhTK58AQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587560903; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=rBvqM7uqXT9D/gGh1/bqjDV4qaqtXDtrXsAmZpFq1AE=; b=MXREL4kimPR66jNKV1jfO00SHH6w/tIWv7AyKo4//LrkZtMSQbDAY3zExcFrsf0AgTl7y5qrgDoxfZL4oigE5FOv2rZU1sLVG+6pj72EhRhMXM1qnbuj6j4OZ3hfz3A8U+QwTAN2/rnZLUWldS4+GmvSSMFy3zl/Bm/6F8c9TAk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1587560902993531.5348509484146; Wed, 22 Apr 2020 06:08:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jRF6f-0001i9-1z; Wed, 22 Apr 2020 13:08:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jRF6d-0001hx-1b for xen-devel@lists.xenproject.org; Wed, 22 Apr 2020 13:07:59 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4968f0de-849a-11ea-83d8-bc764e2007e4; Wed, 22 Apr 2020 13:07:58 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7FB5DABEC; Wed, 22 Apr 2020 13:07:56 +0000 (UTC) X-Inumbo-ID: 4968f0de-849a-11ea-83d8-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Subject: [PATCH] xen/grants: fix hypercall continuation for GNTTABOP_cache_flush Date: Wed, 22 Apr 2020 15:07:53 +0200 Message-Id: <20200422130753.14713-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The GNTTABOP_cache_flush hypercall has a wrong test for hypercall continuation, the test today is: if ( rc > 0 || opaque_out !=3D 0 ) Unfortunately this will be true even in case of an error (rc < 0), possibly leading to very long lasting hypercalls (times of more than an hour have been observed in a test case). Correct the test condition to result in false with rc < 0 and set opaque_out only if no error occurred, to be on the safe side. Partially-suggested-by: Jan Beulich Signed-off-by: Juergen Gross Reviewed-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/common/grant_table.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 96080b3dec..5ef7ff940d 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -3626,12 +3626,12 @@ do_grant_table_op( if ( unlikely(!guest_handle_okay(cflush, count)) ) goto out; rc =3D gnttab_cache_flush(cflush, &opaque_in, count); - if ( rc > 0 ) + if ( rc >=3D 0 ) { guest_handle_add_offset(cflush, rc); uop =3D guest_handle_cast(cflush, void); + opaque_out =3D opaque_in; } - opaque_out =3D opaque_in; break; } =20 @@ -3641,7 +3641,7 @@ do_grant_table_op( } =20 out: - if ( rc > 0 || opaque_out !=3D 0 ) + if ( rc > 0 || (opaque_out !=3D 0 && rc =3D=3D 0) ) { /* Adjust rc, see gnttab_copy() for why this is needed. */ if ( cmd =3D=3D GNTTABOP_copy ) --=20 2.16.4