LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH -next] x86/mm: fix an unused variable "tsk" warning
@ 2019-05-31 21:37 Qian Cai
  2019-06-12 17:55 ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Qian Cai @ 2019-05-31 21:37 UTC (permalink / raw)
  To: mingo, tglx, bp
  Cc: dave.hansen, luto, peterz, hpa, x86, linux-kernel, Qian Cai

Since the commit "signal: Remove the task parameter from
force_sig_fault", "tsk" is only used when MEMORY_FAILURE=y and generates
a compilation warning without it.

arch/x86/mm/fault.c: In function 'do_sigbus':
arch/x86/mm/fault.c:1017:22: warning: unused variable 'tsk'
[-Wunused-variable]

Also, change to use IS_ENABLED() instead.

Signed-off-by: Qian Cai <cai@lca.pw>
---
 arch/x86/mm/fault.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 46ac96aa7c81..40d70bd3fa84 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1014,8 +1014,6 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
 do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
 	  vm_fault_t fault)
 {
-	struct task_struct *tsk = current;
-
 	/* Kernel mode? Handle exceptions or die: */
 	if (!(error_code & X86_PF_USER)) {
 		no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
@@ -1028,9 +1026,10 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
 
 	set_signal_archinfo(address, error_code);
 
-#ifdef CONFIG_MEMORY_FAILURE
-	if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
+	if (IS_ENABLED(CONFIG_MEMORY_FAILURE) &&
+	    (fault & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE))) {
 		unsigned lsb = 0;
+		struct task_struct *tsk = current;
 
 		pr_err(
 	"MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
@@ -1042,7 +1041,6 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
 		force_sig_mceerr(BUS_MCEERR_AR, (void __user *)address, lsb);
 		return;
 	}
-#endif
 	force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address);
 }
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] x86/mm: fix an unused variable "tsk" warning
  2019-05-31 21:37 [PATCH -next] x86/mm: fix an unused variable "tsk" warning Qian Cai
@ 2019-06-12 17:55 ` Borislav Petkov
  2019-06-12 18:19   ` Eric W. Biederman
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2019-06-12 17:55 UTC (permalink / raw)
  To: Qian Cai, Eric W. Biederman
  Cc: mingo, tglx, dave.hansen, luto, peterz, hpa, x86, linux-kernel

On Fri, May 31, 2019 at 05:37:21PM -0400, Qian Cai wrote:
> Since the commit "signal: Remove the task parameter from
> force_sig_fault", "tsk" is only used when MEMORY_FAILURE=y and generates
> a compilation warning without it.
> 
> arch/x86/mm/fault.c: In function 'do_sigbus':
> arch/x86/mm/fault.c:1017:22: warning: unused variable 'tsk'
> [-Wunused-variable]
> 
> Also, change to use IS_ENABLED() instead.
> 
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  arch/x86/mm/fault.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index 46ac96aa7c81..40d70bd3fa84 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -1014,8 +1014,6 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
>  do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
>  	  vm_fault_t fault)
>  {
> -	struct task_struct *tsk = current;
> -
>  	/* Kernel mode? Handle exceptions or die: */
>  	if (!(error_code & X86_PF_USER)) {
>  		no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
> @@ -1028,9 +1026,10 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
>  
>  	set_signal_archinfo(address, error_code);
>  
> -#ifdef CONFIG_MEMORY_FAILURE
> -	if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
> +	if (IS_ENABLED(CONFIG_MEMORY_FAILURE) &&
> +	    (fault & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE))) {
>  		unsigned lsb = 0;
> +		struct task_struct *tsk = current;
>  
>  		pr_err(
>  	"MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
> @@ -1042,7 +1041,6 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
>  		force_sig_mceerr(BUS_MCEERR_AR, (void __user *)address, lsb);
>  		return;
>  	}
> -#endif
>  	force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address);
>  }
>  
> -- 

I was puzzled just like Dave because this code is not in tip.

Turns out there's this in linux-next:

commit 318759b4737c3b3789e2fd64d539f437d52386f5
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Mon Jun 3 10:23:58 2019 -0500

    signal/x86: Move tsk inside of CONFIG_MEMORY_FAILURE in do_sigbus


-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] x86/mm: fix an unused variable "tsk" warning
  2019-06-12 17:55 ` Borislav Petkov
@ 2019-06-12 18:19   ` Eric W. Biederman
  2019-06-12 19:53     ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Eric W. Biederman @ 2019-06-12 18:19 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Qian Cai, mingo, tglx, dave.hansen, luto, peterz, hpa, x86, linux-kernel

Borislav Petkov <bp@alien8.de> writes:

> On Fri, May 31, 2019 at 05:37:21PM -0400, Qian Cai wrote:
>> Since the commit "signal: Remove the task parameter from
>> force_sig_fault", "tsk" is only used when MEMORY_FAILURE=y and generates
>> a compilation warning without it.
>> 
>> arch/x86/mm/fault.c: In function 'do_sigbus':
>> arch/x86/mm/fault.c:1017:22: warning: unused variable 'tsk'
>> [-Wunused-variable]
>> 
>> Also, change to use IS_ENABLED() instead.
>> 
>> Signed-off-by: Qian Cai <cai@lca.pw>
>> ---
>>  arch/x86/mm/fault.c | 8 +++-----
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>> 
>> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
>> index 46ac96aa7c81..40d70bd3fa84 100644
>> --- a/arch/x86/mm/fault.c
>> +++ b/arch/x86/mm/fault.c
>> @@ -1014,8 +1014,6 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
>>  do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
>>  	  vm_fault_t fault)
>>  {
>> -	struct task_struct *tsk = current;
>> -
>>  	/* Kernel mode? Handle exceptions or die: */
>>  	if (!(error_code & X86_PF_USER)) {
>>  		no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
>> @@ -1028,9 +1026,10 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
>>  
>>  	set_signal_archinfo(address, error_code);
>>  
>> -#ifdef CONFIG_MEMORY_FAILURE
>> -	if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
>> +	if (IS_ENABLED(CONFIG_MEMORY_FAILURE) &&
>> +	    (fault & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE))) {
>>  		unsigned lsb = 0;
>> +		struct task_struct *tsk = current;
>>  
>>  		pr_err(
>>  	"MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
>> @@ -1042,7 +1041,6 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
>>  		force_sig_mceerr(BUS_MCEERR_AR, (void __user *)address, lsb);
>>  		return;
>>  	}
>> -#endif
>>  	force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address);
>>  }
>>  
>> -- 
>
> I was puzzled just like Dave because this code is not in tip.
>
> Turns out there's this in linux-next:
>
> commit 318759b4737c3b3789e2fd64d539f437d52386f5
> Author: Eric W. Biederman <ebiederm@xmission.com>
> Date:   Mon Jun 3 10:23:58 2019 -0500
>
>     signal/x86: Move tsk inside of CONFIG_MEMORY_FAILURE in do_sigbus

Since I am removing the tsk parameter from all of the synchrnous signal
sending functions, on all of the architectures it was easier to go
through my own tree than -tip.

The removal of tsk from force_sig_fault is what caused the warning
in do_sigbus.

My apologies I was a little slow in getting that patch added and
generating work for other folks.

Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] x86/mm: fix an unused variable "tsk" warning
  2019-06-12 18:19   ` Eric W. Biederman
@ 2019-06-12 19:53     ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2019-06-12 19:53 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Qian Cai, mingo, tglx, dave.hansen, luto, peterz, hpa, x86, linux-kernel

On Wed, Jun 12, 2019 at 01:19:06PM -0500, Eric W. Biederman wrote:
> Since I am removing the tsk parameter from all of the synchrnous signal
> sending functions, on all of the architectures it was easier to go
> through my own tree than -tip.

Yeah, I remember reading a mail about it...

> The removal of tsk from force_sig_fault is what caused the warning
> in do_sigbus.
> 
> My apologies I was a little slow in getting that patch added and
> generating work for other folks.

That's fine - now we know what the situation is.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-12 19:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 21:37 [PATCH -next] x86/mm: fix an unused variable "tsk" warning Qian Cai
2019-06-12 17:55 ` Borislav Petkov
2019-06-12 18:19   ` Eric W. Biederman
2019-06-12 19:53     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).