All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Xiang <liu.xiang@zlingsmart.com>
To: linux@armlinux.org.uk
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, liuxiang_1999@126.com,
	liuxiang1999@gmail.com, Liu Xiang <liu.xiang@zlingsmart.com>
Subject: [PATCH] ARM: fix smp_processor_id() in preemptible warning in harden_branch_predictor()
Date: Thu, 25 Mar 2021 17:50:49 +0800	[thread overview]
Message-ID: <20210325095049.6948-1-liu.xiang@zlingsmart.com> (raw)

When CONFIG_HARDEN_BRANCH_PREDICTOR is selected and user aborts occur,
there is a warning:

BUG: using smp_processor_id() in preemptible [00000000] code: errnotest/577
caller is __do_user_fault.constprop.4+0x24/0x88
CPU: 1 PID: 577 Comm: errnotest Not tainted 4.14.188-rt87-fmsh-00004-g58055877a #1
Hardware name: FMSH PSOC Platform
[<8010d6d4>] (unwind_backtrace) from [<8010a228>] (show_stack+0x10/0x14)
[<8010a228>] (show_stack) from [<80698f44>] (dump_stack+0x7c/0x98)
[<80698f44>] (dump_stack) from [<803d17d0>] (check_preemption_disabled+0xc4/0xfc)
[<803d17d0>] (check_preemption_disabled) from [<80110eb8>] (__do_user_fault.constprop.4+0x24/0x88)
[<80110eb8>] (__do_user_fault.constprop.4) from [<801112e4>] (do_page_fault+0x2dc/0x310)
[<801112e4>] (do_page_fault) from [<801012a8>] (do_DataAbort+0x38/0xb8)
[<801012a8>] (do_DataAbort) from [<8010b03c>] (__dabt_usr+0x3c/0x40)
Exception stack(0xb21d1fb0 to 0xb21d1ff8)
1fa0:                                     fffffff4 00000000 00000054 fffffff4
1fc0: 00000000 00000000 7ed81cc8 7ed81ca0 0007a440 00000000 00000000 00000000
1fe0: 00000000 7ed81ca0 00010493 0001f330 20030010 ffffffff

Signed-off-by: Liu Xiang <liu.xiang@zlingsmart.com>
---
 arch/arm/include/asm/system_misc.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h
index 66f6a3ae6..4a55cfbdf 100644
--- a/arch/arm/include/asm/system_misc.h
+++ b/arch/arm/include/asm/system_misc.h
@@ -22,9 +22,10 @@ DECLARE_PER_CPU(harden_branch_predictor_fn_t, harden_branch_predictor_fn);
 static inline void harden_branch_predictor(void)
 {
 	harden_branch_predictor_fn_t fn = per_cpu(harden_branch_predictor_fn,
-						  smp_processor_id());
+						  get_cpu());
 	if (fn)
 		fn();
+	put_cpu();
 }
 #else
 #define harden_branch_predictor() do { } while (0)
-- 
2.17.1


WARNING: multiple messages have this Message-ID (diff)
From: Liu Xiang <liu.xiang@zlingsmart.com>
To: linux@armlinux.org.uk
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, liuxiang_1999@126.com,
	liuxiang1999@gmail.com, Liu Xiang <liu.xiang@zlingsmart.com>
Subject: [PATCH] ARM: fix smp_processor_id() in preemptible warning in harden_branch_predictor()
Date: Thu, 25 Mar 2021 17:50:49 +0800	[thread overview]
Message-ID: <20210325095049.6948-1-liu.xiang@zlingsmart.com> (raw)

When CONFIG_HARDEN_BRANCH_PREDICTOR is selected and user aborts occur,
there is a warning:

BUG: using smp_processor_id() in preemptible [00000000] code: errnotest/577
caller is __do_user_fault.constprop.4+0x24/0x88
CPU: 1 PID: 577 Comm: errnotest Not tainted 4.14.188-rt87-fmsh-00004-g58055877a #1
Hardware name: FMSH PSOC Platform
[<8010d6d4>] (unwind_backtrace) from [<8010a228>] (show_stack+0x10/0x14)
[<8010a228>] (show_stack) from [<80698f44>] (dump_stack+0x7c/0x98)
[<80698f44>] (dump_stack) from [<803d17d0>] (check_preemption_disabled+0xc4/0xfc)
[<803d17d0>] (check_preemption_disabled) from [<80110eb8>] (__do_user_fault.constprop.4+0x24/0x88)
[<80110eb8>] (__do_user_fault.constprop.4) from [<801112e4>] (do_page_fault+0x2dc/0x310)
[<801112e4>] (do_page_fault) from [<801012a8>] (do_DataAbort+0x38/0xb8)
[<801012a8>] (do_DataAbort) from [<8010b03c>] (__dabt_usr+0x3c/0x40)
Exception stack(0xb21d1fb0 to 0xb21d1ff8)
1fa0:                                     fffffff4 00000000 00000054 fffffff4
1fc0: 00000000 00000000 7ed81cc8 7ed81ca0 0007a440 00000000 00000000 00000000
1fe0: 00000000 7ed81ca0 00010493 0001f330 20030010 ffffffff

Signed-off-by: Liu Xiang <liu.xiang@zlingsmart.com>
---
 arch/arm/include/asm/system_misc.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h
index 66f6a3ae6..4a55cfbdf 100644
--- a/arch/arm/include/asm/system_misc.h
+++ b/arch/arm/include/asm/system_misc.h
@@ -22,9 +22,10 @@ DECLARE_PER_CPU(harden_branch_predictor_fn_t, harden_branch_predictor_fn);
 static inline void harden_branch_predictor(void)
 {
 	harden_branch_predictor_fn_t fn = per_cpu(harden_branch_predictor_fn,
-						  smp_processor_id());
+						  get_cpu());
 	if (fn)
 		fn();
+	put_cpu();
 }
 #else
 #define harden_branch_predictor() do { } while (0)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2021-03-25  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25  9:50 Liu Xiang [this message]
2021-03-25  9:50 ` [PATCH] ARM: fix smp_processor_id() in preemptible warning in harden_branch_predictor() Liu Xiang
2021-03-25 10:06 ` Russell King - ARM Linux admin
2021-03-25 10:06   ` Russell King - ARM Linux admin
2021-03-25 13:32   ` Liu Xiang
2021-03-25 13:32     ` Liu Xiang
2021-03-25 14:20     ` Russell King - ARM Linux admin
2021-03-25 14:20       ` Russell King - ARM Linux admin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210325095049.6948-1-liu.xiang@zlingsmart.com \
    --to=liu.xiang@zlingsmart.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=liuxiang1999@gmail.com \
    --cc=liuxiang_1999@126.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.