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: <ba95a574-2dba-4299-9ec4-bb776a228d98@gmail.com>
Date: Thu, 9 Jan 2025 13:14:25 +0200
From: Abdiel Janulgue <abdiel.janulgue@...il.com>
To: Daniel Almeida <daniel.almeida@...labora.com>,
 Daniel Sedlak <daniel@...lak.dev>
Cc: aliceryhl@...gle.com, robin.murphy@....com,
 rust-for-linux@...r.kernel.org, Miguel Ojeda <ojeda@...nel.org>,
 Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>,
 Gary Guo <gary@...yguo.net>, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, Benno Lossin <benno.lossin@...ton.me>,
 Andreas Hindborg <a.hindborg@...nel.org>, Trevor Gross <tmgross@...ch.edu>,
 Danilo Krummrich <dakr@...nel.org>, Valentin Obst <kernel@...entinobst.de>,
 open list <linux-kernel@...r.kernel.org>, Christoph Hellwig <hch@....de>,
 Marek Szyprowski <m.szyprowski@...sung.com>, airlied@...hat.com,
 "open list:DMA MAPPING HELPERS" <iommu@...ts.linux.dev>
Subject: Re: [PATCH v8 2/2] rust: add dma coherent allocator abstraction.


On 08/01/2025 21:09, Daniel Almeida wrote:
> I was trying to test this again, but it apparently doesn’t compile for the reasons
> Daniel Sedlak pointed out above.
> 

Okay, now I noticed the problem.

bindgen generates this rust signature for dma_alloc_attrs():

extern "C" {
     pub fn dma_alloc_attrs(
         dev: *mut device,
         size: usize,
         dma_handle: *mut dma_addr_t,
         flag: gfp_t,
         attrs: ffi::c_ulong,
     ) -> *mut ffi::c_void;
}

We are interested in the last argument 'attrs'. For some reason it seems 
ffi::c_ulong is defined as usize at least on top of `rust-next` commit 
0c5928deada15a8d075516e6e0d9ee19011bb000.

In previous versions ffi::c_ulong used to be u64. I also noticed that 
core::ffi::c_ulong is u64 while crate::ffi::c_ulong is usize. In the 
previous versions they're both u64.

So my mistake here as is I tried to match the signature manually by 
using usize as suggested by the compiler. Maybe we should stick to 
ffi::c_ulong return type for Attrs::as_raw() to be in sync the 
bindgen-generated interface?

Regards,
Abdiel


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ