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] [day] [month] [year] [list]
Message-ID: <20170924102046.357c00ca@gmail.com>
Date:   Sun, 24 Sep 2017 10:20:46 -0400
From:   Chuck Ebbert <cebbert.lkml@...il.com>
To:     Timur Tabi <timur@...eaurora.org>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: Proper way to allocate DMA buffer within a single 4GB block?

On Wed, 20 Sep 2017 17:18:09 -0500
Timur Tabi <timur@...eaurora.org> wrote:

> I have a device that requires I allocated a few buffers for DMA. The 
> problem is that this device has only one register for the upper 32
> bits of all of the buffers. That is, all of buffers must reside
> within the same 4GB block of memory. In order words,
> 
> 	end = start + size - 1;
> 	if (upper_32_bits(start) != upper_32_bits(end))
> 		// Oh no, the buffer spans across a 4GB boundary!
> 
> The buffer is typically less than 16KB in size, so we've never seen
> it actually span across a 4GB boundary.  However, I want to ensure
> that it's impossible.  I wrote this function that re-tries the
> allocation if the first one is invalid, but I suspect that it's too
> hackish.  Is there a better way?
> 

Allocate a buffer twice as big as what you really need. If the first
half doesn't work, the second half will.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ