From patchwork Wed Apr 27 08:30:12 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: 12828463 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 5F74CC433F5 for ; Wed, 27 Apr 2022 08:38:15 +0000 (UTC) Received: from localhost ([::1]:39694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njdBe-0000d6-9U for qemu-devel@archiver.kernel.org; Wed, 27 Apr 2022 04:38:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4S-0005Gv-Dh for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:52 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:51826) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4P-0005vX-Oj for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:47 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23R5nPpC011361; Wed, 27 Apr 2022 08:30:43 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=/0A77trSN3lAKVdjWMt7Tg47i3aJyYUsoTLxaQgRcJc=; b=O3sk40S7HC12YOLEkoI+ECrop4oRt1Kph9dQ10XSG9zyUqrJlHhxbsOePv3Ulc1+kq9c lsrfAQKoAO5vHzUxxDSWgfs1VslIgxPNBlAlOHWEBJhgDkdruA1AEbkjVJ9+Y2rnUtW2 qmjHa0pjKtbJKkPY4w2ZfGZs938Q8Pp/LEj1FTlb9xBv6dsPH4YjW4IGWuP3yi/e4Q12 LYckqDzl1rd31ffMdMo+voGNlXtEwrO0DEUmkJk+7jLEG6z3Emm70tr8T2GtE+v0QF52 eobeyfl9Poa61AWEHybQtaE+x3Pw58fgFXvqhbLFs1PcKnH5Vwm35OJJ1cwh4J6n7wUx Yg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fmaw4gc24-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:43 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 23R8B8bq028095; Wed, 27 Apr 2022 08:30:42 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2048.outbound.protection.outlook.com [104.47.56.48]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fm7w4b4f2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DZzzX0QS4rk8Tla/px3MDFYk1tnnXTlwvCjb71h2zM9Y8YKnY0FY9PauXHDJOXp0zt6yLE+hIYglkDa/3VU3eICx1CjlgjZfg58ZgW6Z0/9DYIKWcXEBUMaVL/vg6mxM1IkgKGb2pYRuVtQqcgTZ4HoFmoI1E5YHqQXUuPV3D9uEnmjhfYoIBj4Q3MlKZZEd18nfZ/g+T8yCQ9bY4fBdPWRa8g0i8IMTVsDjgvrM2FPR5YE1zDn/cMGQqX6NuhiFzD0c+pBLr39Sf/V6CWOLE4D8tXfD3LqPdW7e/dnrhUNhWOiyxIQgPhKGWjIK0HJ2S1cgjYLg2/nffeVxmm6HBg== 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=/0A77trSN3lAKVdjWMt7Tg47i3aJyYUsoTLxaQgRcJc=; b=OBaPbPAwEWSK9867Hz2915bijZ4IK4BQi8WVpF7Ta85X75MTuUuKn6zWqdvG0NLu2X+cBsPWdWw89h73kcEToaJl66oDxpz+u8cYVTw869x31B6daQ2wYbPCdUgznIg2LiKbvEM19JAhP7mp65d81STyfF34nNa/p+VfWNlmQCOOChnwsHzNRPvAlys8WWLLM5zGnQXAU/37zibKkTJ0l2ZmiZ3cYRYEPiINnfGK9Y6Rl4CmEhKIS/x1yPUcxASCy1QVskaCJaUfdUB3dKp/hkMVc099ROgMGRp8wjK3k6cyM4XTIHvhumjmt9p/ObZj86/cmZTFuD4Oio47LFEOQg== 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=/0A77trSN3lAKVdjWMt7Tg47i3aJyYUsoTLxaQgRcJc=; b=LWWw1AbV9F/ycixt2s91r7TPQ2dtZbpfmX/foPyRMv+hyUW9XIW6cZJrkWansgVVjFnphQucXG1VhWlgOLlNytcN55QHBJnYennN31IUhO5vwSnZ0zW3qS3DFEqa8k2sBH2XPcstVAmWwmLqkMSoL5+bu76WdARgnri6u0TEe64= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB2007.namprd10.prod.outlook.com (2603:10b6:903:123::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Wed, 27 Apr 2022 08:30:34 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30%2]) with mapi id 15.20.5206.013; Wed, 27 Apr 2022 08:30:34 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH v2 1/5] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated Date: Wed, 27 Apr 2022 01:30:12 -0700 Message-Id: <1651048216-3365-2-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> References: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: BY5PR20CA0030.namprd20.prod.outlook.com (2603:10b6:a03:1f4::43) 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: 45efa4b8-c274-4b93-ce7d-08da28283294 X-MS-TrafficTypeDiagnostic: CY4PR10MB2007: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: TjrkRI/I0pg+RiLzQO/CyUf4cF+Osa+ZucDz+/qxmODEeex7+jCjzMVGJXUkY8juXO//MoBoy018bk2kL8xcy5haG4DMPPfob47rrow+K6UJaFh90BdHpjLMLIrSkcP5f1/sqZEiPeJLeqPhV03xzcRPepwE7vrnJ00JPVfhjkQ19dss9Uv22XQD7xZAD4Wu7m/Fcd98+8A48bCUM1nCNctGBMT/BqKCx7wRloD7mqTSLCQ6I+WFr9svv3TuvYvruiyjPBl2ao63Xq5KBVwOSEkEv316J9o+z0BzH6KQFViHKKXYF0QbHA6Kj3MiDKbxjFxXLa2iSQ5A98coZuliG4F7B7lRlHzpV5zyoOPWIo5fS/GhqlB2/O4l48fpTKHnlA+CeEXBI7qo5ia8ENAHR2BoFwyDxSyAe4T0niP4J8Pi2tFSOKi1foQwWzAkFIFjTdbYwHyTN/HaZLzsjLPj1I9bVJDQPrnZYbBZ7LshuPIrM2NwDYXwplcE2TqKKwW27epoTrKEhvmteuvONRaZYag1JovBD0UbFfUa67GCBvKMkI4+pYOiIZjbuAVAZIgDWsQUaG9gvhSLQxoQsOAICvN8sXN1cIJSq5U/9MLpDLsNIbUXrM4PP+J7QRPYuU7Er5L3mc4oLoKHosBeWzR53aHg+DpEM8/ol12YwQGMe1XOYHnbp9G8aNh1oyKhV3hqxnpNWNMB/iD8UNSYpIjk5A== 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)(38350700002)(36756003)(2906002)(316002)(508600001)(38100700002)(107886003)(4326008)(6666004)(6506007)(6512007)(52116002)(6486002)(83380400001)(8676002)(186003)(66476007)(66946007)(66556008)(6916009)(86362001)(5660300002)(8936002)(26005)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tOxNhYoaS7eF9iLN+1Bkd2pvzszPWu8rJNCVD0S5+tWpQ0spLGWbC1hnDKbdSCAtGNSaWKLCsbAvfUQy0gfqVEbkl071JKkZ1CAXfut+qfUWPcFjnMpK8zVfO4TtfSQ/DIz8Fhe9AAFGMQ6jgAOuvgzgSg6vO8LIDYplXCRNpFdpjG2EnCWUOjnXptgEggw21k4sxfdO4++gQX3W85uHfQekxLlL0HSTtXtFbkDDF6PQViy4KMrLQdxwTVop694jZAld6mtRPW4tnP9PeGsjgLrnuNbA4h/JD/pLo9vIiX6a3/ie3jPHxFpdZ5rhlGdyjGlxSG4nIpUXNegF8p9ewDUoN9d8TIM0AXZwOa98zycf52T99kxzj9KkUPfBLwksD9DovqBqeElVkuYX+bliYg/tOm5FH1mTGoKzPO4Bgm9HdaVWbTaEOlwcwAKAqnOzjb1PpgGYL4aZ+7ekSNmAhsenMGOz/U0KCkkEkhmKjiaxYL+Tn5bhJtbSXWnsOOI91RCDO+lmBxiTB4oEcKoSegFLAH/smWdv2cZ6dbdPXRE7RjILzJafvftECEBVW733Jyd0D4YxR2B1Qs4wFM/ZosayK+1Qlo2cL/VHGFjFxuI62mcheP/46SdKDEAVaPCBW9C6JAtw7NUwF5cY+D4p3qAJWUaJ4jTC2Z2cj+CHdetfbM4McqqZoagG58K8tAjC33mo90dck7z8i0TprY3iedESgOjlofrF6UBDOOQkVdlqOt1s483VStGo2LFlanZmIQ9BzyvZEi77Co6L5K+PqygNmll2koEOLSlcQxutZOc8SLS/Vml4D08YS1FonUCRVY/OZXU4WM4YUTfRL1CQWIJWDLnDbguxlxFRuk6iSzwr41KRNUbhATNvAK7vi3en7eJLsi9eWQr/aolIQHpBpS9wy48FiadMAOxl5lCriDsf3YILk0Ccpo9Pz5oOpjxmpqgnk02vRY5pDdyAUYZA8bkU/KYE5lfp09Nt3RSpvt90cYKp2xR0VkSzp6e96gbbmw9htCah2Y/9SBpdGwHTVfJt6tGWVYvKmPU2nYoNDGYYC/zGmqe/QYY7jCbcRstFAW0ufAuMiuFYPIEjkvOYc9NS/G5rL3jElhXHhte4yOXvR3WjRGZXFs1G6G9PpvAsrBqfYPDYcc5FozNS0hO9J1KqB2F1VFejIjn6GTjNuKnEuUx6zZmFL7MPkLPuTtKfnka8x473IOl8atvcXxviahjRhw9n2KCDdnql51jqGckXdzFoIMyV2v7obcSFS6ako1ShWJiutLSXbLqbQj98Dzlcfqa0plXUQv4NqzAtn3xSy1SOn9TNfMx/xn2uaXn1HPdGJG+Kzqg44pAQxpOIJcUrHCB8QWgUloYPlW6Sx7rVzVYrMkZErNb53Yg9/4UBB0VnKAxlt+SQMUpE6Y0EvI8ipOhB+5SqLcOGQJguZyTjxUNYvBBpBO4qg7LRHgfOQ/e3wiNCrFBxuZRMWqyMxSVCDF0/VaEiCKHqyDJNvIcY6zGMDk36qOc7PDeqnDkL3h92j0UeFfD4EAs1ws870pBbXejlv1C0poPvqXf0N6o7jAMhWJZWwWdEXxQ6Dxry+6jMG+a3WFTeBxONzItcRh4LLaXmBew5f3ON2Wcw1e2ibsWmxRa6C40F6tQZ4tdi0XsmkY09Sw/OfzSPtxidq2bUZIOefNMnbU9vDa4lb9TpkfjG6i5y2m+7gB9aQFnJ7i+A6mz87ZdCofrroJsDIGqo2US51XBRp1DVP26puuA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45efa4b8-c274-4b93-ce7d-08da28283294 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2022 08:30:34.0481 (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: 0P+0HEMxJIFU0s9oBlwG59xI21Nj826gq3mBUQZNvljXD6zY//uPOeIDX3ybq8yzwhlqPh9YVVZEPWbKu0Dmrw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB2007 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-04-27_02:2022-04-26, 2022-04-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204270055 X-Proofpoint-GUID: MQVPGkb_EYhMzr3E6eIAsjw8Y-8jx8oK X-Proofpoint-ORIG-GUID: MQVPGkb_EYhMzr3E6eIAsjw8Y-8jx8oK 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, 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: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com, sgarzare@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When the control virtqueue feature is absent or not negotiated, vhost_net_start() still tries to set up vhost_dev and install vhost notifiers for the control virtqueue, which results in erroneous ioctl calls with incorrect queue index sending down to driver. Do that only when needed. Fixes: 22288fe ("virtio-net: vhost control virtqueue support") Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 1067e72..ffb3475 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; From patchwork Wed Apr 27 08:30:13 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: 12828467 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 63D16C433F5 for ; Wed, 27 Apr 2022 08:42:31 +0000 (UTC) Received: from localhost ([::1]:44252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njdFm-0003w6-41 for qemu-devel@archiver.kernel.org; Wed, 27 Apr 2022 04:42:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4V-0005Ha-US for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:52 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:54712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4R-0005vl-1u for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:49 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23R63tYk018591; Wed, 27 Apr 2022 08:30:43 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=DspXsKZNXmo2/rCGCBj6kmSyCTVknJ40KrJIjBAAXjI=; b=B+5TsiZb4RYHS2uI/KKKgT6qONQZxmgdI863G6XO5L0llTcPrufAlE1v3UVp/8cRWmdI rtWQrAxUOBlod0h/ho6W0BnPSaNReODM1gi6WE2c8dlbakjrJtXuwnFWS3Ykzbaw19XZ XScC/D6+rghNy/2ltbcWvyDvYQs2JqKfP8nZ4c/MuTOhVUNd9YmFy5mTJqo/LBNW5pe+ HBQnsAlE79PSiKTRQ8umpMTLaemM+KpRso8xH2Xk44yFcwv1pHC0g5XvTezBFJqt5QOW J0d+5AH8/dKFUIlRVyjZZf3+KULMcyqsz61M9LRW4A5kSfGsXI/89AgFW0jnHGf+Qsi8 Rg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fmb5k0b0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:42 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 23R8UfWA030459; Wed, 27 Apr 2022 08:30:42 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2048.outbound.protection.outlook.com [104.47.56.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fp5ykf12n-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g1EfaISOhHI/psgPO0uQngeBiZBiXxmGzsJnRpJ1vNmiX8Alxz/im+TTAuVg6kEgzkiI6hEThB4dB9lwprKSsCbzy/1KLWMhcJLnEtGQjMiiIttfAvwBtWRFyXryxetL46XwbbzZomZpwUpT72XRtVp9vVfwKwyX8jgyVo/7fcxiFQKSdvAQHCQ4tlhGe8jFQFSc3MEazxcpNuF+xDykTVPdGtedDPR2/o9VlqHDCq3gEhcKloq+XM1z8+OlRftuUwadcLo/Jqdv4KNpjy95tYmYjyn0o1Jig0tajUIGVAY1tSZUDAVjm4g6ef7dbYWhcvPBL71AGiTOQolRzTOiig== 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=DspXsKZNXmo2/rCGCBj6kmSyCTVknJ40KrJIjBAAXjI=; b=WqOMzdfGjN0vg15CkZjhcoOwziq9d98jRmVIWCN9FxhkO72KLW0Jhr47ege5Z+ufBEwSVrV4gOh/20/ZGBz9i9XqfUGkt4bI3y1EDl1zt42EVfmUrpBvT97IpNW1TjRNsgKHohnPhZNaoEcIgu8lHAerU7o2RDGRPl/j3S3av1oCsEV7mLWcZOIJsPwkOTpa1XwgHvHhXeCsxrzT/AiFgWgzwGkaF5hptramnWhYgCIMTCv4m+O06EQXYF1xeJirEnXIMs2iQj6kdwm9/zCVt5P8vBFUSLfpwuB9ZAYRROff5hqGfrTagQO6dZvFAj4C+tLputBBeGt++PeVyozJtg== 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=DspXsKZNXmo2/rCGCBj6kmSyCTVknJ40KrJIjBAAXjI=; b=gFb/JoyzP6Kb7QyfuavtMn7ZnJeJCt02P+oBLG5dXBcc9lR3Qo6vbGlpNRCTYWZCz/xSsg5/3FVjctDXzD9s5ZK6rRt+ajylvAk40HNnMbcQSDleySbWWTS3qsSQ1/zBARCRe9bY96m93+iYNHLEIU9bgppeWFQA70UhpyaXPds= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB2007.namprd10.prod.outlook.com (2603:10b6:903:123::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Wed, 27 Apr 2022 08:30:35 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30%2]) with mapi id 15.20.5206.013; Wed, 27 Apr 2022 08:30:35 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH v2 2/5] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa Date: Wed, 27 Apr 2022 01:30:13 -0700 Message-Id: <1651048216-3365-3-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> References: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: BY5PR20CA0030.namprd20.prod.outlook.com (2603:10b6:a03:1f4::43) 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: 00f08e0c-700a-4f98-b067-08da2828333b X-MS-TrafficTypeDiagnostic: CY4PR10MB2007: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: oZo36sGY8siID90RjelqvuknT8fAjQmhewgPP25WpaYp17RlmbAjQ7rqVsW/HVPrvRmI/HF7JU55w7cYw4/f7QgvBv6Q4YEeyctsK8TqVk9OzQRj4Fnnz3FRhrrN7Iy2qUwyU/mWTdosV22XOmZsX23j1Fnz1DAzrhdvBnh0w2xMTJvHOHzbgQq+QKnBSwOfmrzziAKVidtNdrUqBbNVN05w1AhUzXdQdbSJz7VO66/rAyPVav7pQoOlx3vznCPpim+b21+DVVq47r+G+F/99vppSEnO7OSwEfJq25O0aBlNMV2IZ5SG0m1rOq5SIQmDnkNf3ftIEXn7K+Wm6GLvbdrf4ztWURx3N5WJaS9qqg/CgXbQBhexm49y5cNVDeLSBskVxFtXmJ6mBu5W8RjkMnrGDQQRUVACNjFw9QJMlSKoho29tWI/XhJ2XS6i5Gqyxvt5kxkKTqnbuI+yDzU/GPDNGTWdihhEKu7Dy214TEJ9ZOLd6YMOlHITTjhAvi4hD+4CCTmoETStlhVDY9XxEWr98sOD57EsUjYy8OsMVCO0AD25xUvG0iCR6m3QFN2GFwrza9WlLB2Zm2qRwWMpZKFE/XqxCklqp8+F5n/z3FyBPtGhSL7F5xTrrIMbiwky5W+t5CeVRm9Y+rsHOb5icc0zzqueNLBhWqndHnY6R/sUm18wPsTDECwe5i3IXTETDDLVtCTE8+CP7qIbkjEB6A== 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)(38350700002)(36756003)(2906002)(316002)(508600001)(38100700002)(107886003)(4326008)(6666004)(6506007)(6512007)(52116002)(6486002)(83380400001)(8676002)(186003)(66476007)(66946007)(66556008)(6916009)(86362001)(5660300002)(8936002)(26005)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WN8wkuGV1a0e79fHlgbmzd/3es3zR5UwT91GQk+UeFdw8Qpw5+w52+y0hy/aWIn0PGtm2MJBetNf31n443tUYG1VL5WmWD6Q4wA7g+dLozdqvgGI9MBUtq08QuIFzNl1pKFypalOlCqgwjQelyJeGrL5GsN6q0sLfQ9VJLENzgEebdoA679dU+Htl/+uHPvi7FafECV1BU5Trqfu57LhO3Y/9M2vd8U0bXufTqQ6mx0lkmsI7pIYFw5clhpml/b9zyBQfMjobgrBwwec0mk4rjpU7dycQkw/v1eBL7HNmDMWATU0pqYt4baao+P8cN53ZZePANEpqRUkHxJ8HzydH9EM+A/rR6Q2eLqRVgpm6NgneIdZGnw6dO/srUBfhSlc88U7yF1g7veMADJpl2SuRnI1hwSr9gmFHgyqMVVf1MUr3MLmfKY6TgKkQvZWqJxHQCQYABhl/HnDDLRseQl0l0prYyBIci5Dw3B5/U71RJfOnUlg+tP8MT5iUEQ7UKeYxhlp8xWjYexq21MwNrntLgk+V9M71B037pQ4KWXxxWsPAk7DGWk6tekJnSkgsEGP4lQ4OGLDxoI01jtToaCpsU6Kkjs0JFBEIUrTfWF/B9vAOKYenbNp/akC1BtH4XjJ5c49nCWoRofa8kyAYrT0kkIkBB98NRd+e+td0u/23Pm9swBEoG9tAso1emI5EBA4F597HqGOlT3lItzUjrXQJ5NYK1bQUaz22w5EPqNjfOMznG7q8C+zyqYvXXtgGywKx+NSSQ7C/Cp9yvORziCjz5IFRvMivHtO234JdjXPcJ1yFtfpivW8/YudJR7tdG5miSisy5kBa7HIg8W74CAiuGnFB3Ob7eL4NrI1dJWGL4viFdHQstaEs1EaSqyp0qQVON2Wi6CXfo8x+d5tyIRxChScTT2ByXOJT2GzdxeG3MY9yhQC950xM0UpIIwCG9ti42qhKBoOlhoLCl13Ec/Fjvf3rGZlts7LJbBacxUwd4Z+KXgn9LJkLUsmzMDD0T+DtHWNYQvXfw0001n2IoyWiKoKzGPEez0PRZofhxsuEewL9kcUMFEdkXGHFOrqXJOgBhcvDpeKJ27Vze6z6GUXRBd3d60O5yiFo1LVFpVDRzN2v7Hf2rNwBLIaj0+kXshXpJqFEpy2mZWx/350nGLZavxfvDfxbyPoxG9Vu7IBL5jcW0NSQ9BuVhoxFtSdcLHjD4RoJxrN6gI9WVDaInesdcg3kNZ/fA119YbTGbafK8cOZA2Z6Ti0JBGMZAGq8JyVBu+AEXvPBpXeQURhtYp2ChfpxWmI67kDYNIXkI/B2mjKRNXXqg4Hz2jUAuegWZr64dYtCgunaCx0i9dshSDnR7gINstY2zpkf7wOhiU3kN40UwoNkJEsxC98bfhyo3d6TJh9yIUEllKSDPW7J2b8n9RONf2FnDnZaIDTMtu18vb9Y0nb4+OGFjnoyYeaxnfCq4/UnP70/bkGYPiUc5qjfxGFi9e0aPbUanbxjaZE975tatWy5F6x6dHPqjFdxl6IgVghmYSwNyFZ45HWzlEUi4TXYiqt78s4oJG3gm5uGrV4ko84jy6XS34nkmursZfpgT5GFeBmOPicr/i+zx+JO1ZHEoG0K1q5eK4M1qPBfdknY5WW8QP9Ap3s8rq4BXP9bQR8UmeMy2FuxkhlGpL5GhhnULCG7bXFY2hIfRlFRh+yjdXVXHwHTsA/AY7XDg5rgE6GLi4jX9Npugtj34qRy0gwhj0gG6qhtlzFvtXwo5E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00f08e0c-700a-4f98-b067-08da2828333b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2022 08:30:35.1886 (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: XW4Kbkw14CTh2t05G5aQ4i972m999ja1JmxkJOaQ3TQM6Wqk0cq8p0P+9bpN7C6MBsv4nDzm9ct5qGrcb1RIhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB2007 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-04-27_02:2022-04-26, 2022-04-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204270056 X-Proofpoint-GUID: F8TBjAg4OSyYiE8rUzYUh-y-ojQUGfCQ X-Proofpoint-ORIG-GUID: F8TBjAg4OSyYiE8rUzYUh-y-ojQUGfCQ 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, 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: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com, sgarzare@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. Fixes: 22288fe ("virtio-net: vhost control virtqueue support") Suggested-by: Jason Wang Signed-off-by: Si-Wei Liu --- hw/net/virtio-net.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index ffb3475..8ca0b80 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3171,8 +3171,17 @@ 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) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { + error_report("virtio-net: bogus vq index ignored"); + return false; + } + 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); } @@ -3180,8 +3189,17 @@ 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) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { + error_report("virtio-net: bogus vq index ignored"); + return; + } + 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 Apr 27 08:30: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: 12828470 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 C9CF9C433F5 for ; Wed, 27 Apr 2022 08:47:37 +0000 (UTC) Received: from localhost ([::1]:51252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njdKi-0000QE-HA for qemu-devel@archiver.kernel.org; Wed, 27 Apr 2022 04:47:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4V-0005HZ-UM for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:52 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:54546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4Q-0005vi-UY for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:48 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23R5rGTQ018608; Wed, 27 Apr 2022 08:30:43 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=UH8ONQDqwjqYQ4lGiy+B4eQ6Ks2NSI+/jFWft0KaAxI=; b=Kgr0YtxpIFHgUv+t60J9e3AJn4tl9r68KrD8t7x84ZJffa221mh2jGJTwlPFKlUYHP70 tLdIcqnDRsH7MEgOyoPLflqRNAd+15ntuJ+FUk2wIY+unuQdC0c77rzPdl3Q+xw+WyyY TLTQVoGtokRKhTYkpnt2yqcu4APmpTDNmTBFyod6OwHE/tsCDVEDPzFI56Hh5KUIzPZq rzLL/WfCkFU7uTGWlmL1SPYQ3s6fyBACipXUFMl44suSM3C1r/0G+eEhRk9fPzCJ9ZvX 90xKJ82PHiQ+7Uoh/EeBF3n7Drz6aHftRh8W4T8yZ+blSmRetCaFezIixX6aP8Fq6OCg BQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fmb5k0b10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:43 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 23R8UfWD030459; Wed, 27 Apr 2022 08:30:43 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2048.outbound.protection.outlook.com [104.47.56.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fp5ykf12n-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d5MJs5orxz4UU0Wx/zS9XbfIJOmKZYU4xjx1tb+QKXC2h61AyGPDYNTTvJn0DpPebiczIrEwb1FptLLBQAjqEDtjKFFttEv/j9dh2sGpzBFpxhmq/buaIKrDHH8T0OSD7YWhO5kODGHj4+lbPK8UPuTDpJGQEILUgLcaFxsRjEFB8UaxVXAIzggiMHz0R5PvhOczRf6bSkYN8zSM+C71bJ/fiIXi4ocPgWPrX+08Uo6NuerePE4ED/qmvHMzQC56qaziKCCuqGi//puepJndGfhpV16A/7809WUJhsVOpeWnMVRkgqcJztm467W7jYGtvNksfaQqC1fSXnzf/PdzmA== 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=UH8ONQDqwjqYQ4lGiy+B4eQ6Ks2NSI+/jFWft0KaAxI=; b=kuOsLLxRxGER7RI7CqQvM3Jflok8VZU+TDFaaoOXC7wUFetgMAJx+IvaofC8xUUBdMq7iS81iG9ASsjoMAefICd6JXoQmr1pmR62YBFH/9T8/dtU13e+Is3tev8QItFnAHB6B/tmDcvfA77LOclTUKeQ20cMXPQsC7CsqDpkJsU28rgtwa/XwOJFlTt/Mfh+8uqhh83ZNNUVOQfHS38/SZVTMDWvr24hvaKVGYbOfC044QexKtW8pVC602PWNkC2Yd2WVyKWE/L7xdeGlH+hqP3p3u462c9bLXWwt2Bk7fUM7t9aL6aPU3WxHyeQDVaUHIHO+hMDi22SMDpF5vKIXA== 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=UH8ONQDqwjqYQ4lGiy+B4eQ6Ks2NSI+/jFWft0KaAxI=; b=uvZi2VKYSv03sC2Dwhj/DXTs5TUYYLq9+KiWkQ14XzcrTNZnioV4t47c60BcRD3av5NSGv1tORMQovt9IW0vnlGoMAiRR3EG66Tb8QRUkRMglCDP+FPZ/CgBjDB3NgRXgzThcBfp/s0ktILh3xtdiWPA/UU6Ci1EroBpAV4ZOTU= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB2007.namprd10.prod.outlook.com (2603:10b6:903:123::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Wed, 27 Apr 2022 08:30:36 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30%2]) with mapi id 15.20.5206.013; Wed, 27 Apr 2022 08:30:36 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH v2 3/5] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa Date: Wed, 27 Apr 2022 01:30:14 -0700 Message-Id: <1651048216-3365-4-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> References: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: BY5PR20CA0030.namprd20.prod.outlook.com (2603:10b6:a03:1f4::43) 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: eeaf614c-b918-4d48-7da8-08da282833ee X-MS-TrafficTypeDiagnostic: CY4PR10MB2007: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: xqmmwTNCV1ugtSfMhYWtKnvKtASg0iJ2riswU5A/ET03+nrBJW/6xBTcGkdg9qGUUmxkTDm+/XAcbwmdWDQnzOZsl3eAfHm0aKsFbo46mtrjevdbJtcD9oPHi+dZlD7nDYS9scOQ218wC1MwmWA08/LjZWu1Za0Mr5IwEwzKLg93aoBwWSua3lOl2fJ71k3Qhx1cETvLIn772eUXgyfezKGQ/DhiqRCKNP3M0oPQwl7+Orn4F5bpW9sSgtt8svWlZEAUBo0LG/23g0cFToJVORvoWp5I8+tj8mA7Me4H/1zEQpMK/LnzotpBsflzL+jOx6B/HdTyy1ZfV/HBnRD9hWFJF2EuSH9GzRdSwU/QtnnpBe2sZU0wkduBv6xqfHTpZ9n07wx07E4ynOW3+gAWEcgZR6z3WxMPeA84Js1KtSBEMn0WKEPPn79Daxfj76griQKynlF5kW59S3uQGXgKscYvN2Q/M96mTVE/8AM3BwdKnz7wTvZuQ6iwxp7CRs6RedsPU4BNoOWwaWMpUWdxN5K98s26lVBD4xNoZGLiTeOTn2Z2wJ3Z/3hNVWXe5VqPaeFyXcFT0Pi6TDMo92gta9UQd37u+QLOxzMp5zXaaYYTewQpMfuIkcSR9AFkyc1OYiezEenXZh39TNnHTo/zTDtB3vP6DYDdYpQWigek5c5u8Wu7d20q8Zkbp26nK7cqKA9sRYPYnoi1JfMzyjAD8A== 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)(38350700002)(36756003)(2906002)(316002)(508600001)(38100700002)(107886003)(4326008)(6666004)(6506007)(6512007)(52116002)(6486002)(83380400001)(8676002)(186003)(66476007)(66946007)(66556008)(6916009)(86362001)(5660300002)(4744005)(8936002)(26005)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2e3kktCfI5bwC3PLSgZDqd1CXr7f25nV5SypX1voADYrBuX2JlkG1zdgCpLIMh4SJNcKzc9dLDT7ux9MUgZFoumJxsghxLaK1HDgt9s2/o908ZjKl/hCkn1fiiqzElFbZcsysg+dIMsDLkrkQUDcKKNAnQjmnBuL4woEDfLOd0eJo63WjO67+8sV4DS+eeE4IJMgu29lrv1NH9+PIwVo87+KVkB6hDLAfhvgQYXLXQh0kD2Gapadnv/n5kfY4No/HOVnjFefOyVDyJkMnrjUQxuF3z/mFeuTPxRxZzfYFIARcfJ/ctOL5aPqDvyPETqowfkgeaZ3nNELWQIJa7SkfrPMStYTUeNPYRy8laW+ADVT1L1PEu82dzCOTnNjGZGeBcwgz0JqDunnwUlL6Fo4f2t7TmvWoRBnRpV+XI1CjidRCxT/fGtCe7fdi4+kOshvVv2x1OqLlVgF+Mwd8THnw5ayjsbl5RmOqRGjQT4RWz2yUyYEtLHC669Ea3qc01I1HlRWuWKgiYM38CwIewEdhhM47Kj2YVg8w9DqAzGcQL4MbYDpfqYMjcMnFfEzjpwr2nWqkvVx6FUoZGo9vOxGf/4iDMP36OAWPyYq+rE3weNlnxfJ62mmGeU3dklYXA+m0MIrwmUDtMF2ox+55u06WlIfQxpcRnQxp8K5kSCWGh73dfLQojgjDbTCM1HlsDYxTAqi5od2FnvVx2RV80jAvHbkale4m2lSXzfWVf1HTt92FD1WRZMviuctS52bsVDeWCNtdGw4JD0HL4S4aXoUHrEx1U4Zm1X3PtAteDMVuk5l7D2i923iM80CWukETlL1Efn9jZcePHhS3uToVZ6U7BoMV2ns3Nk4MskItHTRkm/+jlSD7lQH+olwHzXIK3WWJWC+OhFy4AqjLrBvpeuR7rubc7CikBc0tNeQKeN3jwiXQ6v2FhjYAFl+qGwSl4nDHeJqCB+1mUYx7qqM3+bCRnZn5Kkdmjd3sUfOP2+MFfmqzvB6eWEFoF0cLG7lsr7UruqnETutYRJiOdqUMVbEE2/Yu1BZeiMrFahP1ZbD7FVT2SflgD+1C/yEUCYHf46N3J+PeWlrouaCW/CybugKSYwv8IeCatCCMn0fryR8Up3QyJQfSnqnP9mHSajMrRBEt39l0X+iqTcZ2s25xdNaOLzGTRFIyRpCW9rMSG5fmNt+KcWI9o604Wjt3B4KCXcq7C11kEPnDz8MWf+MzuFw5gltoTfUrJYHW31nruAXd3ugZOdYcl+mHDXOKmw6EPwzaNdkbD1f7Qjz4kJjebsDSGdjY+hVKxtubLSOEXO8LQUt+9csR1Q2T5M8qvRjFFis1Q8oXSnKwp5diid9CkpS2mHGnb32jxLAKdsmcmmQrKJ1PKDGcHfFG5m4AKG3Gug3XzcriS6Rsce6QPbqvawj7xsuMsmlJhog+l6J3Iw0pnE85eCcpN/InWG9ZYup7UXiN0UP7HsLm1F8FntadxQfZHeaZnSIi+Jm830JOs7r0ZSDrgVAs9V+t16uO9OskZ4yYc1fGSNfiYzoL6vfXn1mmhEEsXCpWraqyu9Uu+8OUos7nZHsnofLTHNhh+jB7F53cFNn6wjaRKVcGa7lZE4mtZi8j51Gex9ZBtR1V8fLJJh9bz4dJ4v+4GMxE4t9TEuvUVrWbN/Fq6g4AaaJBRzvceGZxBpi6rmQCKBZs6W2DvTvfzsGu1jcoh/0gpKKiBrf0dg/qSJBW2DFnrXZ3jOX8TeIxiSDT/riOb/NfGAz9pk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeaf614c-b918-4d48-7da8-08da282833ee X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2022 08:30:36.3604 (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: xduYlCNNMWubWNSGkqNAKGFuZyNWCT+8CAwOi/HQgsUUcNGRAdguZ5ZwwC3IPlNmQUtn3pTZGN2B9Gkwqs31pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB2007 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-04-27_02:2022-04-26, 2022-04-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204270056 X-Proofpoint-GUID: A2kMDwNtrwkUxdQrCWjObNPnI6mo1dsH X-Proofpoint-ORIG-GUID: A2kMDwNtrwkUxdQrCWjObNPnI6mo1dsH 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, 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: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com, sgarzare@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 Apr 27 08:30: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: 12828469 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 23A21C433F5 for ; Wed, 27 Apr 2022 08:44:39 +0000 (UTC) Received: from localhost ([::1]:46358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njdHq-0005Sl-4R for qemu-devel@archiver.kernel.org; Wed, 27 Apr 2022 04:44:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4X-0005Is-Br for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:53 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:57284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4V-0005w0-FN for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:53 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23R6q87n003700; Wed, 27 Apr 2022 08:30:45 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=4eBz8jXBwAKOkC6klvoyWnzOAv8yPwpTsqzeeAgeBf0=; b=HV5vixaLCPMyjEeOVsQnU7Kg4xPbsigllEAwbq3oHVxaAeKJve5ZD7fSGSg9yQ10RuXo phVMmb404/NI1S/9Mfsund0z12xTt68YsRI/Oa+5ywOx1BADBMMxhnf+4TY9Iap1UKh0 nsGWrkOIeadNO4y8dhTVCQx5DQvFDm3cGTb6Aigbz5UsBaGfqXcPpI4hVkHm/ziptedw zZ3Ah6ToAlcH9zuHcJ0KmWqTG7KK4kWeEl7XfjtH80m08B6QXUpGBnL3FHu0hrCwTuDi VkN4ia7VqavtSj8mklqPcUsxRDZvdyIKVpc1U0+MHPSz/gU+dyo4GTnJdk9g3kiT3OsN QA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fmbb4r1ax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:44 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 23R8B8bv028095; Wed, 27 Apr 2022 08:30:44 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2048.outbound.protection.outlook.com [104.47.56.48]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fm7w4b4f2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BNKgZ2K4+8idevnpLJ8lACcwluFIK0PkI1Ghp6+lyihSdElaVGRMp08krLawbb8+orcjbA6Nb4U57iFRP5MH+ye1diQ77d+0Qa+5owZaKiiRgoI6HRPtUbPBvXRhCIsTH4XYKPo95cIIDlQnYkj+OoyFi/aiRPGjzhm7EsgotFPFltgA7Xpp5pltAO23+4FUc/FYvLOSolOI1Q9BMgVPb4fGTGxKuiU6SEWIegqwUNu0v+vxF/scENAWLig/OhFpu11g1201MWXJADI+0g56PBFhCZ5+yOvngw37wOSApNTsxGORElR/3j2wv71CdeKhXfZZWCpGXrAuruxkNOfZTQ== 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=4eBz8jXBwAKOkC6klvoyWnzOAv8yPwpTsqzeeAgeBf0=; b=MrAS0Kwe87kU9yaXSu77BLeEPUteQ02WhW5nmUh6x/9EGWeAQYEATxWy3mpOcHAnh5QBuCcMckfFH6IafbKlQ65y/WkduiK1J4Zc2tTgIySyWWjKYIJ6RwndfY+5NcQacn/b+TUSIIJXAsEbeBuYaSqDB0fIJyVRH1jqQ7wMet/QpMajxzRTJ4FlZZH16EKI8R/fBjX5X6KDA8rkWH4+kNr9DwGDH5+TtyXALm0aYNrbfdb7NiYS82Gvu3Jwg/VWBHlTLoWqVmPVC0S72U1b1fwXrPNCBpK3qNW+IcCr21QakUpwTwo3m4EPdP/yc7Vob/AEZH9BQN01onu+HGQOkw== 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=4eBz8jXBwAKOkC6klvoyWnzOAv8yPwpTsqzeeAgeBf0=; b=Psj2jFprz6kWQJOyoXNn2dwrFFMciY4gK5nYgoX7lobSTqE999O5PlLvWRUYUXt1EAT9duxL/0Hxc6M0f24tmGZBUr1Oz8JAnXHim8s+NmJK1/EgIkflsTsP1WUzM2lRL8xvcvG6vrpsbJwjMNrvx9kdoBi8xk9WADA2A4Dg/Nc= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB2007.namprd10.prod.outlook.com (2603:10b6:903:123::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Wed, 27 Apr 2022 08:30:37 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30%2]) with mapi id 15.20.5206.013; Wed, 27 Apr 2022 08:30:37 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH v2 4/5] vhost-net: fix improper cleanup in vhost_net_start Date: Wed, 27 Apr 2022 01:30:15 -0700 Message-Id: <1651048216-3365-5-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> References: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: BY5PR20CA0030.namprd20.prod.outlook.com (2603:10b6:a03:1f4::43) 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: 2e6e7889-87fd-41db-8667-08da2828349c X-MS-TrafficTypeDiagnostic: CY4PR10MB2007: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: 89p/BhrHQouI+3xqGvsz2g+a3ZPoPkkZwlNHqjfWxYOy2h16VWSOjG7tPnGQvxlK494iyYziXWkEHxGhzslAlUNanbuQyctd6vXzLPfNCme0dlQOf5Xbc0KnyptUm0rmZl6z36bMKJNG4bqCITs9Wgvikq0jAMQ7Jji0celjhsaoN3XAsMtGonfcIHIIKQ2L8ih3ZyZQEQnLBXRwF8PzeGL72xtkA2BbiSVe0R5oTjU4NX41SAdPW8fLoVFjvQrCChCUM6cUI2CUa35CX+VxFzxsG/TAQTzv5hPx5LR8OfpBfBteslIAxd9lTQWsqtt/I2a+7WGae4t0yJNCdPi6JL2K9yEjIN2RukYZeZOSqFfWIptjEFF2w3MURbJlj3CYj2uwBlSW95Pe8Wc2NpQgHeodrMxEwKzyZw5Cs0SANiZ0bNfCPqzpJpbxiB5DRCQHcVizHlFCBx1OXFs55uWTUS2c2WHZl7u3Q065XwV6qPrXaxX4m3KlY+b5pmZZk0xvnAdAq/YCgiYzwC606u+0l7TgYfyNSUiBQVg/784hEgLyz9w8BEdWhduHUqDlXyKg6rPFT0G3Uw2tMXmTn4iKNsb60k30sNj1CnqvBTIaIhxC6G/cANNir70+tBZzmmr2Jvxrb8Z6tRX63anblGB10+HQGb+7pxdWhEItkwW8k0bTQZfRMtKcCMfmHmLoJIHelSExuTya1jIfSE4rYe0Rag== 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)(38350700002)(36756003)(2906002)(316002)(508600001)(38100700002)(107886003)(4326008)(6666004)(6506007)(6512007)(52116002)(6486002)(83380400001)(8676002)(186003)(66476007)(66946007)(66556008)(6916009)(86362001)(5660300002)(8936002)(26005)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k8B6VGI4OCuqJaZ357+zHCW94+YOpWE3gQ0I8ZkD/KO8j141eUaPnolli/z5KDfB7ieZkLO2XIEPtHsMiQbM1KFRZd0g+4wZOG8gmNetGBqxDaQt4fxA39gKawnqvyGSYgyNfr1OmGfPO2amMrlYigCLe4Z8+z89zc7YzKpo5Q/9rWWoOXgxbTAnWVZQRNf/wqA4paejfOd2agm0GYEJT7dmma+uD19Hf031JKqpY2qF506rDrTomme5rVJDGWpMbED6Hjx0F3FbvSyK4D9ZtVEH0g8YEXaOPiKlakgmU9bMi85Ozo37SegaMr4w117dyYuVyDB1aJPl3X0/CxlAHyUspmm3ShOfRs0SWP81FAnPofDmjNZYTL4PVb8LuP6su5LidDZDsUan5F23XF0zvuxvrRCILPKaBfb2Y9dDqKeuNsNsRBPiX95XzTCgBhq3Eng3y7Gm/cJ7eJNR4UMyzw/Ctzs1NE+kCdzHpI5KX+u4B7BAkVJPgNSm+/OdEz4UL3FKutHAEy1pdcFGaftgdUYfFkZY/EsKUpo32ghVeJQ/DgxHUhZvO+wwu7yV0PrQXtZywT1H3YF5yh4KFIpLaB8n2ZoPoRZGsEsXhWgwWV82SjY8ny12gtv9ujaf1oV+KeRdA6P8m9OHGXBfO26Wq125IoNn+/sv/Opa1k+AQlPWUX0sYNTDFRSobZDTjeSb3R6bgV8rRlWT5NU3uEFocwbGrMIIZdrRiULVkCi78bs3DPBvqc1Lz6RpkkgIt3A5EgkN1uT86EvrjIY5gaiiYJUGB6qbQ5RwJIqEJf0KrKV9fyRoS7OtPiGOq8+MpzewQbJL/fxAk0jFdKmxF+5/Tg2eZVPJ4Tk8+IfKeqnN1p+W5NmtCViR7GtYbXTU4/nUjYtJeq/5cWwXWF393UmtLufJWPi00IcXj+l/n8/xVCEXMS7opIYCJ5Fl02jhpK4C4Q93FJz87np8047IbyY68+s87u/vdxN9mddIg2yq3qiip4NbroVtFdY5TqGjyGtd0NNrzmHD0aipI9TLKLKpIKbAXLhBG97YLMA66KaCR0bCSQqFtLZxi2W6KM+H6Uu6oCiu2t71xPAyaGCffxqIbpG01mhnKe1cGe+88Guv/akU7jACNTL8EzfubPRjA+spoVzb/QOu3L2kCtsdgfmdMOJdvZlpw3QR+QeNVQzHYPlAnQgeTs7vUDoWTV8Qrer8uvITtPa/Kmtqw/E5L1Vmo9Kle8Tlh48nEu5To+MrupFptoh5LZQwx6SpVgSZ/H+l2XzJ5CrgyVjJ+xkfgJLR9iNqKoOka4MyIlKf2qREU1kyQFcqJs+5w2ituOqv/ilO1+RkEv38sBQxDf5+DzLoF+OtCWbUKUig4PycwDbTkx9A0au3NYczLdPYpqaARajpBZ/WsBqwU1nD8eqJ4u6VcfHKd9udm3wHT/9mrvkVDJw5aR1/qfpiklZKZfj5k7jdf5RP+kH7k57SPTs+sHgHos0d5mgOn34riKxLRb9us9zTsFqnFWtJuENZOv3MG6j7JeI4+L68yBZGIhtC6ryOHu1SCGY0u3rBSNSl4Osw4MCn+Jc+n/jK0xPHdapOLNSv9T9RZNrJkSgcOuACzaRb/tiobXozBHasDHnDDNjwHmmV+oYzjmwzuo7uPtw8wDZQ7uXOYw8Lj6/emnFaIfqwYKFPsMhzTCQwXJNZqbOYY2NwR2VB+a1DzxcYsq9CgnShwnx2HQVOW12W2/Qqf5g9LXF25NwPrgtT0B2xGAw9C1E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e6e7889-87fd-41db-8667-08da2828349c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2022 08:30:37.4853 (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: iZLPlqtvzC/FaLwQjIPFlrM9PWI3M+ntvoDBQBMZI1JopwW/dTQG83t6XWQTLUS/GbwXr+oYUc/748behEepeQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB2007 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-04-27_02:2022-04-26, 2022-04-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=928 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204270055 X-Proofpoint-ORIG-GUID: sriJ2bByb47hRjxpcRZvywxcOVXMJOob X-Proofpoint-GUID: sriJ2bByb47hRjxpcRZvywxcOVXMJOob 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, 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: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com, sgarzare@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 Apr 27 08:30:16 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: 12828468 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 3CE91C433EF for ; Wed, 27 Apr 2022 08:43:09 +0000 (UTC) Received: from localhost ([::1]:44816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njdGO-0004JM-0R for qemu-devel@archiver.kernel.org; Wed, 27 Apr 2022 04:43:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4Y-0005Kj-Vs for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:31:00 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:61710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njd4V-0005wI-KR for qemu-devel@nongnu.org; Wed, 27 Apr 2022 04:30:54 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23R6Wrs4003733; Wed, 27 Apr 2022 08:30:48 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=HCzqBCZEyHVXxyMcVDvAqb4MIcypJP2/pjPP2j94jpc=; b=te0yvzj0zsH/tQnVxte8GooNbJ8Z2WW2g9rvg1h7IOmNYtilcMl/ZxMthTjJq3etRAQ5 TTjfvK+qdFrbrBvqdRs5j6quGuFG/j1Bf5/V9fZ5kieGo/eFMS+bMzOxpOU1do0gsQ5J tPXtaGFcRgxUYvoaX6gZ6A7JspgJqm/Ea7XvtTOcgvHkWxobReGYCNgKEMXMFWxM2t7p 8IU147lTH2vB7XGK6ZwcPguOTSVXJXUeswVQik4siBdQVSie1YfeijZcFHMqxOOFRssK sCTRq72sPaPrrlFeTKY5Sm0UjUwkDL08LrycfiyD3k5mDWTx5QEjWa8wlWFwmJIjut9i 2A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fmbb4r1b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:48 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 23R8UfWG030459; Wed, 27 Apr 2022 08:30:47 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2048.outbound.protection.outlook.com [104.47.56.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fp5ykf12n-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Apr 2022 08:30:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dP78CARvcFv9cVAwcaSfqUH3WWfzmdoACw9zvRw2zpQrwsNJB4jom2t817nYDhgS0pv4cZ2hJE8tGQNDuFjrLQBeYXLCTrLbHCi/lsqRJU5cKWNsMXQI4h2EuqyuBf0y3GRjSY0IVYEmIjUZY2ncQpgqlD4CJknvW4/QY+B+jZxT3T1HuN2GlwpOJbQKukiiW7FzMXEQzk/tG4DY+ROJNX5A+asbqJbOrvhmntoObYSboEEUY6O1g/6+HCovNeHYKOwuQvFY+0Lzw4gflZZ4rG2C08dckQjpYdktMNgPEBb7NbkvBWDz0y/WbqNghOv8XEnNaBCiD/9zYRe9Ro7pJg== 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=HCzqBCZEyHVXxyMcVDvAqb4MIcypJP2/pjPP2j94jpc=; b=krKzkU11xTuLu/vbPWlTeWvPNSqU5B9D/fFwtXWJLqbm3ER1j7dvK0RD6B+0rm6zmKSpOpCzcoLNq3WQkEJZqZZSYqY3fVUUJxB+M3VPN3LbSmtBLKJPTYZLymkF61ztagxWY5RAzsXaiDtMZiDJBclS6xCM/1+kEJps9mDjk6GmRH7LTfQR4iEYBL/1PoNZyxV5VgjiR4mEqgF98yszbzL7c+Dj9Wp8PtNhF0IVo29xscVcTL7DQAvfS6qMyfOsq6J9TjB3x6yWA020JqwytIIkU6BXWMWylDz8HR5/q2MvEcoGoGPGsAgqe+VGhlKeRG7dGwJTlIw1ownC8LzgMw== 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=HCzqBCZEyHVXxyMcVDvAqb4MIcypJP2/pjPP2j94jpc=; b=gEWTQC/Poe11S8ayvc/JQOvwLfPwHm1vijb20pxdKdLrzYEDTeGJvB0/s4eiQAg1tXww5UQ/2YYRUbKmWLBhZ4Dw1x7RSECKNOlfYiQNZVROGQnLI8xeDJU3+W+nRalb/Uos0aLOv7ZQ8iaFugSZ0vgYMFgXa9IL1SbO/Du22d8= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB2007.namprd10.prod.outlook.com (2603:10b6:903:123::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Wed, 27 Apr 2022 08:30:38 +0000 Received: from BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30]) by BYAPR10MB3287.namprd10.prod.outlook.com ([fe80::c89:e3f5:ea4a:8d30%2]) with mapi id 15.20.5206.013; Wed, 27 Apr 2022 08:30:38 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Subject: [PATCH v2 5/5] vhost-vdpa: backend feature should set only once Date: Wed, 27 Apr 2022 01:30:16 -0700 Message-Id: <1651048216-3365-6-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> References: <1651048216-3365-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: BY5PR20CA0030.namprd20.prod.outlook.com (2603:10b6:a03:1f4::43) 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: 94e45c28-89bc-46da-2cd0-08da28283548 X-MS-TrafficTypeDiagnostic: CY4PR10MB2007: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: rZ63wz4CG+c0B6ftx6cSOm7hRQMniPAnt5NwQU4X6OFujDfaQMsbHpNCZa1E2Pi5alluwp0l8Nczrf17ugvqnTFWQNzyg1S8C6TvKp4FEEPN0BOT3HS5Wo3svYzZZfZj7Qv9y+IhCkSBj4JgYATAE5CHwW/QJs6itPw9d/8lOtJQ9RSps7zYLPju4C8ZPeHhPr6DUpL8+dNDpliUeKYdZBrdOI1mdUhoIHuqFdcBPt301NjRAXMlbdhAQhzfEUieTICmfBLBjST/DzWChqG1j5ySUedUzhNUDOCFMuBjalpl1qdEI3Fyf75aBldi11SRSPGWJrlC2cHVPzqR0ChB/nMvfFJEn12Cm4j1lJkeeAOl4M9dTQYJ+nFCKuz9/DjREb2OF9/KCM60g2E/fP7NbEcPQLklmY2Dja0cp/2+UJr7297x/PdAQgHhYRwfjw45B27vsjt59RQ+ORF+7YVugm4qCTI4eqxCNyXLIj1CIEl4AR9FMfHQf0pD17BtCu96FepTWGmfkyLqclZImc4AUenKiy7v2ZIX84Xkk82TjvVQ32SmfXUGjnrxPlvGsHr6xoKQct2uZk2eYDY5jWTfU+CBUN+U62iSvvY0Fa3xMlSgcl4kWFJbz0ZPJJdQFvGt8X992Pfz7GGHF1XBjmRh+bxHw0f/AYBHsgEJ0r9UM7nWC9w5H8UwH1vhbNAa3xWXO6ZOVBmZfYYsdL5joJPkUw== 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)(38350700002)(36756003)(2906002)(316002)(508600001)(38100700002)(107886003)(4326008)(66574015)(6666004)(6506007)(6512007)(52116002)(6486002)(83380400001)(8676002)(186003)(66476007)(66946007)(66556008)(6916009)(86362001)(5660300002)(8936002)(26005)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?kdY7AibcCxab/s1Hmo8zFHDuH8tD?= =?utf-8?q?KQ6Y4JdYhwfZQP6LQ0j5v3uP5jSTUY/qhs2O3jWtVCNtXQW3JqXi9Rx8BwJU71b3d?= =?utf-8?q?pSKxgZP8CzZq7TpfLDmcVbBKeZZefGysObU2rFpgmuh13B0vlh3X3qZhlSveSQer1?= =?utf-8?q?L5BTLokUMOVZdcdi8/j56gfUSGetF20WgbWLDFg3KzThYF2Wqf3+aCwNWiIDNNadb?= =?utf-8?q?qUAWZVS8OYNfeAzSdpkx3TNK3SwKhwlwXp46gj+7117vMOlyX+rIK6GjyN7vpp6a1?= =?utf-8?q?/6SILAymK5Aa3BusGsMG6gIvtEfqxUxGkJw9e0WvichNBIGMZCio0e3hx5KYIB3PT?= =?utf-8?q?j0f7I/4htFwX87HW7ArArdwx23ecPeVgeQIGLOv+udKC12w/O+3NdeddPsR0dEkRj?= =?utf-8?q?rvoFAiJ+8glf0FPO5gHMmiW3wjiiY3YqS8AdP3SShLvnWcszrrae46m4tzOpyxhqS?= =?utf-8?q?5aE7z3dSKKJKx8Ukz7mw0q1VflIeY67rfXooU74kdYFzXO7MG3PhZkoQg8dYYoT3R?= =?utf-8?q?PJ1SqBHHQMJ0sBX9mT6m8xlsQk1wm7Q62ThEOUJWE/kPOK3p4L1mg0oH+JeY7Pjpi?= =?utf-8?q?eEULe9CH1zc9Ng/ZsPl4Nj/4DG2PIwq9bgOPhcA+ZZtjm1/HZtAc/UGaRGWLZTq2m?= =?utf-8?q?uVU0TzlEKm85cHWSKtfnIHqonwGtnK0HPyCEKXX55pKKrVztGilQT/8/FEISX4bNM?= =?utf-8?q?BlW/c7DyeLyvAEW+fqca+cDuoW4P4LUVMTlcS6IUiE9BtNupcf4qjUF9ZFQFO3W0q?= =?utf-8?q?ntl6x/4HwyDDthWGTDHTmisy7jaEF6SRRzYqh92ybkPGppRC9tHGfhLxdmSky0wVx?= =?utf-8?q?vPgzyVcuvksv+EOJhkBaE2PcF4qbjBuufYtnyEODW6XyzTORwOPCCYPQAgr8qAIHn?= =?utf-8?q?B/j+clfvPswRZw947Z5L/9xpmD1G3GdysFUE8k5GBfNsE9+XFGlNBUMCtxxeJaBVU?= =?utf-8?q?u+L/ij7Ccyd3Y8krs43+DLnQHc5Id+zlUw815Ea3whgzr+EmJTwbpcdJ/2HH1NDQC?= =?utf-8?q?wqaO96+o9Bmgn9dlPjfytPLLIqeKg3IXB3vvPxiYUXacgPj8MYC+EF6oIlNY7MHuA?= =?utf-8?q?hvNbP9cPtliSx+UUeGMzLORHwIrfG7QiK3OrrFayGrUUSFNsy9y1T0+ZOv9MStd4I?= =?utf-8?q?D/rfcGEzJYEJGr6yk3Us/P3hhU2Bxi9TdWhoYvleJunVsdXXap0Lc4epPlH0mWyYm?= =?utf-8?q?qad9RjyGIJbzFstTvBWmcJotgpbSk39p6VXfnBTBS0tB6n/UX9Bbw7oNzcGfupkUI?= =?utf-8?q?m09HQw/mecsptvZwplw8asVehjA1SBI10+T8a6xBCacJUW/ifJAkR7vErrt2UQt9S?= =?utf-8?q?m4WRC14aXJCyHV3dqumc83CxwwWacagOBKOq5fXh3O7sdEwtN5MCtue2wnyc61fZl?= =?utf-8?q?51sUg+8uwUAEpQrVK6OYGcT2YjIGXraKd3Ssc0w0SNHmXR6137Pp2wiqRJiDdpU9j?= =?utf-8?q?hbIX+uPjhEr4BV6Dd1qPHxDxD7mXuznlOFjio48etG4GGl3X1vQlPDUWGvKhotph6?= =?utf-8?q?5pHSyQ2tFayRFBMKw8s03C8m9tikxFCHcGscoOr9X/JJz/hVnpiY5gvFubY3BVYEY?= =?utf-8?q?pDvs1maIAV8m7b02+ayrpMG1C/vJI9rF53HJC5u4R8STvf0Tc/wRZEWPI34kRXOQK?= =?utf-8?q?nZx7qkjOJUAiwqcPv0okVRUyVkE59jdtMSl6XaVVdPAoo5XT6JlSQ=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94e45c28-89bc-46da-2cd0-08da28283548 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2022 08:30:38.6103 (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: xzWqzy2msuzSqPjer6LhNJqzpoa3wulI2MauD+HgnHFNE26K+A5mgog3b1TglP1yex35CwAa/X1gM5Vbdkq8sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB2007 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-04-27_02:2022-04-26, 2022-04-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204270056 X-Proofpoint-ORIG-GUID: JFm68mETmgtNj98Xo2zTBaaC8MVox_vC X-Proofpoint-GUID: JFm68mETmgtNj98Xo2zTBaaC8MVox_vC 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, 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: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com, sgarzare@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 ioctls 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. For more readibility of code, vhost_vdpa_one_time_request() is renamed to vhost_vdpa_first_dev() with polarity flipped. This call is only applicable to the request that performs operation before setting up queues, and usually at the beginning of operation. Document the requirement for it in place. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang Acked-by: Eugenio PĂ©rez --- hw/virtio/vhost-vdpa.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 8adf7c0..fd1268e 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -366,11 +366,18 @@ static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v) v->iova_range.last); } -static bool vhost_vdpa_one_time_request(struct vhost_dev *dev) +/* + * The use of this function is for requests that only need to be + * applied once. Typically such request occurs at the beginning + * of operation, and before setting up queues. It should not be + * used for request that performs operation until all queues are + * set, which would need to check dev->vq_index_end instead. + */ +static bool vhost_vdpa_first_dev(struct vhost_dev *dev) { struct vhost_vdpa *v = dev->opaque; - return v->index != 0; + return v->index == 0; } static int vhost_vdpa_get_dev_features(struct vhost_dev *dev, @@ -451,7 +458,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp) vhost_vdpa_get_iova_range(v); - if (vhost_vdpa_one_time_request(dev)) { + if (!vhost_vdpa_first_dev(dev)) { return 0; } @@ -594,7 +601,7 @@ static int vhost_vdpa_memslots_limit(struct vhost_dev *dev) static int vhost_vdpa_set_mem_table(struct vhost_dev *dev, struct vhost_memory *mem) { - if (vhost_vdpa_one_time_request(dev)) { + if (!vhost_vdpa_first_dev(dev)) { return 0; } @@ -623,7 +630,7 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev, struct vhost_vdpa *v = dev->opaque; int ret; - if (vhost_vdpa_one_time_request(dev)) { + if (!vhost_vdpa_first_dev(dev)) { return 0; } @@ -665,7 +672,7 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev) features &= f; - if (vhost_vdpa_one_time_request(dev)) { + if (vhost_vdpa_first_dev(dev)) { r = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features); if (r) { return -EFAULT; @@ -1118,7 +1125,7 @@ static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, struct vhost_log *log) { struct vhost_vdpa *v = dev->opaque; - if (v->shadow_vqs_enabled || vhost_vdpa_one_time_request(dev)) { + if (v->shadow_vqs_enabled || !vhost_vdpa_first_dev(dev)) { return 0; } @@ -1240,7 +1247,7 @@ static int vhost_vdpa_get_features(struct vhost_dev *dev, static int vhost_vdpa_set_owner(struct vhost_dev *dev) { - if (vhost_vdpa_one_time_request(dev)) { + if (!vhost_vdpa_first_dev(dev)) { return 0; }