um: Minor fixes and cleanups
Subsystems (2)
v2 cover um: Minor fixes and cleanups
A series of minor fixes and cleanups for UML.
Changes since v1:
https://lore.kernel.org/lkml/[email protected]/
- Add "um: Stop tracking host PID in cpu_tasks";
- Add missing headers for i386;
Tiwei Bie (6):
um: Make local functions and variables static
um: Fix the declaration of vfree
um: Remove unused functions
um: Fix the return type of __switch_to
um: Add missing headers
um: Stop tracking host PID in cpu_tasks
arch/um/drivers/pcap_kern.c | 4 +-- arch/um/drivers/ubd_user.c | 2 +- arch/um/include/shared/as-layout.h | 1 - arch/um/include/shared/um_malloc.h | 2 +- arch/um/kernel/kmsg_dump.c | 2 +- arch/um/kernel/mem.c | 2 ++ arch/um/kernel/process.c | 46 ++++++------------------ arch/um/kernel/reboot.c | 1 + arch/um/kernel/skas/mmu.c | 1 + arch/um/kernel/skas/process.c | 5 +-- arch/um/kernel/time.c | 6 ++-- arch/um/kernel/tlb.c | 7 +--- arch/um/os-Linux/drivers/ethertap_kern.c | 2 +- arch/um/os-Linux/drivers/tuntap_kern.c | 2 +- arch/um/os-Linux/signal.c | 4 +-- arch/x86/um/bugs_32.c | 1 + arch/x86/um/bugs_64.c | 1 + arch/x86/um/elfcore.c | 1 + arch/x86/um/fault.c | 1 + arch/x86/um/os-Linux/mcontext.c | 1 + arch/x86/um/os-Linux/registers.c | 2 +- arch/x86/um/os-Linux/tls.c | 1 + 22 files changed, 35 insertions(+), 60 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/6 um: Make local functions and variables static
This will also fix the warnings like:
warning: no previous prototype for ‘fork_handler’ [-Wmissing-prototypes]
140 | void fork_handler(void)
| ^~~~~~~~~~~~
--- arch/um/drivers/pcap_kern.c | 4 ++-- arch/um/drivers/ubd_user.c | 2 +- arch/um/kernel/kmsg_dump.c | 2 +- arch/um/kernel/process.c | 8 ++++---- arch/um/kernel/time.c | 6 +++--- arch/um/os-Linux/drivers/ethertap_kern.c | 2 +- arch/um/os-Linux/drivers/tuntap_kern.c | 2 +- arch/um/os-Linux/signal.c | 4 ++-- arch/x86/um/os-Linux/registers.c | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-)
arch/um/drivers/pcap_kern.c +2 -2
@@ -15,7 +15,7 @@ struct pcap_init {char *filter; }; -void pcap_init_kern (struct net_device *dev,void *data) +static void pcap_init_kern (struct net_device *dev,void *data) {struct uml_net_private *pri;struct pcap_data *ppri;
@@ -50,7 +50,7 @@ static const struct net_kern_info pcap_kern_info = { .write = pcap_write, }; -int pcap_setup (char *str,char **mac_out,void *data) +static int pcap_setup (char *str,char **mac_out,void *data) {struct pcap_init *init = data;char *remain, *host_if =NULL , *options[2 ] = {NULL ,NULL };
arch/um/drivers/ubd_user.c +1 -1
@@ -23,7 +23,7 @@#include <os.h> #include <poll.h> -struct pollfd kernel_pollfd; +static struct pollfd kernel_pollfd;int start_io_thread (unsigned long sp,int *fd_out) {
arch/um/kernel/kmsg_dump.c +1 -1
@@ -57,7 +57,7 @@ static struct kmsg_dumper kmsg_dumper = { .dump = kmsg_dumper_stdout }; -int __init kmsg_dumper_stdout_init (void ) +static int __init kmsg_dumper_stdout_init (void ) {return kmsg_dump_register (&kmsg_dumper); }
arch/um/kernel/process.c +4 -4
@@ -137,7 +137,7 @@ void new_thread_handler(void) }/* Called magically, see new_thread_handler above */ -void fork_handler (void ) +static void fork_handler (void ) {force_flush_all ();
@@ -268,14 +268,14 @@ int clear_user_proc(void __user *buf, int size)static atomic_t using_sysemu =ATOMIC_INIT (0 );int sysemu_supported; -void set_using_sysemu (int value) +static void set_using_sysemu (int value) {if (value > sysemu_supported)return ;atomic_set (&using_sysemu, value); } -int get_using_sysemu (void ) +static int get_using_sysemu (void ) {return atomic_read (&using_sysemu); }
@@ -313,7 +313,7 @@ static const struct proc_ops sysemu_proc_ops = { .proc_write = sysemu_proc_write, }; -int __init make_proc_sysemu (void ) +static int __init make_proc_sysemu (void ) {struct proc_dir_entry *ent;if (!sysemu_supported)
arch/um/kernel/time.c +3 -3
@@ -319,7 +319,7 @@ void time_travel_add_event_rel(struct time_travel_event *e,time_travel_add_event (e, time_travel_time + delay_ns); } -void time_travel_periodic_timer (struct time_travel_event *e) +static void time_travel_periodic_timer (struct time_travel_event *e) {time_travel_add_event (&time_travel_timer_event, time_travel_time + time_travel_timer_interval);
@@ -812,7 +812,7 @@ unsigned long calibrate_delay_is_known(void)return 0 ; } -int setup_time_travel (char *str) +static int setup_time_travel (char *str) {if (strcmp (str,"=inf-cpu" ) ==0 ) { time_travel_mode =TT_MODE_INFCPU ;
@@ -862,7 +862,7 @@ __uml_help(setup_time_travel,"devices using it, assuming the device has the right capabilities.\n" "The optional ID is a 64-bit integer that's sent to the central scheduler.\n"); -int setup_time_travel_start (char *str) +static int setup_time_travel_start (char *str) {int err;
arch/um/os-Linux/drivers/ethertap_kern.c +1 -1
@@ -63,7 +63,7 @@ const struct net_kern_info ethertap_kern_info = { .write = etap_write, }; -int ethertap_setup (char *str,char **mac_out,void *data) +static int ethertap_setup (char *str,char **mac_out,void *data) {struct ethertap_init *init = data;
arch/um/os-Linux/drivers/tuntap_kern.c +1 -1
@@ -53,7 +53,7 @@ const struct net_kern_info tuntap_kern_info = { .write = tuntap_write, }; -int tuntap_setup (char *str,char **mac_out,void *data) +static int tuntap_setup (char *str,char **mac_out,void *data) {struct tuntap_init *init = data;
arch/um/os-Linux/signal.c +2 -2
@@ -72,7 +72,7 @@ static int signals_blocked;static unsigned int signals_pending;static unsigned int signals_active =0 ; -void sig_handler (int sig,struct siginfo *si,mcontext_t *mc) +static void sig_handler (int sig,struct siginfo *si,mcontext_t *mc) {int enabled = signals_enabled;
@@ -108,7 +108,7 @@ static void timer_real_alarm_handler(mcontext_t *mc)timer_handler (SIGALRM ,NULL , ®s); } -void timer_alarm_handler (int sig,struct siginfo *unused_si,mcontext_t *mc) +static void timer_alarm_handler (int sig,struct siginfo *unused_si,mcontext_t *mc) {int enabled;
arch/x86/um/os-Linux/registers.c +1 -1
@@ -17,7 +17,7 @@#include <linux/elf.h> #include <registers.h> -int have_xstate_support; +static int have_xstate_support;int save_i387_registers (int pid,unsigned long *fp_regs) {
Signature · 1 line
2.34.1
PATCH v2 2/6 um: Fix the declaration of vfree
In reply to Tiwei BieThe definition of vfree has changed since commit b3bdda02aa54 ("vmalloc: add const to void* parameters"). Update the declaration of vfree in um_malloc.h to match the latest definition.
--- arch/um/include/shared/um_malloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/include/shared/um_malloc.h +1 -1
@@ -12,7 +12,7 @@ extern void *uml_kmalloc(int size, int flags);extern void kfree (const void *ptr);extern void *vmalloc (unsigned long size); -extern void vfree (void *ptr); +extern void vfree (const void *ptr);#endif /* __UM_MALLOC_H__ */
Signature · 1 line
2.34.1
PATCH v2 3/6 um: Remove unused functions
In reply to Tiwei BieThese functions are not used anymore. Removing them will also address below -Wmissing-prototypes warnings:
arch/um/kernel/process.c:51:5: warning: no previous prototype for ‘pid_to_processor_id’ [-Wmissing-prototypes] arch/um/kernel/process.c:253:5: warning: no previous prototype for ‘copy_to_user_proc’ [-Wmissing-prototypes] arch/um/kernel/process.c:263:5: warning: no previous prototype for ‘clear_user_proc’ [-Wmissing-prototypes] arch/um/kernel/tlb.c:579:6: warning: no previous prototype for ‘flush_tlb_mm_range’ [-Wmissing-prototypes]
--- arch/um/kernel/process.c | 21 --------------------- arch/um/kernel/tlb.c | 6 ------ 2 files changed, 27 deletions(-)
arch/um/kernel/process.c +0 -21
@@ -48,17 +48,6 @@ static inline int external_pid(void)return userspace_pid[0 ]; } -int pid_to_processor_id (int pid) -{ -int i; - -for (i =0 ; i < ncpus; i++) { -if (cpu_tasks[i].pid == pid) -return i; - } -return -1 ; -} -void free_stack (unsigned long stack,int order) {free_pages (stack, order);
@@ -250,21 +239,11 @@ char *uml_strdup(const char *string) }EXPORT_SYMBOL (uml_strdup); -int copy_to_user_proc (void __user *to,void *from,int size) -{ -return copy_to_user (to, from, size); -} -int copy_from_user_proc (void *to,void __user *from,int size) {return copy_from_user (to, from, size); } -int clear_user_proc (void __user *buf,int size) -{ -return clear_user (buf, size); -} -static atomic_t using_sysemu =ATOMIC_INIT (0 );int sysemu_supported;
arch/um/kernel/tlb.c +0 -6
@@ -576,12 +576,6 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, }EXPORT_SYMBOL (flush_tlb_range); -void flush_tlb_mm_range (struct mm_struct *mm,unsigned long start, -unsigned long end) -{ -fix_range (mm, start, end,0 ); -} -void flush_tlb_mm (struct mm_struct *mm) {struct vm_area_struct *vma;
Signature · 1 line
2.34.1
PATCH v2 4/6 um: Fix the return type of __switch_to
In reply to Tiwei BieMake it match the declaration in asm-generic/switch_to.h. And also include the header to allow the compiler to check it.
--- arch/um/kernel/process.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/um/kernel/process.c +2 -1
@@ -26,6 +26,7 @@#include <linux/resume_user_mode.h> #include <asm/current.h> #include <asm/mmu_context.h> +#include <asm/switch_to.h> #include <linux/uaccess.h> #include <as-layout.h> #include <kern_util.h>
@@ -73,7 +74,7 @@ static inline void set_current(struct task_struct *task)extern void arch_switch_to (struct task_struct *to); -void *__switch_to (struct task_struct *from,struct task_struct *to) +struct task_struct *__switch_to (struct task_struct *from,struct task_struct *to) { to->thread.prev_sched = from;set_current (to);
Signature · 1 line
2.34.1
PATCH v2 5/6 um: Add missing headers
In reply to Tiwei BieThis will address below -Wmissing-prototypes warnings:
arch/um/kernel/mem.c:202:8: warning: no previous prototype for ‘pgd_alloc’ [-Wmissing-prototypes] arch/um/kernel/mem.c:215:7: warning: no previous prototype for ‘uml_kmalloc’ [-Wmissing-prototypes] arch/um/kernel/process.c:207:6: warning: no previous prototype for ‘arch_cpu_idle’ [-Wmissing-prototypes] arch/um/kernel/process.c:328:15: warning: no previous prototype for ‘arch_align_stack’ [-Wmissing-prototypes] arch/um/kernel/reboot.c:45:6: warning: no previous prototype for ‘machine_restart’ [-Wmissing-prototypes] arch/um/kernel/reboot.c:51:6: warning: no previous prototype for ‘machine_power_off’ [-Wmissing-prototypes] arch/um/kernel/reboot.c:57:6: warning: no previous prototype for ‘machine_halt’ [-Wmissing-prototypes] arch/um/kernel/skas/mmu.c:17:5: warning: no previous prototype for ‘init_new_context’ [-Wmissing-prototypes] arch/um/kernel/skas/mmu.c:60:6: warning: no previous prototype for ‘destroy_context’ [-Wmissing-prototypes] arch/um/kernel/skas/process.c:36:12: warning: no previous prototype for ‘start_uml’ [-Wmissing-prototypes] arch/um/kernel/tlb.c:594:6: warning: no previous prototype for ‘force_flush_all’ [-Wmissing-prototypes] arch/x86/um/bugs_32.c:22:6: warning: no previous prototype for ‘arch_check_bugs’ [-Wmissing-prototypes] arch/x86/um/bugs_32.c:44:6: warning: no previous prototype for ‘arch_examine_signal’ [-Wmissing-prototypes] arch/x86/um/bugs_64.c:9:6: warning: no previous prototype for ‘arch_check_bugs’ [-Wmissing-prototypes] arch/x86/um/bugs_64.c:13:6: warning: no previous prototype for ‘arch_examine_signal’ [-Wmissing-prototypes] arch/x86/um/elfcore.c:10:12: warning: no previous prototype for ‘elf_core_extra_phdrs’ [-Wmissing-prototypes] arch/x86/um/elfcore.c:15:5: warning: no previous prototype for ‘elf_core_write_extra_phdrs’ [-Wmissing-prototypes] arch/x86/um/elfcore.c:42:5: warning: no previous prototype for ‘elf_core_write_extra_data’ [-Wmissing-prototypes] arch/x86/um/elfcore.c:63:8: warning: no previous prototype for ‘elf_core_extra_data_size’ [-Wmissing-prototypes] arch/x86/um/fault.c:18:5: warning: no previous prototype for ‘arch_fixup’ [-Wmissing-prototypes] arch/x86/um/os-Linux/mcontext.c:7:6: warning: no previous prototype for ‘get_regs_from_mc’ [-Wmissing-prototypes] arch/x86/um/os-Linux/tls.c:22:6: warning: no previous prototype for ‘check_host_supports_tls’ [-Wmissing-prototypes]
--- arch/um/kernel/mem.c | 2 ++ arch/um/kernel/process.c | 2 ++ arch/um/kernel/reboot.c | 1 + arch/um/kernel/skas/mmu.c | 1 + arch/um/kernel/skas/process.c | 1 + arch/um/kernel/tlb.c | 1 + arch/x86/um/bugs_32.c | 1 + arch/x86/um/bugs_64.c | 1 + arch/x86/um/elfcore.c | 1 + arch/x86/um/fault.c | 1 + arch/x86/um/os-Linux/mcontext.c | 1 + arch/x86/um/os-Linux/tls.c | 1 + 12 files changed, 14 insertions(+)
arch/um/kernel/mem.c +2 -0
@@ -12,12 +12,14 @@#include <linux/slab.h> #include <asm/fixmap.h> #include <asm/page.h> +#include <asm/pgalloc.h> #include <as-layout.h> #include <init.h> #include <kern.h> #include <kern_util.h> #include <mem_user.h> #include <os.h> +#include <um_malloc.h> #include <linux/sched/task.h> #ifdef CONFIG_KASAN
arch/um/kernel/process.c +2 -0
@@ -15,6 +15,7 @@#include <linux/proc_fs.h> #include <linux/ptrace.h> #include <linux/random.h> +#include <linux/cpu.h> #include <linux/slab.h> #include <linux/sched.h> #include <linux/sched/debug.h>
@@ -27,6 +28,7 @@#include <asm/current.h> #include <asm/mmu_context.h> #include <asm/switch_to.h> +#include <asm/exec.h> #include <linux/uaccess.h> #include <as-layout.h> #include <kern_util.h>
arch/um/kernel/reboot.c +1 -0
@@ -9,6 +9,7 @@#include <linux/spinlock.h> #include <linux/slab.h> #include <linux/oom.h> +#include <linux/reboot.h> #include <kern_util.h> #include <os.h> #include <skas.h>
arch/um/kernel/skas/mmu.c +1 -0
@@ -10,6 +10,7 @@#include <asm/pgalloc.h> #include <asm/sections.h> +#include <asm/mmu_context.h> #include <as-layout.h> #include <os.h> #include <skas.h>
arch/um/kernel/skas/process.c +1 -0
@@ -12,6 +12,7 @@#include <kern.h> #include <os.h> #include <skas.h> +#include <kern_util.h> extern void start_kernel (void );
arch/um/kernel/tlb.c +1 -0
@@ -8,6 +8,7 @@#include <linux/sched/signal.h> #include <asm/tlbflush.h> +#include <asm/mmu_context.h> #include <as-layout.h> #include <mem_user.h> #include <os.h>
arch/x86/um/bugs_32.c +1 -0
@@ -3,6 +3,7 @@* Licensed under the GPL */ +#include <arch.h> #include <signal.h> #include <kern_util.h> #include <longjmp.h>
arch/x86/um/bugs_64.c +1 -0
@@ -4,6 +4,7 @@* Licensed under the GPL */ +#include <arch.h> #include <sysdep/ptrace.h> void arch_check_bugs (void )
arch/x86/um/elfcore.c +1 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/elf.h> +#include <linux/elfcore.h> #include <linux/coredump.h> #include <linux/fs.h> #include <linux/mm.h>
arch/x86/um/fault.c +1 -0
@@ -3,6 +3,7 @@* Licensed under the GPL */ +#include <arch.h> #include <sysdep/ptrace.h> /* These two are from asm-um/uaccess.h and linux/module.h, check them. */
arch/x86/um/os-Linux/mcontext.c +1 -0
@@ -3,6 +3,7 @@#define __FRAME_OFFSETS#include <asm/ptrace.h> #include <sysdep/ptrace.h> +#include <sysdep/mcontext.h> void get_regs_from_mc (struct uml_pt_regs *regs,mcontext_t *mc) {
arch/x86/um/os-Linux/tls.c +1 -0
@@ -6,6 +6,7 @@#include <sys/syscall.h> #include <unistd.h> +#include <os.h> #include <sysdep/tls.h> #ifndef PTRACE_GET_THREAD_AREA
Signature · 1 line
2.34.1
PATCH v2 6/6 um: Stop tracking host PID in cpu_tasks
In reply to Tiwei BieThe host PID tracked in 'cpu_tasks' is no longer used. Stopping tracking it will also save some cycles.
--- arch/um/include/shared/as-layout.h | 1 - arch/um/kernel/process.c | 12 ++---------- arch/um/kernel/skas/process.c | 4 ---- 3 files changed, 2 insertions(+), 15 deletions(-)
arch/um/include/shared/as-layout.h +0 -1
@@ -31,7 +31,6 @@#include <sysdep/ptrace.h> struct cpu_task { -int pid;void *task; };
arch/um/kernel/process.c +2 -10
@@ -43,13 +43,7 @@* cares about its entry, so it's OK if another processor is modifying its * entry. */ -struct cpu_task cpu_tasks[NR_CPUS ] = { [0 ...NR_CPUS -1 ] = {-1 ,NULL } }; - -static inline int external_pid (void ) -{ -/* FIXME: Need to look up userspace_pid by cpu */ -return userspace_pid[0 ]; -} +struct cpu_task cpu_tasks[NR_CPUS ] = { [0 ...NR_CPUS -1 ] = {NULL } };void free_stack (unsigned long stack,int order) {
@@ -70,8 +64,7 @@ unsigned long alloc_stack(int order, int atomic)static inline void set_current (struct task_struct *task) { - cpu_tasks[task_thread_info (task)->cpu] = ((struct cpu_task ) - {external_pid (), task }); + cpu_tasks[task_thread_info (task)->cpu] = ((struct cpu_task ) { task }); }extern void arch_switch_to (struct task_struct *to);
@@ -208,7 +201,6 @@ void um_idle_sleep(void)void arch_cpu_idle (void ) { - cpu_tasks[current_thread_info ()->cpu].pid =os_getpid ();um_idle_sleep (); }
arch/um/kernel/skas/process.c +0 -4
@@ -18,12 +18,8 @@ extern void start_kernel(void);static int __init start_kernel_proc (void *unused) { -int pid; -block_signals_trace (); - pid =os_getpid (); - cpu_tasks[0 ].pid = pid; cpu_tasks[0 ].task = current;start_kernel ();
Signature · 1 line
2.34.1