forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARM: 8930/1: Add support for generic vDSO
The arm vDSO library requires some adaptations to take advantage of the newly introduced generic vDSO library. Introduce the following changes: - Modification vdso.c to be compliant with the common vdso datapage - Use of lib/vdso for gettimeofday - Implementation of elf note Signed-off-by: Vincenzo Frascino <[email protected]> Signed-off-by: Russell King <[email protected]>
- Loading branch information
Showing
8 changed files
with
195 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* Copyright (C) 2018 ARM Limited | ||
*/ | ||
#ifndef __ASM_VDSO_GETTIMEOFDAY_H | ||
#define __ASM_VDSO_GETTIMEOFDAY_H | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#include <asm/barrier.h> | ||
#include <asm/cp15.h> | ||
#include <asm/unistd.h> | ||
#include <uapi/linux/time.h> | ||
|
||
extern struct vdso_data *__get_datapage(void); | ||
|
||
static __always_inline int gettimeofday_fallback( | ||
struct __kernel_old_timeval *_tv, | ||
struct timezone *_tz) | ||
{ | ||
register struct timezone *tz asm("r1") = _tz; | ||
register struct __kernel_old_timeval *tv asm("r0") = _tv; | ||
register long ret asm ("r0"); | ||
register long nr asm("r7") = __NR_gettimeofday; | ||
|
||
asm volatile( | ||
" swi #0\n" | ||
: "=r" (ret) | ||
: "r" (tv), "r" (tz), "r" (nr) | ||
: "memory"); | ||
|
||
return ret; | ||
} | ||
|
||
static __always_inline long clock_gettime_fallback( | ||
clockid_t _clkid, | ||
struct __kernel_timespec *_ts) | ||
{ | ||
register struct __kernel_timespec *ts asm("r1") = _ts; | ||
register clockid_t clkid asm("r0") = _clkid; | ||
register long ret asm ("r0"); | ||
register long nr asm("r7") = __NR_clock_gettime64; | ||
|
||
asm volatile( | ||
" swi #0\n" | ||
: "=r" (ret) | ||
: "r" (clkid), "r" (ts), "r" (nr) | ||
: "memory"); | ||
|
||
return ret; | ||
} | ||
|
||
static __always_inline u64 __arch_get_hw_counter(int clock_mode) | ||
{ | ||
#ifdef CONFIG_ARM_ARCH_TIMER | ||
u64 cycle_now; | ||
|
||
isb(); | ||
cycle_now = read_sysreg(CNTVCT); | ||
|
||
return cycle_now; | ||
#else | ||
return -EINVAL; /* use fallback */ | ||
#endif | ||
} | ||
|
||
static __always_inline const struct vdso_data *__arch_get_vdso_data(void) | ||
{ | ||
return __get_datapage(); | ||
} | ||
|
||
#endif /* !__ASSEMBLY__ */ | ||
|
||
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef __ASM_VDSO_VSYSCALL_H | ||
#define __ASM_VDSO_VSYSCALL_H | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#include <linux/timekeeper_internal.h> | ||
#include <vdso/datapage.h> | ||
#include <asm/cacheflush.h> | ||
|
||
extern struct vdso_data *vdso_data; | ||
extern bool cntvct_ok; | ||
|
||
static __always_inline | ||
bool tk_is_cntvct(const struct timekeeper *tk) | ||
{ | ||
if (!IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) | ||
return false; | ||
|
||
if (!tk->tkr_mono.clock->archdata.vdso_direct) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
/* | ||
* Update the vDSO data page to keep in sync with kernel timekeeping. | ||
*/ | ||
static __always_inline | ||
struct vdso_data *__arm_get_k_vdso_data(void) | ||
{ | ||
return vdso_data; | ||
} | ||
#define __arch_get_k_vdso_data __arm_get_k_vdso_data | ||
|
||
static __always_inline | ||
int __arm_update_vdso_data(void) | ||
{ | ||
return !cntvct_ok; | ||
} | ||
#define __arch_update_vdso_data __arm_update_vdso_data | ||
|
||
static __always_inline | ||
int __arm_get_clock_mode(struct timekeeper *tk) | ||
{ | ||
u32 __tk_is_cntvct = tk_is_cntvct(tk); | ||
|
||
return __tk_is_cntvct; | ||
} | ||
#define __arch_get_clock_mode __arm_get_clock_mode | ||
|
||
static __always_inline | ||
int __arm_use_vsyscall(struct vdso_data *vdata) | ||
{ | ||
return vdata[CS_HRES_COARSE].clock_mode; | ||
} | ||
#define __arch_use_vsyscall __arm_use_vsyscall | ||
|
||
static __always_inline | ||
void __arm_sync_vdso_data(struct vdso_data *vdata) | ||
{ | ||
flush_dcache_page(virt_to_page(vdata)); | ||
} | ||
#define __arch_sync_vdso_data __arm_sync_vdso_data | ||
|
||
/* The asm-generic header needs to be included after the definitions above */ | ||
#include <asm-generic/vdso/vsyscall.h> | ||
|
||
#endif /* !__ASSEMBLY__ */ | ||
|
||
#endif /* __ASM_VDSO_VSYSCALL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (C) 2012-2018 ARM Limited | ||
* | ||
* This supplies .note.* sections to go into the PT_NOTE inside the vDSO text. | ||
* Here we can supply some information useful to userland. | ||
*/ | ||
|
||
#include <linux/uts.h> | ||
#include <linux/version.h> | ||
#include <linux/elfnote.h> | ||
#include <linux/build-salt.h> | ||
|
||
ELFNOTE32("Linux", 0, LINUX_VERSION_CODE); | ||
BUILD_SALT; |
Oops, something went wrong.