Skip to content

Commit

Permalink
x86/vdso: Access rng vdso data without vvar.h
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
t-8ch authored and KAGA-KOKO committed Nov 2, 2024
1 parent 59b7761 commit c3a190d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 2 additions & 0 deletions arch/x86/entry/vdso/vdso-layout.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ SECTIONS
#include <asm/vvar.h>
#undef EMIT_VVAR

vdso_rng_data = vvar_page + __VDSO_RND_DATA_OFFSET;

pvclock_page = vvar_start + PAGE_SIZE;
hvclock_page = vvar_start + 2 * PAGE_SIZE;
timens_page = vvar_start + 3 * PAGE_SIZE;
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/include/asm/vdso/getrandom.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#ifndef __ASSEMBLY__

#include <asm/unistd.h>
#include <asm/vvar.h>

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

#define __vdso_rng_data (VVAR(_vdso_rng_data))
extern struct vdso_rng_data vdso_rng_data
__attribute__((visibility("hidden")));

static __always_inline const struct vdso_rng_data *__arch_get_vdso_rng_data(void)
{
if (IS_ENABLED(CONFIG_TIME_NS) && __arch_get_vdso_data()->clock_mode == VDSO_CLOCKMODE_TIMENS)
return (void *)&__vdso_rng_data + ((void *)&timens_page - (void *)__arch_get_vdso_data());
return &__vdso_rng_data;
return (void *)&vdso_rng_data + ((void *)&timens_page - (void *)__arch_get_vdso_data());
return &vdso_rng_data;
}

#endif /* !__ASSEMBLY__ */
Expand Down
5 changes: 0 additions & 5 deletions arch/x86/include/asm/vvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ extern char __vvar_page;

DECLARE_VVAR(0, struct vdso_data, _vdso_data)

#if !defined(_SINGLE_DATA)
#define _SINGLE_DATA
DECLARE_VVAR_SINGLE(__VDSO_RND_DATA_OFFSET, struct vdso_rng_data, _vdso_rng_data)
#endif

#undef DECLARE_VVAR
#undef DECLARE_VVAR_SINGLE

Expand Down

0 comments on commit c3a190d

Please sign in to comment.