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

ARM: 8329/1: miscellaneous vdso infrastructure, preparation

Define the layout of the data structure shared between kernel and
userspace.

Track the vdso address in the mm_context; needed for communicating
AT_SYSINFO_EHDR to the ELF loader.

Add declarations for arm_install_vdso; implementation is in a
following patch.

Define AT_SYSINFO_EHDR, and, if CONFIG_VDSO=y, report the vdso shared
object address via the ELF auxiliary vector.

Note - this adds the AT_SYSINFO_EHDR in a new user-visible header
asm/auxvec.h; this is consistent with other architectures.

Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Nathan Lynch and committed by
Russell King
1713ce7c c517d838

+113 -1
-1
arch/arm/include/asm/Kbuild
··· 1 1 2 2 3 - generic-y += auxvec.h 4 3 generic-y += bitsperlong.h 5 4 generic-y += cputime.h 6 5 generic-y += current.h
+1
arch/arm/include/asm/auxvec.h
··· 1 + #include <uapi/asm/auxvec.h>
+9
arch/arm/include/asm/elf.h
··· 1 1 #ifndef __ASMARM_ELF_H 2 2 #define __ASMARM_ELF_H 3 3 4 + #include <asm/auxvec.h> 4 5 #include <asm/hwcap.h> 6 + #include <asm/vdso_datapage.h> 5 7 6 8 /* 7 9 * ELF register definitions.. ··· 132 130 #define arch_randomize_brk arch_randomize_brk 133 131 134 132 #ifdef CONFIG_MMU 133 + #ifdef CONFIG_VDSO 134 + #define ARCH_DLINFO \ 135 + do { \ 136 + NEW_AUX_ENT(AT_SYSINFO_EHDR, \ 137 + (elf_addr_t)current->mm->context.vdso); \ 138 + } while (0) 139 + #endif 135 140 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 136 141 struct linux_binprm; 137 142 int arch_setup_additional_pages(struct linux_binprm *, int);
+3
arch/arm/include/asm/mmu.h
··· 11 11 #endif 12 12 unsigned int vmalloc_seq; 13 13 unsigned long sigpage; 14 + #ifdef CONFIG_VDSO 15 + unsigned long vdso; 16 + #endif 14 17 } mm_context_t; 15 18 16 19 #ifdef CONFIG_CPU_HAS_ASID
+32
arch/arm/include/asm/vdso.h
··· 1 + #ifndef __ASM_VDSO_H 2 + #define __ASM_VDSO_H 3 + 4 + #ifdef __KERNEL__ 5 + 6 + #ifndef __ASSEMBLY__ 7 + 8 + struct mm_struct; 9 + 10 + #ifdef CONFIG_VDSO 11 + 12 + void arm_install_vdso(struct mm_struct *mm, unsigned long addr); 13 + 14 + extern char vdso_start, vdso_end; 15 + 16 + extern unsigned int vdso_total_pages; 17 + 18 + #else /* CONFIG_VDSO */ 19 + 20 + static inline void arm_install_vdso(struct mm_struct *mm, unsigned long addr) 21 + { 22 + } 23 + 24 + #define vdso_total_pages 0 25 + 26 + #endif /* CONFIG_VDSO */ 27 + 28 + #endif /* __ASSEMBLY__ */ 29 + 30 + #endif /* __KERNEL__ */ 31 + 32 + #endif /* __ASM_VDSO_H */
+60
arch/arm/include/asm/vdso_datapage.h
··· 1 + /* 2 + * Adapted from arm64 version. 3 + * 4 + * Copyright (C) 2012 ARM Limited 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 + */ 18 + #ifndef __ASM_VDSO_DATAPAGE_H 19 + #define __ASM_VDSO_DATAPAGE_H 20 + 21 + #ifdef __KERNEL__ 22 + 23 + #ifndef __ASSEMBLY__ 24 + 25 + #include <asm/page.h> 26 + 27 + /* Try to be cache-friendly on systems that don't implement the 28 + * generic timer: fit the unconditionally updated fields in the first 29 + * 32 bytes. 30 + */ 31 + struct vdso_data { 32 + u32 seq_count; /* sequence count - odd during updates */ 33 + u16 tk_is_cntvct; /* fall back to syscall if false */ 34 + u16 cs_shift; /* clocksource shift */ 35 + u32 xtime_coarse_sec; /* coarse time */ 36 + u32 xtime_coarse_nsec; 37 + 38 + u32 wtm_clock_sec; /* wall to monotonic offset */ 39 + u32 wtm_clock_nsec; 40 + u32 xtime_clock_sec; /* CLOCK_REALTIME - seconds */ 41 + u32 cs_mult; /* clocksource multiplier */ 42 + 43 + u64 cs_cycle_last; /* last cycle value */ 44 + u64 cs_mask; /* clocksource mask */ 45 + 46 + u64 xtime_clock_snsec; /* CLOCK_REALTIME sub-ns base */ 47 + u32 tz_minuteswest; /* timezone info for gettimeofday(2) */ 48 + u32 tz_dsttime; 49 + }; 50 + 51 + union vdso_data_store { 52 + struct vdso_data data; 53 + u8 page[PAGE_SIZE]; 54 + }; 55 + 56 + #endif /* !__ASSEMBLY__ */ 57 + 58 + #endif /* __KERNEL__ */ 59 + 60 + #endif /* __ASM_VDSO_DATAPAGE_H */
+1
arch/arm/include/uapi/asm/Kbuild
··· 1 1 # UAPI Header export list 2 2 include include/uapi/asm-generic/Kbuild.asm 3 3 4 + header-y += auxvec.h 4 5 header-y += byteorder.h 5 6 header-y += fcntl.h 6 7 header-y += hwcap.h
+7
arch/arm/include/uapi/asm/auxvec.h
··· 1 + #ifndef __ASM_AUXVEC_H 2 + #define __ASM_AUXVEC_H 3 + 4 + /* VDSO location */ 5 + #define AT_SYSINFO_EHDR 33 6 + 7 + #endif