Message ID | a583352e8ae8f6a9a08f9b84a2c543fe43ef94db.1724309198.git.christophe.leroy@csgroup.eu (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Wire up getrandom() vDSO implementation on powerpc | expand |
On Thu, Aug 22, 2024 at 09:13:09AM +0200, Christophe Leroy wrote: > include/asm-generic/unaligned.h | 11 +---------- > include/vdso/unaligned.h | 15 +++++++++++++++ > 2 files changed, 16 insertions(+), 10 deletions(-) > create mode 100644 include/vdso/unaligned.h Do you need to also adjust the `#include <asm/unaligned.h>` inside of lib/vdso/getrandom.c to instead read `#include <vdso/unaligned.h>`? Jason
Le 26/08/2024 à 09:20, Jason A. Donenfeld a écrit : > On Thu, Aug 22, 2024 at 09:13:09AM +0200, Christophe Leroy wrote: >> include/asm-generic/unaligned.h | 11 +---------- >> include/vdso/unaligned.h | 15 +++++++++++++++ >> 2 files changed, 16 insertions(+), 10 deletions(-) >> create mode 100644 include/vdso/unaligned.h > > Do you need to also adjust the `#include <asm/unaligned.h>` inside of > lib/vdso/getrandom.c to instead read `#include <vdso/unaligned.h>`? Yes, all adjustments to lib/vdso/getrandom.c are in patch 2. Christophe
diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h index a84c64e5f11e..95acdd70b3b2 100644 --- a/include/asm-generic/unaligned.h +++ b/include/asm-generic/unaligned.h @@ -8,16 +8,7 @@ */ #include <linux/unaligned/packed_struct.h> #include <asm/byteorder.h> - -#define __get_unaligned_t(type, ptr) ({ \ - const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ - __pptr->x; \ -}) - -#define __put_unaligned_t(type, val, ptr) do { \ - struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ - __pptr->x = (val); \ -} while (0) +#include <vdso/unaligned.h> #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) #define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr)) diff --git a/include/vdso/unaligned.h b/include/vdso/unaligned.h new file mode 100644 index 000000000000..eee3d2a4dbe4 --- /dev/null +++ b/include/vdso/unaligned.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __VDSO_UNALIGNED_H +#define __VDSO_UNALIGNED_H + +#define __get_unaligned_t(type, ptr) ({ \ + const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ + __pptr->x; \ +}) + +#define __put_unaligned_t(type, val, ptr) do { \ + struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ + __pptr->x = (val); \ +} while (0) + +#endif /* __VDSO_UNALIGNED_H */
getrandom vDSO implementation requires __put_unaligned_t() and __put_unaligned_t() but including asm-generic/unaligned.h pulls too many other headers. Follow the same approach as for most things in include/vdso/, see for instance commit 8165b57bca21 ("linux/const.h: Extract common header for vDSO"): Move __get_unaligned_t and __put_unaligned_t into a new unaligned.h living in the vdso/ include directory. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> --- include/asm-generic/unaligned.h | 11 +---------- include/vdso/unaligned.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 include/vdso/unaligned.h