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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aV5tUE02ipda-R76@ryzen>
Date: Wed, 7 Jan 2026 15:27:28 +0100
From: Niklas Cassel <cassel@...nel.org>
To: Koichiro Den <den@...inux.co.jp>
Cc: jingoohan1@...il.com, mani@...nel.org, lpieralisi@...nel.org,
	kwilczynski@...nel.org, robh@...nel.org, bhelgaas@...gle.com,
	Frank.Li@....com, linux-pci@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] PCI: dwc: ep: Support BAR subrange inbound
 mapping via address-match iATU

Hello Koichiro,


I like this design way more, where you have a one-shot (all-or-nothing)
submap programming to avoid leaving half-programmed BAR state.


On Wed, Jan 07, 2026 at 01:13:58PM +0900, Koichiro Den wrote:
> +/* Address Match Mode IB iATU mapping */
> +static int dw_pcie_ep_ib_atu_addr(struct dw_pcie_ep *ep, u8 func_no, int type,
> +				  const struct pci_epf_bar *epf_bar)
> +{
> +	struct pci_epf_bar_submap *submap = epf_bar->submap;
> +	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> +	enum pci_barno bar = epf_bar->barno;
> +	struct device *dev = pci->dev;
> +	u64 pci_addr, parent_bus_addr;
> +	struct dw_pcie_ib_map *new;
> +	u64 size, off, base;
> +	unsigned long flags;
> +	int free_win, ret;
> +	unsigned int i;
> +
> +	if (!epf_bar->num_submap || !submap || !epf_bar->size)
> +		return -EINVAL;
> +
> +	/* Work on a sorted copy */
> +	struct pci_epf_bar_submap *smap __free(kfree) = kcalloc(
> +				epf_bar->num_submap, sizeof(*smap), GFP_KERNEL);
> +	if (!smap)
> +		return -ENOMEM;
> +
> +	memcpy(smap, submap, epf_bar->num_submap * sizeof(*smap));
> +	sort(smap, epf_bar->num_submap, sizeof(*smap),
> +	     dw_pcie_ep_submap_offset_cmp, NULL);

My only comment is that:

Why not simply let dw_pcie_ep_validate_submap() return an error if the
caller of dw_pcie_ep_set_bar() did not provide a submap with offsets in
ascending order (i.e. sorted).

Performing an unconditional sort of the submap here looks a bit out of
place, IMO.


> +
> +	ret = dw_pcie_ep_validate_submap(ep, smap, epf_bar->num_submap, epf_bar->size);
> +	if (ret)
> +		return ret;


Kind regards,
Niklas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ