From patchwork Mon Jul 26 17:00:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Erb X-Patchwork-Id: 96299 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9F864A0C47; Mon, 26 Jul 2021 19:00:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 36393410EA; Mon, 26 Jul 2021 19:00:47 +0200 (CEST) Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by mails.dpdk.org (Postfix) with ESMTP id 2CEF3410EA for ; Mon, 26 Jul 2021 19:00:45 +0200 (CEST) Received: by mail-qv1-f49.google.com with SMTP id x12so1919152qvo.12 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=Fhf68WMGb8FIZZaxRpiOVQBDTUjF/cAGzarHBR00XvHurKhMQEWcNpaaUpegDRGGms nlNrFsO9vQ7asMYJOSHF2aluCUeY4gdM7p+B/lQ+KG0+mRrCluLdQ1T0WwnKS5wPd9IQ Coz01Z6huSgDPY4Fbq3yn5+qtXIp2dObtBggclYDU80yY8THh+cy7TEQUeYrfcyumv79 gpQ3REI9ywkM4NRm+w+tfAJpb3TarZGTP0luFAlGrvh+2LfBsD2K0I8oayhAL4pvJx9a Krp5gjIyKD3hkT45KSh1WBH36PDo0XEXokvyjJD54raNykCjpMnx9erALd1hC/Jsf6iH XEkw== X-Gm-Message-State: AOAM5303XoyHFpkyboJ+OioKE1N7eqQEmgmcKGYKrQCO+RsJgS9dMUCx hDl02tF/vjgJUrjEYHdV/SLckw== 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-dev] [PATCH v2] 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. Cc: stable@dpdk.org Signed-off-by: Jonathan Erb Signed-off-by: Jonathan Erb 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);