Message ID | 20250111070751.2588654-15-yukaixiong@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | sysctl: move sysctls from vm_table into its own files | expand |
On 1/11/25 01:07, Kaixiong Yu wrote: > When CONFIG_SUPERH and CONFIG_VSYSCALL are defined, > vdso_enabled belongs to arch/sh/kernel/vsyscall/vsyscall.c. > So, move it into its own file. To avoid failure when registering > the vdso_table, move the call to register_sysctl_init() into > its own fs_initcall(). > > Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com> > Reviewed-by: Kees Cook <kees@kernel.org> > --- > v5: > - fix the error discovered by Geert Uytterhoeven. > Move the call to register_sysctl_init() into > its own fs_initcall() as Geert Uytterhoeven's patch does. > - take the advice of Joel Granados, separating path14 in V4 > into patch14 and patch15 in V5. This patch just moves the > vdso_enabled table. The next patch removes the vm_table. > - modify the change log Speaking of, what would it take to add gettimeofday() and clock_gettime() vdso functions on superh? I looked into it a few weeks ago but found the subsystem hard to parse. Rob P.S. On j-core we have three memory mapped registers any process can read, the rtc_nsec, rtc_seclo, and rtc_sechi fields in the AIC structure at https://github.com/j-core/jcore-soc/blob/master/targets/boards/turtle_1v1/board.h#L29 (volatile unsigned *hlc = (void *)0xabcd0220, or just x = *(volatile unsigned *)0xabcd0228; if you're checking before/after nanoseconds for quick and dirty profiling), which has let us be really lazy but ideally there would be a proper vdso wrapper, and the with-mmu version is going to want a little more kernel participation...
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c index add35c51e017..d80dd92a483a 100644 --- a/arch/sh/kernel/vsyscall/vsyscall.c +++ b/arch/sh/kernel/vsyscall/vsyscall.c @@ -14,6 +14,7 @@ #include <linux/module.h> #include <linux/elf.h> #include <linux/sched.h> +#include <linux/sysctl.h> #include <linux/err.h> /* @@ -30,6 +31,17 @@ static int __init vdso_setup(char *s) } __setup("vdso=", vdso_setup); +static const struct ctl_table vdso_table[] = { + { + .procname = "vdso_enabled", + .data = &vdso_enabled, + .maxlen = sizeof(vdso_enabled), + .mode = 0644, + .proc_handler = proc_dointvec, + .extra1 = SYSCTL_ZERO, + }, +}; + /* * These symbols are defined by vsyscall.o to mark the bounds * of the ELF DSO images included therein. @@ -58,6 +70,14 @@ int __init vsyscall_init(void) return 0; } +static int __init vm_sysctl_init(void) +{ + register_sysctl_init("vm", vdso_table); + return 0; +} + +fs_initcall(vm_sysctl_init); + /* Setup a VMA at program startup for the vsyscall page */ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) { diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 7ff07b7560b4..21c362768358 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2012,18 +2012,7 @@ static struct ctl_table kern_table[] = { #endif }; -static struct ctl_table vm_table[] = { -#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL) - { - .procname = "vdso_enabled", - .data = &vdso_enabled, - .maxlen = sizeof(vdso_enabled), - .mode = 0644, - .proc_handler = proc_dointvec, - .extra1 = SYSCTL_ZERO, - }, -#endif -}; +static struct ctl_table vm_table[] = {}; int __init sysctl_init_bases(void) {