Skip to content

Commit c3a190d

Browse files
t-8chKAGA-KOKO
authored andcommitted
x86/vdso: Access rng vdso data without vvar.h
The vdso_rng_data is at a well-known offset in the vvar page. Make use of this invariant to remove the usage of vvar.h. Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 59b7761 commit c3a190d

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

arch/x86/entry/vdso/vdso-layout.lds.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ SECTIONS
2424
#include <asm/vvar.h>
2525
#undef EMIT_VVAR
2626

27+
vdso_rng_data = vvar_page + __VDSO_RND_DATA_OFFSET;
28+
2729
pvclock_page = vvar_start + PAGE_SIZE;
2830
hvclock_page = vvar_start + 2 * PAGE_SIZE;
2931
timens_page = vvar_start + 3 * PAGE_SIZE;

arch/x86/include/asm/vdso/getrandom.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#ifndef __ASSEMBLY__
99

1010
#include <asm/unistd.h>
11-
#include <asm/vvar.h>
1211

1312
/**
1413
* getrandom_syscall - Invoke the getrandom() syscall.
@@ -28,13 +27,14 @@ static __always_inline ssize_t getrandom_syscall(void *buffer, size_t len, unsig
2827
return ret;
2928
}
3029

31-
#define __vdso_rng_data (VVAR(_vdso_rng_data))
30+
extern struct vdso_rng_data vdso_rng_data
31+
__attribute__((visibility("hidden")));
3232

3333
static __always_inline const struct vdso_rng_data *__arch_get_vdso_rng_data(void)
3434
{
3535
if (IS_ENABLED(CONFIG_TIME_NS) && __arch_get_vdso_data()->clock_mode == VDSO_CLOCKMODE_TIMENS)
36-
return (void *)&__vdso_rng_data + ((void *)&timens_page - (void *)__arch_get_vdso_data());
37-
return &__vdso_rng_data;
36+
return (void *)&vdso_rng_data + ((void *)&timens_page - (void *)__arch_get_vdso_data());
37+
return &vdso_rng_data;
3838
}
3939

4040
#endif /* !__ASSEMBLY__ */

arch/x86/include/asm/vvar.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ extern char __vvar_page;
6262

6363
DECLARE_VVAR(0, struct vdso_data, _vdso_data)
6464

65-
#if !defined(_SINGLE_DATA)
66-
#define _SINGLE_DATA
67-
DECLARE_VVAR_SINGLE(__VDSO_RND_DATA_OFFSET, struct vdso_rng_data, _vdso_rng_data)
68-
#endif
69-
7065
#undef DECLARE_VVAR
7166
#undef DECLARE_VVAR_SINGLE
7267

0 commit comments

Comments
 (0)