lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240409233942.828440-1-peter.colberg@intel.com>
Date: Tue,  9 Apr 2024 19:39:33 -0400
From: Peter Colberg <peter.colberg@...el.com>
To: Wu Hao <hao.wu@...el.com>,
	Tom Rix <trix@...hat.com>,
	Moritz Fischer <mdf@...nel.org>,
	Xu Yilun <yilun.xu@...el.com>,
	linux-fpga@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Russ Weight <russ.weight@...ux.dev>,
	Marco Pagani <marpagan@...hat.com>,
	Matthew Gerlach <matthew.gerlach@...ux.intel.com>,
	Peter Colberg <peter.colberg@...el.com>
Subject: [RFC PATCH v2 0/9] fpga: dfl: fix kernel warning on port release/assign for SRIOV

DFL ports are registered as platform devices in PF mode. The port device
should be removed from the host when the user wants to configure the
port as a VF and pass through to a virtual machine. The FME device
ioctls DFL_FPGA_FME_PORT_RELEASE/ASSIGN are designed for this purpose.

In the previous implementation, the port platform device is not completely
destroyed on port release: it is removed from the system by
platform_device_del(), but the platform device instance is retained.
When the port assign ioctl is called, the platform device is added back by
platform_device_add(), which conflicts with this comment of device_add():
"Do not call this routine more than once for any device structure", and
will cause a kernel warning at runtime.

This patch tries to completely unregister the port platform device on
release and registers a new one on assign. But the main work is to remove
the dependency on struct dfl_feature_platform_data for many internal DFL
APIs. This structure holds many DFL enumeration infos for feature devices.
Many DFL APIs are expected to work with these info even when the port
platform device is unregistered. But with the change the platform_data will
be freed in this case. So this patch introduces a new structure
dfl_feature_dev_data for these APIs, which acts similarly to the previous
dfl_feature_platform_data. The dfl_feature_platform_data then only needs a
pointer to dfl_feature_dev_data to make the feature device driver work.

The single monolithic v1 patch is split into multiple, smaller patches
at the request of the maintainer. The first patch adds temporary macros
that alias dfl_feature_dev_data ("fdata") to dfl_feature_platform_data
("pdata") and associated functions from the "fdata" to the corresponding
"pdata" variants. Subsequent patches separate out most of the symbol
name changes required by this patch series, one patch per file. The last
patch of the series removes the macros and applies the actual change.

Link: https://lore.kernel.org/all/DM6PR11MB3819F9CCD0A6126B55BCB47685FB9@DM6PR11MB3819.namprd11.prod.outlook.com/T/#t

This series applies after the following non-RFC patches:
- fpga: dfl: remove unused function is_dfl_feature_present
- [v2] fpga: dfl: remove unused member pdata from struct dfl_{afu,fme}

Changes since v1:
- Split monolithic patch into series at request of maintainer.
- Substitute binfo->type for removed function feature_dev_id_type() in
  parse_feature_irqs().
- Return ERR_PTR(-ENOMEM) on !feature->params in
  binfo_create_feature_dev_data().
- Reorder cdev as first member of struct dfl_feature_platform_data
  such that container_of() to obtain pdata evaluates to a no-op.
- Change afu_ioctl_*() to receive dfl_feature_dev_data instead of
  dfl_feature_platform_data.
- Change fme_hdr_ioctl_*() to receive dfl_feature_dev_data instead of
  dfl_feature_platform_data.
- Replace local variable pdata with fdata in afu_mmap().
- Remove unused local variable pdata in afu_dev_{init,destroy}().
- Remove unused local variable pdata in fme_dev_{init,destroy}().
- Reorder local variables in afu_dma_unpin_pages() to reverse Christmas
  tree order.
- Align kernel-doc function name for __dfl_fpga_cdev_find_port_data().
- Substitute @fdata for @pdata in kernel-doc comments for
  dfl_fme_create_mgr() and dfl_fme_destroy_mgr().

Peter Colberg (8):
  fpga: dfl: alias dfl_feature_dev_data to dfl_feature_platform_data
  fpga: dfl: migrate AFU DMA region management driver to
    dfl_feature_dev_data
  fpga: dfl: migrate AFU MMIO region management driver to
    dfl_feature_dev_data
  fpga: dfl: migrate FPGA Management Engine driver to
    dfl_feature_dev_data
  fpga: dfl: migrate FME partial reconfiguration driver to
    dfl_feature_dev_data
  fpga: dfl: migrate Accelerated Function Unit driver to
    dfl_feature_dev_data
  fpga: dfl: migrate DFL support header to dfl_feature_dev_data
  fpga: dfl: migrate dfl_get_feature_by_id() to dfl_feature_dev_data

Xu Yilun (1):
  fpga: dfl: fix kernel warning on port release/assign for SRIOV

 drivers/fpga/dfl-afu-dma-region.c | 119 ++++----
 drivers/fpga/dfl-afu-error.c      |  59 ++--
 drivers/fpga/dfl-afu-main.c       | 281 +++++++++----------
 drivers/fpga/dfl-afu-region.c     |  51 ++--
 drivers/fpga/dfl-afu.h            |  26 +-
 drivers/fpga/dfl-fme-br.c         |  24 +-
 drivers/fpga/dfl-fme-error.c      |  98 +++----
 drivers/fpga/dfl-fme-main.c       |  86 +++---
 drivers/fpga/dfl-fme-pr.c         |  88 +++---
 drivers/fpga/dfl.c                | 433 +++++++++++++++---------------
 drivers/fpga/dfl.h                | 139 ++++++----
 11 files changed, 722 insertions(+), 682 deletions(-)

-- 
2.44.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ