Skip to contentSkip to conversation

x86/mce: remove unused mce_vaddr

PATCH Superseded Miaohe Lin 2 participants 3 messages May 28, 2023 – Jun 3, 2023

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 x86/mce: remove unused mce_vaddr

Since commit a6e3cf70b772 ("x86/mce: Change to not send SIGBUS error during copy from user"), mce_vaddr is not used anymore. Remove it and clean up the relevant code.

---
 arch/x86/kernel/cpu/mce/severity.c | 7 +------
 include/linux/sched.h              | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)
arch/x86/kernel/cpu/mce/severity.c +1 -6
index c4477162c07d..0acc0039de81 100644
@@ -252,12 +252,7 @@ static bool is_copy_from_user(struct pt_regs *regs)
 		return false;
 	}
 
-	if (fault_in_kernel_space(addr))
-		return false;
-
-	current->mce_vaddr = (void __user *)addr;
-
-	return true;
+	return !fault_in_kernel_space(addr);
 }
 
 /*
include/linux/sched.h +0 -1
index eed5d65b8d1f..3054a7087230 100644
@@ -1493,7 +1493,6 @@ struct task_struct {
 #endif
 
 #ifdef CONFIG_X86_MCE
-	void __user			*mce_vaddr;
 	__u64				mce_kflags;
 	u64				mce_addr;
 	__u64				mce_ripv : 1,
Signature · 1 line
2.27.0
#1 lore raw
Quoted 3 lines · Miaohe Lin

Since commit a6e3cf70b772 ("x86/mce: Change to not send SIGBUS error during copy from user"), mce_vaddr is not used anymore. Remove it and clean up the relevant code.

Hi Miaohe,

Not so sure that the 'clean up' part is useful. See below.

Quoted 13 lines
---
 arch/x86/kernel/cpu/mce/severity.c | 7 +------
 include/linux/sched.h              | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)
arch/x86/kernel/cpu/mce/severity.c +0 -0
index c4477162c07d..0acc0039de81 100644
@@ -252,12 +252,7 @@ static bool is_copy_from_user(struct pt_regs *regs)
 		return false;

arch/x86/kernel/cpu/mce/severity.c static bool is_copy_from_user(struct pt_regs *regs) · line 256

Quoted 10 lines
arch/x86/kernel/cpu/mce/severity.c +1 -6
 	}
 
-	if (fault_in_kernel_space(addr))
-		return false;
-
-	current->mce_vaddr = (void __user *)addr;
-
-	return true;
+	return !fault_in_kernel_space(addr);
 }

Refactoring the return is unnecessary and seems less readable. How about removing the assignment, and leaving the rest, as is:

arch/x86/kernel/cpu/mce/severity.c +0 -2
index c4477162c07d..1c03221ddcb1 100644
@@ -255,8 +255,6 @@ static bool is_copy_from_user(struct pt_regs *regs)
        if (fault_in_kernel_space(addr))
                return false;
 
-       current->mce_vaddr = (void __user *)addr;
-
        return true;
 }
 

Alison

Quoted 17 lines
arch/x86/kernel/cpu/mce/severity.c +0 -0
 /*
include/linux/sched.h +0 -1
index eed5d65b8d1f..3054a7087230 100644
@@ -1493,7 +1493,6 @@ struct task_struct {
 #endif
 
 #ifdef CONFIG_X86_MCE
-	void __user			*mce_vaddr;
 	__u64				mce_kflags;
 	u64				mce_addr;
 	__u64				mce_ripv : 1,
Signature · 1 line
2.27.0
author
#2 lore raw
Quoted 43 lines · Alison Schofield
Quoted 3 lines · Miaohe Lin

Since commit a6e3cf70b772 ("x86/mce: Change to not send SIGBUS error during copy from user"), mce_vaddr is not used anymore. Remove it and clean up the relevant code.

Hi Miaohe,

Not so sure that the 'clean up' part is useful. See below.

Quoted 13 lines
---
 arch/x86/kernel/cpu/mce/severity.c | 7 +------
 include/linux/sched.h              | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)
arch/x86/kernel/cpu/mce/severity.c +0 -0
index c4477162c07d..0acc0039de81 100644
@@ -252,12 +252,7 @@ static bool is_copy_from_user(struct pt_regs *regs)
 		return false;

arch/x86/kernel/cpu/mce/severity.c static bool is_copy_from_user(struct pt_regs *regs) · line 256

Quoted 10 lines
arch/x86/kernel/cpu/mce/severity.c +1 -6
 	}
 
-	if (fault_in_kernel_space(addr))
-		return false;
-
-	current->mce_vaddr = (void __user *)addr;
-
-	return true;
+	return !fault_in_kernel_space(addr);
 }

Refactoring the return is unnecessary and seems less readable. How about removing the assignment, and leaving the rest, as is:

arch/x86/kernel/cpu/mce/severity.c +0 -0
index c4477162c07d..1c03221ddcb1 100644

arch/x86/kernel/cpu/mce/severity.c static bool is_copy_from_user(struct pt_regs *regs) · line 260

Quoted 8 lines
arch/x86/kernel/cpu/mce/severity.c +0 -2
@@ -255,8 +255,6 @@ static bool is_copy_from_user(struct pt_regs *regs)
        if (fault_in_kernel_space(addr))
                return false;
 
-       current->mce_vaddr = (void __user *)addr;
-
        return true;
 }
 

Sounds good to me. Will do it in v2. Thanks for your advice.