From 60567cfb44249250ce3f86b8131a07b37c7ef55b Mon Sep 17 00:00:00 2001 From: Miguel Ojeda Date: Fri, 18 Sep 2020 22:25:01 +0200 Subject: Ignore the alignment requirement on `kernel_param` Signed-off-by: Miguel Ojeda --- rust/module/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rust/module/src/lib.rs b/rust/module/src/lib.rs index bb15188a6abb..82dac6780b9c 100644 --- a/rust/module/src/lib.rs +++ b/rust/module/src/lib.rs @@ -219,9 +219,14 @@ pub fn module(ts: TokenStream) -> TokenStream { const {param_name}: __{name}_{param_name} = __{name}_{param_name}; - // FIXME: does the `align` do the right thing here? - // `core::mem::size_of(usize)` - #[repr(C,align(8))] + // Note: the C macro that generates the static structs for the `__param` section + // asks for them to be `aligned(sizeof(void *))`. However, that was put in place + // in 2003 in commit 38d5b085d2 (\"[PATCH] Fix over-alignment problem on x86-64\") + // to undo GCC over-alignment of static structs of >32 bytes. It seems that is + // not the case anymore, so we simplify to a transparent representation here + // in the expectation that it is not needed anymore. + // TODO: revisit this to confirm the above comment and remove it if it happened + #[repr(transparent)] struct __{name}_{param_name}_RacyKernelParam(kernel::bindings::kernel_param); unsafe impl Sync for __{name}_{param_name}_RacyKernelParam {{ -- cgit v1.2.3