From patchwork Fri May 6 04:54:29 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: 12840561 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 D7B14C433EF for ; Fri, 6 May 2022 05:02:17 +0000 (UTC) Received: from localhost ([::1]:40062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmq6a-00051T-Sl for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 01:02:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzS-0004se-AR for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:54 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:56652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzN-0004R0-1O for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:52 -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 245MAYha013665; Fri, 6 May 2022 04:54:44 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=cgz1sON8aTlVYkW5iYCcqfzaqlnTFYYWf9ArGyKnUFvriaLzrzVUOIn2vddKKVpy11p5 DNVtTTo67OuEVO6ZWwVbJ+mGRs0YFesjezve9srUseuMgNTmxUP0/9vhE2GZ0haIU6DB WK9aUvyrkgUwQMJ0T84cbP8bJq6Br8zHwo51RxsfqRL/UIBqLbf4Z+3y6hIUz3iJf5tP 4pZ8PpO0N5pFBDZKqWt3XlyVhUY169HDakOb0cOBckMFkdx18jbWkVAzZeIq/G5Vjftb egpKAFB+tYH2NRztFUa+MSNN6LDoYiQMDE8gqVEkF5baNktJRfn4DjmKN+CVLfPhNLFx ug== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3frvqsn4cw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:44 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2464oaaw006680; Fri, 6 May 2022 04:54:42 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fus8ywve1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mEDUgPLyrhRRVUXtFyA77sX7X3XsYdHC7MCxRxUkitsjemomjJYU7sWT0fYGpRLhFf1O2y0s5KJlEqfjjNAEU36QnNVNcHJy7HXbCw8a7qrVnIhSRCjN+NSvZJFccqRpOTHJbndyyWbZreosP8SS7yo4/RjUovXDbwtXGyI34e53DOgvjDOjmM5MXdgUDIPRF8x8M3WbA8yNYvz3W3PLkngjshwGgWUrABjANVDdtz6zx0C9MRzYNMFO4YsM4DBlM/wj3f0EtPANARlSsedRB4CxHqRYlX07a0CHwEX6CGmcKmy+5oYcUZQub627Zl2NMsZO/20WduAFVucZ5cqpKw== 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=gQZjp75JYqtpk9LauRB5IgN9cHDVZz9zFalN969x9IpxpQLlzxJNC8gnQOqormCudM2RIFauLHmtZMLbQTz9OX0y74397zQJWGVg0fnPG0ShZU6MhtplmtXsh7GRgNnPUi7YpbILpKXMO+GnGjah/tPR4J2aPxChIAq9FqrRSmyUaQb8PDj0Vbjy8GGpWHxN8lJ1By81YhbZIcGEE/km4RS2Yi2o4+zbcFyXWZPqDhu+GegrNjoN57nQnjmAmJjnJ7+gNOoNsncJGAMBiRybzstqTJ3o0bWF8GuYzOKcdoNYHW8AI6dDUIuxs5c2LsCQ71WzeZOgYmu6XDajDQ64qQ== 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=oSsN5TWm3rx/ica05xHWbvUX8Z4s2UyoUVSrygdfMuX0z2yl8Wwc36vFzhOyhCrO7AtK9AUUfmfq3JHd+J6NouDU85HjmnPL8KhIle7oKzElGtZ2FqVhMIWFx3Z3vZfFotLjrW5WVuKBVWrDFU+nNkxZVv7cHT0p3Obubcwe0Iw= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB1416.namprd10.prod.outlook.com (2603:10b6:903:29::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27; Fri, 6 May 2022 04:54:41 +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.5227.018; Fri, 6 May 2022 04:54:41 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com, sgarzare@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com Subject: [PATCH v3 1/6] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated Date: Thu, 5 May 2022 21:54:29 -0700 Message-Id: <1651812874-31967-2-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> References: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: SJ0PR05CA0140.namprd05.prod.outlook.com (2603:10b6:a03:33d::25) 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: e6d61c01-4e9b-4d7d-5921-08da2f1c87a4 X-MS-TrafficTypeDiagnostic: CY4PR10MB1416: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: vArLhh4G1DlJR1qgQxmen32i0u+Lp3DMpVpb5cVrh7+s4hNHfpe/aVIHjtCrxIR2svgplv8/HmYaknlGjdDFYco5neYNBstcgftwvStA7Ynok35Ogfv6Z+3XE3hKTwUJykz9l8SLU5FVGb9WLtqN60goijhsaH3zvEoXzQj3uAzXKP6sLU2GwyvUi0nSNpDn/eTT7BrhB+/nS9B9VYNepzu3MqKqZEqgDTcp8nKb54gvq7LIlz/iP7KGVJCSa9OxT0A2BBQ9biuO921VlmU7vnTAawybvmGJ8C6J6Vc5kwFEk8YNlRQK+WydHKtQgg2QzDTtHo3jrkSM8nYTGp4iotCle0s96H8kbZpur3nt50m7RjQfGNJd6YTHL8Sr2qWyXdElX9Ei4Hvm1TvaeU4XT1e+z8zgpRUurb44m0SGJfPhSK3JpAM8eRhHF1PiniDxlJmqdd7vfrH+BgXoPYn+jUgnTeC73tXv7W3TvTkscq84byTI00JkbT7yS3PSkx5Zfot6jBH7AZCykww7Z2f4qlRUQQAvp6T/w9DOQGZDvI6V0ZKP70zxt0XswEbDA8UYNo34Ohlkn3//8cynJJA92Qg9OXnXZk7GCAbQMiKpWfKaSNaNRnnZFIxjYR1fMCtiRnuCEzOr1cn68KM7XsURnm/zmJux3A6rzPkl+7v/apb6fvPdEZJagxaP0pRzzBQyhYcWUhK65aArvOsRPkSmeA== 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)(2906002)(316002)(6916009)(5660300002)(8936002)(186003)(2616005)(38350700002)(38100700002)(107886003)(6486002)(52116002)(6666004)(6506007)(36756003)(66476007)(66946007)(66556008)(83380400001)(4326008)(8676002)(508600001)(86362001)(6512007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g4z0ZAacYq7EZ+AAe5xQew3UuysqtWryTB6UgZPSb74U2ZRP2VwUquYNL/ktm4ZCfeYp2Z1HPdBizraWKLwc9UGsSRSZuzCWCumJR4v31gRVGQDQjIrQZ0BeVY5at2MdUchoe4eDzaxkHBPQP2wzZi8BdeaU/wUYIAU7QkF0mGZYb1QqSd3s4Pr0nJRasMgh6m//UAVaab3tqZAxnIhv/UDZX8TiGdoJSOSUcyAzOhweNuyDoG3GdFKPNB9tOqTMtHgYoA5o0PkQ7gHNruRZf/notzDCGIoKlli97qGEbeXbWYQwUbCjxPB7m9JQjZb6uiFqFie07gpC6gzpHCmykknv0Otw5h3sVLO+P/JYBakZZkiEWdEDWx2VY3RchcyJDMhk/ig9HBZkoHhy43Q5zpMQuYuP2bL8EC75oWdH0zFMz512CwHLDg6fI0aMEXa9RYAsrNzZxWB3gos/ipQTmWnGOykkSrRZ1j+BZuSAo8my6EJsSgO9Zf8anL3csRXIenYbhBANMAtEn1K7vseN3KPKBNyHL+4WWxMld+56364I5eytYNs5u1xDDIhxWOkNrabWGk79rZAToymDS5ttFvva+eV2pZwsz3kvF88juWIFKyPOzLEqsCUoOPFvMhcfM27iCyCngyIANFEULV6qkIsy645FS/Sl/W5E+t3bq0ZSN/yuTHP6D/W+12GvLcU+vV8ktWKdB98YW3kkRhDtns8yTignvo195J7dr0yHCuHLAbf0Bk9BeCN1igorrQyRaEUi1DMDmpRr3d5vSxZ+9HYz5y+K4fpv1t9knkiKNg64MGt5iEMH7GZLUhW604oT0m5xbUJuX7x1bbij9AKz+tgBJtBfNJ2psjm40bVilcjE/ZgSXx/FgjsVkqgjboAkYxkpQMq/Z4H7bAJr9+W8usbhiB38RCu4Hrq5pbvIjdxtCK/dn+ZypO4kL680gZNma9IFKjhm+2F7OHbXs8i/S+sNWNZCRqqVoqCyLDyDMgYP4iKgPKGOnqa63TX7LMYF/1+s7hMrMbD54wVUWbQsRohvqXv3mAUYIV6O8H2VnnOJ2hDHvGKKcc4V/d/botbXGXe4ZYV1V3z7HdjGM+1E3JuH7hzC9pCHNNRD4HXbAp/rTIPwK3nu6Su7LNWW/hVO+no7uSFYXkL5tbs2WJRn63nEhD+avhg8s4uVQBq0X3HN62y10K2h0PJe2MjfRzdOhYzkSlqetKpTFVFruyolrpPveUMohuFXFE07JRXo+rOHdCAhJJdK4WI+pQKBkLToE79rPhXJgmpqJ8PdLYs7KDtIZ2CqyySxEF75B2CR0F3HuBluQe6h3+A3HhnRnA83etGWnaziFrFj6uiJJ4K+/8hlUlbOJ5EAB21mrRQO5Q/J0rFRtJR3k6izxh8VJQ7kH7aKWBUpW2qtn7BTt/7+jd/+EGEHa4B1vELbhnjyxmzYL2WFFXrkYUfpF52YN0TMQUOUABpxFwH8AiJT1Y3fiKiH2k707wJtcwOiaT3F1m3TgW1MrzDPwXK/huqU+tdDXFnxL8zGPbOmgtB8a3eLXZDNRyjAB0ggJTmRDiIqN2ppGD4OZcSzVyzTMJRuik5duc5MhboUo7i9BOXvBxRKLrtyD1oaMKMGbMHmVMiQZPy34pXZKpfLdgI8FHDt98SGXgJrI1I96/pNcAm86uuegpCR+YqG0ub1rRConX6Xa8ZJDcP30t2lfEXNeBQruakRDAfx2AQxEPkT/YTFupgg3RS2ej47zVVHEqJ1tzB6U58= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6d61c01-4e9b-4d7d-5921-08da2f1c87a4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 04:54:41.0443 (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: E6OMWBLlnS8KPJla7E6qrhxLuNTf37f2NvgEIcTDn8/ReHoz6Lnk3w0Riic27EFxIPlP7lcd0ES/COClM2C0jg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1416 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_01:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205060023 X-Proofpoint-GUID: _dMbJdfbVZ0lsPJlRxTStCi6rkxQOcvh X-Proofpoint-ORIG-GUID: _dMbJdfbVZ0lsPJlRxTStCi6rkxQOcvh 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: , 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 --- 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 Fri May 6 04:54:30 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: 12840557 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 29B67C433F5 for ; Fri, 6 May 2022 04:56:42 +0000 (UTC) Received: from localhost ([::1]:59440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmq1A-0006sY-GM for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 00:56:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzS-0004sl-EF for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:54 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:58794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzO-0004R9-92 for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54: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 245MEZ2U026114; Fri, 6 May 2022 04:54:46 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=fEPFWGbZ8+IHsjEeFpB37DX6xH/iWUNvL2PJ8TmNEeE=; b=wz8GIuZXJi6CBr7GVAh+H2jRLnWiGnRXb+V0yRQxgwunwhnmktnc+XoJMF3CnzRyGyHK b4Z647rIeP5tL8/M3s8ZK4IqCL9xeY2yTT+LyETU2p2WQ+FJ+KYij0cxFOfLExb2Prbl ZzYsaJ+y0U842X6hQIA2wyfMHtZcHx29Ri6/cJ7F76V221cGB07WAEVbCsUqXNLFhGnE P4igV+i6NkbDvXsh5nHApCoCB7Iwbxr8mKCq/Szc20uhKZ11f/G6UMJrfFMp49NrU20V VlFeiLpjnZPpVabQfnAoBqa7GODVSygO1U7ExNjWQfsgVf+qVhpJz5M4kojflkihV/LW Ww== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fruhccuc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:46 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2464ovZU016814; Fri, 6 May 2022 04:54:44 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fruj5htmd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l428MROl0aU0w0QCzDiOIkN0hsAP/datAMgyUNFxWDZjSR8rLlxHUlOQ4uQALQopGcQToGi3nM32uhSjC3ylCPTUcimrrdmVyF29G/JtkQuFAPHHYCiVcJfI3zm9swFqoZYT2/tEZXo0EEpqNaoOs36nHigcxMy1cqIfMdphjD2K89CEzZ4aAOEQnuTvJ5sBjn+rOcigNVPeCZN+CfgHYQ8oXOyEmUdXYOmuuYulx/GipQ2MiW6JtD3xdqvHzL3znnZnPKy9R/nm4+vLJ2Xl54oQRdxqwNPPWHDWnvjSTgFFyQB7NghiGjeACtyaRad1/aX/27eazkc4sPdU/4ZFFQ== 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=fEPFWGbZ8+IHsjEeFpB37DX6xH/iWUNvL2PJ8TmNEeE=; b=UMMXvUQIfjgyoCy2pKOpECuyXe0A6HvBHBW7fePE+KzYdPyNlHwALhy3SmyILWxVctPiCRYVWrupxgQRw4E8jhiAWNAeBiJ4Lk1Ww/MuAAR2nrNlseO91NFXDc+34F+RcRWHq1cStD3fV6evsETJg8DhOPnKcmhQD9PWqHuNaLTdOFUsP34Wt3SYZct9nL0dx/Ti+NR8OXGCkO888mpYORnt6MSDNhrvg4vpqMGFes1ybZTyzR4bWY/MACdPqTfKJy9IlgZGxwLwSoo3f9UuolcIq2X+EneyS0biG6nu696//0dYZcqvUCHEloARD7V+eAS1IxgrNW8yTkHFzL/NJA== 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=fEPFWGbZ8+IHsjEeFpB37DX6xH/iWUNvL2PJ8TmNEeE=; b=USDT8aQ/2p0FUG5N07x+OKkeA+grJFjFSzncNG0brP/vhdFS2XZBG1Z+VYLnqUclV+vb3YUFvZascI2Tl5wNUDyyxVBEufAc5ybyLmGtaQJU+gRuVa5TGieNZqyGrjmxsl6az9U0YIZixxqNjztL1yMJSZAtMhHXxYAXBEKbPew= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB1416.namprd10.prod.outlook.com (2603:10b6:903:29::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27; Fri, 6 May 2022 04:54:42 +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.5227.018; Fri, 6 May 2022 04:54:42 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com, sgarzare@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com Subject: [PATCH v3 2/6] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa Date: Thu, 5 May 2022 21:54:30 -0700 Message-Id: <1651812874-31967-3-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> References: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: SJ0PR05CA0140.namprd05.prod.outlook.com (2603:10b6:a03:33d::25) 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: 45228081-b607-4647-afab-08da2f1c8860 X-MS-TrafficTypeDiagnostic: CY4PR10MB1416: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: HMusEOkPgcadyYiKO3732DoE3tWQgV0TJwSbu0h8QNrt2oOizOYwd08kOa7IUJb+B0yr790Pyx3aGT22C8DI8X4Xog8DDyqC9EVitoRaznqse/O4Kk6UVfCalLIXqJT06hixvEECOmhbWBMcFCpPzZrJTh2DEcGKKloQi5YKXWhXy2ls9bPKhRGFW0hC60udpIBhujtxDWYDXKL0fJhxpaq2hF2DglrqYvYzaD/A5uvNMhzvLWNlpz67M23jupuiM8qzyMZKjE3Sc3SZNUJba7ShM6DyOQU/GKTiyjqJ89DL6QZmH3y+blixJVhRcjwa22GIHsF0Kgl+0emBbJLJPhCptPaco/EZkyAGI0q1bxgs/O4pLv/z8O2XXTH5C61u6yjpwE5/2L3BpMpnLooO/uNDd2JxHsw7Jg/aJdeFyogQz049ZU4tflTjdWSwDkJtc1klbHTkOnimeD11rhdUrl1SOX8CxzDWz8+BMzK5bsxkhgPJ97EgMESgFWb0Mj9pV5sHlByOp7XunrnAaIdjpFe6onsS5z8bd1nRuisZjrS+bVfZ5wFVT1qwHwRAbZaMF0JCpVKSKndSC/G/Vp6NK0cYSoslH8VsqRcI41NhuMrsEedM99IT704LxSRVUv+dP3EpPIrZaTGUdJFIbr0N+P1SHeaY3ORDwoBmuNiaaYfbkqupb/SBtAFMqBT1VqHgpkJdqO673IyOaqaLyHZkqw== 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)(2906002)(316002)(6916009)(5660300002)(8936002)(186003)(2616005)(38350700002)(38100700002)(107886003)(6486002)(52116002)(6666004)(6506007)(36756003)(66476007)(66946007)(66556008)(83380400001)(4326008)(8676002)(508600001)(86362001)(6512007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vz3AlC6yA6HkPi4gKfse1XpQiAO2xmrUM83yA+PPXbxXj5i8SBNRVEkUMSvDk6YCekLFscrQL5DohSx1bwzT7CtTS9RwvUD5wqcGGLN8RC0Ku3t7CHCOQdUQzga6cMwss1rW8cwixo2HStxTGRMp3mzh+yWCODqhX+SsVr9xpgAISGACh8HEkQMVogItUEMmDUuIsViDjbypd4mjWbbSzb5txigZoCQ5y6T56nlUumvnmfoNwlI8/PkHakjjPl4AGLMu9UPfGNl5fSe8aUAUL8rE3OMyZWZmy49ayuoX9Fbh7auAIhm7WDlKWmizFpXv/XmYRXEFBQ3lxmULIEHdewxXfWMatvnPCvZPnP5vamJUqbBl7Bkg3PBpaL95zGNXV0V3ObDFYHwqcBEA5yGayi5YVvapZYEmw/kvbH+c3NykimRGgpkY/zqtQDt4AU65Lb1sY25CxyaektEgJolFnjpunv8moEuFY/eQAh9n7Mi/lg51sVcD+iEdQinYjkHuIzN6Iq4nYI0NuMF+vHQOLvO2LsoHLMyHoWz9AeSNc4zi6M/tf2l4omC7yI8LDX3eCm0BlVItLys8ZWgKJg8kVGmHzXxNBhAgjYb/LVdU+RQXI2lMn57t3araQTOVW4ESKhkcr/34IPhCTxBfFpK4WJqN/2dwzDB6k4P7NzgfXkTGFUZ5k6f00zSyN6kmV+T0KsF0GZYlkymVaCiPYWGVXRyxWzjE/4v/1huL9wU1NTfPW/jQe4CGkwL4meEv0pNL5s71I1t6pZf+bO9yKnimwlDKSUCppfSk7Lk2IOGopG6QHJAzr0v1qBZAr9Cj53kxrO6mW/ysZhIEY3vmDN2Le1K0EJRGH6XQ/1PD2Ku+IXpx30D+9vpWNKKsu/2HsvS4BzkHthVWAIKlAGet2iW5cpw6jQpshUz4a67bv7Od6vYJCC6Jx6uzm05RzYP99Try8Q69R1RnGAhzE2pmehczYKwjCXr9LjB9WFcH4Qy930Y2+LbN8o0fYjE623PJwotLLz54v8pWsS9SapedHM/ChIOYYS2EFvO89yMOWYSx66fFUnCBW3t+bn92NsG1Jlhd3KRoHe3JSxZdnL+G5JfUaABXZ8GKPXAoZcvZ+b24j0v7wdtZTEkJ63Td7qlBF7TY+1sBEGldhwTXrDFAcACrjUjMuR6SAW/vri0gp9NoCc5aR6pEcUTBQef4A+jU7ugtLzYi/72juKyTaz+wXHQp98nNp+K4c3k0DP3VFJOenWf7nTNvVMgllmvvtyxWGVEth2YUumJQVYaMHySeDoT+LvkV30/TMyYqffwWIfNJid7NAJB8Vtrn34bsW0TPFDjYfYL6DGBrZGAXW0vV8rN5g3ZCBfo6u75ttXcD4Djnhc3ZbeB4Or8c5Q04yOBQPNU1v9oFQ/EblrIIB4kQVKOH0Z6SkFINCOfFmXZpN32DB8XH2H4wipasKL+d7koLGATKQTEvBg2Vg883UZinSa5eBUk/zkRAHFX8BM2Ig6RS9VHR7HROZN9aIM0XJXQDdtImFf0vFF4iyixgHpPvPl1U2brMNDWdw/G41+sU7j5Gkd6ayRV0gBr0+vDggOjHwLhf5eSyzKuHKBny/wUYdRO6phPlLzAtZvE0nHs2LVcCkDMJ36sRlht/kqWnp/ZiLSttgDt15rOCPLxOVx38Jl0lCRACAsr1xXfGGr/6/c10y5meJNFswm4KJw1163mrnDTKf1rLIqPGXoCDXlEAw6wxlXbVNeEkW3U5fC1kpVJMVdM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45228081-b607-4647-afab-08da2f1c8860 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 04:54:42.2005 (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: c/epdJhw2nEqj824IQvhdmoNsOT5RW6YzIC4AdzCmzvXC65qHdDU8tZ5CPKMKypHrw3GtwrpvVoyOzjGkAbpFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1416 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_01:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205060023 X-Proofpoint-GUID: WULJ2Ao8mvhUKA-GZG1WnWiSvGS7UBaL X-Proofpoint-ORIG-GUID: WULJ2Ao8mvhUKA-GZG1WnWiSvGS7UBaL 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: , 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 ensure 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 Acked-by: Jason Wang --- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index ffb3475..f0bb29c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/atomic.h" #include "qemu/iov.h" +#include "qemu/log.h" #include "qemu/main-loop.h" #include "qemu/module.h" #include "hw/virtio/virtio.h" @@ -3171,8 +3172,22 @@ 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) { + /* Must guard against invalid features and bogus queue index + * from being set by malicious guest, or penetrated through + * buggy migration stream. + */ + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: bogus vq index ignored\n", __func__); + 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 +3195,22 @@ 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) { + /* Must guard against invalid features and bogus queue index + * from being set by malicious guest, or penetrated through + * buggy migration stream. + */ + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: bogus vq index ignored\n", __func__); + 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 Fri May 6 04:54:31 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: 12840558 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 BC127C433F5 for ; Fri, 6 May 2022 04:56:50 +0000 (UTC) Received: from localhost ([::1]:59662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmq1J-00071q-OK for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 00:56:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzS-0004sj-G8 for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:54 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:58542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzO-0004R7-9x for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:53 -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 2461IxOV025194; Fri, 6 May 2022 04:54:46 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=i3GtDvST5WvUADyzYseVU+FTa9b/eY1mSb4dPZI3Sj4fTN1r1nRMNXl5fMLZ2H97FJ41 o4CRlnOiVllD/IT0l/r0c58mcjTB+VJ06nrizlHhkMvCMeaX4FiBoAFb8xXAK1871so+ F1bO2OgIU79jelVBfPhQn8jLkwB66bXLujS42oiINoEzffP84fTeKITMgeKMlNmnT7V9 lBnfk0+CuWoB3XtZmgWqQeZFPTs6kUpashj9A85qSK3owQPa9XytdRwRnCQUk+pVuOsf 6Gpz3NiAeupzdkiN4IPt0qdCoW2UvuEHhc5X6hknoyEm9pFCgrad8DWvRbuiLOineLfA Wg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fruw2n3n1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:46 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2464ovZV016814; Fri, 6 May 2022 04:54:44 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fruj5htmd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k9ziVb9Zmovv9T+gul0BlUvfqlDmEJqaO93TOt5rlSDZ6ZXBdcVkEr2IrfZYDfrc6X/DlI1zRJ/oeUhIs1LefmEUdi1qHGbnl532xMErp2hpmfqqNbmevKli5TcxXfpfs9JQ862rFepehuHe3G+1DCs0UEcOdMhJg46HIAROC03OQ/B/lLftccK4VJlyKPWjTf2qHu38boKxHMWbnERw56f2a4lUJPtrItaizVFs43eld8m1vbjYW3fMNZ60xX2bIorjnTFjj6qFNbpgvldZmCP8bF4oKjlG0eyJ5WBJbUjV+rGyhbMVzG3/ONv2worabDdq3EQYuTS+CWBjjgwEKQ== 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=Z5M6bcZFT7qf3wuOwom8OpDifdMAnUW0Z7firwkFSVtM+2m7Sbj4+D/sCRVYoFeK9O7/tjVnfL4/J34BkCJyQFMikN11qC0VOdfQYj30LT9jbGYyfX6QhPzkPi0iWiyfUU7L6ptHihoOpUR0+uqnbHXoUhc9AzyVONilnHPOTI8cZmB9UEPG6yRJxaR5XWWo+eUGO+NtMaw8bbGiOpwJxc3bg2lR54MY4vVXWN7YtYJZBza9Cj2QGxy3QuvwAmj+965RpNaIToeQcFjSeYQol0d/8Fr4HSnAuS8mHZtAQ6veONR7JhXipbRdlh9kn5taSagihTk2FbNG2eeUpoUBRw== 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=DNIsKhOkfnhAuU0LI2LrrGdZgrcRi8HMmFMDpBeQ2a8s6a8RdO/Se2QQzInIcMo2LMf0ZlDCHD+AtJtSOh4fC3ZGh21xkwpXH2tXAxi7ubsWW4pLQ/TosDCQuT3cR525WBwXVH7daNBYr2cA42NAVmKOQH0ukQ2GFuNF1FMHSLk= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB1416.namprd10.prod.outlook.com (2603:10b6:903:29::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27; Fri, 6 May 2022 04:54:43 +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.5227.018; Fri, 6 May 2022 04:54:43 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com, sgarzare@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com Subject: [PATCH v3 3/6] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa Date: Thu, 5 May 2022 21:54:31 -0700 Message-Id: <1651812874-31967-4-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> References: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: SJ0PR05CA0140.namprd05.prod.outlook.com (2603:10b6:a03:33d::25) 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: 404e7a5b-d5e6-453e-1a96-08da2f1c8911 X-MS-TrafficTypeDiagnostic: CY4PR10MB1416: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: Ej5ungwuaqX2HSENpVkagtI27oR9k+Z6WaeGEzmUgy/B+TTPDUizbZQ8oqc0IkOxSrqQIm9MJE9Vx1U7DG7dSKkmjiBfz1/1wImt+2g4r7N8NETcTIwxIYPvfI2g0nClih0uLz0Smvx87898hikoMCBD8JmN2mJAx36+e+6NfARRgAYHCkDyW0Z09bGpeDSVgPUITUjF38+cokXPyjARS/4ZpbUYiosOKzvI2Iu7NrjnPMGPfrDHsNgUDUhNvQHbdaDpttXe9H0sWuiivzJUUMupm1jYXmVzwe2AeiDUStoIlSQt8dRGARyMfMe6NAgF2APAI6uWuCsZ6xtO2bIZCZzQC8arl55K3G+IjKTyHrCZCYlTTqwpMI3txfovwnuMFSTJx+9ngfEcY8p2uG0dRdVJfzzukclO2nN+xQ5ieHfm3CqgtPwcVP0eGEo9BAeZhZzaAqReKu8IkyC85hI5ibLfgaijE6U62wl0nUm10lp3vMGhg1n4JTI/tkcxZNqA94h3PdPrcUuHg/K7O5ptEx8Xqes2cZ7/JA0NxIgVOEekTACkvcAeSM3qR9PDf1LK4S/tf9511sjd6dLcONW5iU2rMcBk/qs2+xeHPWlYpJDgVvmKXePMuF3TYq3IuZU4u5EKiaFkDQYjhgsm7RvcYHEu2f3v/uEfFSR8pQAckI1mBLYrltoT0iXuvNiR4Bt8PJgdqgN/WW5KsQv0BE8Pug== 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)(2906002)(316002)(6916009)(5660300002)(8936002)(186003)(2616005)(38350700002)(38100700002)(107886003)(6486002)(52116002)(6666004)(6506007)(36756003)(66476007)(66946007)(66556008)(83380400001)(4326008)(8676002)(508600001)(4744005)(86362001)(6512007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fOqfrFkLlviixC7wGpMCvPyEN+wdDP7L69eoSeLMgl75AaPJsfAZEgxeEOpwCiZOBYYfICQm2s5CAFk+x1RrpYHd/0feRa/EAIxtaXXhs/BbGPjst7fvSyoKMvxQKYYKr8tKhiixbOEaiF7aMqPpjp2pLjdCOS67Obj/h+DyyAQUI7O1ykYLwIOAhQrRooz5eVNDpg1ThggZ1CnVEwsEo2S1uVY1mv2t1hTdQC5yYOInsXFujpEkBtKzc3Zy+LUGIohtOB/F9VgAAQu2Saw0EAW6v+x7fKi/+4vbhkbEcW7x8ovPJsp0GPPHMoXxygMP+N3pw9k+l5NVUOqvRo0qLH8BrMqWsp0lrLq674ryMDGjO+uTunTjthLmtWcqUAw0KJKJV5/JCtmxtZnwE96KH4O+Q2crM1djBrAlVMw2wUYGRaKY9jt0GRf69nGo2Pte3A0rCB8H85LtW9xgHkNZI99lbDuilfJX71+HGawtCh28EmOjugNncSapYue1usSPgx+PCihjMfUBnShLUPr8kSHaO6KTW5I31UCmlSJKdSqSVJJS6BukyHp+jvWl6TU7qpR6qJ2Oa/1OtAPLCVzk34DkjMYsX5bcAdSLM5muG76aoUqX0dWMHeB+qaIwkWAGoUFNuWG79yeik4W28lRa3p6xV5UoZsctcWbH14GI4P06EDT+5q1xXV3gWdzT4dG/XGy/WkEfykKJH3MsFDa4EkZfoyRrLIrndBT8jeQuGisnzLe6kYs5SPpnAunnjFiu5IRSSs0PF82JKdjaHs7VYS3LNM7DM9TvzC0kCU/YTotnjCfZamfZK1nqax75T0v2vkD6cH0Eb2TuNz61g7Y1ocj0zx+SJiCljdDwg0QXq1Br/hmAtvm4ymHO+cobwlA2ErTc5eOs5C5aytuOJWTffQ599LKrchZKS5aFtwMWGora1cNogY2SCuzk+I+5mJjRkf2/mgaaJGLJCh2mcOzMsVHoSMDfaSctItrhjWNT8cbClo13PebPA6tlIUyJ2pwUpMcfYRrsJbyUQyWB4Rcm/Wn6XAGOghMdnvJdZ7KVEAf9cfXH/6aHcjce0eyhl5duM8Gg12PMUtl8wliIY2TBStA0RF1I39kdvWdAqN80oOdOoGme42d3twQ3qEkZL8+hjSQaw2RBwQfoaAulkkXA0qVIIF5fvXsoLgJCuHgNmghi1vTGBoeeO8jpN51LpuzsdRolGTh43e0NfGo+KEb0axcSsi590WLdbbufn28ACiZIM+X/2dIgfbiD1VCTaKaAxc9nonxBaJdvMsfE3GkO7baFERCRVvgJhnabYuRmdj6ESMsFpJeUgrY+bBZLDFZYDyc2QfXK6dwJmvcaW1hbeUoKiiOhGvuTf/ngYJKNnZTlL4Zjaro1ykusLO46vE9rJOy/8AlTPx7KwuCe4MosuxH6CBNbpBqtuBtlhTqlLaUtVhTym1uD2eRvbCOPt34t4fmeWuEJdytG8QzTIXUzyjQIIIotu/+gThpcxeHxCiCMVKxA3EwbfS7jHUnBNxy9ffpjRZp8W287Ero6mVGe1n24+Jd18Y22jubgutRLP2XtOWDWt6Oj9VtkvIoimiSzsPAYuIM2kTM7Njnjfp3nMnfs5Ko7BcVuZmA+TX/bcrosYrChFzfoyrUY9ssBpGGVtz+XB1vT5XNhV19q9y48j4Y64X6jZGSARjA3NQJmICiz3JgJJj1nT7gwyxW62nAE2t8ivfSHByLZDRXiX/LJQfDRqGqUWFq6m3znjfw8LcE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 404e7a5b-d5e6-453e-1a96-08da2f1c8911 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 04:54:43.4191 (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: i/LfQSpZw0Iq1exhiymB6/VxKQcOj4bWnjmhvD+aGWocb6SrkTok2DJyNodTLRxUG4WS0SM/Ij749QQFsrEyXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1416 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_01:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205060023 X-Proofpoint-GUID: EV92WzS2Af2SpGlrqIoXrkYpzb1WuTED X-Proofpoint-ORIG-GUID: EV92WzS2Af2SpGlrqIoXrkYpzb1WuTED 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: , 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 Fri May 6 04:54:32 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: 12840562 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 7E32AC433F5 for ; Fri, 6 May 2022 05:03:42 +0000 (UTC) Received: from localhost ([::1]:42142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmq7x-0006Tq-Jx for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 01:03:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzS-0004sk-De for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:54 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:62722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzP-0004RL-T6 for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:53 -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 245Nd6p3027626; Fri, 6 May 2022 04:54: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 : mime-version; s=corp-2021-07-09; bh=4eBz8jXBwAKOkC6klvoyWnzOAv8yPwpTsqzeeAgeBf0=; b=GHiqnu0IyfskNKkEjmBl74Xm78qmtkWGwhvJTlkzztz1/pbSEZyhm2SxopPo9R7+RkPV CZTYX4PqOH8zd2oc9tP/tshzIYjHXcen7+VtuvjQduTBOlYbXprd3elfmRu5DBQjz8GU 3h16Md4i5Kg1x1ThG2GFt66zmfYa4P1pkPobVD5DkOEbgqk4V3hb7lxK5QaknysK0Ipr C0/DNuqP+jIHdmtMbAaGV9GcwHMvloL8XtD+dzw46XKzORzEJEJVsR8X38rfQq6Z3CK4 NwugDPtNg7ZbgATDYUYGfYhxxsrv/KY8m0wiLyOPeHaPuWWJ3xP0yXrB+PSnN3uTvGyf wQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fruw2n3n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:48 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2464pP7Z039424; Fri, 6 May 2022 04:54:46 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fs1a7wn38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rcx3QLIA3iZtopsLpIt5igAtBkqDyHbZZcG1tBfvjkq0HcfRXc8MmcTwXHAfKT+iI3nfmEBce8c1NU/9ZkKJhefW4ryKgl/Bqg0eVrVcHppk6eYZv88PL1CYGDpEOMKSHAPEVo/OFz4lvXEyHrBiSfdBd/YVtVPGVQ8rZF9/WEAiOC3deIZoXVvMxLrGrnGSuvQCcbD2gRwnZVQYQQItdjBMSdo48ocQYFySiSItsww/MJLWQkzNECFLScjG+LMZpakn/DhoPW3CkXbP/Yf4N4y0MajEiTxhr5bSvP6fCSmxplt2TmPVtXc5arzf2+Jjp3yyH3YN9uXhcb0Ut1E9sg== 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=nK2FXzfZfwcAX65ZN4XbOMGcgiCTkd/Yb3kZFlPN/yIMsnloFvtpCq3y1WGDHQQZYSkuhbIzfmpcj6KnvS2INLUpL3jqE32LLx10B5aMX+kMPf62YhXtnMpQ9RQLy+9vRwBmN3vE0fQNw9Ygz81wc6+0NEpWSmrG/Mp7I0RUMbBBhp0yNRp6xeKhol3ksByk8NBK3Q7q22Z+XLXhR8CZl3SCwaa+CyKDYyfL3PcDKnqJDhgMPKdfrmyg+XWH9UQXZp2SvUyHjcq0gbARVQbfdiGFPy7s2CscrL/MHirZ5ikBVOfTplnNWDl/ROmKoee8IDiSi4fIbS0DNQrviVtKnA== 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=JPbyXWiGAe1yg6UXqB4HvKjT4bSRY73Hhm72GH8CZvmGkbxzZhYI08jJ6lfgkotjQQAq3xIqEmBezeMeJvwbEhK8WM5E7QiNEAg95glqzsDqJPk/jix+hIZie7ui7jWk86tF7gnKh28PR/VFcpn3uv5ND4Rajx0hRrXnVemLABE= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB1416.namprd10.prod.outlook.com (2603:10b6:903:29::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27; Fri, 6 May 2022 04:54:44 +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.5227.018; Fri, 6 May 2022 04:54:44 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com, sgarzare@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com Subject: [PATCH v3 4/6] vhost-net: fix improper cleanup in vhost_net_start Date: Thu, 5 May 2022 21:54:32 -0700 Message-Id: <1651812874-31967-5-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> References: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: SJ0PR05CA0140.namprd05.prod.outlook.com (2603:10b6:a03:33d::25) 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: 5c40ea8a-e96f-402a-5cc3-08da2f1c89d9 X-MS-TrafficTypeDiagnostic: CY4PR10MB1416: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: 5Ac5e9q1XxAVCzshHKxFvKk5GjhJ5t7ob1w4OkDaC0noJ5BWY+g5gxy9oy/Ar2H2qbbUyjRoeBSZM8tbFyNUnmjOq9fBq0ZSd9tKGuXTiCbz7Y7FVqTY0KWQo805jn6MqbsBwAgOWl5cnpKsv5yW9qfZC4Xhjf0c0hm/cd4TdEiKYQkGdkeo0X8AamEUzokc353XxfZ0PJ9qT9JkwqIvpNjoDrKYx0Y6miwhs5JBxJne6U8KpRqSl7Qkyx/7MjJO/3cuvH7MHeB/dh9dU0N4eXkj4uvsrL3lZbLJKzjsNeoFvr4VBccgjpufHKV0Q82K8Py9WzkGDk3abrn1PW5Mn91BGzUuPzayaeOKd6sjJItegX38Jpj1xgX7FFhz+S4RFAjQJEB2Sz04p9NvY6pkz9j17n7J9uBiWPDduOLnzlQyJGGqkOr8qPbv3yLpWuLtGo59FSnTU+MzXuvl/ZFkGWtHkLXHCHazsP0uuHp4IFaFlxYurchm4UBq0AiAbuyiaUDeEeErea94BpdTMWG7gqnINAmAiGXC0Uc2wqSn9BAdVrTkacf6P7yayo+Wer9lLMhtk5Z4f/j7PMrvb3ATTCIExlhda2+Ub1LG2NN2E27PI3DR7boeOrKnGWM3FBNsa63N7W+YmtGTcJUPCrntOAVJCMaQh+iHgp+hGqT9/tZ1yag24C4wGdzDhv+we1lbj9aC6KBQQ4ipRJjXsMmYsw== 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)(2906002)(316002)(6916009)(5660300002)(8936002)(186003)(2616005)(38350700002)(38100700002)(107886003)(6486002)(52116002)(6666004)(6506007)(36756003)(66476007)(66946007)(66556008)(83380400001)(4326008)(8676002)(508600001)(86362001)(6512007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A2RPKY4b/3uw3YZihSdktCCRXUDf/YoUCDv1T3xZ4MR54+ln8icAd9QCeuq4cRHxq07XvBPYIoztw1v15vuvXWa3mpbBQNivUbv+aXqo7/o94S2u8S55XHziKFHHJOytX1or+CPXgtvaCeVw86tArji8jdfepwS8YKlWA8oCkJrpVvE2GFlGVjQtfMqHfUmBN5RhSFXdPbi+dTJ8JebLVJ6DT2n/jiDf7wOzQ3hHjrIkxvIfoC4iJBnrj8cIZYbKOR8mNXWDMleom4JrHLMDI19PNAZ12Pw8rLLJkVqr7xWga1NO50iX5qby6/fnXiSamybr+b/xe1uBvQTEsM/fl4Knnwq1DxTcUQ6/+8TTmYbKBNbBmoz7r0FQWvNCYUmMEvY/JdpdxgMrnf6CgOITj6uk7S/GK/F/bOxtgwpnGgoKJnYEvtn24+qGXb8Zwe+qUYDvR4To0HUq4KWjySmHtNnp1/phpnzRKrmyeJaFwVRKgKboNuzQ8js6K7lGymJzrzgzrnkrQwRrc5G5XSMo92YYZTGbTKPvBX9SnE80c3TqcDyjUIysvCGvUTe/bTI4bzm58ibmTi5BAiQDso01v87mWM3lhJCTiIXqTqU5xWSxgXkzxdxBRyZWM0kHjTM02gJMzqt3W6NQUzV52E4AHEKvTLsexfJhrqAyLdAK/NgtTwWLToHY31r/QpR5YF3CS+c6OumdB4WfP6ZyooVagK3hhxz4EANriv1rv2ITcFapGEg1wteYzi+yAcD7TVUJQ92kGBMzGY9IuQ5VJh9SXo7b+BkDo9gavBt2XkrTKQXOrPUY76zgkK5bFvTwpcM22GWl128CFPgegl+Wi9kZEcN5+crpEnhDw2atUY20Is5TjQuW7FzLNG1NrXrQkT23b8NPClgmlzeuDzND3ln6TT2ANcpEUDyhKEVn4mM4nGbsclvmAyLZ7Kqfl9MGe/uSOiMS6i/7OVhuDzVLuwhdgKdBuUO7eZALWYpabmvTZ1hH1CBOeRVgxYIz3/SkUhIg00FOKgFZFx5Czc5DCqfYdxCAII67eRn+bkxSo/Waix9y5CBqaXlPkZzG1ezUEgFRzD+QnArCaV6mZJS5tDaDmKYA/7ALsV519LS68+u18lHKl6iqlXVyebG3Xgoyi/HXAqchcFFHgCtIFCXEJHcf7tkyh7Q8YQB3YeCTPtK4DCxFXksQBZEx17WwPPzxMo8ypnoj2vzN04ixSulHobzIxPod1Ywm7XTdBdjxq37UjgRz0fBwHrNiHzTpZEC39rtXj0ZfKpCKw7qYIw0YzdGwbkSqulvfsoFxOlX8gRYu4PoSkvUU4HU1cKoRyMwYm+yo4Ie+BGxo8VvP86Ile4YYaM4SuP9XFDyv/BylGLoh2+t4Hx5uuffWw1+E/AgWmhEB6RMarCKZD+0n0cZwCK04kcKbvgGuEsVKfQD8GutUDufN0R/Zsj1Ye83y/csdWw7c+mDEhMag8ly7z//mD1jDvXlFrn+CkGbycAJ2jJ3Q1EQy7GvGz1wEk7A2vqOiaKs5N/rK9t1MRWwIAuffrzbmUl0WAxBLt8CMbSTKDECZBoPezzO6MHEOhtxhPBGxoZ6sbMWF8bbOHWaOMOc+nljZTM/tPGK9d76yNU8oEDNjDJCbYblRSVGzYPPz0DAmvt0K1/ij5VoYxrxyKDaR3R++l/UFfjuDFFoSYmkXXWAua/aCK4C2iJ9fpEEHLD983xB242waqRUnTa7Zippyv7Nhys/Lh6BY+dZwnfmK3VqQo2w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c40ea8a-e96f-402a-5cc3-08da2f1c89d9 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 04:54:44.7784 (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: J3nU+7sUsenOTdrYIbjzCUcmnhoalE1yqDQF2EvOEqdGOdf/aTyeVSRaliS7NB/N5drrPNj9EqE1vsQMtCld4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1416 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_01:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=936 mlxscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205060023 X-Proofpoint-GUID: VLs5i74F_nQ0nDaf0AOfMNI_pzCcbUrX X-Proofpoint-ORIG-GUID: VLs5i74F_nQ0nDaf0AOfMNI_pzCcbUrX 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: , 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 Fri May 6 04:54:33 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: 12840556 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 76D30C433F5 for ; Fri, 6 May 2022 04:56:36 +0000 (UTC) Received: from localhost ([::1]:59416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmq15-0006rY-8n for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 00:56:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzS-0004sm-An for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:54 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:62476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzP-0004RH-Mb for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54: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 245MEZ2Y026114; Fri, 6 May 2022 04:54:50 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=dLX8BN2lrT5onf49HSoR/BD4a0vQFc3g/nDfJ0MQXuKMhvECYwF66y7hBPccrOsEgw+5 B73sWRQnyw8M90gWpy+kYUU3FBB01Kkk58eqYmmpYwXq1u5AiPT4KfBu9ZLZBSxrEVOV 4Vi+sY83P6DDPf/f+6+9vKl5d05h/OafRgXqUQ+WaAFb1D2cUsx44v7a6sntQm4cnyHC c+ysjG1phF5CH9jtI/5ny29R2b2xGpOPBmW5gmuywy7mFKJF6Pf6ftttIaMFD+1iyz+P xohpEy5lXt8t9c4vgRZRDuFYfnLdB4wCgMc9Ue80dclZAsT9k96unXRZJUzwA7FtqTwP Fg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fruhccuc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:49 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2464pPLI039454; Fri, 6 May 2022 04:54:48 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2107.outbound.protection.outlook.com [104.47.55.107]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fs1a7wn3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jy+mv8uRcZ1APXOYLyqQ79lfNKRC8kpag9xlPutfCS0clhdwWroj8tQsGjijWjublN8ox8HUaIznUpIRAGWrOvXBp4SPf1QRcSKbDBdppp0U8cJTExZbupZVxFSnrzA69cA/eUbls9Av9amUtZ7D62cZi21Qe/ChX1k5MJ0sPSttuIT3u28g+sB1an3AhVXyxpPOKdM3FbM5+XjNqP8aMsJSB0i5GJ42YqvJs3CHG7UM1hFT0YigYw03bMVMHHTzD8ZudrBaQhTKiabpQCmiXKmfw9RQNuNJ2R83yxqEB3Vq+NkxHR5d6vgIrjFOPq4t40WvYXlm5Hl4djTdHl+Trg== 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=c25oBdX+1GyLSUqJOea/BQl1MAdy7tup8ju3sDZGfZaDK/ZPLuBvveQ55mUVrLsX7FBcOWIsW+iHl5b04b04MuyT/CY5VK6YsD2zn1nn8zmI1Wgv1rJJo6iUE6usDR5/XzwLQdCZnCor5NLfNUGL3CFHhghh0bSIN0pljxb4HEypzwoX7TUXr2J0/776M3jakv44bErkG5t+124SKOun4mYf+WJojQLlhqeG+0pFvfxgjQAoF7rrFX8Zb0bvF7UVq0sCGXNT/c3yUvYaEzxiJWV/MSXJ33SJiKtSWWxseR1SigBG6bKoUd2C2J8kh4qUf+d4aYeZ11DYsTcrS5UyVg== 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=SwgxxRo4aqkT/cQOXHj7sxPG24Zs+Q0zZMbRHY/VQebQCSSBjUhpF+1eekkPnY26eRoURyxgcAZPnN7sMLfuXShbP/2sh8qKsfMK5aZLXTARWtc6vaqeDE7aQiaGsJh4AeWd8Rg47tHr4PfdwV2K89XPFQJNBVxlfy6sD0wVPI4= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB1416.namprd10.prod.outlook.com (2603:10b6:903:29::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27; Fri, 6 May 2022 04:54:46 +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.5227.018; Fri, 6 May 2022 04:54:46 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com, sgarzare@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com Subject: [PATCH v3 5/6] vhost-vdpa: backend feature should set only once Date: Thu, 5 May 2022 21:54:33 -0700 Message-Id: <1651812874-31967-6-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> References: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: SJ0PR05CA0140.namprd05.prod.outlook.com (2603:10b6:a03:33d::25) 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: e4a808eb-34df-41dd-0123-08da2f1c8aa4 X-MS-TrafficTypeDiagnostic: CY4PR10MB1416: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: +KU0IqFuKRwVl2IF7aCiR8WcJQ1MuVN41Ql1mCIBxxVO4zIVqGvnuI7Av9do7IXFmvafmLPmgggMEwRij80mXA2FWnSqqDtb2gXKA8douW2k9LgE+X7b+opUFF7xX8O6QV7ZB+7RhqrgNKdyCzoDvSj9fl+7iiSyK94sC7AFEK+vv8DCeS49sQwcOdSR8Il1dKOT0n4s9YnHnYUd/6CoP+nDU61n19YyX4uQq9A3ShMMG2gUrZKWvjJrr5irtClsb0VZotrfUkYDRfKmKwf5vzinN8hp+W8lGXNCBjGx1/ETXgFURQY3WIv7Gg7bBQrlCSKsOTqJ1RoAQelnNthCuKwl8/BFaAPMPw19CX3mPAjGpFviRd2gjPxodZ6HcyMUdvZQCnSEkceHegrYErS1v9JPadLIhf7EKVbP720/eZ/bpi7WMYxFGMU610TgePnHibJfu4SLbVfeIyujJ368IqCr27zkENqVUivEOi74kRRN5d4Wxyh45DnZNHIffztlfnJwX8ETF08lPMHVDKqGWuPIS3GYg6fljRmOFBVUmHuaHO/c2+nVMHfz5tTapWFTk5lckEZJmo1Wop0fFNpi+lKZS3XJXw//Vc5PoG+whXxtcZoQmy4i2l2gdSC5n7F6HU77wnVmu0gUyuVBl1tqo5TUjr+fh6Rj0r+qIEcNZ498rZa8Lb4tHEMwQkRhCBvf4PD/fME9aZ0QA3ouMXnD/Q== 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)(2906002)(316002)(6916009)(5660300002)(8936002)(186003)(2616005)(38350700002)(38100700002)(107886003)(6486002)(52116002)(6666004)(6506007)(36756003)(66476007)(66946007)(66556008)(83380400001)(4326008)(8676002)(508600001)(66574015)(86362001)(6512007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?uqKSlVKaKtV+/x36F9TObjeNG44J?= =?utf-8?q?fre/e1j2JUyKFX8Ng9feuuAghVELsErW/Rf0G9gy1vXfYYQhJMKtBbxyVY68ZUQt4?= =?utf-8?q?juxCK9TTry6/fLy9KQEUcEvFmTGxj8HmXfg4w3hjpyA1AZTASX/TE1Y/wsI/7eOfx?= =?utf-8?q?fEwJykpk28kz+wU9HAIxwxm6x7Gsqf87MM9LNPPmlSAVCcceL+dmv3C1YvjFqWP+y?= =?utf-8?q?SCPODX2ZjKe51qI8zO3K9M0Vx9GmbnAZRB6KiIKQMnFYvQDwm1xvTJifk/Ga1thVB?= =?utf-8?q?n60NvttdgA/S4QQrLIZmd4iHv4mKouzWbU3FsEHlBKin034a21HMP8Py7iIH7FIWO?= =?utf-8?q?N9S5jcUx4zcUyz6RSCv2LqiqDmxWNzURQ+scnUzQOZsyNGvifgp2QJJ/iPLv6vh50?= =?utf-8?q?Ol8vfub/kNNcaeajMjZfbs5QW6Ga/eQZGQeSpP+Ac0XIFRVwRmRM6Iyl4bDgGAfJI?= =?utf-8?q?9AH886sCDdpFQe7czhMgQHm5wgrIlx7GDi8OKNAZTXxlPUIwQYi6vqOkUeUmuUfGm?= =?utf-8?q?/dLi+zUsUS51SjlCcvBjM7RxLDl/U80gtD3eb5UkZO5Z/KjRHwK7nsy4mHXifiO4P?= =?utf-8?q?nZpo1fPiTvjyR8ogYF7kCKQQHQA+80oTJZ26i+22RFxzxkK3aMiN+c/gezixjU1ZZ?= =?utf-8?q?1r4RKoZ/QCmy0FWib/JEP1wF3RU3g48XGxnVevJBpGfZzXLohVqk+Uk5oZXxHsIiZ?= =?utf-8?q?IT7WUXuS5aC14sZ1FXHnvYpkSt8nsRFqmfvJPjUvP3uVevULFMLd+sjEarBIsVJwp?= =?utf-8?q?QPBoOfTKzqOUIPDZenj8YYUuQrJCSb2ucrfABtRAk2qXdetyRm5NsWoEohZktDtNK?= =?utf-8?q?BUtDIJAtqWAj+/oXK3PIT0RhpKUx/F61Bug0T/32MyeopqoLOlfSuT+nUYoSK3NsZ?= =?utf-8?q?fnGC2px8RyvmKjHqybONpejyESi8xYiLMDAgTdE1sDjHATM8mattxZpGApELopJkg?= =?utf-8?q?EZ188MQBk9qRRbGgBLFWN/7lID9Vp1a89ogf9obREMVr3jtGflz3cqKfrmQQnoNiH?= =?utf-8?q?F+SDoTgdRvcZqtcdaE3A0u3tXUO/kR4OWcrXgbMohP6xdg1QHpJU91M1raYrCWvO4?= =?utf-8?q?4ILNYiW//A6+dfF47FacVjyMnpVvSm5BFNXepySJK4hrqtmyoL/daq0PPDx56Pl/o?= =?utf-8?q?95xHZ3N1CMG/e5eOKhE2gQqGLpbUeJc3/+RNmy6HPTr01GurijUybCcEbEu1hYSjF?= =?utf-8?q?aSgjtD/PPuq6jPOouvsyTSdZOoPcDHjOC+AWRe2Y12yEeXE0qOaeozumc/VKj7Mm3?= =?utf-8?q?FCcQR412pJ61VrW0NQUilwMIVlGn5hAFURFXiqcUysrBe/Br+hECbhPxUcsTN6AZw?= =?utf-8?q?toxgrUcsW2jx3oh0uBu7XMxXsbNHYwt1xnE7O3R3O4hIvPkB7tW3lfMEdwRKQbTtw?= =?utf-8?q?ogxJrC9s6DlbOhtQU06GzPmxWghBv79HtpSIcMFBiA/Xze+0Qz/bCYbhDhkD/7PrA?= =?utf-8?q?hQbhpcnd/qgN2bKnGeFxc6SAigBCBlH5uELO4Wxe3ETawkwH78bYQOULihOJQwN3O?= =?utf-8?q?iX6hWHPgEbLOVhmSBqRlEnzQVPIbPonUAlodU/WxpMN+mDfNEj8XBO5YPOXjwgZN7?= =?utf-8?q?YpXCGyOv43TICxxoollDzgN7OiPoLHrlYXx/atdisJto6jEHc91OUYEsOLIEl7Tpw?= =?utf-8?q?PC76KuJpT6UMx5wqzeBTpNecszcMJROLQRdNU5t8U0s+b2vYh/SHs=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4a808eb-34df-41dd-0123-08da2f1c8aa4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 04:54:46.0440 (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: jOyktMlor/AJmqGrPBWa1e8A2KZwnf87cStzvQydr5iTKKMRiqnzL+Ii+i5/7lHfpK66mZrhLu4nllL0NjDXgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1416 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_01:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205060023 X-Proofpoint-GUID: Z4pZBVZFvryjJaLPeliXNxEC6mJfNYU8 X-Proofpoint-ORIG-GUID: Z4pZBVZFvryjJaLPeliXNxEC6mJfNYU8 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: , 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; } From patchwork Fri May 6 04:54:34 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: 12840560 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 36D71C433F5 for ; Fri, 6 May 2022 04:59:27 +0000 (UTC) Received: from localhost ([::1]:36692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmq3q-0002Wk-9i for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 00:59:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzU-0004tR-0C for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:56 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:65132) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmpzR-0004Rg-Nj for qemu-devel@nongnu.org; Fri, 06 May 2022 00:54:55 -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 245Nd6p5027626; Fri, 6 May 2022 04:54:50 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=D2ClcG20RODJ8/B3gEdze2fdcqiapKpiiR/cDwXzYSM=; b=sgn0M845BezLAP9k4kFktd9J9FHo0VKZGvsIfkc7tZYFS1UYANH8MJcv/1eHH/5HR2mi z9u5fSlLFl57T/TXBmlr7PO98lRTeoORDo8YaEl1szJhXNsITwsWwaOMQYAg2mkC62Hz C/sRMi36+TtbQiobhm+BpxHoPjPQdSd+eokGM72WEIC2idsqU3VURK7x2X2e+BtmfurQ /Ry5d01v5/n40IWvvlXqJt83dHEy6moSjwBHh2hIXXsN9ZLFUEFC+QZZ74vCstNOI1Sg IAfNuHlJTN1G8jNsi94J55LFtG7x5vrwAS7FZXiH+9vtwx/8f3/fBRKVvFaRvldBrKn5 1Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fruw2n3nb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:50 +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 2464p5H2004871; Fri, 6 May 2022 04:54:49 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3frujbkqy2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 May 2022 04:54:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E3Nh3baSkCrUUmmDLYI5HxAQ2dHtY7qofWG9huKmqbtW8rWvtRVTvXKTZqU9dGiqSpXAvNhcNOWitWKzGHbjG+yAWnCQQHzBIhaMGenfmuXgpXu03XG+vV8Nk5jzhF4JCYocATrhOCkS/SVfgasoXPRtavtYHXe/awj7uuLSfKfC/O4bylZdqFwmvjVuvXGVBZJMJ1VqrzZe6NY/B6rP7KRnDkoP4KkbNSShMZBe6NyGxOuz8841CbvEvBJ00IT7TGRvS6fw0P5urEAunrB69UCyWxosfU9M6Qw+Tn1sV5XT+C6IHwed2NaW2cLXkd5ghkFF43z484dgcrEiZz8W6A== 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=D2ClcG20RODJ8/B3gEdze2fdcqiapKpiiR/cDwXzYSM=; b=nKgk88QokPQ/za3VxtzgemcN1Zs01kNEQMPqbN4UHNrPkK4hwO+kAU1i7FUEjQ7rg6GoYJE/9iMi5wqM0yj9fMDDmhJCxxn/B68Svf3ucH7zB547f0yOERzR04B+t7p2RZIiK7Yh+Fbk8cnJozdCFkNON1iks6ai8Nr8qFdqpIMVqA9O84KKIIq8WI4XtVueQKY7P8hqFMOW82rch6OIoh0KZonwD5gz4CK9Q71BAOVP+rVaq9U48Dd298+5uPdewDnf8c9fUFOAlI0Mc4uvbvzNUckjbtcOy8Xy1imFkTG+jCBCM2r8O+XwSN0YvAbJVqozPrlvmJpyfN7L/AWqGg== 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=D2ClcG20RODJ8/B3gEdze2fdcqiapKpiiR/cDwXzYSM=; b=JQHKdZo/3HMavibZ/Ax+uP0VAC54SBx9IwJ0NABADJt8U8UUxvKz8dHnrNITN9ksYYgGMHlhd5+1I4/iu+ILTSRyXJq3KwSPAFJMjvJrEY1lDVMTD8Dg7M15fa/bSdwmdwn/dyeS/07hk1sv/G5uHS7dF8qspTQoKQ4ygMvyyz0= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by CY4PR10MB1416.namprd10.prod.outlook.com (2603:10b6:903:29::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27; Fri, 6 May 2022 04:54:47 +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.5227.018; Fri, 6 May 2022 04:54:47 +0000 From: Si-Wei Liu To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com, sgarzare@redhat.com, eli@mellanox.com, si-wei.liu@oracle.com Subject: [PATCH v3 6/6] virtio-net: don't handle mq request in userspace handler for vhost-vdpa Date: Thu, 5 May 2022 21:54:34 -0700 Message-Id: <1651812874-31967-7-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> References: <1651812874-31967-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: SJ0PR05CA0140.namprd05.prod.outlook.com (2603:10b6:a03:33d::25) 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: cc1e9220-34e3-463b-f55d-08da2f1c8b5d X-MS-TrafficTypeDiagnostic: CY4PR10MB1416: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: x8MJLwrpWkRBwhtP+ADH+dAwl8F78QBF4qgMS++AUi284N7eAchOYGE6W9TVOXW2gDn5sKccjNP/8zobQ4Y1AbVld1fML4FmOAa2g1WMN+yHEPoLXrGV9aTcao5i49tZTwea1wEoukQqWNqTN8yaUrSqEAiLDpSEZmur/KCPJDHv1q8PYJu4Wybw8i30hSMm4yCYCXlThzLyJdQRK18S/lGv4D4jw2kO/9D6JzbGK8cR3McajrLD6U3hk9zOsEgKRwGVOzntPC+Ck2cBnycorfDN6QbRSWfZXJdods2VqtheVT5XIs9SD1Pr1bxr89JGETd1LHKn6zxrjw33VkrfeER39HlN4fVUiL/2aSp/hS9/6Jxe1WzwYymV/3vOoCNRL6zzegRiA6xQcro0a9So7kcZzCbOTj9Yspm9TOSqxSl9Ju/7HDsoHWKzA93BBHFQOsRpVk//vKEPtMEAOAOmiom9cfyz8oCW2cQIZVUzGaIcXQKyO41jnUau8Q3fVb4FCkZEdXdzn11eBJtIAWA5i6xMuwk/tdbgwkeE8B0OkVhzVZV9XuSBpPPAVrepCVKKXk40UFW7Ag0FaFF9NFbKxIwXbLF7/w2IgUkJPH313uZ/F2xyg29KSMy0j5zTHcbWX9n8mOrxERat48+0sYibqefeO24iivCAfww/9rMjg1+qVPNn3NMDzjZ8/COScRWrLyq3Yoyxwr9o6UCKufAIsA== 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)(2906002)(316002)(6916009)(5660300002)(8936002)(186003)(2616005)(38350700002)(38100700002)(107886003)(6486002)(52116002)(6666004)(6506007)(36756003)(66476007)(66946007)(66556008)(83380400001)(4326008)(8676002)(508600001)(86362001)(6512007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Hd9U33B17tUjghLw7b79rlXql/uvmkJWaI0Olz3ooLgWaSW7iHIfCMa54V/yBri2ntKQltgCcATfi1KbtT/iTNWkkVIdkdz/DR12GMiwMCAJ5d0dVpbpaCQsppPV6OFwocLRJun3Y59eFnMXJLOdCaCJtjgma87rmtmOQs5uqTGiJlDagYHB2VMcqXLQDfntI8/4vWEqzGQDlDv2Pm8thwt9jdwnMaK4At4k+AaDtp04dLyx0hIf8FReL1oLvUhHwX0abuED4JNk0FcPGmVPA066b+S83ZYTO8Z0Zd255OedR1uZXe6mo4glrywpngipOeWdSGpmjG1ZIfrgwR5qLaBnmKiU0jy6AqURdlXbTtuxeJmwkHaCnOXaV7JChHSRqb5CVwvqmkpnROcm17Mk7NjuTW27SBYRUiK1OAIgtShXt+GqfyDHYtr43DR1p6l+YsZd9moPZ0VKVKu/lxS3buMojossHsasa2ADnIjvq+199LEigaT3PGOaT/phZZv4XUQM6lA/gpC2oKJYeegfql2BgZVq42Zr0PFiQ1JQzGLyZ4NUMHUFJPvkb64sBjauZMW+SyxQWGja6nw0vQ7tANzfSjx99nv4fWE2xXHv/EksD6a4KvOnVEYhoZCdba/YVyX1/X0qGAe9n62vZ7shF+ULSv/zGysscSH6jE8r8tOlhqg0FJenOYAE+BoYSFxPz/GomUeRgOKrMt+YXae1Gv6oSb6onix60meXUtxsVEY9FFQP12Db03bLUBGR3sHgPDzUiNcm3cFsf4xMvebSCkt/T3SCA40v973I3HPLPHCzdRfwBivxN25Pc/EXY4Cdt9bLjcTNKM2/5uQiA/wmiX796Yd0g02YcyPZ6JXdB9E3N+JbtAB0p6zld/gd+Y39xex2YkFa38xOP0vCFTa7BC0/Iw+wgS8dVb43Tj7UMC6u6GI8YwDwPz+kawqgIA0lbNlVyRqGw7jFjeFVITu8PH2qm+y2uhyU2qwhdj9Fpz7zmrUTBDZ95MRGgdY3tnrpf6N/5bR+F7A7H1aCEiDn8PDtiGXx7uKPepnuzrFfwXcvJdPLrQZuiFSYh5MULsp+EkiiwTcP95HJT/eEeXXvBzab0ilqy8sTyeaKTzeOZk4oLihd8MkfMw/x8vfehTpSQadrECfATc9OCa6uvjxl+o9MvpAwWe0tBaBaXvZ2OG7FS9ck/eTt/VHIzu4A3ZLArQBZAoFXM1t42L7E663tXWFVqSyPugyyMVu7PSe3IMseGC6iBc9Q11VDF/YECaNYI+Mv2UPjxAKDB6aloKNcatZJWh6zabHd0vuXRb/GAMpQDFv61DESFql+b7198ftH7FEBO33TJV3+hPNh9unjRhbflFW3pV/6ZmCEyBfSDKVSrPp5xY5udQGyliGH56D4MijuWGUkRm3yOoLK7v5ZruVru18N55Bic4nDuQnu+hhIY7aCxyf+F+emaa151vkP3re5JXSUZyWVFO3F0XPXBXSSyulL4Kz9CrznMdV4ED0QIOSNuWIAlITIiMzZNUdywEb0yWbl+qCZKqGedF3n7u6tgiW75YIixjCyV+qISQwCoDWgAVKV4kP6wSBbzfQqXqAwmfOgp2mz5bXGUZrcadyRPHUcYkr4DHFfSEJ5/WcgStrAYZL8eQgbQ+4DOyoEBxl3D/wyl7k6afbMUhrLyOLj76/PDLfLsnEWXYB/EWUNTgPbaVbBJWiw4dIghX07JenfsMFJvBpmjquFn9UyHdpuKn0egdI+SD/uyOHbzuQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc1e9220-34e3-463b-f55d-08da2f1c8b5d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 04:54:47.2470 (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: Pt1VbNjNEaELF4P6H2Kz5Q2zqlVUMQhQ1SOZq7G6AmyD2PuSGLluHHwQmToyPfnvU04sAOCV2l1QH9qSXa42kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1416 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_01:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205060023 X-Proofpoint-GUID: YqdkC8QRHldMgTg1xA2kftDOnyU4JyQW X-Proofpoint-ORIG-GUID: YqdkC8QRHldMgTg1xA2kftDOnyU4JyQW 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" virtio_queue_host_notifier_read() tends to read pending event left behind on ioeventfd in the vhost_net_stop() path, and attempts to handle outstanding kicks from userspace vq handler. However, in the ctrl_vq handler, virtio_net_handle_mq() has a recursive call into virtio_net_set_status(), which may lead to segmentation fault as shown in below stack trace: 0 0x000055f800df1780 in qdev_get_parent_bus (dev=0x0) at ../hw/core/qdev.c:376 1 0x000055f800c68ad8 in virtio_bus_device_iommu_enabled (vdev=vdev@entry=0x0) at ../hw/virtio/virtio-bus.c:331 2 0x000055f800d70d7f in vhost_memory_unmap (dev=) at ../hw/virtio/vhost.c:318 3 0x000055f800d70d7f in vhost_memory_unmap (dev=, buffer=0x7fc19bec5240, len=2052, is_write=1, access_len=2052) at ../hw/virtio/vhost.c:336 4 0x000055f800d71867 in vhost_virtqueue_stop (dev=dev@entry=0x55f8037ccc30, vdev=vdev@entry=0x55f8044ec590, vq=0x55f8037cceb0, idx=0) at ../hw/virtio/vhost.c:1241 5 0x000055f800d7406c in vhost_dev_stop (hdev=hdev@entry=0x55f8037ccc30, vdev=vdev@entry=0x55f8044ec590) at ../hw/virtio/vhost.c:1839 6 0x000055f800bf00a7 in vhost_net_stop_one (net=0x55f8037ccc30, dev=0x55f8044ec590) at ../hw/net/vhost_net.c:315 7 0x000055f800bf0678 in vhost_net_stop (dev=dev@entry=0x55f8044ec590, ncs=0x55f80452bae0, data_queue_pairs=data_queue_pairs@entry=7, cvq=cvq@entry=1) at ../hw/net/vhost_net.c:423 8 0x000055f800d4e628 in virtio_net_set_status (status=, n=0x55f8044ec590) at ../hw/net/virtio-net.c:296 9 0x000055f800d4e628 in virtio_net_set_status (vdev=vdev@entry=0x55f8044ec590, status=15 '\017') at ../hw/net/virtio-net.c:370 10 0x000055f800d534d8 in virtio_net_handle_ctrl (iov_cnt=, iov=, cmd=0 '\000', n=0x55f8044ec590) at ../hw/net/virtio-net.c:1408 11 0x000055f800d534d8 in virtio_net_handle_ctrl (vdev=0x55f8044ec590, vq=0x7fc1a7e888d0) at ../hw/net/virtio-net.c:1452 12 0x000055f800d69f37 in virtio_queue_host_notifier_read (vq=0x7fc1a7e888d0) at ../hw/virtio/virtio.c:2331 13 0x000055f800d69f37 in virtio_queue_host_notifier_read (n=n@entry=0x7fc1a7e8894c) at ../hw/virtio/virtio.c:3575 14 0x000055f800c688e6 in virtio_bus_cleanup_host_notifier (bus=, n=n@entry=14) at ../hw/virtio/virtio-bus.c:312 15 0x000055f800d73106 in vhost_dev_disable_notifiers (hdev=hdev@entry=0x55f8035b51b0, vdev=vdev@entry=0x55f8044ec590) at ../../../include/hw/virtio/virtio-bus.h:35 16 0x000055f800bf00b2 in vhost_net_stop_one (net=0x55f8035b51b0, dev=0x55f8044ec590) at ../hw/net/vhost_net.c:316 17 0x000055f800bf0678 in vhost_net_stop (dev=dev@entry=0x55f8044ec590, ncs=0x55f80452bae0, data_queue_pairs=data_queue_pairs@entry=7, cvq=cvq@entry=1) at ../hw/net/vhost_net.c:423 18 0x000055f800d4e628 in virtio_net_set_status (status=, n=0x55f8044ec590) at ../hw/net/virtio-net.c:296 19 0x000055f800d4e628 in virtio_net_set_status (vdev=0x55f8044ec590, status=15 '\017') at ../hw/net/virtio-net.c:370 20 0x000055f800d6c4b2 in virtio_set_status (vdev=0x55f8044ec590, val=) at ../hw/virtio/virtio.c:1945 21 0x000055f800d11d9d in vm_state_notify (running=running@entry=false, state=state@entry=RUN_STATE_SHUTDOWN) at ../softmmu/runstate.c:333 22 0x000055f800d04e7a in do_vm_stop (state=state@entry=RUN_STATE_SHUTDOWN, send_stop=send_stop@entry=false) at ../softmmu/cpus.c:262 23 0x000055f800d04e99 in vm_shutdown () at ../softmmu/cpus.c:280 24 0x000055f800d126af in qemu_cleanup () at ../softmmu/runstate.c:812 25 0x000055f800ad5b13 in main (argc=, argv=, envp=) at ../softmmu/main.c:51 For now, temporarily disable handling MQ request from the ctrl_vq userspace hanlder to avoid the recursive virtio_net_set_status() call. Some rework is needed to allow changing the number of queues without going through a full virtio_net_set_status cycle, particularly for vhost-vdpa backend. This patch will need to be reverted as soon as future patches of having the change of #queues handled in userspace is merged. Fixes: 402378407db ("vhost-vdpa: multiqueue support") Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- hw/net/virtio-net.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f0bb29c..e263116 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1381,6 +1381,7 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd, { VirtIODevice *vdev = VIRTIO_DEVICE(n); uint16_t queue_pairs; + NetClientState *nc = qemu_get_queue(n->nic); virtio_net_disable_rss(n); if (cmd == VIRTIO_NET_CTRL_MQ_HASH_CONFIG) { @@ -1412,6 +1413,18 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd, return VIRTIO_NET_ERR; } + /* Avoid changing the number of queue_pairs for vdpa device in + * userspace handler. A future fix is needed to handle the mq + * change in userspace handler with vhost-vdpa. Let's disable + * the mq handling from userspace for now and only allow get + * done through the kernel. Ripples may be seen when falling + * back to userspace, but without doing it qemu process would + * crash on a recursive entry to virtio_net_set_status(). + */ + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { + return VIRTIO_NET_ERR; + } + n->curr_queue_pairs = queue_pairs; /* stop the backend before changing the number of queue_pairs to avoid handling a * disabled queue */