Re: [RFC 06/13] rust: add bindings for memattrs

2025-01-23 Thread Paolo Bonzini
On 1/23/25 16:10, Zhao Liu wrote: Another solution would be to implement Zeroable for __BindgenBitfieldUnit in bindings.rs, but this is much nicer! It works even with old Rust versions and, even though it needs manual implementation of the trait each type, it doesn't require enumerating the fiel

Re: [RFC 06/13] rust: add bindings for memattrs

2025-01-23 Thread Zhao Liu
> Another solution would be to implement Zeroable for __BindgenBitfieldUnit in > bindings.rs, but this is much nicer! It works even with old Rust versions > and, even though it needs manual implementation of the trait each type, it > doesn't require enumerating the fields one by one. So it's bett

Re: [RFC 06/13] rust: add bindings for memattrs

2025-01-20 Thread Paolo Bonzini
On 1/20/25 17:52, Zhao Liu wrote: Sorry I missed this comment before... Now I have a MemTxAttrs like, typedef struct MemTxAttrs { unsigned int secure:1; unsigned int space:2; unsigned int user:1; unsigned int memory:1; unsigned int requester_id:16; unsigned int pid

Re: [RFC 06/13] rust: add bindings for memattrs

2025-01-20 Thread Zhao Liu
On Fri, Dec 06, 2024 at 02:13:57PM -0500, Paolo Bonzini wrote: > Date: Fri, 6 Dec 2024 14:13:57 -0500 > From: Paolo Bonzini > Subject: Re: [RFC 06/13] rust: add bindings for memattrs > > Il ven 6 dic 2024, 09:42 Peter Maydell ha > scritto: > > > On Fri, 6 Dec 2

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-08 Thread Zhao Liu
On Sun, Dec 08, 2024 at 10:30:34AM +0100, Paolo Bonzini wrote: > Date: Sun, 8 Dec 2024 10:30:34 +0100 > From: Paolo Bonzini > Subject: Re: [RFC 06/13] rust: add bindings for memattrs > > Il sab 7 dic 2024, 10:21 Philippe Mathieu-Daudé ha > scritto: > > > >

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-08 Thread Paolo Bonzini
Il sab 7 dic 2024, 10:21 Philippe Mathieu-Daudé ha scritto: > >> is still decently packed and simplifies things a lot. > > > > The old struct is 4 bytes, and the new one is 8 bytes. We do > > a lot of directly passing 'struct MemTxAttrs' arguments around > > as arguments to functions (i.e. not pa

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-07 Thread Philippe Mathieu-Daudé
On 6/12/24 11:59, Peter Maydell wrote: On Thu, 5 Dec 2024 at 18:30, Paolo Bonzini wrote: On 12/5/24 19:15, Richard Henderson wrote: On 12/5/24 00:07, Zhao Liu wrote: The MemTxAttrs structure is composed of bitfield members, and bindgen is unable to generate an equivalent macro definition for

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-06 Thread Paolo Bonzini
Il ven 6 dic 2024, 09:42 Peter Maydell ha scritto: > On Fri, 6 Dec 2024 at 14:28, Paolo Bonzini wrote: > > Yes, hence "decently" packed. But I think in both cases it's passed in > registers, and for 64-bit machine that shouldn't change anything. > > True. Though it does mean we go from "space to

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-06 Thread Peter Maydell
On Fri, 6 Dec 2024 at 14:28, Paolo Bonzini wrote: > > > > Il ven 6 dic 2024, 05:59 Peter Maydell ha scritto: >> >> > is still decently packed and simplifies things a lot. >> >> The old struct is 4 bytes, and the new one is 8 bytes. > > > Yes, hence "decently" packed. But I think in both cases it'

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-06 Thread Paolo Bonzini
Il ven 6 dic 2024, 05:59 Peter Maydell ha scritto: > > is still decently packed and simplifies things a lot. > > The old struct is 4 bytes, and the new one is 8 bytes. Yes, hence "decently" packed. But I think in both cases it's passed in registers, and for 64-bit machine that shouldn't change

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-06 Thread Richard Henderson
On 12/6/24 02:41, Zhao Liu wrote: BTW, may I ask why you favor bool over uint8_t, and is it because they are indeed just 0/1 as well? :) Yes, exactly. :-) r~

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-06 Thread Peter Maydell
On Thu, 5 Dec 2024 at 18:30, Paolo Bonzini wrote: > > On 12/5/24 19:15, Richard Henderson wrote: > > On 12/5/24 00:07, Zhao Liu wrote: > >> The MemTxAttrs structure is composed of bitfield members, and bindgen is > >> unable to generate an equivalent macro definition for > >> MEMTXATTRS_UNSPECIFIE

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-06 Thread Zhao Liu
On Thu, Dec 05, 2024 at 05:51:42PM -0600, Richard Henderson wrote: > Date: Thu, 5 Dec 2024 17:51:42 -0600 > From: Richard Henderson > Subject: Re: [RFC 06/13] rust: add bindings for memattrs > > On 12/5/24 12:30, Paolo Bonzini wrote: > > On 12/5/24 19:15, Richard Henderson

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-05 Thread Richard Henderson
On 12/5/24 12:30, Paolo Bonzini wrote: On 12/5/24 19:15, Richard Henderson wrote: On 12/5/24 00:07, Zhao Liu wrote: The MemTxAttrs structure is composed of bitfield members, and bindgen is unable to generate an equivalent macro definition for MEMTXATTRS_UNSPECIFIED. I'm happy to move away fro

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-05 Thread Paolo Bonzini
On 12/5/24 19:15, Richard Henderson wrote: On 12/5/24 00:07, Zhao Liu wrote: The MemTxAttrs structure is composed of bitfield members, and bindgen is unable to generate an equivalent macro definition for MEMTXATTRS_UNSPECIFIED. I'm happy to move away from bit fields to uint32_t or suchlike to

Re: [RFC 06/13] rust: add bindings for memattrs

2024-12-05 Thread Richard Henderson
On 12/5/24 00:07, Zhao Liu wrote: The MemTxAttrs structure is composed of bitfield members, and bindgen is unable to generate an equivalent macro definition for MEMTXATTRS_UNSPECIFIED. I'm happy to move away from bit fields to uint32_t or suchlike to enable MEMTXATTRS_UNSPECIFIED be a compile-

[RFC 06/13] rust: add bindings for memattrs

2024-12-04 Thread Zhao Liu
The MemTxAttrs structure is composed of bitfield members, and bindgen is unable to generate an equivalent macro definition for MEMTXATTRS_UNSPECIFIED. Therefore, we have to manually define a global constant variable MEMTXATTRS_UNSPECIFIED to support calls from Rust code. However, the binding meth