Skip to content

Commit

Permalink
RISC-V: Add VDSO entries for clock_get/gettimeofday/getcpu
Browse files Browse the repository at this point in the history
For now these are just placeholders that execute the syscall.  We will
later optimize them to avoid kernel crossings, but we'd like to have the
VDSO entries from the first released kernel version to make the ABI
simpler.

Signed-off-by: Andrew Waterman <andrew@sifive.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
  • Loading branch information
Andrew Waterman authored and Palmer Dabbelt committed Nov 27, 2017
1 parent b7e5a59 commit 28dfbe6
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arch/riscv/kernel/vdso/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Copied from arch/tile/kernel/vdso/Makefile

# Symbols present in the vdso
vdso-syms = rt_sigreturn
vdso-syms = rt_sigreturn
vdso-syms += gettimeofday
vdso-syms += clock_gettime
vdso-syms += clock_getres
vdso-syms += getcpu

# Files to link into the vdso
obj-vdso = $(patsubst %, %.o, $(vdso-syms))
Expand Down
26 changes: 26 additions & 0 deletions arch/riscv/kernel/vdso/clock_getres.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 SiFive
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include <linux/linkage.h>
#include <asm/unistd.h>

.text
/* int __vdso_clock_getres(clockid_t clock_id, struct timespec *res); */
ENTRY(__vdso_clock_getres)
.cfi_startproc
/* For now, just do the syscall. */
li a7, __NR_clock_getres
ecall
ret
.cfi_endproc
ENDPROC(__vdso_clock_getres)
26 changes: 26 additions & 0 deletions arch/riscv/kernel/vdso/clock_gettime.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 SiFive
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include <linux/linkage.h>
#include <asm/unistd.h>

.text
/* int __vdso_clock_gettime(clockid_t clock_id, struct timespec *tp); */
ENTRY(__vdso_clock_gettime)
.cfi_startproc
/* For now, just do the syscall. */
li a7, __NR_clock_gettime
ecall
ret
.cfi_endproc
ENDPROC(__vdso_clock_gettime)
26 changes: 26 additions & 0 deletions arch/riscv/kernel/vdso/getcpu.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 SiFive
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include <linux/linkage.h>
#include <asm/unistd.h>

.text
/* int __vdso_getcpu(unsigned *cpu, unsigned *node, void *unused); */
ENTRY(__vdso_getcpu)
.cfi_startproc
/* For now, just do the syscall. */
li a7, __NR_getcpu
ecall
ret
.cfi_endproc
ENDPROC(__vdso_getcpu)
26 changes: 26 additions & 0 deletions arch/riscv/kernel/vdso/gettimeofday.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 SiFive
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include <linux/linkage.h>
#include <asm/unistd.h>

.text
/* int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz); */
ENTRY(__vdso_gettimeofday)
.cfi_startproc
/* For now, just do the syscall. */
li a7, __NR_gettimeofday
ecall
ret
.cfi_endproc
ENDPROC(__vdso_gettimeofday)
4 changes: 4 additions & 0 deletions arch/riscv/kernel/vdso/vdso.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ VERSION
LINUX_4.15 {
global:
__vdso_rt_sigreturn;
__vdso_gettimeofday;
__vdso_clock_gettime;
__vdso_clock_getres;
__vdso_getcpu;
local: *;
};
}

0 comments on commit 28dfbe6

Please sign in to comment.