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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231023060845.GA11907@lst.de>
Date:   Mon, 23 Oct 2023 08:08:45 +0200
From:   Christoph Hellwig <hch@....de>
To:     Jia He <justin.he@....com>
Cc:     Christoph Hellwig <hch@....de>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Robin Murphy <robin.murphy@....com>, iommu@...ts.linux.dev,
        linux-kernel@...r.kernel.org, nd@....com
Subject: Re: [PATCH v3 2/2] dma-mapping: fix dma_addressing_limited() if
 dma_range_map can't cover all system RAM

> + */
> +static int check_ram_in_range_map(unsigned long start_pfn,
> +				  unsigned long nr_pages, void *data)
> +{
> +	unsigned long end_pfn = start_pfn + nr_pages;
> +	struct device *dev = (struct device *)data;

No need for the cast here.

> +	struct bus_dma_region *bdr = NULL;
> +	const struct bus_dma_region *m;
> +
> +	while (start_pfn < end_pfn) {
> +		for (m = dev->dma_range_map; PFN_DOWN(m->size); m++) {
> +			unsigned long cpu_start_pfn = PFN_DOWN(m->cpu_start);
> +
> +			if (start_pfn >= cpu_start_pfn
> +			    && start_pfn - cpu_start_pfn < PFN_DOWN(m->size)) {

Linux coding style keeps the && on the previous line.

> +				bdr = (struct bus_dma_region *)m;

If you also declared bdr as const this should be able to do away with
the cast.

>  bool dma_addressing_limited(struct device *dev)
>  {
> -	return min_not_zero(dma_get_mask(dev), dev->bus_dma_limit) <
> -			    dma_get_required_mask(dev);
> +	if (min_not_zero(dma_get_mask(dev), dev->bus_dma_limit) <
> +			 dma_get_required_mask(dev))
> +		return true;
> +
> +	return !all_ram_in_dma_range_map(dev);

So, all the dma range map thing is really a dma-direct concept.  So I
think here in dma_addressing_limited we should just do a:

	if (likely(!ops))
		return !dma_direct_all_ram_mapped(dev));
	return false

with dma_direct_all_ram_mapped move to dma-direct.c.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ