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 854E0A0C48; Tue, 20 Jul 2021 16:58:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 242A04068B; Tue, 20 Jul 2021 16:58:44 +0200 (CEST) Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by mails.dpdk.org (Postfix) with ESMTP id 3648640689 for ; Tue, 20 Jul 2021 16:58:43 +0200 (CEST) Received: by mail-qv1-f50.google.com with SMTP id c15so10224717qvw.6 for ; Tue, 20 Jul 2021 07:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=banduracyber-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=ism9ApEnags4fYtdRVE4CwcmOd31yIJaTkZIvhJAoug=; b=q1y5CU2wLLD8PPeX4/40iYyrzFGXcxrNHjp7xqvVTpqJcTuj4fQJ7o9dos+KmTaYQ3 5VfcxTgLst84FjG6NxJHFa7Wkwk3MoUJPZVo5+Uc20Did5ClRpBSvdQ+po1aIzoUFN35 Ojx/kxx9Bzfo6tUk6ibzkIXntKDhUrc2Jz2Wv+fYDbIB8fqdlviwJwb0w0/rOXVAZNjC p8k9ohxoOYzAhLVnPSUt+ngcQq5UUCCNtO6jbQbqYPRgD90v7fYfO6AE0bHvVKLzzH/M M6fneqm/YUW9URHK/gDA4V8Y6CzuIbVpdVdhQygV8vpD+OKYMdxYciX91EbupurDoU3X wdTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ism9ApEnags4fYtdRVE4CwcmOd31yIJaTkZIvhJAoug=; b=BIJBMkGCMfSqGlUkIwvFhpaOIGYPnEY1qRcyKvJNNLRUkJs2ZLefHDgPJK691EILgF Fca8LuXNwVAU2gXKCJPR6H/lbKZIzYIoHqUHDFJnFcZz3VcXkYTFq6Tznq8PgWGWTmWr TlVTIcp8MaHPDAk6oV0Fu06Grj7kuRyV0Ysr+v0bquvY23ozLoLX9JmXfud7suPDHi1c uXLnLfUH4cH6ZhrSZcCTn/ClffdTK3w3jPviXJFjFgeOwSikbrZ4ZNPLhSj8Vu0BjId5 JWYqnMZkCeSlBMmvlsbUJup/+Qsl1JvZyrPRFDXiRJi/Xwhc3MXUTfL1AvjeFoTkvS46 pnbQ== X-Gm-Message-State: AOAM530tfuotwc6wmo4Jxq1OQoze/QC1NKdp7eCQHEJWIwGVDPDjbAwO Q3adSE3rypmdXlbsyYwC5lu3fA== X-Google-Smtp-Source: ABdhPJw7LOAx7Fb85ReOPbR/WIsmoKVJE7H+QMu8QJPceda0ynr8xQSfFJ+aDj+53WEgMQV8IEzymQ== X-Received: by 2002:ad4:5cef:: with SMTP id iv15mr30650465qvb.14.1626793122461; Tue, 20 Jul 2021 07:58:42 -0700 (PDT) Received: from localhost.localdomain (dyn-69-88-36-66.myactv.net. [69.88.36.66]) by smtp.gmail.com with ESMTPSA id n124sm2120609qkf.119.2021.07.20.07.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 07:58:42 -0700 (PDT) From: jerb To: sthemmin@microsoft.com, longli@microsoft.com Cc: dev@dpdk.org, jerb Date: Tue, 20 Jul 2021 10:58:39 -0400 Message-Id: <20210720145839.12180-1-jonathan.erb@banduracyber.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] bus/vmbus: Fix crash when handling packets in secondary process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Have secondary processes construct their own copy of primary channel with own mappings. Remove vmbus_channel primary ptr from struct mapped_vmbus_resource as its not used. Populate virtual memory address "addr" in struct rte_mem_resource for secondary processes as netvsc will attempt to reference it thus causing a crash. It was initialized for primary processes but not for secondary. Signed-off-by: jerb --- drivers/bus/vmbus/private.h | 1 - drivers/bus/vmbus/vmbus_channel.c | 4 +--- drivers/bus/vmbus/vmbus_common_uio.c | 15 ++++++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h index 528d60a42f..746212bd5f 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -42,7 +42,6 @@ struct mapped_vmbus_resource { rte_uuid_t id; int nb_maps; - struct vmbus_channel *primary; struct vmbus_map maps[VMBUS_MAX_RESOURCE]; char path[PATH_MAX]; }; diff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_channel.c index f67f1c438a..119b9b367e 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -351,10 +351,8 @@ int rte_vmbus_chan_open(struct rte_vmbus_device *device, err = vmbus_chan_create(device, device->relid, 0, device->monitor_id, new_chan); - if (!err) { + if (!err) device->primary = *new_chan; - uio_res->primary = *new_chan; - } return err; } diff --git a/drivers/bus/vmbus/vmbus_common_uio.c b/drivers/bus/vmbus/vmbus_common_uio.c index 8582e32c1d..7b9a8ef434 100644 --- a/drivers/bus/vmbus/vmbus_common_uio.c +++ b/drivers/bus/vmbus/vmbus_common_uio.c @@ -69,8 +69,10 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev) fd, offset, uio_res->maps[i].size, 0); - if (mapaddr == uio_res->maps[i].addr) + if (mapaddr == uio_res->maps[i].addr) { + dev->resource[i].addr = mapaddr; continue; /* successful map */ + } if (mapaddr == MAP_FAILED) VMBUS_LOG(ERR, @@ -88,9 +90,9 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev) /* fd is not needed in secondary process, close it */ close(fd); - dev->primary = uio_res->primary; - if (!dev->primary) { - VMBUS_LOG(ERR, "missing primary channel"); + if (vmbus_chan_create(dev, dev->relid, 0, + dev->monitor_id, &dev->primary)) { + VMBUS_LOG(ERR, "cannot create primary channel"); return -1; } @@ -211,8 +213,11 @@ vmbus_uio_unmap_resource(struct rte_vmbus_device *dev) return; /* secondary processes - just free maps */ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + if (dev->primary != NULL) + rte_free(dev->primary); return vmbus_uio_unmap(uio_res); + } TAILQ_REMOVE(uio_res_list, uio_res, next); -- 2.17.1