Skip to contentSkip to conversation

Some minor cleanups for UML

PATCH Superseded Tiwei Bie 2 participants 9 messages Aug 16, 2024 User-mode Linux (UML)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

cover Some minor cleanups for UML

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 | 10 +---------
 arch/um/include/shared/skas/mm_id.h     |  1 -
 arch/um/include/shared/skas/skas.h      |  2 --
 arch/um/kernel/exec.c                   |  3 ---
 arch/um/kernel/tlb.c                    | 17 +++++++----------
 6 files changed, 8 insertions(+), 32 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 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 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 | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
arch/um/kernel/tlb.c +7 -10
index 44c6fc697f3a..dddbc473baa7 100644
@@ -82,16 +82,13 @@ 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 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 | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/um/include/asm/processor-generic.h +1 -9
index 5a7c05275aa7..864389ee29f6 100644
@@ -28,19 +28,11 @@ 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;
 	} request;
 };
@@ -51,7 +43,7 @@ struct thread_struct {
 	.fault_addr		= NULL, \
 	.prev_sched		= NULL, \
 	.arch			= INIT_ARCH_THREAD, \
-	.request		= { 0 } \
+	.request		= { } \
 }
 
 /*
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH 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 | 1 -
 1 file changed, 1 deletion(-)
arch/um/include/shared/skas/mm_id.h +0 -1
index 1e76ba40feba..b3571a8afec9 100644
@@ -8,7 +8,6 @@
 
 struct mm_id {
 	union {
-		int mm_fd;
 		int pid;
 	} u;
 	unsigned long stack;
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH 4/6] um: Remove unused mm_fd field from mm_id

Hi Tiwei,

Quoted 17 lines · Tiwei Bie

It's no longer used since the removal of the SKAS3/4 support.

---
 arch/um/include/shared/skas/mm_id.h | 1 -

 1 file changed, 1 deletion(-)
arch/um/include/shared/skas/mm_id.h +0 -0
index 1e76ba40feba..b3571a8afec9 100644
@@ -8,7 +8,6 @@


 struct mm_id {
  union {

arch/um/include/shared/skas/mm_id.h +0 -1
-		int mm_fd;
Quoted 3 lines

  int pid;
  } u;
  unsigned long stack;

Maybe we should also remove the union here while at it? It is pretty pointless after all.

Benjamin

author
#6 lore raw

Re: [PATCH 4/6] um: Remove unused mm_fd field from mm_id

Hi Benjamin,

Quoted 10 lines · Benjamin Berg

Hi Tiwei,

Quoted 7 lines · Tiwei Bie

It's no longer used since the removal of the SKAS3/4 support.

---
 arch/um/include/shared/skas/mm_id.h | 1 -

 1 file changed, 1 deletion(-)
Quoted 16 lines
Quoted 10 lines
arch/um/include/shared/skas/mm_id.h +0 -0
index 1e76ba40feba..b3571a8afec9 100644
@@ -8,7 +8,6 @@


 struct mm_id {
  union {

arch/um/include/shared/skas/mm_id.h +0 -1
-		int mm_fd;
Quoted 3 lines

  int pid;
  } u;
  unsigned long stack;

Maybe we should also remove the union here while at it? It is pretty pointless after all.

That makes sense. Will do. Thanks!

Regards,
Tiwei

Quoted 2 lines

Benjamin

author
#7 lore raw

PATCH 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
#8 lore raw

PATCH 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