Skip to contentSkip to conversation

Some minor cleanups for UML

PATCH Superseded Tiwei Bie 1 participant 7 messages Aug 16, 2024 User-mode Linux (UML)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

v2 cover Some minor cleanups for UML

Changes in v2:

- Remove the pointless union (suggested by Benjamin Berg);
- Minor tweaks on coding style;

v1: https://lore.kernel.org/linux-um/[email protected]/

Tiwei Bie (6):
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 declarations of undefined functions

 arch/um/include/asm/pgtable.h           |  7 -------
 arch/um/include/asm/processor-generic.h | 20 +++++---------------
 arch/um/include/shared/skas/mm_id.h     |  5 +----
 arch/um/include/shared/skas/skas.h      |  2 --
 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/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 +-
 13 files changed, 28 insertions(+), 57 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/6 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
index 5bb397b65efb..83373c9963e7 100644
@@ -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
author
#2 lore raw

PATCH v2 2/6 um: Remove the redundant newpage check in update_pte_range

In reply to Tiwei Bie

The 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
index 44c6fc697f3a..548af31d4111 100644
@@ -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
author
#3 lore raw

PATCH v2 3/6 um: Remove unused fields from thread_struct

In reply to Tiwei Bie

These 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
index 5a7c05275aa7..bce4595798da 100644
@@ -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
index f36b63f53bab..be2856af6d4c 100644
@@ -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(&current->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
index 5f9c1c5f36e2..68657988c8d1 100644
@@ -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
author
#4 lore raw

PATCH v2 4/6 um: Remove unused mm_fd field from mm_id

In reply to Tiwei Bie

It'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
index 1e76ba40feba..140388c282f6 100644
@@ -7,10 +7,7 @@
 #define __MM_ID_H
 
 struct 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
index 3736bca626ba..680bce4bd8fa 100644
@@ -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
index 47f98d87ea3c..886ed5e65674 100644
@@ -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
index 47b9f5e63566..29b27b90581f 100644
@@ -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
index c55430775efd..9a13ac23c606 100644
@@ -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
index f7088345b3fc..b6f656bcffb1 100644
@@ -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
author
#5 lore raw

PATCH v2 5/6 um: Remove the call to SUBARCH_EXECVE1 macro

In reply to Tiwei Bie

This macro isn't 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
index 2c15bb2c104c..cb8b5cd9285c 100644
@@ -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
author
#6 lore raw

PATCH v2 6/6 um: Remove declarations of undefined functions

In reply to Tiwei Bie

The definitions of these functions do not exist anymore.

---
 arch/um/include/shared/skas/skas.h | 2 --
 1 file changed, 2 deletions(-)
arch/um/include/shared/skas/skas.h +0 -2
index ebaa116de30b..85c50122ab98 100644
@@ -10,10 +10,8 @@
 
 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);
 extern unsigned long current_stub_stack(void);
 extern struct mm_id *current_mm_id(void);
 extern void current_mm_sync(void);
Signature · 1 line
2.34.1