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 39D7FA0C4D for ; Mon, 26 Jul 2021 19:00:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 333B8410F1; Mon, 26 Jul 2021 19:00:48 +0200 (CEST) Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by mails.dpdk.org (Postfix) with ESMTP id 2A696410E6 for ; Mon, 26 Jul 2021 19:00:45 +0200 (CEST) Received: by mail-qv1-f41.google.com with SMTP id s14so5443669qvm.4 for ; Mon, 26 Jul 2021 10:00:44 -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=UC7VhCOgUYpOCpoG1o82VdxuHxLJjTqpi/bG3sy/zrU=; b=TgZArHre+Q5ImjriAvsDeSLnA5YRHBmkQqU1fWeWSCoYQFWReatNViVS+mcbDizQM9 thhAWzF/aje3hVHEeucHgn83NxmXrPkaIYcLBCx50bgOQikFECtJcV9M22MRh/yXWFNp I2buZYOcR4mdihYK67gnWy5mI9M2N3aI7aRLhPZYZPUHAOO+vsasbc3wXVewpOPfOVMT YVi6C40mvmrH3/D+nHLwjYljTZvi4n/ySGU2yVPdi6gxbOqHkXNKjTMG/m8SrH7a0+3n GLogFu5fcLwjW19SKoUAr0ZUgocIp8ktp8+K9F60nRUg8AMF+X1OoZICoHf1aBDRDIxO sTXA== 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=UC7VhCOgUYpOCpoG1o82VdxuHxLJjTqpi/bG3sy/zrU=; b=Asz194tcSrYNXWVK6cr36isYSnFpPJ+CTDRtXfxC57rf22bpgZFEBDgvetVqq+Y/Wu BQf1pYrHu3hQNb/hfd8Y6x14NQuVrq+mpIOEcj0de5dO13zUsHEQCtMl/jel9+gi60xZ dvjvtJsX8yZlmnX9wVftxF2/I+Ws42iY8JFYa9Vv6H/l+F0b8otSk+jXJquC+q/Jvbov z6s8PFuUKV7m/b9YiaTwI8F7vhmo0F4+O0Rq/K5D1o11015nJO0/IOlPNvx/ceV35Klk 9kpvZUuIj5OUBCHkEsBk54p63TSPQJIqy3E5gC61MA3QGovh8TZkYLEWI76SqEO9r8xl gNQA== X-Gm-Message-State: AOAM532ypMuyiS9a3OhDDywliLSQnVrb/mzB+S9LkXb45XGEd9MjCGBU tV+q5Pf7LgMI3a2X/WISY1eGRA== X-Google-Smtp-Source: ABdhPJwcSEDeGYM/J6neMJ1+wSmEcrs6mERTLisCvM9UjPOGuscNKOX1+XOdm3FgWAujSiOiWcjVgA== X-Received: by 2002:a0c:ff01:: with SMTP id w1mr18809076qvt.28.1627318844374; Mon, 26 Jul 2021 10:00:44 -0700 (PDT) Received: from localhost.localdomain (dyn-69-88-36-66.myactv.net. [69.88.36.66]) by smtp.gmail.com with ESMTPSA id k7sm272791qkj.79.2021.07.26.10.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 10:00:43 -0700 (PDT) From: Jonathan Erb To: sthemmin@microsoft.com, longli@microsoft.com Cc: dev@dpdk.org, Jonathan Erb , stable@dpdk.org Date: Mon, 26 Jul 2021 13:00:40 -0400 Message-Id: <20210726170040.25155-1-jonathan.erb@banduracyber.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-stable] [PATCH v2] bus/vmbus: Fix crash when handling packets in secondary process 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 Sender: "stable" 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. Cc: stable@dpdk.org Signed-off-by: Jonathan Erb --- v2: * Remove unnecessary check for NULL pointer before call to rte_free() per reviwer comment. drivers/bus/vmbus/private.h | 1 - drivers/bus/vmbus/vmbus_channel.c | 4 +--- drivers/bus/vmbus/vmbus_common_uio.c | 14 +++++++++----- 3 files changed, 10 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..83c56b6fa2 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,10 @@ 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) { + rte_free(dev->primary); return vmbus_uio_unmap(uio_res); + } TAILQ_REMOVE(uio_res_list, uio_res, next); -- 2.17.1