From patchwork Wed Mar 30 06:33:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 12795531 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEB56C433EF for ; Wed, 30 Mar 2022 06:55:27 +0000 (UTC) Received: from localhost ([::1]:47872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZSEo-000712-OJ for qemu-devel@archiver.kernel.org; Wed, 30 Mar 2022 02:55:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRto-0007g6-Iw for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:44 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:65252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtm-0005NG-7d for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:44 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22U3JZIA019606; Wed, 30 Mar 2022 06:33:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=S5AxDfsrdedpyw2JBAWFuCmoEymXZ8OoPSmPcK922pY=; b=ja6CCAUEe8FQqY84o4d7DeKowJEHwnBnJ9Pd2zpvRmLPBSMvXPHQbcF6W/evopTTx8wo Wm6Isisp1TdkPMlAco6WIWMd+KdWZAr514cbxsIMW/kuBUNnOOmfao2EztsBqR2ctH+3 8mWmU0oq9SaeJAzrT/hmVAyzogTxVoJ8oB9ZADOUEiOQ4rTHKXaNQfCNMgPKXXEyO4vN C6gfoneqJZHWWeyQlxT6/SaJ6Wo3UehfRI12UWvV0bl73ZhItCaTEowY/bDnD4/o+FSe WEDLlM6KD32blbiCBTgW4Rc3WqT567HTYopNWjGxCBGey/LFuBCDc8q9sg12q5f3EJuR LQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1se0gjjm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:32 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22U6IC5H013067; Wed, 30 Mar 2022 06:33:31 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by userp3020.oracle.com with ESMTP id 3f1v9fk5ts-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7Q+BRFmNE9ipwx1yIFWphz4vEE57HG3UwmnaHLBDeIvCGdzMERgtGFZ6rn3PPu0H1ohjONKIHfKzj7V/kgXYq3t3KIUKfwrmx4LzSezTXi6oRzZhv4/4qCmXLgPzugQKXk1KYZHGggXzXCFymWiLT6Jj3dh+8Dfu6N8hit9v33PVQ8lqws7fRDYPH239/ag61eMjNxobECzY+zd7KhHyNMb+DYqYI0980SrLlGpNQt8W29e0TM64lS/OFjRHwJ7zA22g+G5kUJ+0N9aT2sY3zEz3YDqjgnXOGLKfjkyJZCpbx3amWxdDczbcswyg1myjwwdA1t1Zbi9ieCpZJhlmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S5AxDfsrdedpyw2JBAWFuCmoEymXZ8OoPSmPcK922pY=; b=h9cSWGZJvu+hu9UHY733iHeUweT5/gl73dNLwGW+NBdB8diDXTN6IJKtJAQylQ34xjJb1C+roOv4k1A0dwPy7pIRNc9oTXxgVUMHaZCm7DnESxN7g0N+TYu7swK/cI1WhbKlvUN8uGVtpALjtpjGozho0+WYrB112twfxqbG6hBk0x/CWzaCY6NIvIS5vDAyf9ZGNXyFgNIH7SvtWGpHw6UdXjNC7BZkz7tv4KBgo+vyZqRg8guO8Ayyur/AF8UMJCS5QV6wr7yC3mDmxcnNzSW/awsGBVfhvamysWZGG7hq3dpY7MB0KgLWzs/GzML15YCFj7+YwAaOLN3vCbl9cA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S5AxDfsrdedpyw2JBAWFuCmoEymXZ8OoPSmPcK922pY=; b=kDGt7TThdj3IGvZtQ4XaDI76C7rzK3cRTu3FfuSGlUXtbgQ0Swgr5VRUeL47Wwlv/GHn59actSxONkWANSEh311JRLEtsGcZJt6lMHvMMQOWFFsF+t4T/JdmCdbFNTUawMxwo+Yx66eBkhf3SF7hnrvZEapifXpymSdS1lEqCSY= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by BY5PR10MB4067.namprd10.prod.outlook.com (2603:10b6:a03:1b4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 06:33:29 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96%6]) with mapi id 15.20.5102.023; Wed, 30 Mar 2022 06:33:29 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH 1/7] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa Date: Tue, 29 Mar 2022 23:33:11 -0700 Message-Id: <1648621997-22416-2-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> References: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR11CA0006.namprd11.prod.outlook.com (2603:10b6:5:190::19) To BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dbbc5084-058f-4ed0-fc2d-08da121733f3 X-MS-TrafficTypeDiagnostic: BY5PR10MB4067:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nkudZ+iJOzxhXKD5UaMlgcYOiZg5Q0xWEGO+DsYxlbOglhr5QzoAQnKH4wRAR76pPAXq87UGuPU2cS/g9xmYnqUiNGYbeqMr3qOGpvapvf+7CjAG9jA8V4feJzt92UrMPVlmQunof3Ziy8qB8yvE+C5QmESR1yeFHnPZzZDJy2EUKgqn4V3rr+e0kJDYAYGfyAMOCH2oGiL561+dY4qTaeT8fJ/zOZ/axE0RBIwzs2j1F3iPh1DBFVKTUNMp3G51rpvNzdDS+WTWzizEymp7NWPU6PD+ZrT3TF6ILaqKsvJrYhNyDaBB1zfqpxGv5yTnkYJyojclc0s9PL/iwwVPenQ+Kpdf/+6FuouUSFGGNEWAOhV+VE4InljxsSZzFtSU6DsF0k07w1cROppS762KqfVrVejBnHuZAJmC7PicJK0w+ibTeVfrrmQx7mJJU+FakpWWv/XWWC0MW4jaiWiS7AJCVoPgzxqGt7Vp9sxLd8ufURNgW3hbR7AgjEbahHuTslEOjSXmmnAL1fC6SB1z8VeBCzG1SDx28Ubu+kReIh35ANKBc64zdqjXeewz/sP8zNKJdCTmLscR+lqTHPa7W1XQo+Ohx5swbmktISefdmHgAIpkRZ9zuxV83nGNvtsOvPF96ZbVEP/B7Uc0JMElbjOBb+eurv6GZr/8/zZyM3hueMAMvtJWlM47W/S3VGAQ8z4c7iSN1ES6abJHHC68bw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3287.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(508600001)(6486002)(316002)(86362001)(36756003)(26005)(107886003)(6916009)(52116002)(186003)(2906002)(2616005)(8936002)(6512007)(6506007)(6666004)(5660300002)(83380400001)(8676002)(4326008)(38350700002)(38100700002)(66476007)(66556008)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AnE8KURg6lzsJFa1PwS9dnV4ys2Fp9MwtcnAPkVRh4BeGJ0ZPP+xgHPkQNLpC5VDuOk7lFybz3r4oFNqE9n1wtwIFAZVVC8CV7P2SnAi7pvmE+JRfQArNG2Ot/HIh0ySoUuADTFDJ/k3vCypNSghuJ5tCImfqGPohc829+89rKvkV17EXZGUJ9GuAUrMDFCz75fchFjMY4zex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xNUAt54egKQrAA7K1UxgH/HxgB1YmQE2AE9tfrklspzxuA3wUXLcnoV0sSpszrWnVCVm7rogRNsdl/Z85bRR0SGOMdI12oNBqFQq5aecHvlkkt4X9xhc00PIW/7uA/O+myDyfIRXrIR+OojW7Bw2aD896kJL6XuDuZSm9DilDCZUWPsqqjrRWzAMC02R3NKQ4p/jhX0MZmVxbAaCaQowaAheX05Qr2YqoDnS7UrqGfuPNQsfWjMX1BWTlO6BoE93GnKsMHKGC2IGsrC+cW+70PB9FatXoSKOiFwxKNFUwnkfoUgafyPEhEX7tFfqb2lvvFCJ273N6z87DQgV0TO/44FZtVOVaCOBRWSDf4Wo9LzarUnuC+P2MqiRY1/BL598MAiw+Tc+1mPbkPiMv+0ZV5dr1N0EeRH0YSmnLuu3nsGYnGTan+IHN/cBokASDqxPPZ78yHzWlR9J7rZHwxh5DFHgKqH1OMnEBCFsqVpi61G0DYSL+d5oG40= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbbc5084-058f-4ed0-fc2d-08da121733f3 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 06:33:29.3084 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rF0MmgXrhe/AlPiMab0qGy+8iXhbL9UrzhsboAei1cfPTK1P0ectjcFASK/IKijMcUShobGfoMBBNDw4xWGP5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4067 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10301 signatures=695566 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300030 X-Proofpoint-ORIG-GUID: FNHcDJw8IvVmXA_QacuM1AFiNoeMg8es X-Proofpoint-GUID: FNHcDJw8IvVmXA_QacuM1AFiNoeMg8es Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: si-wei.liu@oracle.com, eperezma@redhat.com, jasowang@redhat.com, eli@mellanox.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" With MQ enabled vdpa device and non-MQ supporting guest e.g. booting vdpa with mq=on over OVMF of single vqp, below assert failure is seen: ../hw/virtio/vhost-vdpa.c:560: vhost_vdpa_get_vq_index: Assertion `idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs' failed. 0 0x00007f8ce3ff3387 in raise () at /lib64/libc.so.6 1 0x00007f8ce3ff4a78 in abort () at /lib64/libc.so.6 2 0x00007f8ce3fec1a6 in __assert_fail_base () at /lib64/libc.so.6 3 0x00007f8ce3fec252 in () at /lib64/libc.so.6 4 0x0000558f52d79421 in vhost_vdpa_get_vq_index (dev=, idx=) at ../hw/virtio/vhost-vdpa.c:563 5 0x0000558f52d79421 in vhost_vdpa_get_vq_index (dev=, idx=) at ../hw/virtio/vhost-vdpa.c:558 6 0x0000558f52d7329a in vhost_virtqueue_mask (hdev=0x558f55c01800, vdev=0x558f568f91f0, n=2, mask=) at ../hw/virtio/vhost.c:1557 7 0x0000558f52c6b89a in virtio_pci_set_guest_notifier (d=d@entry=0x558f568f0f60, n=n@entry=2, assign=assign@entry=true, with_irqfd=with_irqfd@entry=false) at ../hw/virtio/virtio-pci.c:974 8 0x0000558f52c6c0d8 in virtio_pci_set_guest_notifiers (d=0x558f568f0f60, nvqs=3, assign=true) at ../hw/virtio/virtio-pci.c:1019 9 0x0000558f52bf091d in vhost_net_start (dev=dev@entry=0x558f568f91f0, ncs=0x558f56937cd0, data_queue_pairs=data_queue_pairs@entry=1, cvq=cvq@entry=1) at ../hw/net/vhost_net.c:361 10 0x0000558f52d4e5e7 in virtio_net_set_status (status=, n=0x558f568f91f0) at ../hw/net/virtio-net.c:289 11 0x0000558f52d4e5e7 in virtio_net_set_status (vdev=0x558f568f91f0, status=15 '\017') at ../hw/net/virtio-net.c:370 12 0x0000558f52d6c4b2 in virtio_set_status (vdev=vdev@entry=0x558f568f91f0, val=val@entry=15 '\017') at ../hw/virtio/virtio.c:1945 13 0x0000558f52c69eff in virtio_pci_common_write (opaque=0x558f568f0f60, addr=, val=, size=) at ../hw/virtio/virtio-pci.c:1292 14 0x0000558f52d15d6e in memory_region_write_accessor (mr=0x558f568f19d0, addr=20, value=, size=1, shift=, mask=, attrs=...) at ../softmmu/memory.c:492 15 0x0000558f52d127de in access_with_adjusted_size (addr=addr@entry=20, value=value@entry=0x7f8cdbffe748, size=size@entry=1, access_size_min=, access_size_max=, access_fn=0x558f52d15cf0 , mr=0x558f568f19d0, attrs=...) at ../softmmu/memory.c:554 16 0x0000558f52d157ef in memory_region_dispatch_write (mr=mr@entry=0x558f568f19d0, addr=20, data=, op=, attrs=attrs@entry=...) at ../softmmu/memory.c:1504 17 0x0000558f52d078e7 in flatview_write_continue (fv=fv@entry=0x7f8accbc3b90, addr=addr@entry=103079215124, attrs=..., ptr=ptr@entry=0x7f8ce6300028, len=len@entry=1, addr1=, l=, mr=0x558f568f19d0) at /home/opc/qemu-upstream/include/qemu/host-utils.h:165 18 0x0000558f52d07b06 in flatview_write (fv=0x7f8accbc3b90, addr=103079215124, attrs=..., buf=0x7f8ce6300028, len=1) at ../softmmu/physmem.c:2822 19 0x0000558f52d0b36b in address_space_write (as=, addr=, attrs=..., buf=buf@entry=0x7f8ce6300028, len=) at ../softmmu/physmem.c:2914 20 0x0000558f52d0b3da in address_space_rw (as=, addr=, attrs=..., attrs@entry=..., buf=buf@entry=0x7f8ce6300028, len=, is_write=) at ../softmmu/physmem.c:2924 21 0x0000558f52dced09 in kvm_cpu_exec (cpu=cpu@entry=0x558f55c2da60) at ../accel/kvm/kvm-all.c:2903 22 0x0000558f52dcfabd in kvm_vcpu_thread_fn (arg=arg@entry=0x558f55c2da60) at ../accel/kvm/kvm-accel-ops.c:49 23 0x0000558f52f9f04a in qemu_thread_start (args=) at ../util/qemu-thread-posix.c:556 24 0x00007f8ce4392ea5 in start_thread () at /lib64/libpthread.so.0 25 0x00007f8ce40bb9fd in clone () at /lib64/libc.so.6 The cause for the assert failure is due to that the vhost_dev index for the ctrl vq was not aligned with actual one in use by the guest. Upon multiqueue feature negotiation in virtio_net_set_multiqueue(), if guest doesn't support multiqueue, the guest vq layout would shrink to a single queue pair, consisting of 3 vqs in total (rx, tx and ctrl). This results in ctrl_vq taking a different vhost_dev group index than the default. We can map vq to the correct vhost_dev group by checking if MQ is supported by guest and successfully negotiated. Since the MQ feature is only present along with CTRL_VQ, we make sure the index 2 is only meant for the control vq while MQ is not supported by guest. Be noted if QEMU or guest doesn't support control vq, there's no bother exposing vhost_dev and guest notifier for the control vq. Since vhost_net_start/stop implies DRIVER_OK is set in device status, feature negotiation should be completed when reaching virtio_net_vhost_status(). Fixes: 22288fe ("virtio-net: vhost control virtqueue support") Suggested-by: Jason Wang Signed-off-by: Si-Wei Liu --- hw/net/virtio-net.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 1067e72..484b215 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -245,7 +245,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) VirtIODevice *vdev = VIRTIO_DEVICE(n); NetClientState *nc = qemu_get_queue(n->nic); int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1; - int cvq = n->max_ncs - n->max_queue_pairs; + int cvq = virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ? + n->max_ncs - n->max_queue_pairs : 0; if (!get_vhost_net(nc->peer)) { return; @@ -3170,8 +3171,14 @@ static NetClientInfo net_virtio_info = { static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) { VirtIONet *n = VIRTIO_NET(vdev); - NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx)); + NetClientState *nc; assert(n->vhost_started); + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) { + assert(virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)); + nc = qemu_get_subqueue(n->nic, n->max_queue_pairs); + } else { + nc = qemu_get_subqueue(n->nic, vq2q(idx)); + } return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx); } @@ -3179,8 +3186,14 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) { VirtIONet *n = VIRTIO_NET(vdev); - NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx)); + NetClientState *nc; assert(n->vhost_started); + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) { + assert(virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)); + nc = qemu_get_subqueue(n->nic, n->max_queue_pairs); + } else { + nc = qemu_get_subqueue(n->nic, vq2q(idx)); + } vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask); } From patchwork Wed Mar 30 06:33:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 12795523 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6F56C433F5 for ; Wed, 30 Mar 2022 06:46:30 +0000 (UTC) Received: from localhost ([::1]:39106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZS69-0000Q6-Qv for qemu-devel@archiver.kernel.org; Wed, 30 Mar 2022 02:46:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtm-0007at-Uv for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:42 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:2348) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRti-0005NN-G1 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:41 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22U3L5Lv013073; Wed, 30 Mar 2022 06:33:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=D3wScsUPtHx1Nkvc8GMOmB3eklPaOR+YFXHFiKzuiJs=; b=b0l3tW0uePau64F4ZW4YZBHnpFkhRb9hRrVU4rJ6UJu4RR5wIBnJNu7h/GYiA1vtntEU Yfw6UC/Vvk8cxUXdwuu0SxF7LKrST5ObnJ+0IAZY6nNMKv9+YJIpbm8gS4oNY+gAXFRZ HzGAtXOBOQs5xX9rRGMYckQPQ6+nXISOe6akrpC4vyyPUiAq4kV20aufMzxqX+p+5vrF OktSqAuPBEO7Lgw416OQ/pnpDvKfIi8m0cjPDfZOm0tQI4qCRMnMwN+LpR9ZQ+Z4OGfd L8Fm2rEzex+A41DrSTQuqDLcBTWZChMyC4szZBzOMaiLMoXFcSGQo/vwwpnDGcqI/XOi IA== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1tqb8e8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:33 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22U6IT3n114576; Wed, 30 Mar 2022 06:33:32 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by aserp3030.oracle.com with ESMTP id 3f1rv8egk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dWbJZi0ScZnZn6BVKsuwGIAwoI0uuW9gZU5oxipOsIWA7tFfwPh9iXCBMkw9kJTZdRGWp6oIHkXpel4OhUKhvDP8OVgSTU5Nv5c0BdaJzG3U26SxuVxXaZzGC/x3vhS7xPAdAJrG2KYjYWptJAE/fBnhza16yXG0HYOB4oj0v//KkwY56xkP+44znd2tkDQYvV94WDZ9CWXfFJKy0S4iOH2SBe4bnSxBdedREFDBTL2FBP5sUxbHhDmCn/gaYsM87Mii5A+EP45n+HB//7OVAyVdtuOCewEqZGRyE5p2EWx1JNph2MDJ/wddHRfxRHVal6/NFhMi7Kv2SDKPPF7x8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D3wScsUPtHx1Nkvc8GMOmB3eklPaOR+YFXHFiKzuiJs=; b=EdKianlZNIyiH0wILOokEt+QkylQOCwWM7QQloAL1B/H47yZh3ButWFe62DLIIRsuQTVvggkuA9qxmlbbYWB44I4wEaP86/zKS+0TlKzyE/r2fxMMnJoWBUsaPM5MDjbVdEVia75MFqgwo0dFa8UBrNPeoTNir9YZII7bWeA6qPkSXEypDPwymkh2zMDQT00REGltIbVOTlErHqQ5hkR6wvCKhsNoANBOmyUZtr7jHhW1gf7autNrbdi3VgQkwF5Fge1/wOo0g/YqxSO57wEoWiFE8G9a3abyk81AUhJ4Sjy52ka+atIRvkGkfQHrmJVjGVuK2yC/8VtCHVuaG99pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D3wScsUPtHx1Nkvc8GMOmB3eklPaOR+YFXHFiKzuiJs=; b=zmbJrON1bhkR30WKgHeuQj7F7ZdipP0m1SpZRovsF66wcXtTB7igVHwHWw+TvUdWYGwcqeDr8a03Z5FMF/eIqItNkHkQ83I+H2FSbeBntos2vZq/4czFf5sdM9G/oRkwnMCzuV45LnrlTq9PEoHvQ/sj6z82pwxIfdV/Q0xlkKU= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM6PR10MB3130.namprd10.prod.outlook.com (2603:10b6:5:1b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 06:33:31 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96%6]) with mapi id 15.20.5102.023; Wed, 30 Mar 2022 06:33:30 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH 2/7] virtio-net: Fix indentation Date: Tue, 29 Mar 2022 23:33:12 -0700 Message-Id: <1648621997-22416-3-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> References: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR11CA0006.namprd11.prod.outlook.com (2603:10b6:5:190::19) To BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa2a6a33-3acd-41c9-8e33-08da121734ab X-MS-TrafficTypeDiagnostic: DM6PR10MB3130:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i2tBZch4xGYqBXsiJr/2mW6dWPnRgcTbqVcnBttNc8y2uA3xwY2N4mpWAQl/vmSlJRKqzrUnDboqRw/rhhbL7vACHXKWuuHMvtA+oHbc54WWQkvdV0nfw6ZNMFU+8DCmcw3bbBxOwypcUX1DQ4Lv0ruHj2z1qoFcOI9jT229ajb3syewNvTQJ0l3fMLxgFdo/t+M3QgfUyR0CwmEoYjxF8q2wzIC/zaU6gufGkSrNkNTsBpA5YV/z4jBEvlLQd43Ni1CUsgwUHqBsKLSRsTfagkwNfM2XLcCqsWk2TU4WXkXEF7rKFby6Thl9wSSxBAdU3TnFJOR1nzSGaXnUCmDJW3iw57fIyRwuEFL6F3xbhkCRTbfaCOu8mcOTWgBPxdGx6qP5pKsR2Dv0CdcqTsbvWZGPxASd1VOJEOetydcVd5BHvHtW7RmMHu0ZZXchKMkEe4m8YANK5EhL9oEmMO0Dh8xCZbmQfnpV+qhwxPgXPKGSSwYCHwYNwaBU0NcTiZv27XgFVNRm3mpASSFzsi5LL0eoV7S2R0f9HYFymML4h41VyzDC2ne4d7/7/fipsUwdRgXmrMPJhgKK0YdOVnGM/jh+k2GWPZl5bcSbeq/viLZLhYJGqBsJvmgQwWopkepsMH1iB65VlSKyix3MtZ3dAWmWp0xd/go8fGFipTFtyJLYM4Ovvymf+AvaQXYsWVb1IM/j88SqGP1F7qyB9sgeg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3287.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6506007)(36756003)(2906002)(66946007)(66556008)(508600001)(8676002)(6486002)(6666004)(6512007)(4326008)(38350700002)(66476007)(52116002)(38100700002)(26005)(186003)(2616005)(316002)(6916009)(107886003)(66574015)(86362001)(5660300002)(8936002)(83380400001)(4744005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xJ/uYP26ZN6oLjF2fnRHcJ4pfuM2?= =?utf-8?q?6TiPFiG2pyAcvoxInHE3xVj89tnQC3hBG5ahEWSUMNCEK4325p5oSkJaqeMOvQZ6E?= =?utf-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5KGz6wRAi2U2GFa0XDSW6qOPMJONEW5tn1SB1ayTobhirqL2Dlqkx5ATlF4s?= =?utf-8?q?qxk1lF4aymglhpDg8z84AvsoZdwdnmNDnUfpDsRIAO4XLRJuuzlmm0No4u6skKjXe?= =?utf-8?q?O8vV4Jo04JgJxAhYSujR5NES19MHF8deg+JEOZpv/35SWl+tvX5qLrUo2YwpDduui?= =?utf-8?q?Dn7JfLQc+U/EG7mTljfmecWQ6ol+ruDoiCj6htf8apqbYtNQUOgqXr5RWbEmh7fqy?= =?utf-8?q?4Byg53A+T9IgrvHZURMKEq2KCu2NkH85/RLWHpL67s+ChvOYpYtfN+0EtCw1fWfIe?= =?utf-8?q?1V1QogDDcuT4dbDFU1Zm/SOXQm19pInIlIU/yYQ2N/xmK+cFmDXC8xpDU1xgKsXGj?= =?utf-8?q?/Kc/XLWocnUwxX3d1KmqXcZq+ehOt95S/9/IuK0KqBuO8e6gMKFRZDWhbZAJY3I9v?= =?utf-8?q?fMuExz702KIPQDEJyWtaP8jM04WZurcjBggOpnNJmEd+MkgCIxb9ZEot0wpVcezG3?= =?utf-8?q?6lCZA6Nziaj2mI0bTXPZR+TW7cOJHou+ZeI2wcsAuCId7pGqwPOY1jxrAd29Wtdc9?= =?utf-8?q?xQX8P6r6w22D8oWoU6UaE9GWmbR9c3TPkgT4D1cdGS90rSmwAJHN/0RvC+2CT/pzN?= =?utf-8?q?sAflwMJtF3xWGgntvflJ3NDSpEcunCJRgzoOoubz25jgrUcgarsFsA6rkerEeUFwi?= =?utf-8?q?DBt705NZIgbzDT6FSqUQmgjpFV6uE6SQtOhDZAeCMN+fB0qbjM3W4=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa2a6a33-3acd-41c9-8e33-08da121734ab X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 06:33:30.4802 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vp4LS30+FUry9gRAoHeULbgoDemv1tRgjWA2t/7ou/3dIR3oNtvxmBuWxT3F+YYL1IPCmKKjaunZ1KJ8mLyj/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3130 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10301 signatures=695566 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300030 X-Proofpoint-GUID: xkkF64dutdAVaHpjx1jFhVJ1i9Myjeju X-Proofpoint-ORIG-GUID: xkkF64dutdAVaHpjx1jFhVJ1i9Myjeju Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: si-wei.liu@oracle.com, eperezma@redhat.com, jasowang@redhat.com, eli@mellanox.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Eugenio Pérez Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 484b215..ffaf481 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3523,7 +3523,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc = qemu_get_queue(n->nic); nc->rxfilter_notify_enabled = 1; - if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { struct virtio_net_config netcfg = {}; memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN); vhost_net_set_config(get_vhost_net(nc->peer), From patchwork Wed Mar 30 06:33:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 12795529 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 125F5C433F5 for ; Wed, 30 Mar 2022 06:51:39 +0000 (UTC) Received: from localhost ([::1]:44176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZSB7-0004NA-Q2 for qemu-devel@archiver.kernel.org; Wed, 30 Mar 2022 02:51:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtl-0007Xv-2C for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:41 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:39872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRti-0005NQ-BH for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:40 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22U3Mg4E001205; Wed, 30 Mar 2022 06:33:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=g6CCMKEhY4A9XctA35s5iChBffq+Mq8CfEB26NtciaA=; b=pEGLmJdSC1sFrll3dHfVquZblNhirX5rVDfDyOMcv7W9eQxG0c6rTK1Ym8O0XYkqOx8k d0/QK2jySxoeYw2ba7udLQXp+70a7RpuhMGKNewcDYier533+2miJRTa7NahVCSXa6Cg Svg7QgormwxEI9vblH+FH97PwO1G/WLBSjxu80DLaM8Eo8tRXPBqn+1nu7dWL4LsAnvY j54Gic+KkuBUePLy2GemVXwUAoCiyFrvrejb7790oaxliqCAPUpTEIjUM9DduE5Lfoa+ tH5HSUIAlG5/fQF4DeG/9E4xxyXKeQ+tdhc2FqS69BeIM+HeaJ7c1+Q9W7KGP/3NLxkp CA== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1s8crcnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:34 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22U6IT3o114576; Wed, 30 Mar 2022 06:33:33 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by aserp3030.oracle.com with ESMTP id 3f1rv8egk8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZQnoCVh1Y08lO62Yj5EMZAUvlmQxGhOimgG5dA8mPbXSkab1jFRgXNnNpLOhigrcWo+oHzxpLmhr6cGPRjnjJnEhoA9lqNNNRUscoJ/JAJf1ifT5INuN4l0x6yFWa9yErPYLoXwXxzOXcyUXYzKVgrq0DkfTffP/NwbvFggUDy6Td0Kog2GuD6yEMj3pDLf7BAHZ/36DbVp1Oo1AMrlv310jloT4GMkpJ/htBXMmljU5SW0YRdUiepGbEe8kNfEi3ppL2xoMjQG9/TNFiGQJqhn2c53ZjLBPYCsylGVGb/v7U8iqn+PWyBd4z/TEyQSJz5Hy4mP0LWyXcX20S8+2IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g6CCMKEhY4A9XctA35s5iChBffq+Mq8CfEB26NtciaA=; b=CcmvJlKh79AdLzucYroobNhSRHjkcG54G3MB41d2/gVs1Jg4RaUYJh0NMI4HeHjMJuG/VaBAVwoqa9vccR2plM93PqvsYrRElVSu8nDmmo6t66/UvBVZT9A9TnzElluqyo1uZ5ppk+pKgS8E0QYHTMvm+C61Y8yQVhntQnrkSFbYJ/aW0nLUwB2dJLxsa4/Jo3YLGguLTQpJgKnANgRKmjRI09OYOT232sx38bsCArROfhw3itFjgQgcb+sbyF5AYuqf9p+OdyEHNjS58Ve0XnWV971q9LbpKTzXfUwG06ilTrtlVicOMFnoZipDJWVVnHuqhYBR21hg7YBf9rtzpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g6CCMKEhY4A9XctA35s5iChBffq+Mq8CfEB26NtciaA=; b=c6NgcHhU885Tg7TCV3Gdve4QwCulcm1uC5kXcL3XF4TGOeGmsaxf00wDneNOyzgtFQiwje62azUyg3/F3930hZyWyFNDVMvxiwFGV+eeOSylLblj8EAEp1bazAoxogNvaUDd2pS8vXwGDMzM+2ynjjd4GhU4H8XXk6iocACABW8= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM6PR10MB3130.namprd10.prod.outlook.com (2603:10b6:5:1b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 06:33:31 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96%6]) with mapi id 15.20.5102.023; Wed, 30 Mar 2022 06:33:31 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH 3/7] virtio-net: Only enable userland vq if using tap backend Date: Tue, 29 Mar 2022 23:33:13 -0700 Message-Id: <1648621997-22416-4-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> References: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR11CA0006.namprd11.prod.outlook.com (2603:10b6:5:190::19) To BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3ad5ada-bfba-4ffa-f966-08da1217355b X-MS-TrafficTypeDiagnostic: DM6PR10MB3130:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bysm83TLcooahr+rRaDDeujzHSXlu6ns5iKneWEoscjh8v/xdrXBdS1H3gGYaZxfnYzAF757eo3cxutMcqzYLHtUzLqhQiuq2a8ElagBYp7QASo+YQn8TTN+xMMWozqyAlt5nhQC+8tvNML/nOioRhmlYZomb5A1SYLzHK36IMIwYgkJ3wfcKhwO8AE/TQwSyQI/bOay7f+gGeeLryejYwP+KwcnulEtaQaXYMfwkOSLzaFbVREO+rFB6/6ASVNqBL9SyyX8++2sv4SBVL+/gx0iTlhvebr+QVPi/Ut88Zr3X7i3T60i7w5uinPZKqG6oXvcugbPtRG5zBJcAabyxSoXsKqbVMixlYiLGXijQbtqnRFzowhuSS7X12/UORdzqofyNZ4npD3SdChdwYByAoakHNmCgj9Nr2vgatV53iDE1KISbyFNI4C42gMFInI68g3x40mWWNbikU/ge8ReHyeuQhmEPsR3CNp4eeLYJGkU8N0bhQqIYo5oPxr51bN/5WI08aZU6FTJy6xkIZ9tuufHkv1/oAnXMdJazpzaHBdc566Q0dW8DKqgpThZ+Slm2E2w3gZNZUBcuUkBYtMx3oNWZ31WhtZVeeIgYfeYnscr3grMysyHhELyTi+ORHPgsC2c4uuP7laXKP2M2eRbL4Anb/jkXKEDQThqqCnuIecS9/aqIoTJWErfnLf3k00tKUXlNRantyrC/D7L9hR06g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3287.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6506007)(36756003)(2906002)(66946007)(66556008)(508600001)(8676002)(6486002)(6666004)(6512007)(4326008)(38350700002)(66476007)(52116002)(38100700002)(26005)(186003)(2616005)(316002)(6916009)(107886003)(86362001)(5660300002)(8936002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Aukn3spzIfG28kXF+wh2e4jCanuQ?= =?utf-8?q?9llCtWDNee6iKJjPY5+NYl0ghRno6Ch4Spblz/Bkj1O2ZUx3WNNLfi8WAENoB0fav?= =?utf-8?q?fHSsTj2TyonbyPHPlu8ICJMdvLD2G54sTw6cDJVvN0e5o3SYJSSxgRDRvJWI1jS10?= =?utf-8?q?IyFhiukXc+gX7Vo8yQzRqEOo3kyFHZ1p8qztWKGbFtqOZ+XFZbYTjRL1BRM3tXyCA?= =?utf-8?q?pNPzXpUF+zum8edHwjimv7sL9u/m/x1JgBT+n5b+6Yp3zNz4xTFmC+984TVUjJKx/?= =?utf-8?q?VulWs7nZgDd1b/KXo0NMkVrHxitKGkj8WAdB96KBmUZ3w/o0lx4Rjmx48mwZsMo4J?= =?utf-8?q?u01F8BpDiUwIzcl9JSxVBTKdNzjCdEIr4ncS2mhWw9J+IIEa4EVQFUPcbPHPVxxWC?= =?utf-8?q?gi1zxXHAhTGtOiBn+GK98+3pVq1O+zgvJqaoXiWKg7Z7ZJNQcnHqzkH057sGGxxU8?= =?utf-8?q?qynMsuLJI9G6e+b0xg2vHrs6CRYfkTdruWCCcMmoPp+CWJ/OCn/8jMNGOfLIHHj1l?= =?utf-8?q?slxZAA95Og7fv3qC7rVwv++1d12nd3TjdD0DcK0Ao5d2rp8F/dqtADJxfVr5uKbG1?= =?utf-8?q?AzuigaxDSBdvu6bO3g486s7eaKrq/cUg46UOT4L1PcfLKD1NNM9qyU0ogGyYD3KcU?= =?utf-8?q?2IFML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8ZeULeCQ7/QdZnhql2fcqqvGGjb5PNk2?= =?utf-8?q?2o5hT/rtjuHlCIJ6iqymlcRS7e5gCaGjQcVaEw4kMCgZablEQPM+cHi2lL24KCQkv?= =?utf-8?q?6ZEOAGwyiMGoULJmwyCkTmp0BzVXzks31mN6nz4hqJtiDeQtEAj5A=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3ad5ada-bfba-4ffa-f966-08da1217355b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 06:33:31.7145 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3ruuqP7xC7s+jPZzaZ8q02UrSOh6DOoPy2de9EhWAwQyzetaH1ne8GJ1fw+iVFvy73AzUDSaKC/vc4AXeCKQIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3130 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10301 signatures=695566 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300030 X-Proofpoint-GUID: oxqy04K2sKdrn6tNzVMKaB5thiWxiv6L X-Proofpoint-ORIG-GUID: oxqy04K2sKdrn6tNzVMKaB5thiWxiv6L Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: si-wei.liu@oracle.com, eperezma@redhat.com, jasowang@redhat.com, eli@mellanox.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Eugenio Pérez Qemu falls back on userland handlers even if vhost-user and vhost-vdpa cases. These assumes a tap device can handle the packets. If a vdpa device fail to start, it can trigger a sigsegv because of that. Do not resort on them unless actually possible. Signed-off-by: Eugenio Pérez --- hw/net/virtio-net.c | 4 ++++ hw/virtio/virtio.c | 21 +++++++++++++-------- include/hw/virtio/virtio.h | 2 ++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index ffaf481..9cdf777 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3523,6 +3523,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc = qemu_get_queue(n->nic); nc->rxfilter_notify_enabled = 1; + if (!nc->peer || nc->peer->info->type != NET_CLIENT_DRIVER_TAP) { + /* Only tap can use userspace networking */ + vdev->disable_ioeventfd_handler = true; + } if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { struct virtio_net_config netcfg = {}; memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 9d637e0..806603b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3708,17 +3708,22 @@ static int virtio_device_start_ioeventfd_impl(VirtIODevice *vdev) err = r; goto assign_error; } - event_notifier_set_handler(&vq->host_notifier, - virtio_queue_host_notifier_read); + + if (!vdev->disable_ioeventfd_handler) { + event_notifier_set_handler(&vq->host_notifier, + virtio_queue_host_notifier_read); + } } - for (n = 0; n < VIRTIO_QUEUE_MAX; n++) { - /* Kick right away to begin processing requests already in vring */ - VirtQueue *vq = &vdev->vq[n]; - if (!vq->vring.num) { - continue; + if (!vdev->disable_ioeventfd_handler) { + for (n = 0; n < VIRTIO_QUEUE_MAX; n++) { + /* Kick right away to begin processing requests already in vring */ + VirtQueue *vq = &vdev->vq[n]; + if (!vq->vring.num) { + continue; + } + event_notifier_set(&vq->host_notifier); } - event_notifier_set(&vq->host_notifier); } memory_region_transaction_commit(); return 0; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b31c450..b6ce5f0 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -105,6 +105,8 @@ struct VirtIODevice VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; + /* backend does not support userspace handler */ + bool disable_ioeventfd_handler; bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; From patchwork Wed Mar 30 06:33:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 12795522 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0727C433FE for ; Wed, 30 Mar 2022 06:45:20 +0000 (UTC) Received: from localhost ([::1]:38236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZS51-0008FU-Me for qemu-devel@archiver.kernel.org; Wed, 30 Mar 2022 02:45:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtk-0007Ye-Uy for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:40 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:4678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRti-0005NV-Dh for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:40 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22U2x7p0016620; Wed, 30 Mar 2022 06:33:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=JExKC+xPfGEK9iQTGCK+Tq9CMVSmwwriPO9ppJMjhcQ=; b=eFQVouyE53hZNMjzffeiJsHzdV7CKL0RKVt8GO7xOPkkWMw7hMc1WPeoBUUYuKE4H7R7 BicnSh4OojI1KmRbrYS4WvOZodZmCHDokjEJUa7uxWEBvrrltElYQRxWjgSFU+pDflIR 5ShJFLM5evluiQkhoNY8ltRXghGxBYl4l+O0PTeIE4KK9XwCzmrxQnyOWCL5CUTH41Ps CasUHo96w+qNYQ+krQnqHD8a0m9w/j0IrxRnEPC3NMaj/ztHyma7+SxgqLlVDdQFzdSj 6n4u3XXNOg3BQKeS9nNOiNKpaqFGUhQ41HNuiMBUhCs1b74QfUGNPOFvLUwes0MZ4FPB 0Q== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1uctrp2p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:35 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22U6Gxc0113214; Wed, 30 Mar 2022 06:33:34 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3030.oracle.com with ESMTP id 3f1rv8egk9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mJZ4G308wAD1inSTqoUJYH2EUvPWGr0BerI1YyCCJk9z5UCuClhkTeLQFLVlEJmGZ/4GcaWmyuZ+ofSsGmBuu7NzdUn7t9oMiiH3aBT2IhZBhXY6Pus6kOaqJG0d0QSZdpaPaVwOVHFIPagwDeP4b8kUvlosEjiWB8WVFuH2m6n+rGyembOLp3bW5Wo/caKLjl8RqEiypt9qVPGuIdZ00fUja5JYJmbKV+boAEMYiqLI4divDjnYhM/CKoiyDn4l76tWsoa9KajODSPqZCRAUn1vVhTbDCgPBfbrzf+XEkrHJoLGbTTm16QNp99+gxXaOYpnpJNQYUEaBu5OM4cyzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JExKC+xPfGEK9iQTGCK+Tq9CMVSmwwriPO9ppJMjhcQ=; b=K9F4mUzUKrzl88N3hw1NZyFP0ap8ytupu0nVwtcrUj5Fr9Z9H9xikcfAVjQuVl6k1OZ2CRNhq0pdg569UVtuw574WtfqfiMXdbMhYhRExB3mjyG3ucZNu2u1g+8tOCAMk73dsNbjZ5y2a3oh6IesFn1XqCSGwi58E65+VnLgGtmzuy+8ORMgdn9weJYdWKaRaxmJG7r9ALq5FQkIpgsvm5V8pwQ3U6+P1rda27KNVCKihSFOh32bv1s9UZFuQ3e95o8kHyxNio0MTazBNlQRw4YoGIPatDc1T7n9eGi6OKE8/WepftEPPdU9UYOvAkrqb5dljqx+VUgc/HEYSuZtqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JExKC+xPfGEK9iQTGCK+Tq9CMVSmwwriPO9ppJMjhcQ=; b=FLP84Z6ZB0fj9spnRvELCzuyZ4UHtzYqd2405dRGrjFgob7kaejJ5OQ/QgAmLOXcN3qKu1IDdRP0I2vYgFE6g1cLNFPgW/5V/Sg3d+apYgjCoLbx+qSmTDgm/xRNV68tJJSb67ti30HXe9MwCtqvuTa/bT6XN9hc7ZpjbLHyX1o= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM6PR10MB3130.namprd10.prod.outlook.com (2603:10b6:5:1b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 06:33:33 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96%6]) with mapi id 15.20.5102.023; Wed, 30 Mar 2022 06:33:32 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH 4/7] virtio: don't read pending event on host notifier if disabled Date: Tue, 29 Mar 2022 23:33:14 -0700 Message-Id: <1648621997-22416-5-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> References: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR11CA0006.namprd11.prod.outlook.com (2603:10b6:5:190::19) To BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba91b7c8-c283-416c-b237-08da1217361a X-MS-TrafficTypeDiagnostic: DM6PR10MB3130:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r7NnLmkHICcYEXStLy0QaopA9uU3FHgPsdWCm6sj3ziEQiyVC2gvTvvjjvrQ+Sl3bsKGuKnB9huHcEfJh/nd5brKO8ca1GlVV618j09I/SZyki+63LAytZoaKOJylgTx3vIQ8q8g7qtabWW/NIifjjdu8n8p6ELtuGKwzPs2qj/eDOeah90jghqRKyXSVh8+iuQEE1qOVeXQJrQCiG8o6GN8pcazYl9WDVINChg3YMHY+kgjpr/4y9LIgLp6SvKq3/QMshmEwBTTQUkCgSCygloKIrvWvEjTdBZKvVwp9CifwiX5KD26ehL0mB70N8IkcHkoJd/t/hGRRp8voo5rELuSuKB6KeecPM5ToNLXg2UCUfF5C6mJDU1OF+s77WuTZ5uvEWZTbZPzoFKSxq8XiaAkfwsXwxXhAo8EQBJnHOpYC+MBQOiEPmprka+4v9hS/6MP9RjkgPyHxGq+AQBmKz6IRD0wDoEYUScFgOU+Tb9luR6bepvwkj1WIKdhfULlWgYwl2Ce18xK9NXvZ5ymMBM8wu/Ud5TN+MGvwGuAO6512fUQumoxNaujFNlGnhxWF9PuOLAs7m2tGMJpBa3WqP1lCopKku0K6NyaeiXK9VoyruwTrdDNjehb4UalYpc5GaUsIZ5ogf0tV5oWTII0KubkhoJZNqh4N5ohHumTCalL6BisdW7QXNZjbeogt33mlMixg0Dq4NuIfdAtzJ3tTg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3287.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6506007)(36756003)(2906002)(66946007)(66556008)(508600001)(8676002)(6486002)(6666004)(6512007)(4326008)(38350700002)(66476007)(52116002)(38100700002)(26005)(186003)(2616005)(316002)(6916009)(107886003)(86362001)(5660300002)(8936002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ly/X3uU2Z7hBefKdUY75CbQnw1BXPcB+shDD0Nt556/XzaJzumphAkIpQXg2RUrKs24ML4BH7NNKZz+3EIYqVhMXwYdn96192y+KfDeBnYNqXR0SmfGaiXjOXrH45xyCfuVuS6DHNObh244vq/JSEsPEkB8LTD+sna1Xac1lSOVueFctyEo9RvVoEItM4lhzZg6RG/iaFpWEGoodkPonifgCjWS2ahj1NoiUtjO483PkxSNfYD6WGTxQMXULGxTEMbEs6NoojTMvnyhUfT7xWUMxrsMi8JXmMT/03x8S0HnK+pU1Qkq0dDBN9xJx8pstMvLPTZjmJlLk2THp1qZIowfSHgZDNHjr3nVY8uS7YCi5ztY0B9rMDlIzY3MJwQb9NFLFZu17sLCxOINDeUJw2055iMc6xALhINx6U8vqcQUyG2e0NrXidMnp9qNg8ixd7WGvydgM9ErmMQVZgt6v7ii4N2eeTFpuhPKwXwIW+S2l0i+omo25jKYJ0WOzU4DMEVTAX0+OIU53ZcAa1wV0uOOWeWHoun2ykzrnPNAi6UNpQplGVfGUCvhH6H4n3+/WM8iRwJbMAlZNrCQCewZD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ze71wJ1olOTvf+kE7DEA+D9G7oTXRX91fJfJxAcmri9jax+m4tnbmPAaqFBet7CUFsRXd1uSCzSkF43b1qbzwbF+0MVGDy7dL3ac= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba91b7c8-c283-416c-b237-08da1217361a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 06:33:32.8863 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FgmdF7/4rn2zKMvPIpdDJvDe2oAV0XE74hs2FXT4086/vT73xhAqQ7hschnnR5Ybhm6XEz92hu/kNCAysJfJDA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3130 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10301 signatures=695566 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300030 X-Proofpoint-ORIG-GUID: WuvlXlTiQ3QAbKC7RalA0u8MCB-GuQvM X-Proofpoint-GUID: WuvlXlTiQ3QAbKC7RalA0u8MCB-GuQvM Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: si-wei.liu@oracle.com, eperezma@redhat.com, jasowang@redhat.com, eli@mellanox.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Previous commit prevents vhost-user and vhost-vdpa from using userland vq handler via disable_ioeventfd_handler. The same needs to be done for host notifier cleanup too, as the virtio_queue_host_notifier_read handler still tends to read pending event left behind on ioeventfd and attempts to handle outstanding kicks from QEMU userland vq. If vq handler is not disabled on cleanup, it may lead to sigsegv with recursive virtio_net_set_status call on the control vq: 0 0x00007f8ce3ff3387 in raise () at /lib64/libc.so.6 1 0x00007f8ce3ff4a78 in abort () at /lib64/libc.so.6 2 0x00007f8ce3fec1a6 in __assert_fail_base () at /lib64/libc.so.6 3 0x00007f8ce3fec252 in () at /lib64/libc.so.6 4 0x0000558f52d79421 in vhost_vdpa_get_vq_index (dev=, idx=) at ../hw/virtio/vhost-vdpa.c:563 5 0x0000558f52d79421 in vhost_vdpa_get_vq_index (dev=, idx=) at ../hw/virtio/vhost-vdpa.c:558 6 0x0000558f52d7329a in vhost_virtqueue_mask (hdev=0x558f55c01800, vdev=0x558f568f91f0, n=2, mask=) at ../hw/virtio/vhost.c:1557 7 0x0000558f52c6b89a in virtio_pci_set_guest_notifier (d=d@entry=0x558f568f0f60, n=n@entry=2, assign=assign@entry=true, with_irqfd=with_irqfd@entry=false) at ../hw/virtio/virtio-pci.c:974 8 0x0000558f52c6c0d8 in virtio_pci_set_guest_notifiers (d=0x558f568f0f60, nvqs=3, assign=true) at ../hw/virtio/virtio-pci.c:1019 9 0x0000558f52bf091d in vhost_net_start (dev=dev@entry=0x558f568f91f0, ncs=0x558f56937cd0, data_queue_pairs=data_queue_pairs@entry=1, cvq=cvq@entry=1) at ../hw/net/vhost_net.c:361 10 0x0000558f52d4e5e7 in virtio_net_set_status (status=, n=0x558f568f91f0) at ../hw/net/virtio-net.c:289 11 0x0000558f52d4e5e7 in virtio_net_set_status (vdev=0x558f568f91f0, status=15 '\017') at ../hw/net/virtio-net.c:370 12 0x0000558f52d6c4b2 in virtio_set_status (vdev=vdev@entry=0x558f568f91f0, val=val@entry=15 '\017') at ../hw/virtio/virtio.c:1945 13 0x0000558f52c69eff in virtio_pci_common_write (opaque=0x558f568f0f60, addr=, val=, size=) at ../hw/virtio/virtio-pci.c:1292 14 0x0000558f52d15d6e in memory_region_write_accessor (mr=0x558f568f19d0, addr=20, value=, size=1, shift=, mask=, attrs=...) at ../softmmu/memory.c:492 15 0x0000558f52d127de in access_with_adjusted_size (addr=addr@entry=20, value=value@entry=0x7f8cdbffe748, size=size@entry=1, access_size_min=, access_size_max=, access_fn=0x558f52d15cf0 , mr=0x558f568f19d0, attrs=...) at ../softmmu/memory.c:554 16 0x0000558f52d157ef in memory_region_dispatch_write (mr=mr@entry=0x558f568f19d0, addr=20, data=, op=, attrs=attrs@entry=...) at ../softmmu/memory.c:1504 17 0x0000558f52d078e7 in flatview_write_continue (fv=fv@entry=0x7f8accbc3b90, addr=addr@entry=103079215124, attrs=..., ptr=ptr@entry=0x7f8ce6300028, len=len@entry=1, addr1=, l=, mr=0x558f568f19d0) at ../../../include/qemu/host-utils.h:165 18 0x0000558f52d07b06 in flatview_write (fv=0x7f8accbc3b90, addr=103079215124, attrs=..., buf=0x7f8ce6300028, len=1) at ../softmmu/physmem.c:2822 19 0x0000558f52d0b36b in address_space_write (as=, addr=, attrs=..., buf=buf@entry=0x7f8ce6300028, len=) at ../softmmu/physmem.c:2914 20 0x0000558f52d0b3da in address_space_rw (as=, addr=, attrs=..., attrs@entry=..., buf=buf@entry=0x7f8ce6300028, len=, is_write=) at ../softmmu/physmem.c:2924 21 0x0000558f52dced09 in kvm_cpu_exec (cpu=cpu@entry=0x558f55c2da60) at ../accel/kvm/kvm-all.c:2903 22 0x0000558f52dcfabd in kvm_vcpu_thread_fn (arg=arg@entry=0x558f55c2da60) at ../accel/kvm/kvm-accel-ops.c:49 23 0x0000558f52f9f04a in qemu_thread_start (args=) at ../util/qemu-thread-posix.c:556 24 0x00007f8ce4392ea5 in start_thread () at /lib64/libpthread.so.0 25 0x00007f8ce40bb9fd in clone () at /lib64/libc.so.6 Fixes: 4023784 ("vhost-vdpa: multiqueue support") Cc: Jason Wang Signed-off-by: Si-Wei Liu --- hw/virtio/virtio-bus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index 0f69d1c..3159b58 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -311,7 +311,8 @@ void virtio_bus_cleanup_host_notifier(VirtioBusState *bus, int n) /* Test and clear notifier after disabling event, * in case poll callback didn't have time to run. */ - virtio_queue_host_notifier_read(notifier); + if (!vdev->disable_ioeventfd_handler) + virtio_queue_host_notifier_read(notifier); event_notifier_cleanup(notifier); } From patchwork Wed Mar 30 06:33:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 12795521 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5587AC433F5 for ; Wed, 30 Mar 2022 06:44:53 +0000 (UTC) Received: from localhost ([::1]:37374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZS4Z-0007dj-UF for qemu-devel@archiver.kernel.org; Wed, 30 Mar 2022 02:44:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtm-0007ao-43 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:42 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:45128) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtk-0005NZ-6K for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:41 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22U3TIS9011958; Wed, 30 Mar 2022 06:33:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=BQluA8nwLy6ChiMUU9vmCoCIIykSptreDP5LxK4z2HY=; b=0PfvapEmP8tIRllRIlAgpCp/F0uEMJpojI/k9PH4lV5etBIXBPvh+AcHsAvrmlCFkpCJ eocA5Dp5EqWwhSRrRaCNei2Lt5I8mDe3ML67Ov5dXUwFPDXP4tyHJDYaSpYXKcukBhW/ /3Ys372PFfu1Dkj0J0ecc/4KAhG5RhXgffVYQzOjO01orFlrYY+7VK6PpPkcAsfQUYYX g9lMMQiop6ralXIZphJgfuuvDnYfGF48V4FfrEaCr7pK4FGGd/veE25UShO2NDDhtrpm AddpKqctBlImQFO5jWMj/xj7NGepwRb/dk603flgtC316muHz6DW4e98i92ibw90sG4J Lw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1sm2gkk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:37 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22U6IZE8013655; Wed, 30 Mar 2022 06:33:36 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3f1v9fk5v1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OvRI0t8Jvu3T9k+k2IQE2g2QcbC3CzuGWhhJ7DX6b8z4xw6Qp9VWgG6mNbDGicneKoFduMXej/IMv+meoRDlAV3fU4c08POiwfJE9JlHpllWHRSt8ShDSLzLs+NNLPOp7/L18lq+B1oW9kpeVPrd+WJwzBZBy4LhAQRmj3b6f+ZJhLcKc8JJ8uOVirPb6a4qL3rfhuN17AX20PmBPRz0kSwGkIMcNIUa2H/s8PMhzUWO1bAl8UyTAs+5qQNjeeZfjpj14lWykKVUKfmZrsqSL6VkkCmjeJNwyOaTiG4kWdebiFpx/LyTMi5NWGSl173CW5U0QWh5GVVYk8iWhcKTkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BQluA8nwLy6ChiMUU9vmCoCIIykSptreDP5LxK4z2HY=; b=mm/9xGfIlhGcuq7OHlrxuiVhybV2zsJAgevhq1NCQnMihH7DRVh6k7eGlDk9Rm9fIsUZlDE4N8X4bSKBaE9+FKuA/b+GWM9Q88H4eBnpKpU7mbsvm6RVZkw82Ge76QCFaJm0sC7xNhfwB6+bLk8u5Xgd26xqtYlPEP+rRbgQuqXVWXVu6khCEdxnQH2q88C1ZRYBEdBrpUIeDbQEODh2hmJv85JnjduBT+k+lvQPuK2tB33IOP6De5v+BSnL09MeuTD3as+k7CU8RcRGq0IY9NAZhOo8L/L5Jdo9B0H7kuczDJa9HMB0Ibs08GB3Pz/yoQxKC2lWZu+sPD9y5kWC/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BQluA8nwLy6ChiMUU9vmCoCIIykSptreDP5LxK4z2HY=; b=jGgo/3DeqbNM7QpJQ7HWPOqbqapr+uWkG1vledg4gwF37VtpMZ5LmNzoZh4CAFVNSs3VXVH2NHf1QvnAtH4Roef/fLl+s7pXoLcmJc4uWvlxO/OVab3xBIeW+1i+63oMBhxqFCw1kwDTJpxRMMNL63WVonSauc1ExUXSNIFHUZg= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM6PR10MB3130.namprd10.prod.outlook.com (2603:10b6:5:1b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 06:33:34 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96%6]) with mapi id 15.20.5102.023; Wed, 30 Mar 2022 06:33:34 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH 5/7] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa Date: Tue, 29 Mar 2022 23:33:15 -0700 Message-Id: <1648621997-22416-6-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> References: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR11CA0006.namprd11.prod.outlook.com (2603:10b6:5:190::19) To BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e172e2da-1326-4d35-1d4e-08da121736cb X-MS-TrafficTypeDiagnostic: DM6PR10MB3130:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7SKtD8xfE+nkz4iTbBKo1amkgBcgozwcHpK5xiNPhOGCl4gBWR8mchtWzf1bnYa+1GFm35SWwfW8cu0w0KTPv8BiOGkUXA8MwrCgXPY9Bb0a1INal2UY0GOYdK6RUmy7tha35WL4xkddwv8ZOLOnikXgfb2jxExYi5oP5rs48ub+EEcpvyGUNS2Bb630vQ7jcCD/t0yJlXtEJJBPivfdXh2qqDnQpQxMpAsFxUuWdHjRoThuF9LzfieBXUVgg/BJbO/4ROEQoUQHEC8K24CyQYKzWyrF7viw8smlnl+hArgIL89dIAj9QblKnaHyUWt0v3du8btqXM0pkzXTj/YLM0LenAJC0Opwml22y6U6/08hgSpPm6f+Mln2d9M7a6dfRcgOqtcXniT4WVq3zHYH+9fNiSwUYHet9VlpSVayx8g20F1p3QSgUBZGCu5OvWW7MD2o9ax0cLXWdwlzY/Jqi1XUYlFlgA/uK00V50X9gGPq74gT2muoybkH6l/kJopABmiMie0QMZX5Clz+O6DV3M4sSJQxV9ZwNb0bm2jCc/k9P3Y+G+bdkg/PeMWKUlpirvqQb+8Hj110+dLf3L5LX6jSLJ/bNO1PiJl10XGn6S+V0+Md/yZat3XFfxKrKjlfMIsJJVYPV+XGAtETLz66ND1qz6mqhkgd4ETAbGAJX57xCNUzEuUzai0dZJVywIVbXRCn2wkK1DSmxLldkNLHvA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3287.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6506007)(36756003)(2906002)(66946007)(66556008)(508600001)(8676002)(6486002)(6666004)(6512007)(4326008)(38350700002)(66476007)(52116002)(38100700002)(26005)(186003)(2616005)(316002)(6916009)(107886003)(86362001)(5660300002)(8936002)(83380400001)(4744005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4zzAkBt40KnnEobdP3Vno4plPVXyGU9x3xQjHzPzFFYg/3dcxcx6Glb5WesHEODbV7UQkJuQUUgPE1ZXOwvnlO42IIcwbe/67Vd6QxVu+8TDwiRoBkJwzLQLFywcG1u3E8RK7QidKeeY/3ePGcy7yTFU9RB+KYZ+FgsMbbUyEDtLUTpMGzKxxX1qctE0KvDSlxT7sCJ13NY8z1egbMwUYeo+lOSn3zbxEF4L7ON8Ip9vSATI6CJEeH1sbkP57Rdfus5Se747czCM7ihuMb/oPEvV4za/VZUWSIWympq5yRfOwITkcJXsTb63rjBUGbdImhG1bZNcG695HsAzKvshQZU4lQYn41U8jiJ02So5ahUjdcio7dTu9R993Gr8FDE1JIE2F81DIVHq1WE0w6g+DJKu5lrhudd2JkIX03tBd2We37KDfADg8hTa/6DGqS8c1QPkcfsbDuRZy2m9podjnG8cuFjbEBH60HxAOxpGxuT2iSONQswqBUoWq4NzAhn9b33AEnDhyYbkhKW0rnEfq2c0LHxkjpDhbPHtqpuOe/1sUlu3JiCQPLveg89JyzES5YeGk4/dTZQf0hTM0Gh0O6G+Oc36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847kM0q3Gm+C4qVARKJITBegXJqF+VRlZH9hZMe37msXP8PjU4ehsgfq8rSlojcdEacDdDDo8zs+TydeVKzw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e172e2da-1326-4d35-1d4e-08da121736cb X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 06:33:34.1050 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y+NyDyWbGBkeFFqIQlT+phBWBWiwOmt3oTMbx7IxCu1RZPEF/2QzKXyE1Ybp0cwScH6HAFk44OFQrbw4uS4oKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3130 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10301 signatures=695566 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300030 X-Proofpoint-ORIG-GUID: J9oXvlKwtSokl4829iNNyMP460nrDEsd X-Proofpoint-GUID: J9oXvlKwtSokl4829iNNyMP460nrDEsd Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: si-wei.liu@oracle.com, eperezma@redhat.com, jasowang@redhat.com, eli@mellanox.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" ... such that no memory leaks on dangling net clients in case of error. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- net/vhost-vdpa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1e9fe47..df1e69e 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -306,7 +306,9 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, err: if (i) { - qemu_del_net_client(ncs[0]); + for (i--; i >= 0; i--) { + qemu_del_net_client(ncs[i]); + } } qemu_close(vdpa_device_fd); From patchwork Wed Mar 30 06:33:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 12795520 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D515C433F5 for ; Wed, 30 Mar 2022 06:38:29 +0000 (UTC) Received: from localhost ([::1]:57782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZRyN-00028n-UV for qemu-devel@archiver.kernel.org; Wed, 30 Mar 2022 02:38:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtm-0007cN-O6 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:42 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:45534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtk-0005Nd-Ly for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:42 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22U353cY011976; Wed, 30 Mar 2022 06:33:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=Fj8lLe7Wz4qrPIyFrBEKjcKcu/bE8EE+RviLkO5qPLM=; b=ODOyd1FvTSiZCcO2exFQbQ5k+sfLX6jtPyxCPEeWLQfwzahg0OWfoWwQxjKSSv1QClTl DCccsL5qniiBPPfL1ejwMhb4hXYJEMlMMTDx51z5gL6Cour+2Dy+1CXv/pXC7iC3g8yD kbQN/zf09jKmFiy6nnWfLZG3zdP8rmvz3t8YRRfIZ7Z5cF1XG1Cf27saJB7AwSD0Av2X 1+Y83cG0Hl277Yo6lLaDsX/yU+9NhIch7uA+ZZgIDT2DxpL0i7zP5kIDpdXIh18ir89c 4/pr1TgHhk1Xr4Go+wDazE/+L0+A7rvsGo1gR/Yti07VX2aRWAk7nXWGImZD0P7oVKgy Ig== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1sm2gkk6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:38 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22U6HG4j113239; Wed, 30 Mar 2022 06:33:37 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by aserp3030.oracle.com with ESMTP id 3f1rv8egkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sm4dQE+knvH5Rvp5GZrI9lLdXlYDYha1yo1xYqRVthLra1uQlF+NDRp8o7LV1g+qQNuMhRb71/PIpdQahMTD4lrcZLqyYj5IbUK4tbzB7y/cwMJSBQswaEB5p9WeHv0BmqQl0DFKc2LeqXA6uuqXzSULvkOcfXNbuESj2daHV70SC1wfyNcljuZP95uG3TD5jbAWxCWaVoWx5GelgJWJ2k4a253oLhpxmoncBqhDAg1szw1HxqStS1MI0Z4WQkNJneWT+Y0y8q2jZFnzqtDC84lbtKxzBdVC6V6zpJXjsd7q7DVlF3WlVnbsUWc7isVY4FBwGkXeDYjWM2BfupyhWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fj8lLe7Wz4qrPIyFrBEKjcKcu/bE8EE+RviLkO5qPLM=; b=NaB2uujuDvVZTStTsXbrP1K50PtCTq5WbnfK7SUAahSQAHlwRp5a9xUWkBEh8wD+52Xy9otDSQhacbjn97fwLpzFQ4L7DxrEIBDMB6CIZsSmjGR7B5obVHUdcmmZ2adM3JKVQEU+ejv5sTPebQ9Rv7ID4lstb86wS/GPllqcrcrObYYz7B8I1OA+G1ftJdoKr8TF73qE0ivttQTeqmqn8MpwYhS3Sf3ThRAWpYRO8f/PLU2QRmoM3jcpr2Cj1iVtWRyQUubiIIb8coelPocqgfAOScZ7KvWsNQcgsxARYckuzy4dzFM677c+AvLkUU5WdwXAtrIdo5p8T81PMX/X6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fj8lLe7Wz4qrPIyFrBEKjcKcu/bE8EE+RviLkO5qPLM=; b=H0JaQ9yfh/j+ESXftaoZGbNiNJYxGSLSCSCGSiZUO4lAAuLVGPzIrrokAhooz071cijm1l/0AOW2McEGmwYrIXd2s6OufZF+jMAzaK9OdoGm+hVxb4cuqnG+R3k1TyXzcNMO9xFdYk5FJhM6BLLxJ6LNq0jHwgD4NDpEeCk5x+8= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM6PR10MB3130.namprd10.prod.outlook.com (2603:10b6:5:1b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 06:33:35 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96%6]) with mapi id 15.20.5102.023; Wed, 30 Mar 2022 06:33:35 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH 6/7] vhost-net: fix improper cleanup in vhost_net_start Date: Tue, 29 Mar 2022 23:33:16 -0700 Message-Id: <1648621997-22416-7-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> References: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR11CA0006.namprd11.prod.outlook.com (2603:10b6:5:190::19) To BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c9d952f0-6276-45d5-11a3-08da12173785 X-MS-TrafficTypeDiagnostic: DM6PR10MB3130:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bibs51/Q+cfn8eEvrcMml9nWwQqbacxrvR8x3dH4wKFxVvmT/jzUA6UFujmLS9XSHOurGcT1WHYrAcDD9hEGg3qvcP7/8rgKC9mOCcJ1xkRw5hJCzi47QOJ6QlvKACuUCY6GgFwgLvYgkE6h3t/+UoyyznvYlGa6/8cYhlGKyI5FSRXHWVHlc96GwGbpr6ZOqTeTFuiSO1ZffQlm+rKFJc2AkbxYTXf/crEi/ObQs9ZBrM0NcLYPmBIzH1RMHBbTicGHaNZ0iwzOvNMMfkJGFxa8NBjDdw7GuBGZ/irWZ3eLeqlwSPtNS+cAtovvd2qAWmg82iW65tmLm8LeZ/8CAQ6bcC2rtdsNtgdnBhXzYLBYtkDh3IbtWXDnKbSzrm3bNtn8CVBjldyHL56kOGoEu52vmdjnXbJTl1Kbp1/qxt+m5Bor7xUl+VZw6skCFP8kwbf9HGHq3CMlK6QKXrlyjSkyMoySQVa+iAg65LFo/cAod02UR5CLHRmDVCzAs8e5ACANjt33gLSRktHqEuyuFhHK8u7BHYcHQTOCNhSh0POyuQlw5C9Wpe4qDQlOJlX125cFSfhAkL8f+mOcgfKm9abP58w/wGt8uuUIE+4QUtsUxzANcWA55codV3ajHn93ojQqoGc+eMYhy0aI5cEWm+J335e5E6fCuDQqiaJ6EuMCntWgke0PQehenHFoBZpDu0tTe5x0gPyfUrJPXrDj5A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3287.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6506007)(36756003)(2906002)(66946007)(66556008)(508600001)(8676002)(6486002)(6666004)(6512007)(4326008)(38350700002)(66476007)(52116002)(38100700002)(26005)(186003)(2616005)(316002)(6916009)(107886003)(86362001)(5660300002)(8936002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w78EkSB9NV6NxNJqDZBCDgi0iDs1qPYgQF+uTf5kdm9HFukHbh5LhhqIEy+abwYQODFzT7bq7fw/EBweWP9J2xFNzTpYTL86MrZc8PbqEpc+ZIK9ZUVDWn+fss3cImZIQlN0udugTNmlYiJpHbRFFNLeznqhpJfU5vxOU4KNNWGPVNavjpyjMa/wedokdXe2PKXViVSgu8Jg0K/dXV8GIpTKDTDIcH6IXvNADMhDWexQPIKon35QXnxwTtZC7fSiKJMRfIW0KqXQYqXn3uj37VWzrmBXHudd0C5vLn07iPkkmizcS1vaeVcEVLZgITFdrSSGUYbhtA3z+n0kTgAIqk3PYxfFT/Bx70W/nO9UrPS/e7QfNjCJPdLrZvTUVoqLCGglZNmZyRH8RpcfqugOsuvKRy6nxGCCkqnVLBxZqY7yFnBpzaRH8HKr7vWOtKdP7yENpgFzl/RQL1xZ9VgitOr9fjpsw0hoUg8KE+a5kn3DbQ7z0nz7KMCLnAULC0pEUKX1l314uoHMo3Y9vye8LaNc/lUjcQnC1JXYB5EjSB06gh08zZwMDRAdcp/psmw0O39t+BNdh6+9FascqfuFCTHo9s+1Jf9FD14gdlPL6tXNpG+q9iZ4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fag9bwWsA+DxiP+unmig9sDZDz7ylFeKzzyKv2tDvs7gwp22M0PhL1CaOBe11Z9JMyaZXll3Ul0qBTSt8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9d952f0-6276-45d5-11a3-08da12173785 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 06:33:35.2611 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jlzYDl19bJqoL/S1K7jGg+nQhBMAO4wZ+rswN8T1KTee6R2aYNKX12y75Ij+OWndedpO71Y01fB8I7nkgTgX1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3130 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10301 signatures=695566 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=962 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300030 X-Proofpoint-ORIG-GUID: TyWzHYmltIDt9ticOuIsZ1ya2WbU90m5 X-Proofpoint-GUID: TyWzHYmltIDt9ticOuIsZ1ya2WbU90m5 Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: si-wei.liu@oracle.com, eperezma@redhat.com, jasowang@redhat.com, eli@mellanox.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" vhost_net_start() missed a corresponding stop_one() upon error from vhost_set_vring_enable(). While at it, make the error handling for err_start more robust. No real issue was found due to this though. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- hw/net/vhost_net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 30379d2..d6d7c51 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -381,6 +381,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, r = vhost_set_vring_enable(peer, peer->vring_enable); if (r < 0) { + vhost_net_stop_one(get_vhost_net(peer), dev); goto err_start; } } @@ -390,7 +391,8 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, err_start: while (--i >= 0) { - peer = qemu_get_peer(ncs , i); + peer = qemu_get_peer(ncs, i < data_queue_pairs ? + i : n->max_queue_pairs); vhost_net_stop_one(get_vhost_net(peer), dev); } e = k->set_guest_notifiers(qbus->parent, total_notifiers, false); From patchwork Wed Mar 30 06:33:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 12795532 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D377BC433EF for ; Wed, 30 Mar 2022 06:58:56 +0000 (UTC) Received: from localhost ([::1]:50898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZSIB-0000n0-Ub for qemu-devel@archiver.kernel.org; Wed, 30 Mar 2022 02:58:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRto-0007hQ-VX for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:45 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:10926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZRtn-0005OQ-46 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 02:33:44 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22U33v9M016596; Wed, 30 Mar 2022 06:33:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=m6GCeEQu3gXORb0OmoxH83oO/Sjo+X/p6VekmR6QOyI=; b=kEVbKVkLGHvi0BN8618m7gK3nhOxquuURUQf2SoBmskzA+pvVNrht5H2Pz2VIxMfaXGV 7yTp9sTdXbflkZ1O873hKoYAYQhqPJdtoRSmGxhwa5bkPHhaJNqtdK2nToHeokBZ7YHq LrtnWhoxJJCC7xfm50GtMvWX5w5qM3JnM5fzhZZ/LVRdEOfl0A8JiKHFva8Ks5aOM5Qp 8CnPF6GB20f2XffYeah8xkvo1nCqalMjNM7EFeW4gJiNiuvu9KpK9dYsvgwofa4Nmeld +GJtGbbMYayxZtZw1HuKC7zRa78a7yewJU1+mTiu6XJCyaP28t8sjgq2aBxjSqyucRfi OQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1uctrp2r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:40 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22U6JEOQ016506; Wed, 30 Mar 2022 06:33:39 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3020.oracle.com with ESMTP id 3f1v9fk5vs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 06:33:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AXmBNWixHZfAjVTq2vCbR1nMbvs5fFgQoIRIqm5PMztVFVtD4YCr42JU8RP1+JmQ2ejLOnKJGgqKWqQa9BDcQZCAs0kKGGcwlUVYWAoWWpX473fVzlG1FKyylmw4YaMTCBAe+l0IEOSlZLuBSUKiAN5P7XcAaNpoQHfJg/q+F7QgmsbovZoJhQj2wgyb8uGkecC2wVpdzb3PEZoUO+RQ9/usE+JYje4gPbjWOv8NPdgfmke33xu5H2qAvPqURSPnp5/kZUNc1fubScukWq9itFd0/SvAvyihbuGJQ6aSOzII4CwFkMna9oqLp3W6EBOYGFEa8MmVrTWvk0Mpd2uW0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m6GCeEQu3gXORb0OmoxH83oO/Sjo+X/p6VekmR6QOyI=; b=YefoFfuNp0BwZWtuOWUcqlOV1TyDtKJe8mi8Qmp6idpH1cN4dc2HRuqIrreXmTdAGm8swNKfGJjnUQTLhYBCcAaUFszKYNJr2Bj59LZzCAIe5hVECNZU1PBKFViAboySFjIkLgDr4fcQd8crWGvUmSmMe0QVKUW+9aMYWWMaYaVTScNFCqOqColU3TC2xsMxvSzbnhb0+4Z8dWNFSRHi71zuMxqovUh5gbwyKuQJT4hKOFxIYQ0FqfhejWYY9pwpjPxxSrISRwTFMtL6NvrFxOWw2CXdoSAPCLcChkEK1VAMcgUJZs4aYK+piKD+bXm9RWoGzJgybY2P0182TiP9RQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m6GCeEQu3gXORb0OmoxH83oO/Sjo+X/p6VekmR6QOyI=; b=bm4oEeNGnjrSqDnUKcEOps1PkgvGfBt8917haFXn4iEgytc0mB1KoxkYUe2e5FfY1XIWTYCSMSZGzD1YnARCb/Q5FTbe2x+lXOzzw0fCSy6vX+zZoQgS3psK8XEjhQs6WI28IAQ9IoRMMJEt56stRgW2awiF1Q+PcIyV+GG77hw= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM6PR10MB3130.namprd10.prod.outlook.com (2603:10b6:5:1b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 06:33:36 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::e478:4b5e:50a8:7f96%6]) with mapi id 15.20.5102.023; Wed, 30 Mar 2022 06:33:36 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH 7/7] vhost-vdpa: backend feature should set only once Date: Tue, 29 Mar 2022 23:33:17 -0700 Message-Id: <1648621997-22416-8-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> References: <1648621997-22416-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR11CA0006.namprd11.prod.outlook.com (2603:10b6:5:190::19) To BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 093d6841-a77d-48f0-1a64-08da12173833 X-MS-TrafficTypeDiagnostic: DM6PR10MB3130:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6W95GADPyhc2t8n/oawz5j2k7MAOdHNGftrAXgiZ8E8ddmjv3fiKnROo73cZ2LLhL6qax0IFZreV2sQz40rg57qg6k3/PEW9Cf3VJp0hFoGWjZPJIhQMd9YXrdT/4HE0OIVjSdy1bCWEneN2oiUskJga41cxn1nl7ZhgkJWtninTPt3bumWcItteyV+YdDhSBmDcXM6BahX3eMfZXeXZtKXIjxpXeVIC1S2ucJtMSB6GsVFVk8Vcy08snW5zOGwvmwZUzHpAXlrPAex+H7fSI8PLXO66Ak66b+EgiCda4iwvNKbDnWsKMOo6P3+4jxRe0bR0/g7jAnvOJt4Zoxr9Lx8Qma4slDJQ8lwnSpSEnjCBQcInn0UKjmVlf2IlzquFVSL/eHMr+3inuftoNW+q5a+szMulRwmLmooSyQc7eMcplpDAJBKG9e62+vvHvF0YPm1SfxPyWrdfgsqWZJmeex5uKShamDeV0myQX2yN5vCLurbhWHW8b/LXpyvVhPLJZB6P1jP/OOAm5jkOOdeSzhP00DMTSpSV7O5rM92IQV1NSrWDHO9qKqKinfIwm6R0AqFoFaKHX1GhNihBu0+rwLYG/+Fi2jACgAyK4x2jSlF6V9Szg6Fd6KH7vokfyEtPhtZMCyZWl1qTcuQmp4hRAV1cq7ZRzADcnEeQ1kJdWuZPzpGWvKv6bMkNuIn3xbINUvURTWdtqHV7sSqKpNFvEw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3287.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6506007)(36756003)(2906002)(66946007)(66556008)(508600001)(8676002)(6486002)(6666004)(6512007)(4326008)(38350700002)(66476007)(52116002)(38100700002)(26005)(186003)(2616005)(316002)(6916009)(107886003)(86362001)(5660300002)(8936002)(83380400001)(4744005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: muKTl8iOojCEqqYZMHz0HiiYDjhjwn0CPJaOmafNfrGCO1gEn7jiU6INRGrhTRJRbmT5j6pLz/y3M1CcXP5vh/fRYiy7sn31GmYP2tAZGVlrCp5kfy4LAmcG/lXKzmctDgUQIhUChc+D0dMUl5KaM0Z8k17ENErEIjPmMqeqURNXHtMGgwSxv8Q4aytYP61v9IeRwiURM1npImLaKAFb41Wgsibgj2uChVPVZSkJaTEpy9nFN6GQbJ2vm/jjOk129R4H66pgZaiY8CkXL1j46arIr8rcEZRNJnMhhqsSqZUalwtY6jA4PNcz0r4PDZfVFS7Tp5E7rgSPIDNnS5SdBozaiGWHpIhCOj7s7hjUAgtO0QOl1MYTLDjFVyel1kLzKxweb8x4GAjZ5o6Wb3Vp/WsFseOakk+K/6GlI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Ql8ZWP3Y2bAlXWxVxIt2/08nQNsG1BG2HGGnw8rHyN5oNamkQ5wGSynDw4Vw1j7g626E27AdBd4+4sdhIjTkxKn/Cdxg1/kIKWAWs9B4b4cUttA2R75TLijTxFwa4XzUm3NP9HH6ZChTyUtTafu0SRGde3MPo6aeiRVm3DOppSk1cO83VhSjV+9Xcn11Pz8xEKi8skUFf8DgMsHBJRt+BERmTPOG8tjfy/GrcbRs19M+6100jNJNDEawKOG1OgSQ+SFi+aAU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 093d6841-a77d-48f0-1a64-08da12173833 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 06:33:36.3861 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hOZ1jd0lN3K3Bpdom+AA0yrTkMUUoBGXa/bOvhgKe0X3qsolcwa69gKPYm8b9JzOWJa6r82rtWL0rizTfqIggw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3130 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10301 signatures=695566 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300030 X-Proofpoint-ORIG-GUID: fIqAnHwXJu1OXyn4iHVSRwnqj07t8LS_ X-Proofpoint-GUID: fIqAnHwXJu1OXyn4iHVSRwnqj07t8LS_ Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: si-wei.liu@oracle.com, eperezma@redhat.com, jasowang@redhat.com, eli@mellanox.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The vhost_vdpa_one_time_request() branch in vhost_vdpa_set_backend_cap() incorrectly sends down iotls on vhost_dev with non-zero index. This may end up with multiple VHOST_SET_BACKEND_FEATURES ioctl calls sent down on the vhost-vdpa fd that is shared between all these vhost_dev's. To fix it, send down ioctl only once via the first vhost_dev with index 0. Toggle the polarity of the vhost_vdpa_one_time_request() test would do the trick. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang Reviewed-by: Stefano Garzarella Acked-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index c5ed7a3..27ea706 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -665,7 +665,7 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev) features &= f; - if (vhost_vdpa_one_time_request(dev)) { + if (!vhost_vdpa_one_time_request(dev)) { r = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features); if (r) { return -EFAULT;