[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201123102319.8090-8-johan@kernel.org>
Date: Mon, 23 Nov 2020 11:23:18 +0100
From: Johan Hovold <johan@...nel.org>
To: Rob Herring <robh+dt@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jessica Yu <jeyu@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Frank Rowand <frowand.list@...il.com>,
Arnd Bergmann <arnd@...db.de>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
David Miller <davem@...emloft.net>,
Jakub Jelinek <jakub@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Steven Rostedt <rostedt@...dmis.org>,
Daniel Kurtz <djkurtz@...omium.org>,
linux-arch@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
linux-kernel@...r.kernel.org, Johan Hovold <johan@...nel.org>
Subject: [PATCH v2 7/8] params: use type alignment for kernel parameters
Specify type alignment for kernel parameters instead of sizeof(void *).
The alignment attribute is used to prevent gcc from increasing the
alignment of objects with static extent as an optimisation, something
which would mess up the __param array stride.
Using __alignof__(struct kernel_param) rather than sizeof(void *) is
preferred since it better indicates why it is there and doesn't break
should the type size or alignment change.
Note that on m68k the alignment of struct kernel_param is actually two
and that adding a 1- or 2-byte field to the 20-byte struct would cause a
breakage with the current 4-byte alignment.
Signed-off-by: Johan Hovold <johan@...nel.org>
---
include/linux/moduleparam.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 742074ad9f6e..15ecc6cc3a3b 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -288,8 +288,8 @@ struct kparam_array
/* Default value instead of permissions? */ \
static const char __param_str_##name[] = prefix #name; \
static struct kernel_param __moduleparam_const __param_##name \
- __used \
- __section("__param") __attribute__ ((aligned(sizeof(void *)))) \
+ __used __section("__param") \
+ __aligned(__alignof__(struct kernel_param)) \
= { __param_str_##name, THIS_MODULE, ops, \
VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
--
2.26.2
Powered by blists - more mailing lists