Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp22193rdb; Fri, 29 Sep 2023 15:13:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTibxTyKCvZwVMMSEJhVkdRhVFIWWd1qcUyYgKZG5mhJklqldDIKwQALki8qtefMgmHUAq X-Received: by 2002:a05:6870:c6a2:b0:1dd:58a1:2879 with SMTP id cv34-20020a056870c6a200b001dd58a12879mr5352772oab.35.1696025588846; Fri, 29 Sep 2023 15:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696025588; cv=none; d=google.com; s=arc-20160816; b=eeEu0MK8qeohA62QlBn+BGF0/ec0rMwajpXEjsh9HFUxq4+1l8bGfhLYyiknBQvOJT 7YwJbVL8y0PDDUk1zBiMQrC3aGwEM10gNOpHyIdRn2vVxGrSm8B/tIAmRnBL5MYyCshN ZoP5mvnO3fhZK66t4zilrqTVTWUSUNFuCXxeQA268lFdZH/H6nvZ13OTjbpgdKnvm/9H LMZX7EK0qlLMkXrWVzW/vNJOVZ9IpdDOr7BJOnktqAomYLKniOkT7Lvh9mwfXrFWmYY3 KEqTq5O7LouDyUWvOZOvh8tAQIRwABoNcgt9RaRJ2dZW21ECrPinU630NBzovvfO3B3w HAYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DCJeFrp8qYTZeCfmhw+2xGRK1u15QgFzTU3UpWyLFHU=; fh=Tw89qcqYhKhUkCxUz8uuUxMybBwRuo5Q+1aHjDzfJfI=; b=U27EGHHT/xyiM6hwdfRMdFBQquH3QcnGz/n+8UM2P8BkCpMBYTtaDD823t9yPD+eSa jbD8GHAiF3imsMlvyZcvJAJyZaDxS9CnCaYUp9xdaoEgrNEE3IJbPn6nyZUDRZbkzLvz MSOkuhbWJ5SQ3hvj+t36FMw1b3DlUwv6I1tZjHfZ1H4s2vd9jUpk9xYPikv9Ex4rY6x+ xauhdJmuEaocS21/U2664dsQfktknZksCFHSYiXW3ErouKCYjP7NN8iAqvZcLSjw6dC7 14VWTFHLDcPczG345OTCxSbjgFNWPZekhR+FSaIO+eUCRHJSzAPFnzsB/eRHcQCApBm9 weqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejWvwdpL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b5-20020a633405000000b005775302b11csi18982178pga.81.2023.09.29.15.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 15:13:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejWvwdpL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 90EE28057996; Fri, 29 Sep 2023 10:02:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233714AbjI2RBr (ORCPT + 99 others); Fri, 29 Sep 2023 13:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233742AbjI2RBh (ORCPT ); Fri, 29 Sep 2023 13:01:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35CEA1B3 for ; Fri, 29 Sep 2023 10:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696006847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DCJeFrp8qYTZeCfmhw+2xGRK1u15QgFzTU3UpWyLFHU=; b=ejWvwdpLYTpBLTyoaSA2SKdBwv8Ug6Lz0Nupp8xaJME51of2jJ3LDOK4mvvIIq4XrwpyFb //Z5yhPpDAL+eQaGNUtlGS8c5s9VQzn62FOQmdBYYwVB+b9FjI/z5sKk16N5WfY8FhXjs6 urMtr6DsXrZssB/Ltyui9niScaOk8kU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-T6krj4_AO0GgR-xDnZaiLg-1; Fri, 29 Sep 2023 13:00:44 -0400 X-MC-Unique: T6krj4_AO0GgR-xDnZaiLg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 64E673C025CE; Fri, 29 Sep 2023 17:00:41 +0000 (UTC) Received: from rhel-developer-toolbox.redhat.com (unknown [10.2.16.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EB3EC15BB8; Fri, 29 Sep 2023 17:00:39 +0000 (UTC) From: Chris Leech To: Greg Kroah-Hartman , Christoph Hellwig , Rasesh Mody , Ariel Elior , Sudarsana Kalluru , Manish Chopra Cc: Nilesh Javali , Manish Rangankar , Jerry Snitselaar , John Meneghini , Lee Duncan , Mike Christie , Hannes Reinecke , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] UIO_MEM_DMA_COHERENT for cnic/bnx2/bnx2x Date: Fri, 29 Sep 2023 10:00:20 -0700 Message-ID: <20230929170023.1020032-1-cleech@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 29 Sep 2023 10:02:18 -0700 (PDT) During bnx2i iSCSI testing we ran into page refcounting issues in the uio mmaps exported from cnic to the iscsiuio process, and bisected back to the removal of the __GFP_COMP flag from dma_alloc_coherent calls. In order to fix these drivers to be able to mmap dma coherent memory via a uio device, without resorting to hacks and working with an iommu enabled, introduce a new uio mmap type backed by dma_mmap_coherent. While converting the uio interface, I also noticed that not all of these allocations were PAGE_SIZE aligned. Particularly the bnx2/bnx2x status block mapping was much smaller than any architecture page size, and I was concerned that it could be unintentionally exposing kernel memory. Chris Leech (3): uio: introduce UIO_DMA_COHERENT type cnic. bnx2, bnx2x: page align uio mmap allocations cnic, bnx2, bnx2x: use UIO_MEM_DMA_COHERENT drivers/net/ethernet/broadcom/bnx2.c | 2 ++ .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 10 +++--- drivers/net/ethernet/broadcom/cnic.c | 34 ++++++++++++------- drivers/net/ethernet/broadcom/cnic.h | 1 + drivers/net/ethernet/broadcom/cnic_if.h | 1 + drivers/uio/uio.c | 34 +++++++++++++++++++ include/linux/uio_driver.h | 12 +++++-- 7 files changed, 75 insertions(+), 19 deletions(-) -- 2.41.0