Skip to content

Commit 60567cf

Browse files
committed
Ignore the alignment requirement on kernel_param
Signed-off-by: Miguel Ojeda <[email protected]>
1 parent c3f1ced commit 60567cf

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

rust/module/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,14 @@ pub fn module(ts: TokenStream) -> TokenStream {
219219
220220
const {param_name}: __{name}_{param_name} = __{name}_{param_name};
221221
222-
// FIXME: does the `align` do the right thing here?
223-
// `core::mem::size_of(usize)`
224-
#[repr(C,align(8))]
222+
// Note: the C macro that generates the static structs for the `__param` section
223+
// asks for them to be `aligned(sizeof(void *))`. However, that was put in place
224+
// in 2003 in commit 38d5b085d2 (\"[PATCH] Fix over-alignment problem on x86-64\")
225+
// to undo GCC over-alignment of static structs of >32 bytes. It seems that is
226+
// not the case anymore, so we simplify to a transparent representation here
227+
// in the expectation that it is not needed anymore.
228+
// TODO: revisit this to confirm the above comment and remove it if it happened
229+
#[repr(transparent)]
225230
struct __{name}_{param_name}_RacyKernelParam(kernel::bindings::kernel_param);
226231
227232
unsafe impl Sync for __{name}_{param_name}_RacyKernelParam {{

0 commit comments

Comments
 (0)