From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 820A5A00C2 for ; Mon, 26 Sep 2022 10:33:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7CE80400D7; Mon, 26 Sep 2022 10:33:17 +0200 (CEST) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mails.dpdk.org (Postfix) with ESMTP id 08B26400D5 for ; Mon, 26 Sep 2022 10:33:16 +0200 (CEST) Received: by mail-lf1-f46.google.com with SMTP id a2so9667543lfb.6 for ; Mon, 26 Sep 2022 01:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netgate.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=TZ6KZANGWhlvet5pg0LSqyeDjHFz852znq27/sSuNE4=; b=Ow+hk7fhaTxSoPdqJgJHpIDkKORDp9HZbDyESfqCu6aI5dPH6+3nzRKS03704UWmnF Kd2GFfnxSSiR7sxR91HakYL/UiO1PYeZJjzIuseBKcKW46wwUk07przVAZSu1mRyrkAA 7E7Ddb0DDii9wfVJSNqAK+vbfY8xOunxhBpec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=TZ6KZANGWhlvet5pg0LSqyeDjHFz852znq27/sSuNE4=; b=Q/p4PtHWbMugTYikpgMHlBs+8pAyen25G5+E2NoP1dCQmB/QoUzXC9DUURz+0TnSaM gOU9VoqjWym1pg/USfN2icafZEciGcqb/GSGIS4ZrXgcbFuVCHIBkrp0BirOj4aoYW3R ukTvCJxtLCQmwSXKeNu6vWSlR5R6JI6GJHRb4VJ74edUA6UkQHAe7r4IcZpmpIiwtphk 8cYMPYgSBC7+VTCLV269sJAOoszMI7iJMYdFPQH/jZ+/up5prc5vk/heaY7gsg2ppJyP 2lCbg43vPNCTu0YfNjk3dtKJBMwJ8fLqfRt70cQzA8UaWPj1NBnIe7IjrNh2csB9i4rW MbAA== X-Gm-Message-State: ACrzQf07rEDmt/TcJKH+cN3vRPCeosNSBpD/zSXseyTln++XG+8CvYwz qaYM5i5LgeeoEEszI8CV1p/Ohg== X-Google-Smtp-Source: AMsMyM7t0++2uLRzFzZ1wPYGki6ruZbICRhiQZQNsf1JcN2qrwK0SO5oSiW/mNkaiCnM6Kei9kDtWA== X-Received: by 2002:a19:e01e:0:b0:497:81a9:c2c4 with SMTP id x30-20020a19e01e000000b0049781a9c2c4mr8404588lfg.74.1664181195447; Mon, 26 Sep 2022 01:33:15 -0700 (PDT) Received: from pb1-dev.ad.sperasoft.com ([188.233.188.88]) by smtp.gmail.com with ESMTPSA id v7-20020a056512348700b00497a23cf2absm2457653lfr.258.2022.09.26.01.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 01:32:52 -0700 (PDT) From: Alexander Chernavin To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, Alexander Chernavin , stable@dpdk.org Subject: [PATCH v2] net/virtio: fix crash when dev is configured twice Date: Mon, 26 Sep 2022 08:32:12 +0000 Message-Id: <20220926083212.1178663-1-achernavin@netgate.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831085344.47995-1-achernavin@netgate.com> References: <20220831085344.47995-1-achernavin@netgate.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org When first attempt to configure a device with RX interrupt enabled fails for some reason (e.g. because "Multiple intr vector not supported"), second attempt to configure the device with RX interrupt disabled and feature set unchanged will succeed but will leave virtio queues not allocated. Accessing the queues will cause a segfault. First attempt: - virtio_dev_configure() - virtio_init_device() is called to reinit the device because "dev->data->dev_conf.intr_conf.rxq" is "1" - virtio_configure_intr() fails and returns an error - virtio_free_queues() frees previously allocated virtio queues - virtio_init_device() fails and returns an error - virtio_dev_configure() fails and returns an error Second attempt: - virtio_dev_configure() - This time virtio_init_device() is not called, virtio queues are not allocated With this fix, reinit the device during configuration if virtio queues are not allocated. Cc: stable@dpdk.org Signed-off-by: Alexander Chernavin --- v2: * Also CC to stable@dpdk.org drivers/net/virtio/virtio_ethdev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index d180162abd..38bfe050b5 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -2616,6 +2616,13 @@ virtio_dev_configure(struct rte_eth_dev *dev) return ret; } + /* if queues are not allocated, reinit the device */ + if (hw->vqs == NULL) { + ret = virtio_init_device(dev, hw->req_guest_features); + if (ret < 0) + return ret; + } + if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) && !virtio_with_feature(hw, VIRTIO_NET_F_RSS)) { PMD_DRV_LOG(ERR, "RSS support requested but not supported by the device"); -- 2.25.1