From patchwork Sat May 7 02:28: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: 12841820 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 1770AC433F5 for ; Sat, 7 May 2022 02:30:47 +0000 (UTC) Received: from localhost ([::1]:41260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnADV-0007WJ-QU for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 22:30:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABT-0004ss-96 for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:39 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:10360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABQ-0002Sx-BG for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:38 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 246LJ7Pu004092; Sat, 7 May 2022 02:28:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=JkuGtdkhWInQjhsrba3R2eZc81RwUAjT6pVbwusNPQA=; b=x3lFK0PJnE08aEqQ2yCrz1HW6kbRu7M6jQ5p80WZHImg332sBtchA9L151yOgRxtu4P7 jiTKFPmqzc/0U5mQVsVgMpq4R8ppJuUKLzfI9uxefBlfFsPNfpLYdUZfhaCAIFY1VDun n5VPtjw8/8J6UICB1DgAas8KfMazJNUa9WOvw06NgBKsktyXREceerwRk1N0dW3TsDsL PJmxDK3Of5vwnPhJm6n2gkh9tl9WBiDYf7WzAAPyVqxb1kk+g/FCSHO/ICzhiRlp3M5z grYAvojQV+9XSZ02U7rccIS8n37Xytm2t1G5WQN32t51/1/Pj79grgZGTISWg2LeWMxl 0A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3frw0ay1e3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:31 +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 2472B11O033723; Sat, 7 May 2022 02:28:31 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2044.outbound.protection.outlook.com [104.47.51.44]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fwf6y8vjm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KL+tWIqagxyww+UO8ADlVkb7tlF+5Uzp3YZRzyv319arktqz36EowKAJl4JZq8AA+AdScOBZj0ltnBuzeU44La++3k+bScBMlKQWunfMtQJPuJTMyB9cLbkA7IP5suqrf9KQVEmmDYyN+yDDxuhjEKnL6OYpIhUiPATjRxGMzZpLU0yDZpMGX6ePNTT6stO30aaPBsX8D0ZU0iiKZ0SB77r8A13zguLhpRZjE/vSpO4h7g9ZE6c8LcbW2ma5i9mt4t4IimP32PyitntZHdIMShehh+Bxpc7kO7+ea24u3wfL6t0uCFS+mFPkDoXKEiCl9dJvUKLkidwovQKcTbQU7A== 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=JkuGtdkhWInQjhsrba3R2eZc81RwUAjT6pVbwusNPQA=; b=mmAMQJrHYxQDAySXRt5wiZItG/Dfw481+s2vYvoQe1Fz4VaeKOJ/acPHKbcHvmCAAed8exs+RiSkv6fiDd7xo2ipjnpV2B5fd4wWImDIOUaN39c7IKhOkkVjGWZX74D15Id+g1IRV9dVrrHdpTdQqxtfYGopeLqUSdNfC8vnkpZu9YNZCXGs9bB7iUYkgDLbB8SsQRo2B4A7M9sR/aYoaCqmEadC1msrpyx0CD8uC8yc1JOgADMTwVvF1YCV5cZOUnYv8sTfpAGWDChojTiHa1yUk/JdXvj0mTiG725xUsyVHioTKwxCMr0Q3b7+LqVAjE7F37541nH9BQesSN27Xw== 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=JkuGtdkhWInQjhsrba3R2eZc81RwUAjT6pVbwusNPQA=; b=cmRObCetkqTvr7jyzq78Q8P4W3TWkefS61ZgQoEeWS7N1lnEAA55wDMjmuF39w0Q3E7VBVlMOzGcIPrVONt0rXe6posCJdrGO5TfU2/I8tG2PnWn138wUyAkzQexwbuwxJGx5ri169KInl9W5KeVlbD5461VFP+I1rC+9eEuzbY= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM5PR10MB1370.namprd10.prod.outlook.com (2603:10b6:3:f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Sat, 7 May 2022 02:28:29 +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.021; Sat, 7 May 2022 02:28:29 +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 v4 1/7] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated Date: Fri, 6 May 2022 19:28:12 -0700 Message-Id: <1651890498-24478-2-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> References: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR03CA0041.namprd03.prod.outlook.com (2603:10b6:5:100::18) 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: fa333451-e916-4f4e-379a-08da2fd145bd X-MS-TrafficTypeDiagnostic: DM5PR10MB1370: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: lUPjxK9oXZ0I3JDNkKhoty6ua/5u5ujr1SSPR4OBymvPAC5Ev5LTNqwp84WIYPN6Yz35QQEsL2MdQcxeI0m9/vogCg2r8FfB85f6JM3MNSj39pZaxt1imjHkrf15IvwKHwv2cgMaLMUg2eoRoDWVVrmeV0V+Xj7ChNQjiGRuSxv+POI1mN0RfiAAQl792uIJHyYp2zGky9lkEITH/woC8JUFGc/4rmO1zmGJAuNjZ3kXhV6rpCs8BFgXH+8rzn4H5Q2NsygzLA3t/6ElW15QTTHTZMevg1rVHoc28ieMmeHUCmka+0bqJn5Tu1e88ut2CSsdtFJYPzd2D8sD/zzMK9kJfrqh+DGW68hxL8JFWmRbBOblmO7ay+LfQLLh1jZtwGqqbrnGpTVxKS0FHGgiO+Zlt6l69gu39uNveIh1qztb16zDJAsdTBMMeZ/LoQBH4ixsirbrVtoABBAXD8sN0M4u7ohXeorlSFjIogkmvwadIifon+iZjSwd9mZdyDCd2RfjlP1tZ67Y6KIzYkbrGJh0R+uHVPzQQ7XSvErT1bVg2sCZBMz77yGUfJxp1nQL6XK5/vLH9F5TzHGkRnAx3Dg8rZOuqeSV/rmm4ZQ16qMpvwWwH3mBLmThzZ/yGn2pzELdubEIxWbTwwJDhqqn2dAHBbheu+XYk6V18pWdhgolXHmn7OteaReKCM7oroB46SnBZlfefD42nLDcFMscrw== 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)(83380400001)(52116002)(6666004)(508600001)(5660300002)(6506007)(6486002)(8936002)(186003)(86362001)(38100700002)(38350700002)(2616005)(316002)(8676002)(6916009)(66476007)(4326008)(66556008)(2906002)(66946007)(26005)(6512007)(107886003)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KBMTai1pQ9yyjEbyeWmq4WB97yVxE+2Cg15ylEu2Zcx4ZB7cbaajSwGl62ymhKb/qADJSgjsOy4pAiwdTyahzn36SRGuTcsdxG3gE0hXx4rzRlHOHbINmuuLgfyLR31ANtSVNYXC823U90VobdcV7d1XBV0MP3EbTQTMIMjRdaRP5w4rir4o3pHy8Gc2uzN/iuvdlY3GRug+UVKBS6bzJYD+kEbYaz7656zwMohU7plTVXF6yTHk0/zQlJpWBcahIUDwCL8Y1fTXILqbnt5MTR8JsZ1Brk8OKUxQqVeB+cH4f14YGQDbpzcI6HZmxc9HCgREMUfd1sgEXuIMJ+dljvdQ7vFrgAVbvGJUtGp11AcIS2OZZjis9kFBzxEJBtn8xxxKBHulrZ0DZwMU7mIE5x18oyB80PWI3xoxRRrIChHMGCTZhqqNWVvmQ7DTnsdV2MQ/HQrfLANw8UT3xAytdENEnsFdUnK70NMC1FfIbOWL9cMkCwxaFDH88iYo3ddsFGHSs+e87NdLZx/2ZdnG9OriO26nKV5R+1y3p583UHgqpHdhD8l8upAZdrfOotuOQL4qtslbU4gp2TvlRTZJlJ+IYYy0zow7vhsd6Akrqqb3vNo0BA45SiCZA5r1byO2JpYGp7tNEitGzLVJc//auznJ0d++vwpUJLo0Sj5ztRY4GceJVvSFndOe9iC/T6sKcBtbJJlSBSz29EWeUcgkSA5aJ9+7Bn1Uid4qEzQBjyF5uv+Pj7gmZdsvXbOpnWF3wg7+ca3ONP544CkBt3+VdGwecm8q/RiPVuLDo0/RUTYdfMSQGlwYvNsPjXvZGCCLCT53kAkprbttUkCxe8CB3n3eJ5c9RIh4QuovIfBAZmSgj0NlwwlJ1HwSTQ2N0+PqXhhMAF58eusUBzIlT4Lg5WKTM0GH3c7H1C8g1jpNYDZuK68Pp1FJm1PdFmBRrOmPJPQdtAYCnLrBw7xOVb8QyDs0gC9ESWvT8COVYAeQ8cDHu1cXTyK4cmo+8RJn1OKD2PLT+u2Ni7dbTXol7BpKSp8Qa/tQYAoAAdMJV22jahB2KMjJ24lC0H0/n34sxVWgO6kg+C7RWfijof0XWnEYQbVf/mmaHDpE7FbI80JTdGuuUE3WbYKxvr9q26FjA8o66vQXXeS/9zmbcDGf2fQUpomDclPrnmahMC89TJbg3FuFR+XG1+Jfrt1Y+MKMhYXSQ4n1Kw0fa4M9kIkxI0CcV1n94UF2peqKFA8VnJ/7/JHV5mGO+gqaWLyz1bg1oyCrYL8y1NkvKMMNo9bcivc58Mo26NybaKIQk4sKyMbAbqfi7XEBf/Ujh5cG2a7oV9acdYGooC15rjUvDq35+aln9sx9moG3HKZJ5TMzF9LrNM5JZYtMtCxr/Y58C9MF+VQqS0QX01hDy6COF3PSnOqUq9xNvwEJGzVPiiRtlp5xivFu6MRN71Z2En2pxW6hGIRdjBmE0F+NKpm/UgruAdhiMg46pjvEFOc9Av6artes6est4aQoivfiZ/BZz5E+Lw0f9Co5vzeCW9+cI70NKTI0rHC+khDQxH/CGdm5KtY5CzcZA8MHXMJKbxzvwgrIXZ2g9IbZ3Y/KW5I1YyuB8W3Th5jEhgjEDLa7Y6EPEGqRWQYwS1T5UVxwtuTplozMNG2hCBZJ8rWLVzAh6xnZddI09aSJ6tH2/3WTpbRup01V9JZPj12IKYG52pSnha+L0rzzzQ/4QQ/SthSdEQeMsGWTA2fYVs/DLQTeH8ZJVsFqMmI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa333451-e916-4f4e-379a-08da2fd145bd X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 02:28:29.2763 (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: X6fPjqNuhQDhP6l8zSuVSooM2Yt5nqHVcA/A5RxOlAmro728SDRcqBQQqAAbiR0LNoudHUobtQ7JIcM6cDAdWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1370 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_07:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070012 X-Proofpoint-GUID: b4li6udNC4gLGIOGL2Pyf1pJqhXCKtbi X-Proofpoint-ORIG-GUID: b4li6udNC4gLGIOGL2Pyf1pJqhXCKtbi Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 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 Sat May 7 02:28: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: 12841826 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 19E92C433EF for ; Sat, 7 May 2022 02:33:03 +0000 (UTC) Received: from localhost ([::1]:48086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnAFi-0003qw-8L for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 22:33:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABU-0004tD-TY for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:40 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:35158) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABR-0002T4-8o for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:40 -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 2471uQRj027467; Sat, 7 May 2022 02:28:33 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=PT0kcUKTqXifSrWVO280f2P93PTUtAgbpG6/XXG1RCw=; b=cQXHrMYJcIkCL57pB4TpNU1hneWzEQaClhx7+5mdB1l1dYO6emdkycBCFLS0CyQLHjkO 4lcU+NPhCrEIkqTcQMv0n/J0MMrs8RAj/1jieGKibMCa7mEToQ1kSCYP60MUCm2I/apE D2koi/8yRuINYgdDRl7N/gRwuuI9Z5vzR7Qsvbuf/lUQy87jC3qAuNzCAMlFzzgtsEXH 2krX19qhMHy4PuvtadvMJar/kdcC6btmqW+g+6OkoMvjOMy0jaeuMs0QaaVW5GPrzJTa cGc57QzookiGzgMYHs8hL4EIcwvh/NewxnQlompVI99Y1ThcdigVmOLfY3dMpIEa7VXg Rg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fwfj280pt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:33 +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 2472BQES024288; Sat, 7 May 2022 02:28:32 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2045.outbound.protection.outlook.com [104.47.51.45]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fwf700tpe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KJA8cJJbklT/+G3oy85Bz89LJWt4+lp9Cyyfu0f5WifN1V0w/IR8/PqvlanzdCzIQ534JpZCbgmcSB14yJqmAiCMZfSbnhm4IhGH+vbuw7I34YIXVDbpuSC8Bc6Blg0r31EpOd1PWLrxdDvZRiLtGATON+Nr5Mw6G2+xnpUtv9KGHJIPOSqDFPqFTr+kjMWFzOWCdVo/66XqrbVMlgofJZ6heRpMdp3oUIGzjd547ItqSkTHM/GqcIpJEnbayMYjd3iZT4+274r2iHCYvuYROpglLf1lIMU99qI0ToKoheEPTwLZ2HfPHBIV0ENO7ViW+ILJnnG1FiVUaoXJrEuzeQ== 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=PT0kcUKTqXifSrWVO280f2P93PTUtAgbpG6/XXG1RCw=; b=ACtCnT32ymNyHFWtJ35WLDQlYm6vz5smv151RtVV1wfy7Ew+1tcpmgGPemdw7v1V9qaoVWcePoe7jeKpcuQU0aicdU8qz9TmNeYPhn4buShXLjJuZANUYx+kZv6yaB98wpPZWtbYPcDdNGkOikQoFIoc5Uja6ewroUHxYzlZozf5WUS85y/LAzMl2EW4wCkQiFWnJnA2OSaCLxFsYobbdOc4GXbCKdklbpCDOPorcsoyFt059xIKnvy6mbDydOv6+CY4tR8ljPymJgNsC4GzRxJLRbVcc4FrlrVITHRqmn2nGQJej6elZfoA4KmiWGgzLTksd7YmH1+0S56PDhVbmQ== 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=PT0kcUKTqXifSrWVO280f2P93PTUtAgbpG6/XXG1RCw=; b=Tfe0EpvKbXsCXhlFmX4DsIrqfsGCNYw/F73c3Pbo6M3inJYfc2CMkLtQW5GLKi7yWODUTM0zv2K3oRSL+tRPZv3WZ6HDWerMaGc+UUbmivTfybWvex2MWngVzrxbvvxL0X4vQNzOCUdG228dy39TRjdEeRC+0Wvu9Hg7r05vmYI= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM5PR10MB1370.namprd10.prod.outlook.com (2603:10b6:3:f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Sat, 7 May 2022 02:28:30 +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.021; Sat, 7 May 2022 02:28:30 +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 v4 2/7] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa Date: Fri, 6 May 2022 19:28:13 -0700 Message-Id: <1651890498-24478-3-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> References: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR03CA0041.namprd03.prod.outlook.com (2603:10b6:5:100::18) 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: 8e1b554e-787c-44ef-de09-08da2fd14668 X-MS-TrafficTypeDiagnostic: DM5PR10MB1370: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: 462cilQ0Jk90mvccIdw4M9u+WrAVB5JEd0QRG1rus/yvU5UNWO9IxteVjzpe71ZrNnbC8UjhnIk3YI8XpF1qFOZEStygBkOTc7wlXJMF5wq/ByBX2Yw0NEBBRJ+N8dhpHAJ1qRMh2hvVoap+3ZdKWR1RhglYzE31BkSoVj5+3lu7Zac285hEvu/z6qBJl23jaw0Lq1jvY+8RbNgqZSZmINQRtDtB0YQU2/hrU+0UDcNnqOJhEaXqTVPXxQ6HifEQYpr+v1dnSfdqtsSfPLWgqni5mKrDa1ziD0bcLl8yqfgQOYNJqH7Olm4AnYnl/LmgOdzzrGOzLuz0AazTCW0cLsfE5efDiQQnSC+RgbgnaBblhN6EXNxMHJtol9/g5r7UxvaKjVa4ZqrFzY1K1PGSlD8OC2PHi5WAcd1L4gn0nYTKNqAk52/GOPjZRTmN81yIh4f5uCI+YwC7zbLNr3ADMgr79yxtK7l11PFpsNAQluLV2PwUUqMr8ZrKf6JFNR5bmzs0it2dCFNDmtLhhS9OIax1mCXHcMIw2DwEwmq4O7fISLk36qZTdmdeMvxBWaahd1z4URgECVhLEmUKnswxRFkhJtSkkapAqYYCTzwns7g9gf7iHqM1hVVBbCPPWkTON69qG7p4Fj4/cmL7tVqd8cHB243kd7wv0+GQ8X3tZ95XrbbMXkVjpveDtL+Xcf+Y+eCFMW2kForuv9yk8SWqCw== 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)(83380400001)(52116002)(6666004)(508600001)(5660300002)(6506007)(6486002)(8936002)(186003)(86362001)(38100700002)(38350700002)(2616005)(316002)(8676002)(6916009)(66476007)(4326008)(66556008)(2906002)(66946007)(26005)(6512007)(107886003)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nZz4F6ac9gPwy2G3gudlYziXE6DgIzebJ1MiokSGnaY8dtQ+/JCm7KNRf94uI7KyGMZCj0q/Scwb829s2X4kYDRWecnDrAWKQLU7SwhJoPFdzqh2NT98WqEw8hKdmJYwUgj7jwcBtnX6dxqJ4i0cYnc3M9N6McXXkLpGKXzNlo2tc3p9g+t84NAhGt2mjIjWnvG2Ak19ahAUo8pF03fNlYHrtzisXZCKY/nVeIdiG0gaOmfc55Q3AT9XlwPmuX1W24djotssEiLZuUqRRUscXhFxm6lvhcXtbyR2MjNsAQn3C03UUCkBWgZ8p0YDlB3QrvC1c3UjYrtuWm1Y8DE6EpEEgmR5enoopSK/dMIu0QqCn9Jo6eHc/ynDRNP8JDNaawVI1EBQ9vGxLZadYjj313vKkPzFQc7tLgMiwsaJQdbhNnxZP8GqKc5QATVP1HgHYKUaLKe4hBZ8Jxwh0Sru3rB8StFFGWrpWiadJCsIPU7x7kObXXz137AFtNmHym/5xMdmIhi0FWYekLioo890EiGnHLWiF4tgL8HOea9BFQMEioAJurpvmAzooHfKEL7WSPlV/o59gnXthM8GPO8+f652KI4a9VSCoPC7EioNi4M+Rw2iksrMEx4o+J/IAsvKyolcJEr0PQOnZLEE3JxosxuJUMM9ugBOP/niBbmMeFKl1Fz3b0NqeEsBrBjPqRrnjd1B7Lwsjyc4xibmCaIpa40D3ohaBEaE2imWIko9hag9IuG2w3sFe08eq1XUOEpAGAr5boq7NTcX1Us7WQ2Tu/9uqziq23HWgED/4d1skKl7P71J8tnFSmMvckEB3m9qIYro38jjY6o+O5n7+6wG2KP1qwnlWXu1NZPMxw8ANAEhw2hHs3AUEotc7f6hQyZSfqDVa4gnrGsrriHpEDXZeNfl8X24HFOtBIW1VRrRp50dkWnMo1HVURA42lvOj5Qp4RVWVJoJrJEBUalh9aSavCXis9+qUPxlOViFtAnFASPppV3X5auJVKQDad/ZpJ0aG6nYSxe6huq3UEPqNdeS6+h+TqIza3V82irF7IBogxRdwSR0hq0b8hf14XkzgfgHCBtFX/hYWKajBLx4GyRonrWUFHjr7pDmYIP881JCqyIqSfiACrME6K4WhWGRbAF6TGGuFUvu8M2UMbutMdkg8oLpJ+62UmFhZr1Eu4aOYfCHDigOdyQuqVHxDfO66pwoNcx7sErXOriqzOhQVlvtp4djJtK7X73QAFDTgJAMPsfnzC3mX1PqGS+BEu8X1yB6W/yAlQu9VNRnmasAqhozoxFvePJ6PZ7LBSBkHn3P9yOg+yQRw4go+6Na+BNqBnsXhItb0ABnZx0ZHJBHA84xUYdKilbI5+ke76PLIAYIu/8T7i+3d9YGfaDiUNOHfkFQtJHJ+Eve7V2ChsF55nn2Y7NcpmiOzeVDDejrSqaPck6LKvvI8XzPD3EiXBHgGyIYDgjyAmzwerFQj6odSc2F+886s845p3/jAo59SLfd4GRrsNS6V6+1U7K0t4/sTSVMT4KzdjeKyvwzjGkMVzYHdkkJH10iYsU3eqUAgV2oUd9K1s6I6Z4uBMX/CgItJ1IRkt7jqhZQ97xiaW8quuBRrWl32g433P+XAdTt3JYZONX1Up4RDdTWnEx8xPyyOTKdtdzl11k8SzSIt3nxcjKRETVybxEGl19J/ca/xcBbDoPF6EL1y/ov8MrjWY8bZpSFcp1RZLbw4Xj1UqipTgGl0TzMhse+vRbGLY1Ct15lbW8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e1b554e-787c-44ef-de09-08da2fd14668 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 02:28:30.3075 (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: YX2itu6I67ZBct4N+n6eSY8frxgntE0p31ZaYJGJK26TWOxUXGU1yHs9Y6rL8AKp7Xopj3Ed5wBCcBNj7ruyrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1370 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_07:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070012 X-Proofpoint-ORIG-GUID: GlCFG5-b0ekb536C6pfQKfh1JMEFmmM8 X-Proofpoint-GUID: GlCFG5-b0ekb536C6pfQKfh1JMEFmmM8 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 Sat May 7 02:28: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: 12841821 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 A548AC433F5 for ; Sat, 7 May 2022 02:30:49 +0000 (UTC) Received: from localhost ([::1]:41416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnADY-0007cH-Dg for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 22:30:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABU-0004t8-NG for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:40 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:35794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABR-0002T6-7k for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:40 -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 246KM4Vb013484; Sat, 7 May 2022 02:28:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=UH8ONQDqwjqYQ4lGiy+B4eQ6Ks2NSI+/jFWft0KaAxI=; b=QrB7As27w9bVnU7iye251SdZDMMIqzDBDCfI0LQs0aeQ5cUpx5/sD0ogAnAGMXsr8z4F AHuhT/ZrlDDzP9NHLxSoL/MAF/7HDaUXAJnH8MXknt6bgZ7aTbmSUg+3D5PQV+u2MbBr aqTK9lMRlqyktuDfZ3nQBsJkvGK0msbhVFWEuHt+VE3RFpwIIGfclRi52i2R1WuSyj3w LiAd90mIjiD3u+VhXQIDVTZp0n3LbiHR0QAAGWgrpXke3TdlPrL8KBM2LLbEydoDmUcD d7pSf2TBXh3xRfaZaxzTHwQHmTVmB/bOmf0P4W4FT+iG7f+2IzuCe+c4n3pwJqvnBcTt zg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3frvqsqg0x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:34 +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 2472BQET024288; Sat, 7 May 2022 02:28:33 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2045.outbound.protection.outlook.com [104.47.51.45]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fwf700tpe-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BaM7QMOhL3+LiU7qUcY/1H8219MmNF80c7tUTTXBSi4Ft7aFmEZ40bCowBap/sqGvEK5hdgDf7shdwCZp8SDF14aEppTI+xmtR6ikxDtW9p8F7Nc2ZcF7UEgBOCdLBWsg3XMbaQ9VfgVgheC7G7H1+v4hwYIU/2oz/UJocLddytWJ+XYu/JpeXxKD+xWjUHLsWpUoiQAkYehYVwdwQp4hr1RxxkLezJrpRW3Y8G2RVF1GF2wvDczPNw4cCIPavkSdo4wmZaEYSo+RxJ9J8X40TOnHkAJ5S6JFSQAiDdcdfdqyAs/CjStNaOMD8Hn2AziRc6lnNga2W3ua4gdTeCGuA== 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=HPUYbUmMnGIsmSYLjbca1fvPpiB0HFumIlJgghhEltcLp5PP9oS6TQtbbn3Bne7osrLais7uBLxCLByBZ8/cLyl4lo/jPJBu31xrEG8P9DT4KwyeRgLwG9I467N4FRk5rFNNDFLaH1d4KuygboWuXak3swvUmebq/8KKsqCYMYN4u0gsaUzWngXgFGIxZpe5kpazf9BAUs+ZsHRkLrK0M3Pe9/iSOcOsPn+Rgsm++sTCyGu7K+FZr56fatiTNca5+hPU8CdDUUA3f7lCl2SFJdGMAyvuPiK1jn8jbox4+toZdJkylsYAJ3fhC6tiqIFJFQBUjdib3brziqgQ3TWAag== 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=q4g8M5Ud1zM7eVt/CHyxWfEO4QP9Itiv3ftubJgSSYR2h/nbEYJ5MupF6Qq6vsmuhLVHcXpSb9Jh4DkFs98C8x0B42eKkP13uEYlcTVh6dMnxQFABkSHN25ebgVG2bhQU5ELTH/KsUF8VDEXzKROIPUJc/yq3nrpc9Ekj3+2/go= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM5PR10MB1370.namprd10.prod.outlook.com (2603:10b6:3:f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Sat, 7 May 2022 02:28:31 +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.021; Sat, 7 May 2022 02:28:31 +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 v4 3/7] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa Date: Fri, 6 May 2022 19:28:14 -0700 Message-Id: <1651890498-24478-4-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> References: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR03CA0041.namprd03.prod.outlook.com (2603:10b6:5:100::18) 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: 02a8e495-4036-4f68-98eb-08da2fd14708 X-MS-TrafficTypeDiagnostic: DM5PR10MB1370: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: JaN3z7WNpJkhD4v9mARaB2V0ekUR2cYsfKmAEXFtlQsYoYOla7DGJ8ODgFVJMq/pen/A06+DmnpHCfbgJK5KG/+cj/XiGKJBC5HjRlcifD5oBd69an1TOWSjzh6HtAMhtKV0h2/fADpgI1psmo9KOzoLGFPHJKnzJOjq17ggrt4uvFS2v+fyiphugwEV1NDx3HBdQMib596FUyX30wa81QVKNrqop3Jfe4AcROqFz9W2ENRpTZLf7m3WVTIJ/2lbYx2IgI+i8Arfv4GtoI0PDTZFCpWLBTA4hEPgvC/PZoWv5bv0FY68zC54jEvnhgO3t3kCOUFIjJEnDWws5k1gJT8Eigsi1fKrOuif5mlXi2Wc8Z74dKCvsqOpr79+OlxLQ+dUmqvegcRY9sR8ChVItDxybDDdZBFEh//8Y62uZPEoz7EFzkpd/68InpfoL8XdB9u8n0yE7rWG3meFoPQjL64XTI9kl4wWWlcHHbgFf9aEJqQzpsVFtPKmssMH5WrFNOSA4YtxJ525mVPXYIw++IjrO23x53hA/SwK1AV2/zOqY1s1RdT0Sy7vilrm/0z/BRh7PMBBuCHIUjx9Iwn1GXCav1LOPzXocx4S1lJqfgUoLbfeqPekF2bSVIjTfczNKt0m+GQVIARK+CrELwDNp2BBxMIzpdDcLUcWtlpMNp+vx+MAU6/55KheU0XEwPEsxhXo6/2fMiWzI6EyI3OJ9w== 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)(83380400001)(52116002)(6666004)(508600001)(5660300002)(6506007)(4744005)(6486002)(8936002)(186003)(86362001)(38100700002)(38350700002)(2616005)(316002)(8676002)(6916009)(66476007)(4326008)(66556008)(2906002)(66946007)(26005)(6512007)(107886003)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rQClKn9bK1qDawViP5txBkbIwkp6qGcRlaQwTMWF0Q4qeW5MrX0XPWOOhVppwDZo4pwhR/fgmg44/R/upeBPR7BroEeJ1a59sAPHbXN/FFe0GrRLfzmvrq2lzbURSasZT/s5d8kDz41yB3DzqlLLOwA/OhQmbRZTYYsf97pj8eoRG2qaYo6TePSN6yur48be/q+KmFF/1nPSl/bj9Zj2cLZg0BGf4ZZvs8YRhtiA+aTCplLk2pwyyichYLmtrCASmwpHEoaexCyFJcKquDEK8DGq7PhEmlHtbF1TS5YkDpgKmzht2mnE9/1hermNRBQ1sO931mXWX3iJ8hQXSdoTDrkpzExyjhNAbcFF/2KmeqoBMR1H8PrS/ubF1TlEFUTjmhJrB0wDNHK9YJM2ckqJ6IJEo2LntJHGF/6AigvqmU79dQjnQD37IsReuDNWSlQIHycrbrGOJXW0yJV9LF+CisqonugJ7FGM50FZjYZWBjTuhqC+unadSa2TZsnNRqCL2hme4FqrsVsNxuUCx7CE7hPJUMeA1+rDahv4FuYKhbvdwPrkb/6bgKlQXhTZkcUMRHYxnS1H9EMavEWeR3081VRlShjtvyEbO+R8sYqInxhjtayP2Oz7Lg1F0hpE2VRcwbXhHgNGK78GamM6Lq7XnMr6AduZ40Pcv4ln1hlKHMgica4QkqZ3FCTPR6T+3q+d2lCXTZc3XYpWFIsA6Yo6M/jHqo25KU0FWEd0or/XSbEEgC4b4tZDdbV1x5ek98GbgjKWS3lXfNii/qs84rhR5BwNvKLdYgcYe6wg7jniattbE1lkGNzYCK44XLJKw7ViwrBooAbOhGxJRjUQE55NyaTA9dbHFDIlEQeERMeXfcLrWVmnOEnR5txH2OBAgOldlD2I0NGk4VI3Fu1yk1GZ1f74wsRp+T/ep8CB0zBUKe6ZjosFHG+wfWUKCyNjEl6dIC+357m3CQAAuqJMKGciAaeDktU0+KtfBAM1d6fNOQg9PpMuPXThKLBIyC/vt1xMqWWVAs3OW1MnXXWVg/TSUudXTHUHv+n2Ctf3JrDHWiDhzSDeXlK8WZ0FXoCu33v84sf5APBtgxUHAUteaYvZlTLhVwsn+BxnwwysJlAiu6g6W5JsH0m+67PRZQU7pk8YF75+abGRW/F1387eNud4vXWDbjBGT6XgPpntYac/0qY6yyPcrfBtB+ahT5qn4TqrOvrxID/Z7O62i1Oil06z/ivrQxmEVMVnKX6aQXuBvB9d7PD8Zksm7nUZfFkhsmJefdFqngVDoAQHY3lciJDY5N9Cmr9gCTQQe8MhqtDKR/I6V6L01b4uez87zKFXbYBvMvwp/gkaGcSN9ZFCzn69azhdrq/6m347/bQB5hxChvk9V7EI4DlrZzT6NQ8tCUpwABeJFU7NArEVYcuUH/diEWa39RLWVBX/13k3MvRhrsO4Qbvb2IiXgExc1nzzi7c63ZkDjrhWpSsmLz7PA2HQnATx1+VRcqEibxm0B1jauhDsoq7SfHmIU35ZMB1Q9RoehVe7OJ2U3QeiHLd9RG0Os3UqQfXTWVz48WF3yGo5fDgihABwfxG+eQmr/XqB5ZjbVtF8GJFe9PaHtf6mszqAyrTKBjxQnQ0NgmWaepPD26dM6WWbpKDxwyXt3/Cg6tAlYByc9lMwP936/6scViClaCz6BbQ3qQXhSSVKf6TBZ6cQmLv1TCcALDxjUzsyWBGUI0QXUcAaIKLqudRe17DyIfpYAnOGU3M/yT/BdgEadrg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02a8e495-4036-4f68-98eb-08da2fd14708 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 02:28:31.4325 (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: P2OuW39l5oFOvh8a6miaqO8d1gN60ARgsiHMAjeDyspjK/gDshOYmGr+OIT/iGCDRAzbYdy95iBTEXG2CiBjBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1370 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_07:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070012 X-Proofpoint-GUID: lLhfRrWEEZN1fTR1nK-03YvAJkhULkZ0 X-Proofpoint-ORIG-GUID: lLhfRrWEEZN1fTR1nK-03YvAJkhULkZ0 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 Sat May 7 02:28: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: 12841827 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 022AAC433EF for ; Sat, 7 May 2022 02:33:45 +0000 (UTC) Received: from localhost ([::1]:49394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnAGP-0004pB-4m for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 22:33:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABU-0004tE-TZ for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:40 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:37708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABS-0002TD-Hw for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:40 -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 2471VoUs010450; Sat, 7 May 2022 02:28:36 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=BW3UaLtk3JIJwGyncE21Vp3BdzYalbqemCJ/MXTPzCz8YygIZaZqW7WZmSlXvmR42qFG 5BATBw9IkJGwY/j/97x2dw7LpWVq0lUvAU7ZLXoO+MYxeprpxozLsTCLdZCqiwA/Ra7y f/hIlX1+JMwjFdFjy3MUhUfryKvd2sQr3XEfcZ9liq5Vl7SV+dQksOyiEQFjW7/T3ok4 plMpOOAuYjqAOXRZMWsyEfvh697iXVFuRGSJTuKqkVcFfKxD5L/BEbaHvETP4R5lx87S k9hz+rsT30v/ZfB0zCSYIL0SO/IHLDZg024adaEx/E5ib4OjcMXSv+MWRKe6eBdq0R8k qQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fwf6c015x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:35 +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 2472BQci024291; Sat, 7 May 2022 02:28:34 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2049.outbound.protection.outlook.com [104.47.51.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fwf700tpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SG/D5ku9hWvXwrSfpBlnXNmXe3fEyvljEBghPkkZVn6pOz0pGa6EOd5yWHRdt/Q9piEoALfGilPn4x2XCG6+cQYX9PyPrvNu7urrV09VP51nlBFZ27wZO01POGaIE9ksNYj14nkQdaAlMuTq74PjmgXKIgGcAffW90RLXAREBIksSyKI4probaXL6CteZ6L/Oh+pNfY/Tz+kv5RU/ly7BnXthfOEY7ml2X2JELhVJ3SmBntjrqwHN8iyQ/fFTDJt/YnhWtJEAe5KUX1LLCtk+O1a8PGgmO9ZIP4SSZFS5HHa/bvor2w8NVLXK/Sb87Wfp7oNNRB9PaEAYqpm1/tElA== 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=hvxCLAC5QtXGRE77HYbKnpwzb0EsggIxBr2q8MRt5xh9lNmRWgpggZgM0O9IRN8SICRqRwGEqLi8B6I4QJi8Pq5YX6c5zBSlcxE6IW7eEQpie5yYYorECG4GY8+czFR0JgghNevrb/4nyUGIhzJGCdkr794ozZgcY7BYwi+Gv/Yir52zLS24OYVpPeb/hfxxxk4Jsxr+igD4RKSfwzSuTJpOa3gytjfXahUXQqJnrQdscBdkWfBhHE0PM4VREzGswGJ9bxN19IbGFyKQHBwOkLypj7oCs74rgUQjvNjKe0G1RkOg4aMPR7sos/GSJU5T8Urf6D+bkSlBw2EJKBe2LA== 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=UIDP9j+0vGv+pP4QNfHXNjJI135mZ1uto3cunlDyoZgml7AlISXDLfEHGtVhgtQRX6+V3/FjVi8oFryE4WdsPE9d3KAIFNMsJGCpu+1Zmu2PIwuRxKIUPVLe1720Av79+UJJ+tebTjVsgqBPcuSAR+Lm+TmCggBPrCQiao+e0v8= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM5PR10MB1370.namprd10.prod.outlook.com (2603:10b6:3:f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Sat, 7 May 2022 02:28:32 +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.021; Sat, 7 May 2022 02:28:32 +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 v4 4/7] vhost-net: fix improper cleanup in vhost_net_start Date: Fri, 6 May 2022 19:28:15 -0700 Message-Id: <1651890498-24478-5-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> References: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR03CA0041.namprd03.prod.outlook.com (2603:10b6:5:100::18) 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: 2714a7ed-8c10-4c0f-a1bb-08da2fd147b6 X-MS-TrafficTypeDiagnostic: DM5PR10MB1370: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: L70Azbi++vZlWcfEaOQHy9Pf3DCHVViZrJ+KLi1G76wLd8R5dAgFbjrw95SqbQEsizVGK4CqjgnDCCFm/xzlYpllUhEm9WQGa+Zi80OMSBCYdjjZSgKrK6Cl5+4oc0b0UACGxWd9JOAwCNDSLdm+doPX7tmiE41AEjAlPx/oCvwlQw+oirGG/dO5D6iiDSFlVJF153IsxSHusopNQrmHl8YYWkHBB70czhFqVEjflqFF3qvsLysjjvZNR2z3UksjLf/Wq7RDGdxoYq63Nmrb4HwC9nE4TZIE4IJUlvrp2nsWK5qHfFi7P5cyzJ8FeZWpz8kPAOHQNltqijlaN193Ygrz4KCsUG1KbUMyQkzjMjTNFqzRv+mtorULLDxJ4feFJ2AIr3b6I7pBBtfxzTk1xya9nBhUbtCrqpSrRkdAJM922F2wwIZhbezvKvoP4ZVnELf9Rn10XFgN1PKRmShJG4jRTPkwkKcImQP2/H/IoyWikR8C3MSgKSUfD5hr1ioIewkS7PAt9mx2oBwoF3ItBdtISdS990eBiUbhXOs1lzO5SLjZ86Zs5vHLnlnb5OjlAZ4ASkS0SgZwpbx+Hhtt85h10kVxECYyCiNGNrCfOvHEN1fxFbfmgMkup5Bu8ArULOYffN2cTXrNrdItMV2ONRrBn9iY+7IBGssAanI/NPgWh935zke1sF5TmpECes5DCweNxPZ65gBCfOvauSw9uA== 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)(83380400001)(52116002)(6666004)(508600001)(5660300002)(6506007)(6486002)(8936002)(186003)(86362001)(38100700002)(38350700002)(2616005)(316002)(8676002)(6916009)(66476007)(4326008)(66556008)(2906002)(66946007)(26005)(6512007)(107886003)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0rQ9cJR1HgKmiWSEy/xwKBpJBsEFxXEilvhODqMurRM84vdFFbDXxJ+MkeGGD1iD9ZId8D2EtRPfZWh/sUJzJC61jViChZ/X1AcUduM4pGW/Ds2UGnHSV8vnrlBe5Hado7pG2Hwx9E4DfwEh183aJ31ZJ6Q83CxBwPdjngYXM3CJsfImAMmhbF/FRg9FTDrfzv6I4LQj4mabKQM+aFa9EZ9wJHRjeFaqNrYVXsZ/zGg816wB0p01wvy7AY+pXIspxZ2wouFzV83rPqVYDcCM5N+OMQWydk0V5P3b+O+DqXM4PvCejI8B7vvMZ7K6r6hev0jHT09ICOKYbP3q2ScGZKiBzKmEBfRv9aJVomb2neeR7WcSmn/JvEKSX4nbmT+mTGqhzvrAAOAzTwUr8kFkv0aZzTbil+w25Zi2KKJO9LNrGkkwtI7A8snFrO1oyxC3vKpxwz2L/EvPDryC4WTyVe1nHZoFwmQ1OaYqCvh2BD3chpJI8id+03BzxQU4ZQUWYZRwnmJb3o0c8rpnx533YMhDW7UtH2kUZrdJg/RmcyOF0Bj17icVJznqzJXp3CxsnrBmgnOsmVWD27+ZAJWEjPzxCO3NtDGpYEWCBnl75HhL3e+u/K8Z3U2MGOIfOEm7sOKPDXq+uBjcyBc3i8VdQJ/mlKVHunQmf6pBf2UU2ApjZJZFldrenqGV/Aq60fLgB9InynvmV0IAdsAbZVkh2yy7rd/cYCYd55b0hHwo2PDk8BCC/GvL6GGtioB5nS9d/HPEDwEqYJu+430/09sj5LrYiAn4BhYXPuTV7Z2oddKlWm5gtKp/TtYExdrvqAyTemfSCDTLAo3dacI2NZPwk00fvxwvAlv5y1qMQWOv0ORM30du8yLoX8z9/cbQy36ZyvZTqSDtQOXrxBZBXmweVsGYAQIPijFHa5ddH28aTboA2r6EJwUE8wT08KRmeBEaPrAO+n40ywFNJUXU7YE1z1ubSBHZGBlFGlBRjUuZqGR6VL5uAJ3CIyzxqSGMndI4KmmKw4/4cWKVuoSklaedmeC3UxGkd1t4xmWDCRXXSq2pXJuJyR6jJv6v1uA3LehtyWTvg7G8Bm1gvW0hWyjtTHHjsFLi9wkyXrJaNuGNfZ0/HeceAZMnI50ZRxpDQJE1zaiB3/jPzpcw4psQPbnZgu1IlFZg4/pDQRJZPEbJxgk30Fdb9nvUvq78vvuKqfplnN35FyT2dL8LqG8fBGOoeeo9g5q+KnYn17kIJwld5miCh+zhj80G18T3FzvM1BBqDo6X3L/GjJTni7qhioeyjbsCFytffDeoLrCJWA48HhAbNuvha3sUr2AiqGCMNSnnEUTgRdHYJvTs3XeKET9nzjYev916HRfeiUcEborahbZnPCsCxkeszpMrMssM1hgggS2dHCRoHNhfTFGPtz+tTFbEX1jyWCKEm6va2S0vzoK3+uVCqlZoI8/CuYIPkY+szb7Fd/BPTalGMAyCRq7r++IgAOH8lfiVDRgupU9WL6ibvyIMeyemhqP8zZYg0BbOtnG0qhgrq8F+aTM1F0txKMR/DXAFEJ6DLVqCPpUSSOrdie4N64FB8WFaSDp9WBMgGM3mRTREcHK7Wpy6XIGfGw9pF/KMF9ze5vFrgiEUrToZjhgVZNmhfhTUadzZc/CxjKIpF2RjLk9WD3jLD/RbJNzW1fkvIzi8u8jAr3NcbcsIFQxJrOKBJNihRT09WarXQH5hImotq+f85IymYfDLo9xOl0fqXh6TMhfE5Bj+dKM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2714a7ed-8c10-4c0f-a1bb-08da2fd147b6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 02:28:32.5574 (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: 7KokExx7FAV/FQGM0056PJ+BCGwYYnQIE4eeQYmWxaetBOyCy0eCu5/NklCWZwJw7rF0nzx6akAbfg3nwXPUGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1370 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_07:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=938 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070012 X-Proofpoint-ORIG-GUID: yq-JyuH1pDA7WtaSMcaZUL1iwjdQzqM7 X-Proofpoint-GUID: yq-JyuH1pDA7WtaSMcaZUL1iwjdQzqM7 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 Sat May 7 02:28: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: 12841828 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 97C3EC433EF for ; Sat, 7 May 2022 02:35:26 +0000 (UTC) Received: from localhost ([::1]:52058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnAI1-0006hz-IL for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 22:35:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABW-0004uT-6Z for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:42 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:39070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABT-0002TV-H5 for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:41 -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 2471v800024483; Sat, 7 May 2022 02:28:36 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=ViGKnM16jB75iNXNHpW5zLKmY3nCd4zOoNAEzhPK6wE=; b=Q4TLxP62L4tXd5VGmG7c1KIHJfckaNpqGMLEjzBwLGgqGXQnPoqubBmLyZFqnfGaAVEN x2IT0Ms2ra8Dls4YTqhis0WZzwXgfblb40nfkPcvGHAJml2rpfzyg/CJvaEt1AXozv6Q GBU7xjV8f1MjjYKPo9ULHSuPMsEaVaJmJiBH3tcvd/HTzBfm0guT5Bowq+SLKZ8nDECf ZSKVqUjwqoFYrB/8XBNQ6QSzMrjuDjXZ+hgD1rTsL4l9HSvFWyZRcOSCNo4M2WzwH+nY NskLFr2QnFeoocJVFncxAywBr8te1LkdbonO0ohL1yYfgyH9pquX1jgE607s3gSak58i +A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fwfj280pu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:36 +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 2472BQcj024291; Sat, 7 May 2022 02:28:35 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2049.outbound.protection.outlook.com [104.47.51.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3fwf700tpy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A8QilnSLKl+U3ck/4HZSNQi/MX+CCpmZhjhHtWFyE/8J/kzvxi977j6OoVBKrJizpp8gjJ1j1W4AxqnlxyFG5sfO/x3OXr6r3NcCfcwW7jQnAML/yI2XciQWg/ixmb2WVmTqh/PTgFsX7I1vuQvHxYafkKv2jvZm3758qgZTkiqlhA5hvWUyb6UEAr7ds1pOB3/AlEbjVnBLAtcaT3kYv2qaXnktR0IzKZVInGhjZJiWkZLCl4zUfHk2A1l3ylwqBi8GYH6b+T4X3yrc7tpMuhYS+b00HyFesNpKfMo3X0QZfOZZZiqqixBr2Z4x+u3hqUccc04yJ6Irc+2RMAXwUQ== 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=ViGKnM16jB75iNXNHpW5zLKmY3nCd4zOoNAEzhPK6wE=; b=C8RWe8m/jM3o0L1dScRwjt0VAwQWAL9L27Rn6EvrP+fSPDhsadlQV3Ttdr+TMFePFzLzmWADruJZBqPH9hJ6zgW7DBzCLjEv4vOVSbEFcHLQbXpHWC6mffy1LDJ/f2cnP0cO2erLRBOVVT37hQBDJUVj9J5Zjah9LDzcUM8pbDefGQzqlDPMqoRmf0Lks8hFk0ZiY89bdxIYKc52MqXjbcct5RQf7JNRoT2f5a1lKQzaU0t869mDyFxRS/CDJ46odB5xtk/yxMAaCrY3s0irj93IISRiz5AAQATGID15jRPt2zY5f92ubV/R6Sgtqj5edHkSY5ra5qOTugxYCu2JpA== 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=ViGKnM16jB75iNXNHpW5zLKmY3nCd4zOoNAEzhPK6wE=; b=OEIsWXkapeaAGmF2dqrsbGFsY63h9vZBpxh8s8u44xUln0e2C9d+uerFT6j25s9xjBzpL0+La3Epj1/HMQnLX+PIBwM19YgoYnfrfYWkm3rGU5q9Q7BjhAocBGxCsnSAeDVhFg1yYzO/GOzTPpEqr+Zk9fmOL9yBFMIeW+mlSlk= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM5PR10MB1370.namprd10.prod.outlook.com (2603:10b6:3:f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Sat, 7 May 2022 02:28:33 +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.021; Sat, 7 May 2022 02:28:33 +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 v4 5/7] vhost-vdpa: backend feature should set only once Date: Fri, 6 May 2022 19:28:16 -0700 Message-Id: <1651890498-24478-6-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> References: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR03CA0041.namprd03.prod.outlook.com (2603:10b6:5:100::18) 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: 84b09ae7-9cbb-4999-e5ca-08da2fd1485f X-MS-TrafficTypeDiagnostic: DM5PR10MB1370: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: 2wtU9D0Msfzw925pDGpH+Yn6WEbbzLQN8PA2QjBvlj9sfZr7jm3efV5oGH9EwWV4QphGVn5/Krc6vWomr0YloV8nTlNH8gMhiiy/o+zbTvGtZJcxWg1KxhYJt7HvO6PrUVYmpiI2bUMXnKtBR95POm7bvwVY2PlyL1Rtko399dZYorteqxenYpMwAygLgVr0TnZfKtHo9ii9ALtA93jblLWrN84lgdrfVu2mFyYEnWxUizjtlKlu78FjBsCcnwvNpQdTEJdeZAcgnoKS1OEKVspoTqEiR9y/CkyRh9wRr86zDoB6jJh8XnQyCXJbbgczrXE7RjJ5qJXb4dV36DGiEmM2csZnmRw1xEzal5y+V4wD9v9M64u5tAaKvyh0Kx8JSFFdyjNwBQ+xjYOkcszN2XdfpZ/D8tSxRYfBBNOfBHMq0UO7DMV21qqNsVroG6S/PaSR2v6HWusv/eikjF1Njb/ZUQuvbmJDlknHpdNc16O9UmhVAelVDQS09LNLD6CE1YFl7R1Klg78dw5hTkKRO1KapKLTZIC/3gEw7jTTRnCWK5LHYDCfcVmiAL2T6FotbW2l1ABXKgAZ0Z+agidOZS206UgXUB6zGUxoQhX4jlEKMLSDTWxJpBEyEzb3xD+4Jx7SEuZqGrn0sr3eFF1pnHe510bS22fgYaE68F5DoUG0w691M4pjQ61M7EA7uj+/AnfDYJoHICGN5IG8dES5Hg== 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)(66574015)(83380400001)(52116002)(6666004)(508600001)(5660300002)(6506007)(6486002)(8936002)(186003)(86362001)(38100700002)(38350700002)(2616005)(316002)(8676002)(6916009)(66476007)(4326008)(66556008)(2906002)(66946007)(26005)(6512007)(107886003)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?eHI+xRdk0bHjlsfS2SB1F7wt0zrx?= =?utf-8?q?eH9tPxCQMh4RhHjqoRtOxXOsYqwjqVDxq7NX9ER186WW+siqcfUmQ3fCG0qgVwmHh?= =?utf-8?q?DXCrOluzxPXteca68Z78k1dmYJmD4wgvmWFW5FyL7Jziz9FL4S2jfciQAH3gHJmcg?= =?utf-8?q?ci901G5jwW+DhkREeIEqeXmntyDDqjUADcxHBGafLHlDfVduf9+wUeptVpOvCTXSp?= =?utf-8?q?ufIsg3rrB9IjU80M2JCFLGb4dz3FZ2D/upiSiU+UsBgaPiyEkcXXU4m2oLCSZ2f3O?= =?utf-8?q?AnDY1bzxAMPZTny+pVNaV9rf4AofV4GjhcwKfvlg0o51ZvIhk/YEUB03eDbJVi+fy?= =?utf-8?q?/qWqg7nJbkLH6Tlph9yQkxM7bdqL/2G/mI3pNFCDRio3aHRRuHLTznvUYf9iW6LgL?= =?utf-8?q?mI8utyVp2EgcLjBu/ca90u3VP23rA+GXcrdYHNa3NV2R6EUl4rddTVDfugvaMWn28?= =?utf-8?q?3OzgIpG2pBLTqKdTXI7U7zAZBqVuy47DTG+EfKlBO3kz/YbvfC3JZH2BzPkGIsa18?= =?utf-8?q?vlKhRrh/4Kj/BcomLXpgsZmx2A2lZ3yZwnN5FLSB9EoHrFZs0ILfgWRT41XIe8r+j?= =?utf-8?q?wAfpRkSVJRVgtDupc4TEtuPC1twS2N+dnuQneoGyaybY574aIfsCN+u0PwnKIQDrT?= =?utf-8?q?+1JnVf/lGpUvUhK/0g9ygUhuZ2ild1xeugAuEXLyZp6SjF7UU/Zt4t9TcgMlFXJOA?= =?utf-8?q?oSPpBwB6hmeYqZaTKvpwmMzMHFdVYVt2HRoqfKeQMB3LKXa7uGg1soBnNBxJ97FLt?= =?utf-8?q?5ybkyQep8VVcprm8xvRzga52EHSi2p536rkkEmrDw/F4YaKLXcdjB+EgZhMPERcgZ?= =?utf-8?q?QWuSYSVe/401ev5Ejj+5ab4RkQyeJ/R7nBjHzLpWnSjHX0PgI+Np4cYeCDicNmBCB?= =?utf-8?q?gAdUd+QLMG6VdD8JXWK+imdiBZ2PlDMt1HH2TooQ1+6ThrbOpr6WGS0LZZxCp0eh9?= =?utf-8?q?r2naTYYQiQHMr5szohAP808LnCrf3DioLMlOsHL7Y9jBFgDJxP2KKX9w4+x3AdKTd?= =?utf-8?q?wNtDSKRnjT8SVww4Pw1ZOIIhAOPxho7gtM5heSH7A61Sz1QEFHa59k1XocGE1slbR?= =?utf-8?q?fUxEgIw5Stotek6kq1jcTbKo3myfFDMRO2oW+3BGwhcifnqPl+pp9Utx5Ww8EUx4l?= =?utf-8?q?6SGnXB/HvgQYmqv6DN+msi4x9wMI02+jRkwxME/U1ZEkjZpKIfhVh1gNqIIEHa4WG?= =?utf-8?q?pumFuuZfLA4VVamzRAhpgjli5rhxo5sWq62I9HUeubXcSvXVVv5vf7RhvyJxhBcKb?= =?utf-8?q?Vuwd0DeKcLmmlN2iDlXIu3Jk6jHWy4S9gAL9W9LUrIoNgCwn1ERg226qzydVYH/xl?= =?utf-8?q?fAVQSJZYjN8kgvTrqLBfGdle9NfpWQiwJXiMEb08Gpl6qQt2n/njlJJdpB5Vyv3lL?= =?utf-8?q?3RQushLO6iKUUVs01EyS5Whcf+ggKOrRwE2u8dzzI0HOLtPtf87JEDC0GpnG88+jC?= =?utf-8?q?uV6iIoY1EYjTP/pjshY8Y99AJGgZRLmJbaiRl6XVgTOhvfRoq1HnkQczY5fqeuQGI?= =?utf-8?q?0an2x7L9A/SDIfumc3nus0/uVNveVnrYejjxfg+6Va9JD87HOBKv3+9Jgum9saIyM?= =?utf-8?q?Xff/WSro10gfemkaJxWimpm8piRaywa9i6pJs9Mwxg1+JaEl3ITVwAHjeGMF+kNTI?= =?utf-8?q?Ofk/livP0PjNeL3XcfjT7LCHUMjZroomY+Ea8l18xPs6GiV/gUzpg=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84b09ae7-9cbb-4999-e5ca-08da2fd1485f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 02:28:33.6511 (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: 2wpjSQ03HxKptjSa99zGP/9JS1LRak4E8SiKurCGMkZb1lb5wsnAyi3VkzXo9H+I7HXnmaYNsJacN/yXBbY3UQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1370 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_07:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070012 X-Proofpoint-ORIG-GUID: nxf9sqrIIw_LkdQrOxgUPnC1wC6FCfIb X-Proofpoint-GUID: nxf9sqrIIw_LkdQrOxgUPnC1wC6FCfIb 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. Toggle the polarity of the vhost_vdpa_one_time_request() test should do the trick. Fixes: 4d191cfdc7de ("vhost-vdpa: classify one time request") Signed-off-by: Si-Wei Liu Reviewed-by: Stefano Garzarella Acked-by: Jason Wang Acked-by: Eugenio PĂ©rez --- hw/virtio/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 8adf7c0..6e3dbd9 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -665,7 +665,7 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev) features &= f; - if (vhost_vdpa_one_time_request(dev)) { + if (!vhost_vdpa_one_time_request(dev)) { r = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features); if (r) { return -EFAULT; From patchwork Sat May 7 02:28:17 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: 12841822 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 4E930C433EF for ; Sat, 7 May 2022 02:30:50 +0000 (UTC) Received: from localhost ([::1]:41586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnADZ-0007jM-AU for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 22:30:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABX-0004zP-Sk for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:43 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:18118) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABV-0002UF-N8 for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:43 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 246KnA03019339; Sat, 7 May 2022 02:28:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=69YEct9NkzSmmwluj2AMY+/oi6wa/ElLTTi9OwAWgq4=; b=LZ3N/2WCwjaKzoYNCgHaZOyF0/xI7x/tjf1z//kcvPVxWadT2saZW2Jw9Vg7uDulb7YU 0LUQqlWf5v+RehEQ703BIUD4+Ms9Bwi74dKx8CuoNRtlQf8ce/cYjyNiqAX4vgmh020y Kcxf3+M2jMh768c38OfJRmJcJ6KwUbxJK5B1QRCa/HyQ7/QAX4ql4PeqWmyZ9ZPNmUc/ kBiTFl+2GmRcRDcRuM54bSzLat8HeGs/+Hoc95/CCMI2xbghOwIsvGDmJwWIRR+b21j5 TVv43SKIZ3AQsaW4qNjOPfyQaNJhAo6A+zcB4JCgm0DOoNFPR10Hugis0Z7uaXGssYX3 LA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3frwntfkhx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:38 +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 2472BGk7002863; Sat, 7 May 2022 02:28:37 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2040.outbound.protection.outlook.com [104.47.51.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fwf76gu6a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vr4R9SjvA21O42hCZQpxAx0BXZzIPjVX22yhgn2ACqtcyWHOK0ZmrnVcATJ96jBOAEvQeeR/4qdnPl0te5qUBYsHUIyT3DFhUz+86FVLXGFp/MthLJ8yYUWX2ZY0y8Za90BXLW6m03IrHSIjNLLCG49E4aXldjicPlWZbmxSVoKFaEJrYQdx6ahDlCqJGEjGygKsF5URSQJJ5+hi0mWhx3Ytn5sJG6tJd1DkoPjLnIodvFaiJUkV0pyHumFqOpyrLyWnnLh8aAGTTOl9eXItVMJVfqpWRpiey2Gv14BMkWf0b3rCCbyaJSgtyuqTZTA176c2tTyUXSCHkp0mMSrEOg== 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=69YEct9NkzSmmwluj2AMY+/oi6wa/ElLTTi9OwAWgq4=; b=lzTrsirf6tOUWRQy0JBBa+ft6RAAMjHq7Cx9hY/XEgS+27YCxiHo1G6zQDWj/A0x05miNKAr+DqgHpVoNpQQmM4IS8y3A0axZZv/eT/FqDL3nCO1EYEA2RMPhW6pZWxN7ikAALwTtn9Dav4lDpP9EMgLFByLiFwK2dHHfYsMUfTNLlkS0VV7EUVVQjoUEgyO5PXr1lI/s0tpyCSsgMLM9b1or3jmltxburOXumoruR1/x6T00nkwFLPey7yuT6OgdK0fCr2UJgKUJ8tlN4pYh9rscdNgkyJ9mIXul1jC4O4z51lDGGrZFKHjvASqv2gCaCzFyhdvpTLsbcJziZlETw== 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=69YEct9NkzSmmwluj2AMY+/oi6wa/ElLTTi9OwAWgq4=; b=R6B9ie86VMFTv5ek3lLIkjbWQVUIfZStGw5+OOCPg1htXyQ/qrL1rpvD96m3j2h2ji2PsyHiG4ZqaGAUbtCd2Va6BPMm49ZcoQm7fAYqqYouq5HAd7FGLwf5ZWJp6XHY5vrdlqIlv3qXMtWniGtGFN180Z+NKegSqeNnZUiBJsM= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM5PR10MB1370.namprd10.prod.outlook.com (2603:10b6:3:f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Sat, 7 May 2022 02:28: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.5227.021; Sat, 7 May 2022 02:28:34 +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 v4 6/7] vhost-vdpa: change name and polarity for vhost_vdpa_one_time_request() Date: Fri, 6 May 2022 19:28:17 -0700 Message-Id: <1651890498-24478-7-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> References: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR03CA0041.namprd03.prod.outlook.com (2603:10b6:5:100::18) 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: 9d1b57e8-eadf-4c0a-c796-08da2fd14906 X-MS-TrafficTypeDiagnostic: DM5PR10MB1370: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: 1m8A/A64Rt3GC9VHTWkXLqAogDRhqrKrsE5/ucM9zR1ZcGxvdNHduKae2G4E7T09ERTgqcy/OWzzx/bF4hOUwbMaCxBVkTWmADmUWk8YjJFclpTLr+LIst97wmYZVqhLPI7yEH8OimLiVpY8YBqSo2CsUWpp8JyHYEh02FT2M//Mpv0EqltpI94k7xMh4oCRgSyMzjvp26BUpqSC0NM+s/3TccVI3jI0u95eyfRndWK2CQOcMvg0Q3wNYDVmTioQh9FciGJaULfM+Q7CoGWdt/VScubGs3P6LHw3pdbYSiaSBgrGkeuwvih91E/ofY256oDF/lasbF1IHI7OJ055zdZhYV8avkUXtEnoxIa5y9iErGzCDR53K2cuNAhPIuRfijwYMlZayRrzWjkxAUu1OmCOkzOp57MWGVhzpvo8OeoOdbByw/6PR6rJJksPeJMmqAT7XM7cP01erH2KIP9cnbzuFwomcn0GwuiorOTWZy+ZNb2z0cyPSaKvzTcVZuJk0Kjn6oyKcKyVEpIv8AEwIQxiXMviLxqugHHCG6e7eqyU+LAZABmYZSXczy6rPhX3sWT/QEoy70zgqZSncDHLYJcKQzdRTtMk0AYo1OQZ7j9hD5SPzmYg7gESIZffk73PwP2ucVbAIFSyAhQ/2jE4ZkNFhyQbohVdDxuDDV5m72JCiTL2Rau7co3ZgNEEqnUPJl8Sbdf72ToWuSYx+72HrA== 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)(83380400001)(52116002)(6666004)(508600001)(5660300002)(6506007)(6486002)(8936002)(186003)(86362001)(38100700002)(38350700002)(2616005)(316002)(8676002)(6916009)(66476007)(4326008)(66556008)(2906002)(66946007)(26005)(6512007)(107886003)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +IbC1RxmjWWaEpLsTkB0D6co1WY8slVtr4JTdnweF7Amf8I/yOm3dizv6pU1a7NAs8rfCkYeG7T22BOyOWTJoHC0docTzAN+uKmCS/ZC5WilbfitJrzQaDo/1iiNdOeS/+HIrVtLV0hyKnsROj92piVBza7uBVMufgvw1gdNCswH53UtIhQng/cxP2HPoiIhm10ZEnK0zBgCuGUZtPwlWblAL5B8+ZIJGaB2sfefLALa9R+N/OsGBax/UAikjG+FIjCCdDhW9COIAwQD0daEButOht3sw+f41fmSkPfZ3qL/u47jsVCCF6O0UkbTnVkEpDqXekgLEikHIMpvcNQP0BG1E2/kLPFlQKcuXyzBaYN06Gl8XwmFNr/du8jLzyNVqkWFqC6XN6vUX8Ik/SFDkDlfijLrBkNSKbjU8gIE9d8SKfoXoDaAuUXybfiLAzh1whtl/0myJAZK+4A99q2rU2pHyDEUdIF49utwqG30CnU8D6OTDCQok/IBOqyOkfiHcmfogj8AS8kvr4TV8tDkFlj+rm0OqxNTOZ0J1CvyBqb4tlqak73lgFedZBCTpxeg+FIswR+5YoV95c3I7SsH1njk+/7HTxFO48HIh/NzQqukmDimKkN7LGEwOSNi+6XrfMbZDaO8OR30Mx9GYDS0x6PkkpCDUv8y5FB8+7UxzT3jBi2tr1ClPFxafTUBr3iVwlzaKcsZLKg0y2q+AywzFDOonPiU1gbHfvWF6b2XQ22hZ8xe8QEfTqFA2Mg0n4yv38FRTdHhvUa8O62KurBQIonOcaG6buam9d5HVW6CVXdrfl7YllpgVRIqEmSLo7XIS8l0blSc6LweS4Y73FiazjGtN/wC3bjiuCl8mHX3gyfqcVBbx301J2aoie/gwYROHhRdOYyfzjVRHzHTFewXtVjul9s5vpbBWGIyHWk0v/GGCGnqoN0HGd8KQ0ovmNNqI+6Cfo2tkkabsj9YAJl/dhfvfq3zZ4MntxPD1G7Yc/oBhXZgYwhYjs1rYh9fTqV77HnRaiNLFKe0EcH/kCVfCQur/ltlspO8GeK7NCF7G/c7QJN8v3En0iAFEfsmI1t5uuwQ5Fxa0m8SFeknl+d0ZklsM4BbIb/LX+GkNk/xuqRL6SAH+Zl9DGJ9fC8cszM1LZe6aMXTJA7DgA8cnbEfEaj9YaMeRyMbA7lJll17x+lBm56HYr7MLu3OZi4Qtcm6qgvtxklV5l6k5KX7Ai3klTtoopwkOOlD2Tvw2RNaqhv4JlNICf3v1NOKnMWunbpgsmuNF48UzNc88neQdsE3+8s+UxxhoEE7bD2zZz9IGXxpuXyrsLGGBBj7Y3cdPnKYPqxP733mZlSnb0ZOMH0TpvOCzx47A8J7Xka3+V4xReINAKcjyuMktaa/3KJOylRx6gqct7011UyEEabuPB6Vc8x5+XL0ZMC7NHVu4VxWDS040XK35t7QEWvo55wnhCpoVKnKhVp2ebTo9JCcH+NoxzPnjJLeR7NduRHIBqii5azuGJHO9VPl/NG+9+SIlfsaiNggVFUQm8Nv8Dttzj1kGCxeonBZ0WLz90R4Va/f+vIzXo0NWhKRxSJCC6kuWNn01Fe4KJWx+pYCy4RYFWk/qFBHxzH8ZjjjeiOil9y5ziBv8rtqqC6jodooTyQFwlX47wBnDBVqNY8nGR9HHZK7zs5NbLKnifu/uiBbQJiQ3aMXCZtF5B4pk84hh8GAxUWR8/prmKs+D3ISsM49gxN0oJHnHpk3ARJTfKi05/UMLDE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d1b57e8-eadf-4c0a-c796-08da2fd14906 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 02:28:34.7447 (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: duviMxb5jufJhOO/R5isikzs1Fk9KLsb7fNekUSwP5stm9Nt88CkS1KpchjvO/S2hAZeCAr4VOv8PGHVxDIWKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1370 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_07:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070012 X-Proofpoint-ORIG-GUID: LbyYw0oVr-98hkFmKpomz3UwKRQs4moz X-Proofpoint-GUID: LbyYw0oVr-98hkFmKpomz3UwKRQs4moz Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 name vhost_vdpa_one_time_request() was confusing. No matter whatever it returns, its typical occurrence had always been at requests that only need to be applied once. And the name didn't suggest what it actually checks for. Change it to vhost_vdpa_first_dev() with polarity flipped for better readibility of code. That way it is able to reflect what the check is really about. This call is applicable to request which performs operation only once, before queues are set up, and usually at the beginning of the caller function. Document the requirement for it in place. Signed-off-by: Si-Wei Liu Reviewed-by: Stefano Garzarella Acked-by: Jason Wang --- 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 6e3dbd9..33dcaa1 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 Sat May 7 02:28:18 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: 12841830 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 67A5AC433EF for ; Sat, 7 May 2022 02:37:44 +0000 (UTC) Received: from localhost ([::1]:54264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnAKF-0000F2-D5 for qemu-devel@archiver.kernel.org; Fri, 06 May 2022 22:37:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABW-0004vX-B7 for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:42 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:39808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnABU-0002U1-4R for qemu-devel@nongnu.org; Fri, 06 May 2022 22:28:42 -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 246Kvhxg013502; Sat, 7 May 2022 02:28:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=1TcG3CKuNgf2xLxnkMMxY4oTXSOROuq/QliJJdBu0NY=; b=Yp3AzGll0NpXoF+K+CaPN5zl0UOscGyVzJ2EzCvm/Q50rHIKMoe5JNMYKzDnJsmGGq6b aJ0zDbSifrTJZzICp7QzLFJo6HJssjvtoJaQF58OCi87S+m5iTeDCmjH+7wZU/1teh0T X5KRpILC/GwgE7jlriWDBlil10tGCIOWn1Ym6yha/eS58cgII1HKR+vt+zrW22Jix3nD 4UV62fwyoT4w0+Lh38pWzJhOHqoaY5bhNJUuj7sYgxqNLIFBm7Ei4i4w4YXK0P89tLvZ 0q4sumBzU8uIqQeo4KrJGoxAVQtav62MpP0qJHiNeUbg0ld0sw3RqNjuj0rC044+Dh9X Fw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3frvqsqg0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:38 +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 2472BGk8002863; Sat, 7 May 2022 02:28:37 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2040.outbound.protection.outlook.com [104.47.51.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fwf76gu6a-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 May 2022 02:28:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LQ9+eC0yBAtp2A0JzGwI1yFhemDolvzR53R4yEji9YDyuxX5OLCglyUO3153/ghIBWOrBk8jGdZR9iUSxK1HNTMW/dUdvWn2c3bALw3RRoXIXHhBWAyGHjchGMMFYj9H2go5dju+FMUuj950aY5PJlQbuZL0QRRDbCiAx4XcPEJf4gldqbWIengTYUdVlZpwBXPg5g8zc8Md9yFYKpDReK3xdU6VNYLfRoZivVPBiRwfjdqkt8kzlBW9OwlOhwlw7sdRhcmkvfw2T8u1Hs9sQZkpmf/Ugpg86GLl9csLuZeGsBU0D1u2AzSQUKP4v+XbAgl2GDYI+CCdUUXZEFDwuA== 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=1TcG3CKuNgf2xLxnkMMxY4oTXSOROuq/QliJJdBu0NY=; b=VYVaNQd1xJXEmx4CbVlPfxFyoJR2CsU71Y4Gt7/A95jxo2hb+5TECv0AJvJ2C2nWsHC13UoEvgZPohwboVYApEhBcg2CpE/kKC3b63XcCezrvNiY1Hh4r33zmBGZKYIB0SwwLCtkC/+qyXBAfd0ZIYj63Ys2e8wZIRUyh0IbM88WUeMVagetmQLJXW7MWn+/SbftG75OsSvk+198UgukZmcEapMQGHaNHmh1l3fzpGnc5wyQ8hyf11VtXmnuIC44qnGQqN456TIIWL6IyKZA4LoDAh0Rm4dc7+14+PqK9Qvb/0BbrMT+th23PzIHs7yxC2+n05aGSzkeiI7scEePUw== 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=1TcG3CKuNgf2xLxnkMMxY4oTXSOROuq/QliJJdBu0NY=; b=d+n3VUcsh4Hr3TXWZgoqam81Zom2iSvVKvtlvmPS7yj4pOvIclXqM8Em/fQrSw4M5x/h8akL8e1f5Gbt/6uzLBcvvtyBp0XxMcDS3g/b1+Jviur0dHzLlXMiKN/lTvE525oVRIzcqVqt+1vAMt/v8XQHuFUb4AWGiA2SwHdqW0U= Received: from BYAPR10MB3287.namprd10.prod.outlook.com (2603:10b6:a03:15c::11) by DM5PR10MB1370.namprd10.prod.outlook.com (2603:10b6:3:f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Sat, 7 May 2022 02:28: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.5227.021; Sat, 7 May 2022 02:28:35 +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 v4 7/7] virtio-net: don't handle mq request in userspace handler for vhost-vdpa Date: Fri, 6 May 2022 19:28:18 -0700 Message-Id: <1651890498-24478-8-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> References: <1651890498-24478-1-git-send-email-si-wei.liu@oracle.com> X-ClientProxiedBy: DM6PR03CA0041.namprd03.prod.outlook.com (2603:10b6:5:100::18) 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: 509de388-304f-4438-4729-08da2fd149ab X-MS-TrafficTypeDiagnostic: DM5PR10MB1370: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: eJd7gwMK1+KQMLBSoKdDhNQpbQDQIWGR4Kk7phbBMFfET5ccm5HKkUsnBg3Vz5ho0SXm6n3ZP6EB6zLKyfDCUSJgPfV/NE4/hI13jHL57FS5MQ2dhK5G3q3dc17B3bIAEZboYcydg56WodsrRZLs23ZBgQZ6r8luBpXedGdKAh7Xw5rJuMeNgZ8VyJevwkwFseTzxZD+HwzKK9pyEQYwgSv4JIXG1GS+X7PhUllXQFq+b3xdK+z132FejJL/hAbUNyvzCYe54kI8r3Jwlw2BwsHuIi/IMjfaxbIBduCSQ41K6htStjbzRqENV8Q6ne0OkbZErgZ91Vlm2JHVbimeEiKF80Bche1L0Pc9Y3w76wqVj81xMXbd0XoAYb7qPGO3jG+t+TgA5H4p5RM2OibRMJvNAK1/OXmzweX6UEJzKYSkmxriw5tRnl+gceKLNplwhDF3Ajt0wmcoiT8a3Kdo0IV8s/IB2+KLJLLd1KOl4/TaihDGIO7yEmvZIQGpiftaghn8bTJTe4A1JXzLFcPY+0K+bDsXZz0DQ0jujyVpJvW0q11GoTQ+3ghtcBYO4Hh08fbk9Euy/CIgOKjMvLY3rOnKehWsdhziP/TJ+DSm7JwI/VCyC/SjIVNEukKhMiv64GK6UqE16LbiMZ7IuqwaQ/ri2owqRV4KQiEq6hFtgLESHfglOBqWz/UHLoyT2cbZxL/WoH81CmnFcQN/MyM5rg== 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)(83380400001)(52116002)(6666004)(508600001)(5660300002)(6506007)(6486002)(8936002)(186003)(86362001)(38100700002)(38350700002)(2616005)(316002)(8676002)(6916009)(66476007)(4326008)(66556008)(2906002)(66946007)(26005)(6512007)(107886003)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LLM1fnQR/eX4wUp1IvHTL/va0Udrw4TwKie4h8XqeL8YkqCS6MkERwhJQ9F0Il8v44woDREraQb/6lmagZ7+S2vbUD62DCkn3AyCia8PTbBcWfTPx4bFVeZuM9b5ad9YtR13aAnwrXPaS65IY92OZ4vFhESuRRl4y7p1ZrXpQr8/EVoFibczC8uQ6hh3DaEPRyAqvNuo8kUibEOpvhP7PpaCok5/HZoQ9ZuutxgsrglRe84UJ46hMebuxCHmoI8PyIYi19x/K4WNy6TAhNbBUJWZh4GiPMEaVJGVpDRlv/l0Q9QeH9aQhC84eKLKBZiEqvnzZsBzUAnYY1oBywahFO2xE5TBjimdS3Q2FmLwYYlktCkxSpxAplWrv7R7gMftZDoWOnHjPLSYFSxRMu9oWpVdF+dJCXwhoGyDH7+Tco8BL9kKtz+lw0RX9Q30e1w3SSKegG4G7LbMM0cTjhyc1z8JnU+0mck8Cy6zk6i6dgU7FrGRRN9V27NvhaujC4ctYOsrlnM/vpFFzTmlvGq9ePFeREpqom2y57FuF91Mm2PzITKY/yowCVPNRoy83E8F4a/rC16Fcknd300vsz6xzxQeu2sb8PlqQuXzjxEoL+1VTIIjbVXNfcKC1dCqa2blAMdE9Dm6CD+ezrKzAjKGtfBKq8QaZt0CnrQeKJxqmi63WTLLWz6KKUIT9ErvU/bkyH2S0HPKWhnOpkhd7m/uekbLqObYkJDNTFmmspHAPW8j3iqFkT4BZLG/1cr2dZyXGnJWNpEGnCTtE13b0wg229UZwHYd+3+vo+LFOtZjRVF93NZtnivyBmkIVQZnJKtCnM+zn5H1YojsnJX6Ra9AquVNTW9DDHpP5I1zDWRaEZhBqSes59ttJ4MdHkrEgibxUOqbu/Srw/j4SnW+SuGmMQN6e2jr3czYfkL5SccCCe9WB5Frdd1grWzcBwU87TlgDS0LzbOcq5bL7rR/NLlmzEliE4E6XUAn2L/PtAQPg/bbmqafmZk2WkVd0yArKMcfE4pqS02VklnL5+qp7EZW6U+spl81ThmLbdsJj4Pg/BNfrUqOJliON3HPtIbxiMkcGN8H6vQrHXP5kqbLXCCaLmhfj8otqjHyWXu31cp0uvS3GWFjc7WiU33EN/3kfdpdlJfvKg9fBK6u7cKaTZuJh9dYlXjDwhL5TvK3wZISRJ0dUJ0Nho0b3nToKiq2PsjMDuzXoRl6JJAHpHBB4NgLy55YQqjtpxfnHQmnC1Hns7y1aPA63vg6hnRgiA3n9djZ1DSgWeEUU8SAeTNy7Qj4W4yOXcec8MY24Sj0/w/Eh6NdRCZZAmRHHClXRtx0a9vaGCHJ6c7Np9Txlxz/eqyr1zXi6/4LqW7ssa1PiinNWiBMYi/nrtxeAw+CtlRoeUDX4DWcpmx9aYOO8R3P+DQ3MB65kS11ixI0Op+MmR+tnfeaK14szJGfOM9hc/GViQtKP3VjMjc78IdeWbrFPCAPAYL5346lZCqWuBrVDj1zFdxL1+7CgfxUHY0ckDLR9ut0nuNNJ/Fm8c1958PgIgfa8YzWizSsGfz+WXV4u74VG6P51dSHmnq0gauOHmvyhesLac7R4hkQMjunXekhrtf1S6coAkJQD89bjb8Y/3zUmdAEJdquJLoSQxbT2ceHOe0dnBJT2r8Zf4OIn15UkbI6sM02Ond3ATg1gO90453tmYQUxpL/gkvPQLvLuoekCskF9aHRqCcSL0UQMgRcMKg9JHENyloDabfldDTI8y21gls= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 509de388-304f-4438-4729-08da2fd149ab X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 02:28:35.8384 (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: HQr1FG0kBhpjGwjxWpD49kSwNyZ3AyIpsJ1WzmptaLnwJpcNdugCZxDDeooJ9oC9zWtWxkKUdokW8Rmpn/rvfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1370 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-05-06_07:2022-05-05, 2022-05-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070012 X-Proofpoint-GUID: c5C7gTWWEa4uP4CfhOE8iOrStC6LmtI5 X-Proofpoint-ORIG-GUID: c5C7gTWWEa4uP4CfhOE8iOrStC6LmtI5 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..099e650 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 */