From patchwork Wed Aug 7 14:27:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Boeuf, Sebastien" X-Patchwork-Id: 11082277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 645D9912 for ; Wed, 7 Aug 2019 14:28:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52EF328A30 for ; Wed, 7 Aug 2019 14:28:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4737B28A50; Wed, 7 Aug 2019 14:28:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF0E928A4E for ; Wed, 7 Aug 2019 14:28:10 +0000 (UTC) Received: from localhost ([::1]:41840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvMvB-0006GI-Vz for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Aug 2019 10:28:10 -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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,357,1559545200"; d="scan'208,223";a="198683676" 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 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-ID: <003861F2EF38D24C942BA3DEB02163C0@intel.com> 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Sebastien Boeuf 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(-) return false; } @@ -2537,7 +2537,7 @@ int64_t vu_fs_cache_request(VuDev *dev, VhostUserSlaveRequest req, int fd, vmsg.fd_num = fd_num; - if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) == 0) { + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) == 0) { return -EINVAL; } 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, vmsg.fd_num = fd_num; - if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) == 0) { + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) == 0) {