Some minor cleanups for UML
Subsystems (2)
v3 cover Some minor cleanups for UML
Changes in v3:
- Remove "um: Remove declarations of undefined functions";
- Add "um: Remove the declaration of user_thread function";
- Add "um: Remove outdated asm/sysrq.h header";
- Minor tweaks on commit log;
Changes in v2 (https://lore.kernel.org/linux-um/[email protected]/):
- Remove the pointless union (suggested by Benjamin Berg);
- Minor tweaks on coding style;
v1: https://lore.kernel.org/linux-um/[email protected]/
Tiwei Bie (7):
um: Remove unused kpte_clear_flush macro
um: Remove the redundant newpage check in update_pte_range
um: Remove unused fields from thread_struct
um: Remove unused mm_fd field from mm_id
um: Remove the call to SUBARCH_EXECVE1 macro
um: Remove the declaration of user_thread function
um: Remove outdated asm/sysrq.h header
arch/um/include/asm/pgtable.h | 7 ------- arch/um/include/asm/processor-generic.h | 20 +++++--------------- arch/um/include/asm/sysrq.h | 8 -------- arch/um/include/shared/skas/mm_id.h | 5 +---- arch/um/include/shared/skas/skas.h | 1 - arch/um/kernel/exec.c | 3 --- arch/um/kernel/process.c | 8 ++++---- arch/um/kernel/reboot.c | 2 +- arch/um/kernel/skas/mmu.c | 12 ++++++------ arch/um/kernel/skas/process.c | 4 ++-- arch/um/kernel/sysrq.c | 1 - arch/um/kernel/time.c | 2 +- arch/um/kernel/tlb.c | 16 ++++++---------- arch/um/os-Linux/skas/mem.c | 2 +- arch/um/os-Linux/skas/process.c | 2 +- arch/x86/um/sysrq_32.c | 1 - arch/x86/um/sysrq_64.c | 1 - 17 files changed, 28 insertions(+), 67 deletions(-) delete mode 100644 arch/um/include/asm/sysrq.h
Signature · 1 line
2.34.1
PATCH v3 1/7 um: Remove unused kpte_clear_flush macro
This macro has no users, and __flush_tlb_one doesn't exist either.
--- arch/um/include/asm/pgtable.h | 7 ------- 1 file changed, 7 deletions(-)
arch/um/include/asm/pgtable.h +0 -7
@@ -359,11 +359,4 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) return pte; } -/* Clear a kernel PTE and flush it from the TLB */ -#define kpte_clear_flush (ptep, vaddr) \ -do { \ - pte_clear(&init_mm, (vaddr), (ptep)); \ - __flush_tlb_one((vaddr)); \ -} while (0) -#endif
Signature · 1 line
2.34.1
PATCH v3 2/7 um: Remove the redundant newpage check in update_pte_range
In reply to Tiwei BieThe two checks have been identical since commit ef714f15027c ("um:
remove force_flush_all from fork_handler"). And the inner one isn't necessary anymore.
--- arch/um/kernel/tlb.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
arch/um/kernel/tlb.c +6 -10
@@ -82,16 +82,12 @@ static inline int update_pte_range(pmd_t *pmd, unsigned long addr, (x ? UM_PROT_EXEC : 0));if (pte_newpage (*pte)) {if (pte_present (*pte)) { -if (pte_newpage (*pte)) { -__u64 offset; -unsigned long phys = -pte_val (*pte) &PAGE_MASK ; -int fd =phys_mapping (phys, &offset); - - ret = ops->mmap (ops->mm_idp, addr, -PAGE_SIZE , prot, fd, - offset); - } +__u64 offset; +unsigned long phys =pte_val (*pte) &PAGE_MASK ; +int fd =phys_mapping (phys, &offset); + + ret = ops->mmap (ops->mm_idp, addr,PAGE_SIZE , + prot, fd, offset); }else ret = ops->unmap (ops->mm_idp, addr,PAGE_SIZE ); }else if (pte_newprot (*pte))
Signature · 1 line
2.34.1
PATCH v3 3/7 um: Remove unused fields from thread_struct
In reply to Tiwei BieThese fields are no longer used since the removal of tt mode.
--- arch/um/include/asm/processor-generic.h | 20 +++++--------------- arch/um/kernel/process.c | 8 ++++---- arch/um/kernel/skas/process.c | 4 ++-- 3 files changed, 11 insertions(+), 21 deletions(-)
arch/um/include/asm/processor-generic.h +5 -15
@@ -28,20 +28,10 @@ struct thread_struct {struct arch_thread arch;jmp_buf switch_buf;struct { -int op; -union { -struct { -int pid; - } fork, exec; -struct { -int (*proc)(void *); -void *arg; - } thread; -struct { -void (*proc)(void *); -void *arg; - } cb; - } u; +struct { +int (*proc)(void *); +void *arg; + } thread; } request; };
@@ -51,7 +41,7 @@ struct thread_struct { .fault_addr = NULL, \ .prev_sched = NULL, \ .arch = INIT_ARCH_THREAD, \ - .request = { 0 } \ + .request = { } \ }/*
arch/um/kernel/process.c +4 -4
@@ -109,8 +109,8 @@ void new_thread_handler(void)schedule_tail (current->thread.prev_sched); current->thread.prev_sched =NULL ; - fn = current->thread.request.u.thread.proc; - arg = current->thread.request.u.thread.arg; + fn = current->thread.request.thread.proc; + arg = current->thread.request.thread.arg;/* * callback returns only if the kernel thread execs a process
@@ -158,8 +158,8 @@ int copy_thread(struct task_struct * p, const struct kernel_clone_args *args)arch_copy_thread (¤t->thread.arch, &p->thread.arch); }else {get_safe_registers (p->thread.regs.regs.gp, p->thread.regs.regs.fp); - p->thread.request.u.thread.proc = args->fn; - p->thread.request.u.thread.arg = args->fn_arg; + p->thread.request.thread.proc = args->fn; + p->thread.request.thread.arg = args->fn_arg; handler = new_thread_handler; }
arch/um/kernel/skas/process.c +2 -2
@@ -39,8 +39,8 @@ int __init start_uml(void)init_new_thread_signals (); - init_task.thread.request.u.thread.proc = start_kernel_proc; - init_task.thread.request.u.thread.arg =NULL ; + init_task.thread.request.thread.proc = start_kernel_proc; + init_task.thread.request.thread.arg =NULL ;return start_idle_thread (task_stack_page (&init_task), &init_task.thread.switch_buf); }
Signature · 1 line
2.34.1
PATCH v3 4/7 um: Remove unused mm_fd field from mm_id
In reply to Tiwei BieIt's no longer used since the removal of the SKAS3/4 support.
--- arch/um/include/shared/skas/mm_id.h | 5 +---- arch/um/kernel/reboot.c | 2 +- arch/um/kernel/skas/mmu.c | 12 ++++++------ arch/um/kernel/time.c | 2 +- arch/um/os-Linux/skas/mem.c | 2 +- arch/um/os-Linux/skas/process.c | 2 +- 6 files changed, 11 insertions(+), 14 deletions(-)
arch/um/include/shared/skas/mm_id.h +1 -4
@@ -7,10 +7,7 @@#define __MM_ID_Hstruct mm_id { -union { -int mm_fd; -int pid; - } u; +int pid;unsigned long stack;int syscall_data_len; };
arch/um/kernel/reboot.c +1 -1
@@ -29,7 +29,7 @@ static void kill_off_processes(void) t =find_lock_task_mm (p);if (!t)continue ; - pid = t->mm->context.id.u.pid; + pid = t->mm->context.id.pid;task_unlock (t);os_kill_ptraced_process (pid,1 ); }
arch/um/kernel/skas/mmu.c +6 -6
@@ -32,11 +32,11 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm) new_id->stack = stack;block_signals_trace (); - new_id->u.pid =start_userspace (stack); + new_id->pid =start_userspace (stack);unblock_signals_trace (); -if (new_id->u.pid <0 ) { - ret = new_id->u.pid; +if (new_id->pid <0 ) { + ret = new_id->pid; goto out_free; }
@@ -83,12 +83,12 @@ void destroy_context(struct mm_struct *mm)* whole UML suddenly dying. Also, cover negative and * 1 cases, since they shouldn't happen either. */ -if (mmu->id.u.pid <2 ) { +if (mmu->id.pid <2 ) {printk (KERN_ERR "corrupt mm_context - pid = %d\n" , - mmu->id.u.pid); + mmu->id.pid);return ; } -os_kill_ptraced_process (mmu->id.u.pid,1 ); +os_kill_ptraced_process (mmu->id.pid,1 );free_pages (mmu->id.stack,ilog2 (STUB_DATA_PAGES )); }
arch/um/kernel/time.c +1 -1
@@ -839,7 +839,7 @@ static irqreturn_t um_timer(int irq, void *dev)if (get_current ()->mm !=NULL ) {/* userspace - relay signal, results in correct userspace timers */ -os_alarm_process (get_current ()->mm->context.id.u.pid); +os_alarm_process (get_current ()->mm->context.id.pid); } (*timer_clockevent.event_handler)(&timer_clockevent);
arch/um/os-Linux/skas/mem.c +1 -1
@@ -78,7 +78,7 @@ static inline long do_syscall_stub(struct mm_id *mm_idp) {struct stub_data *proc_data = (void *)mm_idp->stack;int n, i; -int err, pid = mm_idp->u.pid; +int err, pid = mm_idp->pid; n =ptrace_setregs (pid, syscall_regs);if (n <0 ) {
arch/um/os-Linux/skas/process.c +1 -1
@@ -588,5 +588,5 @@ void reboot_skas(void)void __switch_mm (struct mm_id *mm_idp) { - userspace_pid[0 ] = mm_idp->u.pid; + userspace_pid[0 ] = mm_idp->pid; }
Signature · 1 line
2.34.1
PATCH v3 5/7 um: Remove the call to SUBARCH_EXECVE1 macro
In reply to Tiwei BieThis macro has never been defined by any supported sub-architectures in tree since it was introduced by commit 1d3468a6643a ("[PATCH uml:
move _kern.c files").
--- arch/um/kernel/exec.c | 3 --- 1 file changed, 3 deletions(-)
arch/um/kernel/exec.c +0 -3
@@ -35,8 +35,5 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)PT_REGS_IP (regs) = eip;PT_REGS_SP (regs) = esp;clear_thread_flag (TIF_SINGLESTEP ); -#ifdef SUBARCH_EXECVE1 -SUBARCH_EXECVE1 (regs->regs); -#endif }EXPORT_SYMBOL (start_thread);
Signature · 1 line
2.34.1
PATCH v3 6/7 um: Remove the declaration of user_thread function
In reply to Tiwei BieThis function has never been defined since its declaration was introduced by commit 1da177e4c3f4 ("Linux-2.6.12-rc2").
--- arch/um/include/shared/skas/skas.h | 1 - 1 file changed, 1 deletion(-)
arch/um/include/shared/skas/skas.h +0 -1
@@ -10,7 +10,6 @@extern int userspace_pid[]; -extern int user_thread (unsigned long stack,int flags);extern void new_thread_handler (void );extern void handle_syscall (struct uml_pt_regs *regs);extern long execute_syscall_skas (void *r);
Signature · 1 line
2.34.1
PATCH v3 7/7 um: Remove outdated asm/sysrq.h header
In reply to Tiwei BieThis header no longer serves a purpose after show_trace was removed by commit 9d1ee8ce92e1 ("um: Rewrite show_stack()").
--- arch/um/include/asm/sysrq.h | 8 -------- arch/um/kernel/sysrq.c | 1 - arch/x86/um/sysrq_32.c | 1 - arch/x86/um/sysrq_64.c | 1 - 4 files changed, 11 deletions(-) delete mode 100644 arch/um/include/asm/sysrq.h
arch/um/include/asm/sysrq.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __UM_SYSRQ_H -#define __UM_SYSRQ_H - -struct task_struct ; -extern void show_trace (struct task_struct * task,unsigned long *stack); - -#endif
arch/um/kernel/sysrq.c +0 -1
@@ -11,7 +11,6 @@#include <linux/sched/debug.h> #include <linux/sched/task_stack.h> -#include <asm/sysrq.h> #include <asm/stacktrace.h> #include <os.h>
arch/x86/um/sysrq_32.c +0 -1
@@ -9,7 +9,6 @@#include <linux/sched/debug.h> #include <linux/kallsyms.h> #include <asm/ptrace.h> -#include <asm/sysrq.h> /* This is declared by <linux/sched.h> */ void show_regs (struct pt_regs *regs)
arch/x86/um/sysrq_64.c +0 -1
@@ -12,7 +12,6 @@#include <linux/utsname.h> #include <asm/current.h> #include <asm/ptrace.h> -#include <asm/sysrq.h> void show_regs (struct pt_regs *regs) {
Signature · 1 line
2.34.1