From patchwork Thu Sep 29 12:18:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tu Dinh Ngoc X-Patchwork-Id: 12993992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A16F4C433F5 for ; Thu, 29 Sep 2022 12:19:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234936AbiI2MTb (ORCPT ); Thu, 29 Sep 2022 08:19:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234810AbiI2MT0 (ORCPT ); Thu, 29 Sep 2022 08:19:26 -0400 Received: from smtp1.irit.fr (smtp1.irit.fr [141.115.24.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 368AF147CEE for ; Thu, 29 Sep 2022 05:19:19 -0700 (PDT) From: Tu Dinh Ngoc To: kvm@vger.kernel.org Cc: Andre Przywara , Will Deacon , Alexandru Elisei , Jean-Philippe Brucker Subject: [PATCH kvmtool v2] virtio-net: Fix vq->use_event_idx flag check Date: Thu, 29 Sep 2022 14:18:58 +0200 Message-Id: <20220929121858.156-1-dinhngoc.tu@irit.fr> In-Reply-To: <20220929122136.38f74d7f@donnerap.cambridge.arm.com> References: <20220929122136.38f74d7f@donnerap.cambridge.arm.com> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org VIRTIO_RING_F_EVENT_IDX is a bit position value, but virtio_init_device_vq populates vq->use_event_idx by ANDing this value directly to vdev->features. Fix the check for this flag in virtio_init_device_vq. Reviewed-by: Andre Przywara Signed-off-by: Tu Dinh Ngoc --- virtio/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtio/core.c b/virtio/core.c index f432421..ea0e5b6 100644 --- a/virtio/core.c +++ b/virtio/core.c @@ -165,7 +165,7 @@ void virtio_init_device_vq(struct kvm *kvm, struct virtio_device *vdev, struct vring_addr *addr = &vq->vring_addr; vq->endian = vdev->endian; - vq->use_event_idx = (vdev->features & VIRTIO_RING_F_EVENT_IDX); + vq->use_event_idx = (vdev->features & (1UL << VIRTIO_RING_F_EVENT_IDX)); vq->enabled = true; if (addr->legacy) {