有没有办法用最新的内核创建一个 vDSO?

Is there a way to create a vDSO with the latest kernel?

我正在尝试使用最新的内核源代码做一个 vDSO。我正在学习本教程 https://www.linuxjournal.com/content/creating-vdso-colonels-other-chicken?page=0,0 但是我没有在 linux-4.20.13/arch/x86/vdso 中找到像 update_vsyscall() 和 vdso 目录这样的函数。我的问题是:有没有办法使用新的内核代码进行虚拟系统调用,例如 gettimeofday()?

中的 vdso 目录
arch/x86/entry/vdso

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/x86/entry/vdso?h=v4.20.13

比如直接给vclock_gettime.c加一个功能,重建内核,重启

diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c
index 007b3fe9d727..a49bef48a9dc 100644
--- a/arch/x86/entry/vdso/vclock_gettime.c
+++ b/arch/x86/entry/vdso/vclock_gettime.c
@@ -238,3 +238,8 @@ notrace time_t __vdso_time(time_t *t)
 }
 time_t time(time_t *t)
    __attribute__((weak, alias("__vdso_time")));
+
+notrace int __vdso_add(int x, int y)
+{
+   return x + y;
+}
diff --git a/arch/x86/entry/vdso/vdso.lds.S b/arch/x86/entry/vdso/vdso.lds.S
index d3a2dce4cfa9..4b976c119845 100644
--- a/arch/x86/entry/vdso/vdso.lds.S
+++ b/arch/x86/entry/vdso/vdso.lds.S
@@ -25,6 +25,7 @@ VERSION {
            __vdso_getcpu;
            time;
            __vdso_time;
+           __vdso_add;
    local: *;
    };
 }

在用户模式下编写测试用例

gcc -otest test.c vdso64.so

#include <stdio.h>

extern int __vdso_add(int x, int y);

int main()
{
    printf("vdso_add: %d\n", __vdso_add(1, 3));
    return 0;
}