2024-04-23 13:11:43

by Tiwei Bie

[permalink] [raw]
Subject: [PATCH v2 0/7] um: A follow-up series of -Wmissing-prototypes fixes

This is a follow-up series built on top of below series:
https://lore.kernel.org/linux-um/[email protected]/

Changes since v1:
https://lore.kernel.org/linux-um/[email protected]/
- include "internal.h" explicitly (Johannes);
- drop the "extern" (Johannes);

Tiwei Bie (7):
um: Fix -Wmissing-prototypes warnings for (rt_)sigreturn
um: Fix the -Wmissing-prototypes warning for __switch_mm
um: Fix the -Wmissing-prototypes warning for get_thread_reg
um: Fix the declaration of kasan_map_memory
um: Add an internal header shared among the user code
um: Fix -Wmissing-prototypes warnings for __vdso_*
um: Remove unused do_get_thread_area function

arch/um/include/asm/kasan.h | 1 -
arch/um/include/asm/mmu.h | 2 --
arch/um/include/asm/processor-generic.h | 1 -
arch/um/include/shared/kern_util.h | 2 ++
arch/um/include/shared/skas/mm_id.h | 2 ++
arch/um/os-Linux/elf_aux.c | 1 +
arch/um/os-Linux/internal.h | 20 ++++++++++++++++++++
arch/um/os-Linux/main.c | 3 +--
arch/um/os-Linux/mem.c | 2 ++
arch/um/os-Linux/skas/mem.c | 3 +--
arch/um/os-Linux/skas/process.c | 1 +
arch/um/os-Linux/start_up.c | 3 +--
arch/x86/um/shared/sysdep/archsetjmp.h | 7 +++++++
arch/x86/um/signal.c | 5 +++--
arch/x86/um/tls_32.c | 17 -----------------
arch/x86/um/vdso/um_vdso.c | 10 ++++++++--
16 files changed, 49 insertions(+), 31 deletions(-)
create mode 100644 arch/um/os-Linux/internal.h

--
2.34.1



2024-04-23 13:13:15

by Tiwei Bie

[permalink] [raw]
Subject: [PATCH v2 5/7] um: Add an internal header shared among the user code

Move relevant declarations to this header. This will address
below -Wmissing-prototypes warnings:

arch/um/os-Linux/elf_aux.c:26:13: warning: no previous prototype for ‘scan_elf_aux’ [-Wmissing-prototypes]
arch/um/os-Linux/mem.c:213:13: warning: no previous prototype for ‘check_tmpexec’ [-Wmissing-prototypes]
arch/um/os-Linux/skas/process.c:107:6: warning: no previous prototype for ‘wait_stub_done’ [-Wmissing-prototypes]

Signed-off-by: Tiwei Bie <[email protected]>
---
arch/um/os-Linux/elf_aux.c | 1 +
arch/um/os-Linux/internal.h | 20 ++++++++++++++++++++
arch/um/os-Linux/main.c | 3 +--
arch/um/os-Linux/mem.c | 1 +
arch/um/os-Linux/skas/mem.c | 3 +--
arch/um/os-Linux/skas/process.c | 1 +
arch/um/os-Linux/start_up.c | 3 +--
7 files changed, 26 insertions(+), 6 deletions(-)
create mode 100644 arch/um/os-Linux/internal.h

diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c
index 344ac403fb5d..0a0f91cf4d6d 100644
--- a/arch/um/os-Linux/elf_aux.c
+++ b/arch/um/os-Linux/elf_aux.c
@@ -13,6 +13,7 @@
#include <init.h>
#include <elf_user.h>
#include <mem_user.h>
+#include "internal.h"

typedef Elf32_auxv_t elf_auxv_t;

diff --git a/arch/um/os-Linux/internal.h b/arch/um/os-Linux/internal.h
new file mode 100644
index 000000000000..317fca190c2b
--- /dev/null
+++ b/arch/um/os-Linux/internal.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __UM_OS_LINUX_INTERNAL_H
+#define __UM_OS_LINUX_INTERNAL_H
+
+/*
+ * elf_aux.c
+ */
+void scan_elf_aux(char **envp);
+
+/*
+ * mem.c
+ */
+void check_tmpexec(void);
+
+/*
+ * skas/process.c
+ */
+void wait_stub_done(int pid);
+
+#endif /* __UM_OS_LINUX_INTERNAL_H */
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index e82164f90288..f98ff79cdbf7 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -16,6 +16,7 @@
#include <kern_util.h>
#include <os.h>
#include <um_malloc.h>
+#include "internal.h"

#define PGD_BOUND (4 * 1024 * 1024)
#define STACKSIZE (8 * 1024 * 1024)
@@ -102,8 +103,6 @@ static void setup_env_path(void)
}
}

-extern void scan_elf_aux( char **envp);
-
int __init main(int argc, char **argv, char **envp)
{
char **new_argv;
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index c6c9495b1432..cf44d386f23c 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -17,6 +17,7 @@
#include <init.h>
#include <kern_util.h>
#include <os.h>
+#include "internal.h"

/*
* kasan_map_memory - maps memory from @start with a size of @len.
diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c
index 953fb10f3f93..1f9c1bffc3a6 100644
--- a/arch/um/os-Linux/skas/mem.c
+++ b/arch/um/os-Linux/skas/mem.c
@@ -17,11 +17,10 @@
#include <skas.h>
#include <sysdep/ptrace.h>
#include <sysdep/stub.h>
+#include "../internal.h"

extern char batch_syscall_stub[], __syscall_stub_start[];

-extern void wait_stub_done(int pid);
-
static inline unsigned long *check_init_stack(struct mm_id * mm_idp,
unsigned long *stack)
{
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 1f5c3f2523d1..41a288dcfc34 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -23,6 +23,7 @@
#include <skas.h>
#include <sysdep/stub.h>
#include <linux/threads.h>
+#include "../internal.h"

int is_skas_winch(int pid, int fd, void *data)
{
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 6b21061c431c..89ad9f4f865c 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -25,6 +25,7 @@
#include <ptrace_user.h>
#include <registers.h>
#include <skas.h>
+#include "internal.h"

static void ptrace_child(void)
{
@@ -222,8 +223,6 @@ static void __init check_ptrace(void)
check_sysemu();
}

-extern void check_tmpexec(void);
-
static void __init check_coredump_limit(void)
{
struct rlimit lim;
--
2.34.1


2024-04-23 13:16:33

by Tiwei Bie

[permalink] [raw]
Subject: [PATCH v2 6/7] um: Fix -Wmissing-prototypes warnings for __vdso_*

The VDSO functions are defined as globals and intended to be called
from userspace. Let's just workaround the -Wmissing-prototypes warnings
by declaring them locally.

This will address below -Wmissing-prototypes warnings:

arch/x86/um/vdso/um_vdso.c:16:5: warning: no previous prototype for ‘__vdso_clock_gettime’ [-Wmissing-prototypes]
arch/x86/um/vdso/um_vdso.c:30:5: warning: no previous prototype for ‘__vdso_gettimeofday’ [-Wmissing-prototypes]
arch/x86/um/vdso/um_vdso.c:44:21: warning: no previous prototype for ‘__vdso_time’ [-Wmissing-prototypes]
arch/x86/um/vdso/um_vdso.c:57:1: warning: no previous prototype for ‘__vdso_getcpu’ [-Wmissing-prototypes]

While at it, also fix the "WARNING: Prefer 'unsigned int *' to bare
use of 'unsigned *'" checkpatch warning.

Signed-off-by: Tiwei Bie <[email protected]>
---
arch/x86/um/vdso/um_vdso.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/um/vdso/um_vdso.c b/arch/x86/um/vdso/um_vdso.c
index ff0f3b4b6c45..cbae2584124f 100644
--- a/arch/x86/um/vdso/um_vdso.c
+++ b/arch/x86/um/vdso/um_vdso.c
@@ -13,6 +13,12 @@
#include <linux/getcpu.h>
#include <asm/unistd.h>

+/* workaround for -Wmissing-prototypes warnings */
+int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts);
+int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
+__kernel_old_time_t __vdso_time(__kernel_old_time_t *t);
+long __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused);
+
int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
{
long ret;
@@ -54,7 +60,7 @@ __kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
__kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time")));

long
-__vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
+__vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)
{
/*
* UML does not support SMP, we can cheat here. :)
@@ -68,5 +74,5 @@ __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
return 0;
}

-long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
+long getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *tcache)
__attribute__((weak, alias("__vdso_getcpu")));
--
2.34.1