From nobody Tue Nov 11 17:30:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565188100; cv=none; d=zoho.com; s=zohoarc; b=J9l56JOndYuOU9CMbtsFOHrlC8YABrOkxPHzWPOGxLuah/FmxzXsjOjMT/7g0lk8YDI/vQ7X56LzYBaXd7k6ncgGH7uTZLjePviwI6XSesOK07ubyIVRXDx7/dpZqtDljYymzrkhI/2SWJnl0CVAkrOknqFfROUQkG0TWuuvEnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565188100; h=Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=y8FaJiVV1nq5gobDL4IUF9PMDvW6AeUJMTuFLpRhF9E=; b=fgjGjO+iy5/QJxA8d5grB8J7WV1lCipPOj/RBn7FyS+73uu3zt+uSEdu+v5S9hUnVMg8lzrc5dPnIPXf9xOIA9Ga6Uj9LaJOPO5T0v2aaoK07F8S4GnFPhUCicMrUYPVkHqpl9Fn12FQBIX+5nZVcWqqIQT6AZolZN1z7iq9Fis= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565188100776985.8022831728474; Wed, 7 Aug 2019 07:28:20 -0700 (PDT) Received: from localhost ([::1]:41840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvMvL-0006GI-SG for importer@patchew.org; Wed, 07 Aug 2019 10:28:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40007) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvMui-0004dt-Vv for qemu-devel@nongnu.org; Wed, 07 Aug 2019 10:27:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvMuh-0002To-VM for qemu-devel@nongnu.org; Wed, 07 Aug 2019 10:27:40 -0400 Received: from mga04.intel.com ([192.55.52.120]:55153) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvMuh-0002Ns-ME for qemu-devel@nongnu.org; Wed, 07 Aug 2019 10:27:39 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2019 07:27:31 -0700 Received: from orsmsx108.amr.corp.intel.com ([10.22.240.6]) by fmsmga004.fm.intel.com with ESMTP; 07 Aug 2019 07:27:31 -0700 Received: from orsmsx163.amr.corp.intel.com (10.22.240.88) by ORSMSX108.amr.corp.intel.com (10.22.240.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 7 Aug 2019 07:27:30 -0700 Received: from orsmsx115.amr.corp.intel.com ([169.254.4.6]) by ORSMSX163.amr.corp.intel.com ([169.254.9.86]) with mapi id 14.03.0439.000; Wed, 7 Aug 2019 07:27:30 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,357,1559545200"; d="scan'208,223";a="198683676" From: "Boeuf, Sebastien" To: "qemu-devel@nongnu.org" Thread-Topic: libvhost-user: Fix the VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD check Thread-Index: AQHVTSw+I7kmgADAmUOtvYF7P6PObQ== Date: Wed, 7 Aug 2019 14:27:30 +0000 Message-ID: <8df105774471bc72bca1397b4058ecc66d963848.camel@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.7.199.52] Content-Type: text/plain; charset="utf-8" Content-ID: <003861F2EF38D24C942BA3DEB02163C0@intel.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.120 Subject: [Qemu-devel] libvhost-user: Fix the VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "marcandre.lureau@redhat.com" , "dgilbert@redhat.com" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From 0a53a81db6dd069f9b7bcdcd386845bceb3a2ac6 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 7 Aug 2019 07:15:32 -0700 Subject: [PATCH] libvhost-user: Fix the VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD check Vhost user protocol features are set as a bitmask. And the following constant VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD value is 10 because the bit 10 indicates if the features is set or not. The proper way to check for the presence or absence of this feature is to shift 1 by the value of this constant and then mask it with the actual bitmask representing the supported protocol features. This patch aims to fix the current code as it was not doing the shifting, but instead it was masking directly with the value of the constant itself. Signed-off-by: Sebastien Boeuf Reviewed-by: Dr. David Alan Gilbert --- contrib/libvhost-user/libvhost-user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost- user/libvhost-user.c index fb61142bcc..11909fb7c1 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -1112,7 +1112,7 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq *vq, int fd, =20 vmsg.fd_num =3D fd_num; =20 - if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) =3D=3D 0) { + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) =3D=3D 0) { return false; } =20 @@ -2537,7 +2537,7 @@ int64_t vu_fs_cache_request(VuDev *dev, VhostUserSlaveRequest req, int fd, =20 vmsg.fd_num =3D fd_num; =20 - if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) =3D=3D 0) { + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) =3D=3D 0) { return -EINVAL; } =20 --=20 2.17.1