Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

random: vDSO: minimize and simplify header includes

Depending on the architecture, building a 32-bit vDSO on a 64-bit kernel
is problematic when some system headers are included.

Minimise the amount of headers by moving needed items, such as
__{get,put}_unaligned_t, into dedicated common headers and in general
use more specific headers, similar to what was done in commit
8165b57bca21 ("linux/const.h: Extract common header for vDSO") and
commit 8c59ab839f52 ("lib/vdso: Enable common headers").

On some architectures this results in missing PAGE_SIZE, as was
described by commit 8b3843ae3634 ("vdso/datapage: Quick fix - use
asm/page-def.h for ARM64"), so define this if necessary, in the same way
as done prior by commit cffaefd15a8f ("vdso: Use CONFIG_PAGE_SHIFT in
vdso/datapage.h").

Removing linux/time64.h leads to missing 'struct timespec64' in
x86's asm/pvclock.h. Add a forward declaration of that struct in
that file.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

authored by

Christophe Leroy and committed by
Jason A. Donenfeld
7f053812 b7bad082

+26 -15
+1
arch/x86/include/asm/pvclock.h
··· 5 5 #include <asm/clocksource.h> 6 6 #include <asm/pvclock-abi.h> 7 7 8 + struct timespec64; 8 9 /* some helper functions for xen and kvm pv clock sources */ 9 10 u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src); 10 11 u64 pvclock_clocksource_read_nowd(struct pvclock_vcpu_time_info *src);
+1 -10
include/asm-generic/unaligned.h
··· 8 8 */ 9 9 #include <linux/unaligned/packed_struct.h> 10 10 #include <asm/byteorder.h> 11 - 12 - #define __get_unaligned_t(type, ptr) ({ \ 13 - const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ 14 - __pptr->x; \ 15 - }) 16 - 17 - #define __put_unaligned_t(type, val, ptr) do { \ 18 - struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ 19 - __pptr->x = (val); \ 20 - } while (0) 11 + #include <vdso/unaligned.h> 21 12 22 13 #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) 23 14 #define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr))
+1
include/vdso/helpers.h
··· 4 4 5 5 #ifndef __ASSEMBLY__ 6 6 7 + #include <asm/barrier.h> 7 8 #include <vdso/datapage.h> 8 9 9 10 static __always_inline u32 vdso_read_begin(const struct vdso_data *vd)
+15
include/vdso/unaligned.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef __VDSO_UNALIGNED_H 3 + #define __VDSO_UNALIGNED_H 4 + 5 + #define __get_unaligned_t(type, ptr) ({ \ 6 + const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ 7 + __pptr->x; \ 8 + }) 9 + 10 + #define __put_unaligned_t(type, val, ptr) do { \ 11 + struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ 12 + __pptr->x = (val); \ 13 + } while (0) 14 + 15 + #endif /* __VDSO_UNALIGNED_H */
+8 -5
lib/vdso/getrandom.c
··· 4 4 */ 5 5 6 6 #include <linux/array_size.h> 7 - #include <linux/cache.h> 8 - #include <linux/kernel.h> 9 - #include <linux/time64.h> 7 + #include <linux/minmax.h> 10 8 #include <vdso/datapage.h> 11 9 #include <vdso/getrandom.h> 10 + #include <vdso/unaligned.h> 12 11 #include <asm/vdso/getrandom.h> 13 - #include <asm/vdso/vsyscall.h> 14 - #include <asm/unaligned.h> 15 12 #include <uapi/linux/mman.h> 13 + #include <uapi/linux/random.h> 14 + 15 + #undef PAGE_SIZE 16 + #undef PAGE_MASK 17 + #define PAGE_SIZE (1UL << CONFIG_PAGE_SHIFT) 18 + #define PAGE_MASK (~(PAGE_SIZE - 1)) 16 19 17 20 #define MEMCPY_AND_ZERO_SRC(type, dst, src, len) do { \ 18 21 while (len >= sizeof(type)) { \