All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot
@ 2019-10-31 13:04 Konstantin Khlebnikov
  2019-10-31 14:29 ` Borislav Petkov
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Konstantin Khlebnikov @ 2019-10-31 13:04 UTC (permalink / raw)
  To: Tony Luck, Borislav Petkov, linux-kernel, linux-edac; +Cc: x86

Function smca_configure() is called only for current cpu thus
rdmsr_safe_on_cpu() could be replaced with atomic rdmsr_safe().

 BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
 in_atomic(): 1, irqs_disabled(): 1, pid: 0, name: swapper/1
 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.19.79-16 #1
 Hardware name: GIGABYTE R181-Z90-00/MZ91-FS0-00, BIOS R11 10/25/2019
 Call Trace:
  dump_stack+0x5c/0x7b
  ___might_sleep+0xec/0x110
  wait_for_completion+0x39/0x160
  ? __rdmsr_safe_on_cpu+0x45/0x60
  rdmsr_safe_on_cpu+0xae/0xf0
  ? wrmsr_on_cpus+0x20/0x20
  ? machine_check_poll+0xfd/0x1f0
  ? mce_amd_feature_init+0x190/0x2d0
  mce_amd_feature_init+0x190/0x2d0
  mcheck_cpu_init+0x11a/0x460
  identify_cpu+0x3e2/0x560
  identify_secondary_cpu+0x13/0x80
  smp_store_cpu_info+0x45/0x50
  start_secondary+0xaa/0x200
  secondary_startup_64+0xa4/0xb0

Except warning in kernel log everything works fine.

Fixes: 5896820e0aa3 ("x86/mce/AMD, EDAC/mce_amd: Define and use tables for known SMCA IP types")
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 arch/x86/kernel/cpu/mce/amd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 6ea7fdc82f3c..c7ab0d38af79 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -269,7 +269,7 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
 	if (smca_banks[bank].hwid)
 		return;
 
-	if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
+	if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
 		pr_warn("Failed to read MCA_IPID for bank %d\n", bank);
 		return;
 	}


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

* Re: [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot
  2019-10-31 13:04 [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot Konstantin Khlebnikov
@ 2019-10-31 14:29 ` Borislav Petkov
  2019-10-31 14:58   ` Ghannam, Yazen
  2019-11-01 13:39   ` Konstantin Khlebnikov
  2019-12-10 10:07 ` [tip: ras/core] x86/MCE/AMD: Do not use rdmsr_safe_on_cpu() in smca_configure() tip-bot2 for Konstantin Khlebnikov
  2019-12-17 10:01 ` [tip: ras/urgent] " tip-bot2 for Konstantin Khlebnikov
  2 siblings, 2 replies; 8+ messages in thread
From: Borislav Petkov @ 2019-10-31 14:29 UTC (permalink / raw)
  To: Konstantin Khlebnikov, Yazen Ghannam
  Cc: Tony Luck, linux-kernel, linux-edac, x86

On Thu, Oct 31, 2019 at 04:04:48PM +0300, Konstantin Khlebnikov wrote:
> Function smca_configure() is called only for current cpu thus
> rdmsr_safe_on_cpu() could be replaced with atomic rdmsr_safe().
> 
>  BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
>  in_atomic(): 1, irqs_disabled(): 1, pid: 0, name: swapper/1
>  CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.19.79-16 #1
					     ^^^^^^^^^^

I'm assuming you hit this on latest upstream too?

>  Hardware name: GIGABYTE R181-Z90-00/MZ91-FS0-00, BIOS R11 10/25/2019
>  Call Trace:
>   dump_stack+0x5c/0x7b
>   ___might_sleep+0xec/0x110
>   wait_for_completion+0x39/0x160
>   ? __rdmsr_safe_on_cpu+0x45/0x60
>   rdmsr_safe_on_cpu+0xae/0xf0
>   ? wrmsr_on_cpus+0x20/0x20
>   ? machine_check_poll+0xfd/0x1f0
>   ? mce_amd_feature_init+0x190/0x2d0
>   mce_amd_feature_init+0x190/0x2d0
>   mcheck_cpu_init+0x11a/0x460
>   identify_cpu+0x3e2/0x560
>   identify_secondary_cpu+0x13/0x80
>   smp_store_cpu_info+0x45/0x50
>   start_secondary+0xaa/0x200
>   secondary_startup_64+0xa4/0xb0
> 
> Except warning in kernel log everything works fine.
> 
> Fixes: 5896820e0aa3 ("x86/mce/AMD, EDAC/mce_amd: Define and use tables for known SMCA IP types")
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
>  arch/x86/kernel/cpu/mce/amd.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
> index 6ea7fdc82f3c..c7ab0d38af79 100644
> --- a/arch/x86/kernel/cpu/mce/amd.c
> +++ b/arch/x86/kernel/cpu/mce/amd.c
> @@ -269,7 +269,7 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
>  	if (smca_banks[bank].hwid)
>  		return;
>  
> -	if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
> +	if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {

Yazen, any objections?

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

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

* RE: [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot
  2019-10-31 14:29 ` Borislav Petkov
@ 2019-10-31 14:58   ` Ghannam, Yazen
  2019-11-01 13:39   ` Konstantin Khlebnikov
  1 sibling, 0 replies; 8+ messages in thread
From: Ghannam, Yazen @ 2019-10-31 14:58 UTC (permalink / raw)
  To: Borislav Petkov, Konstantin Khlebnikov
  Cc: Tony Luck, linux-kernel, linux-edac, x86

> -----Original Message-----
> From: Borislav Petkov <bp@alien8.de>
> Sent: Thursday, October 31, 2019 10:30 AM
> To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>; Ghannam, Yazen <Yazen.Ghannam@amd.com>
> Cc: Tony Luck <tony.luck@intel.com>; linux-kernel@vger.kernel.org; linux-edac@vger.kernel.org; x86@kernel.org
> Subject: Re: [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot
> 
> On Thu, Oct 31, 2019 at 04:04:48PM +0300, Konstantin Khlebnikov wrote:
> > Function smca_configure() is called only for current cpu thus
> > rdmsr_safe_on_cpu() could be replaced with atomic rdmsr_safe().
> >
> >  BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
> >  in_atomic(): 1, irqs_disabled(): 1, pid: 0, name: swapper/1
> >  CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.19.79-16 #1
> 					     ^^^^^^^^^^
> 
> I'm assuming you hit this on latest upstream too?
> 
> >  Hardware name: GIGABYTE R181-Z90-00/MZ91-FS0-00, BIOS R11 10/25/2019
> >  Call Trace:
> >   dump_stack+0x5c/0x7b
> >   ___might_sleep+0xec/0x110
> >   wait_for_completion+0x39/0x160
> >   ? __rdmsr_safe_on_cpu+0x45/0x60
> >   rdmsr_safe_on_cpu+0xae/0xf0
> >   ? wrmsr_on_cpus+0x20/0x20
> >   ? machine_check_poll+0xfd/0x1f0
> >   ? mce_amd_feature_init+0x190/0x2d0
> >   mce_amd_feature_init+0x190/0x2d0
> >   mcheck_cpu_init+0x11a/0x460
> >   identify_cpu+0x3e2/0x560
> >   identify_secondary_cpu+0x13/0x80
> >   smp_store_cpu_info+0x45/0x50
> >   start_secondary+0xaa/0x200
> >   secondary_startup_64+0xa4/0xb0
> >
> > Except warning in kernel log everything works fine.
> >
> > Fixes: 5896820e0aa3 ("x86/mce/AMD, EDAC/mce_amd: Define and use tables for known SMCA IP types")
> > Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> > ---
> >  arch/x86/kernel/cpu/mce/amd.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
> > index 6ea7fdc82f3c..c7ab0d38af79 100644
> > --- a/arch/x86/kernel/cpu/mce/amd.c
> > +++ b/arch/x86/kernel/cpu/mce/amd.c
> > @@ -269,7 +269,7 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
> >  	if (smca_banks[bank].hwid)
> >  		return;
> >
> > -	if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
> > +	if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
> 
> Yazen, any objections?
> 

This looks good to me.

We can go further and remove the "cpu" parameter from this entire function.
But that can be another patch.

Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>

Thanks,
Yazen

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

* Re: [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot
  2019-10-31 14:29 ` Borislav Petkov
  2019-10-31 14:58   ` Ghannam, Yazen
@ 2019-11-01 13:39   ` Konstantin Khlebnikov
  2019-11-07 10:53     ` Borislav Petkov
  1 sibling, 1 reply; 8+ messages in thread
From: Konstantin Khlebnikov @ 2019-11-01 13:39 UTC (permalink / raw)
  To: Borislav Petkov, Yazen Ghannam; +Cc: Tony Luck, linux-kernel, linux-edac, x86

On 31/10/2019 17.29, Borislav Petkov wrote:
> On Thu, Oct 31, 2019 at 04:04:48PM +0300, Konstantin Khlebnikov wrote:
>> Function smca_configure() is called only for current cpu thus
>> rdmsr_safe_on_cpu() could be replaced with atomic rdmsr_safe().
>>
>>   BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
>>   in_atomic(): 1, irqs_disabled(): 1, pid: 0, name: swapper/1
>>   CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.19.79-16 #1
> 					     ^^^^^^^^^^
> 
> I'm assuming you hit this on latest upstream too?

I tried 5.4 once but there was no warning.
Code in 4.19 and in mainline almost the same.

Probably hardware needs full power cycle to reset state or something else.

> 
>>   Hardware name: GIGABYTE R181-Z90-00/MZ91-FS0-00, BIOS R11 10/25/2019
>>   Call Trace:
>>    dump_stack+0x5c/0x7b
>>    ___might_sleep+0xec/0x110
>>    wait_for_completion+0x39/0x160
>>    ? __rdmsr_safe_on_cpu+0x45/0x60
>>    rdmsr_safe_on_cpu+0xae/0xf0
>>    ? wrmsr_on_cpus+0x20/0x20
>>    ? machine_check_poll+0xfd/0x1f0
>>    ? mce_amd_feature_init+0x190/0x2d0
>>    mce_amd_feature_init+0x190/0x2d0
>>    mcheck_cpu_init+0x11a/0x460
>>    identify_cpu+0x3e2/0x560
>>    identify_secondary_cpu+0x13/0x80
>>    smp_store_cpu_info+0x45/0x50
>>    start_secondary+0xaa/0x200
>>    secondary_startup_64+0xa4/0xb0
>>
>> Except warning in kernel log everything works fine.
>>
>> Fixes: 5896820e0aa3 ("x86/mce/AMD, EDAC/mce_amd: Define and use tables for known SMCA IP types")
>> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
>> ---
>>   arch/x86/kernel/cpu/mce/amd.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
>> index 6ea7fdc82f3c..c7ab0d38af79 100644
>> --- a/arch/x86/kernel/cpu/mce/amd.c
>> +++ b/arch/x86/kernel/cpu/mce/amd.c
>> @@ -269,7 +269,7 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
>>   	if (smca_banks[bank].hwid)
>>   		return;
>>   
>> -	if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
>> +	if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
> 
> Yazen, any objections?
> 

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

* Re: [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot
  2019-11-01 13:39   ` Konstantin Khlebnikov
@ 2019-11-07 10:53     ` Borislav Petkov
  2019-12-17  7:53       ` Borislav Petkov
  0 siblings, 1 reply; 8+ messages in thread
From: Borislav Petkov @ 2019-11-07 10:53 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Yazen Ghannam, Tony Luck, linux-kernel, linux-edac, x86

On Fri, Nov 01, 2019 at 04:39:17PM +0300, Konstantin Khlebnikov wrote:
> I tried 5.4 once but there was no warning.
> Code in 4.19 and in mainline almost the same.

Yes, but early boot code has changed a lot since 4.19. If you can't
trigger it on 5.4, then I'll drop the BUG splat from your commit message
and change it to talk about replacing the IPI-sending function, which is
a good cleanup in itself.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

* [tip: ras/core] x86/MCE/AMD: Do not use rdmsr_safe_on_cpu() in smca_configure()
  2019-10-31 13:04 [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot Konstantin Khlebnikov
  2019-10-31 14:29 ` Borislav Petkov
@ 2019-12-10 10:07 ` tip-bot2 for Konstantin Khlebnikov
  2019-12-17 10:01 ` [tip: ras/urgent] " tip-bot2 for Konstantin Khlebnikov
  2 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Konstantin Khlebnikov @ 2019-12-10 10:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Konstantin Khlebnikov, Borislav Petkov, Yazen Ghannam,
	H. Peter Anvin, Ingo Molnar, linux-edac, Thomas Gleixner,
	Tony Luck, x86-ml, LKML

The following commit has been merged into the ras/core branch of tip:

Commit-ID:     17ba1939e3676417590ec6f7555608e137e1719a
Gitweb:        https://git.kernel.org/tip/17ba1939e3676417590ec6f7555608e137e1719a
Author:        Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
AuthorDate:    Thu, 31 Oct 2019 16:04:48 +03:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Mon, 09 Dec 2019 14:54:59 +01:00

x86/MCE/AMD: Do not use rdmsr_safe_on_cpu() in smca_configure()

The function smca_configure() is called only on the current CPU
therefore replace rdmsr_safe_on_cpu() with atomic rdmsr_safe() and avoid
the IPI.

 [ bp: Cleanup commit message. ]

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/157252708836.3876.4604398213417262402.stgit@buzz
---
 arch/x86/kernel/cpu/mce/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 5167bd2..e41e3b4 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -269,7 +269,7 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
 	if (smca_banks[bank].hwid)
 		return;
 
-	if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
+	if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
 		pr_warn("Failed to read MCA_IPID for bank %d\n", bank);
 		return;
 	}

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

* Re: [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot
  2019-11-07 10:53     ` Borislav Petkov
@ 2019-12-17  7:53       ` Borislav Petkov
  0 siblings, 0 replies; 8+ messages in thread
From: Borislav Petkov @ 2019-12-17  7:53 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Yazen Ghannam, Tony Luck, linux-kernel, linux-edac, x86

On Thu, Nov 07, 2019 at 11:53:10AM +0100, Borislav Petkov wrote:
> On Fri, Nov 01, 2019 at 04:39:17PM +0300, Konstantin Khlebnikov wrote:
> > I tried 5.4 once but there was no warning.
> > Code in 4.19 and in mainline almost the same.
> 
> Yes, but early boot code has changed a lot since 4.19. If you can't
> trigger it on 5.4, then I'll drop the BUG splat from your commit message
> and change it to talk about replacing the IPI-sending function, which is
> a good cleanup in itself.

Ok, I was able to trigger it myself:

[    0.822602] BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
[    0.822602] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1
[    0.822602] no locks held by swapper/1/0.
[    0.822602] irq event stamp: 0
[    0.822602] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
[    0.822602] hardirqs last disabled at (0): [<ffffffff8106dda9>] copy_process+0x8b9/0x1ca0
[    0.822602] softirqs last  enabled at (0): [<ffffffff8106dda9>] copy_process+0x8b9/0x1ca0
[    0.822602] softirqs last disabled at (0): [<0000000000000000>] 0x0
[    0.822602] Preemption disabled at:
[    0.822602] [<ffffffff8104703b>] start_secondary+0x3b/0x190
[    0.822602] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.5.0-rc2+ #1
[    0.822602] Hardware name: GIGABYTE MZ01-CE1-00/MZ01-CE1-00, BIOS F02 08/29/2018
[    0.822602] Call Trace:
[    0.822602]  dump_stack+0x71/0xa0
[    0.822602]  ___might_sleep.cold.92+0xf7/0x11f
[    0.822602]  wait_for_completion+0x3c/0x180
[    0.822602]  ? generic_exec_single+0xca/0x100
[    0.822602]  rdmsr_safe_on_cpu+0xe8/0x100
[    0.822602]  ? wrmsr_on_cpus+0x20/0x20
[    0.822602]  mce_amd_feature_init+0x2ab/0x590
[    0.822602]  mcheck_cpu_init+0x17a/0x4d0
[    0.822602]  identify_cpu+0x3f0/0x750
[    0.822602]  identify_secondary_cpu+0x13/0x80
[    0.822602]  smp_store_cpu_info+0x45/0x50
[    0.822602]  start_secondary+0x50/0x190
[    0.822602]  secondary_startup_64+0xa4/0xb0

Rerouting patch...

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

* [tip: ras/urgent] x86/MCE/AMD: Do not use rdmsr_safe_on_cpu() in smca_configure()
  2019-10-31 13:04 [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot Konstantin Khlebnikov
  2019-10-31 14:29 ` Borislav Petkov
  2019-12-10 10:07 ` [tip: ras/core] x86/MCE/AMD: Do not use rdmsr_safe_on_cpu() in smca_configure() tip-bot2 for Konstantin Khlebnikov
@ 2019-12-17 10:01 ` tip-bot2 for Konstantin Khlebnikov
  2 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Konstantin Khlebnikov @ 2019-12-17 10:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Konstantin Khlebnikov, Borislav Petkov, Yazen Ghannam,
	H. Peter Anvin, Ingo Molnar, linux-edac, stable, Thomas Gleixner,
	Tony Luck, x86-ml, LKML

The following commit has been merged into the ras/urgent branch of tip:

Commit-ID:     246ff09f89e54fdf740a8d496176c86743db3ec7
Gitweb:        https://git.kernel.org/tip/246ff09f89e54fdf740a8d496176c86743db3ec7
Author:        Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
AuthorDate:    Thu, 31 Oct 2019 16:04:48 +03:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Tue, 17 Dec 2019 09:39:33 +01:00

x86/MCE/AMD: Do not use rdmsr_safe_on_cpu() in smca_configure()

... because interrupts are disabled that early and sending IPIs can
deadlock:

  BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
  in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1
  no locks held by swapper/1/0.
  irq event stamp: 0
  hardirqs last  enabled at (0): [<0000000000000000>] 0x0
  hardirqs last disabled at (0): [<ffffffff8106dda9>] copy_process+0x8b9/0x1ca0
  softirqs last  enabled at (0): [<ffffffff8106dda9>] copy_process+0x8b9/0x1ca0
  softirqs last disabled at (0): [<0000000000000000>] 0x0
  Preemption disabled at:
  [<ffffffff8104703b>] start_secondary+0x3b/0x190
  CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.5.0-rc2+ #1
  Hardware name: GIGABYTE MZ01-CE1-00/MZ01-CE1-00, BIOS F02 08/29/2018
  Call Trace:
   dump_stack
   ___might_sleep.cold.92
   wait_for_completion
   ? generic_exec_single
   rdmsr_safe_on_cpu
   ? wrmsr_on_cpus
   mce_amd_feature_init
   mcheck_cpu_init
   identify_cpu
   identify_secondary_cpu
   smp_store_cpu_info
   start_secondary
   secondary_startup_64

The function smca_configure() is called only on the current CPU anyway,
therefore replace rdmsr_safe_on_cpu() with atomic rdmsr_safe() and avoid
the IPI.

 [ bp: Update commit message. ]

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: <stable@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/157252708836.3876.4604398213417262402.stgit@buzz
---
 arch/x86/kernel/cpu/mce/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 5167bd2..e41e3b4 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -269,7 +269,7 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
 	if (smca_banks[bank].hwid)
 		return;
 
-	if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
+	if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
 		pr_warn("Failed to read MCA_IPID for bank %d\n", bank);
 		return;
 	}

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

end of thread, other threads:[~2019-12-17 10:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-31 13:04 [PATCH] x86/MCE/AMD: fix warning about sleep-in-atomic at early boot Konstantin Khlebnikov
2019-10-31 14:29 ` Borislav Petkov
2019-10-31 14:58   ` Ghannam, Yazen
2019-11-01 13:39   ` Konstantin Khlebnikov
2019-11-07 10:53     ` Borislav Petkov
2019-12-17  7:53       ` Borislav Petkov
2019-12-10 10:07 ` [tip: ras/core] x86/MCE/AMD: Do not use rdmsr_safe_on_cpu() in smca_configure() tip-bot2 for Konstantin Khlebnikov
2019-12-17 10:01 ` [tip: ras/urgent] " tip-bot2 for Konstantin Khlebnikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.