From: jason77.wang@gmail.com (Hui Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: imx6q restart is broken
Date: Fri, 17 Aug 2012 16:11:32 +0800 [thread overview]
Message-ID: <502DFCB4.9050502@gmail.com> (raw)
In-Reply-To: <20120817034854.GE24242@S2101-09.ap.freescale.net>
Shawn Guo wrote:
> On Thu, Aug 16, 2012 at 11:34:46PM +0100, Russell King - ARM Linux wrote:
>
>> This doesn't get around the problem that userspace can still effectively
>> issue a DoS against the system by just running a dmb in a tight loop.
>> Or maybe this would have a much more dramatic effect:
>>
>> while (1) {
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> asm("dmb");
>> }
>>
>> and make that 3 seconds to get a ps listing turn into something much
>> longer?
>>
>>
> >From my testing, no, it does not get the thing even worse.
>
>
>> I think what needs to happen here (while we wait) is someone _with_ the
>> problem needs to experiment, and find out how many nops are needed for
>> the DMB not to have much effect in cpu_relax(). If it turns out we just
>> need to put one nop in, then that's not _too_ bad.
>>
>
> At least, I need to have 5 nops to get rid of the issue, something like
> below.
>
> Regards,
> Shawn
>
> --8<---
>
> diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
> index 99afa74..3e1b099 100644
> --- a/arch/arm/include/asm/processor.h
> +++ b/arch/arm/include/asm/processor.h
> @@ -80,7 +80,14 @@ extern void release_thread(struct task_struct *);
> unsigned long get_wchan(struct task_struct *p);
>
> #if __LINUX_ARM_ARCH__ == 6 || defined(CONFIG_ARM_ERRATA_754327)
> -#define cpu_relax() smp_mb()
> +#define cpu_relax() do { \
> + asm("nop"); \
> + asm("nop"); \
> + asm("nop"); \
> + asm("nop"); \
> + asm("nop"); \
> + smp_mb(); \
> + } while (0)
> #else
> #define cpu_relax() barrier()
> #endif
>
>
>
In my test, if the number of nops is equal or more than 4, the reset can
work fine.
diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h
index 0511238..3ad4258 100644
--- a/arch/arm/include/asm/barrier.h
+++ b/arch/arm/include/asm/barrier.h
@@ -22,7 +22,11 @@
: : "r" (0) : "memory")
#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
: : "r" (0) : "memory")
-#define dmb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" \
+#define dmb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5\n" \
+ "nop\n" \
+ "nop\n" \
+ "nop\n" \
+ "nop\n" \
: : "r" (0) : "memory")
next prev parent reply other threads:[~2012-08-17 8:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-08 10:18 imx6q restart is broken Shawn Guo
2012-08-08 10:53 ` Dirk Behme
2012-08-09 3:18 ` Hui Wang
2012-08-09 4:41 ` Shawn Guo
2012-08-09 6:32 ` Sascha Hauer
2012-08-09 8:06 ` Catalin Marinas
2012-08-09 8:18 ` Shawn Guo
2012-08-09 9:20 ` Russell King - ARM Linux
2012-08-09 12:01 ` Shawn Guo
2012-08-09 12:22 ` Shawn Guo
2012-08-09 13:57 ` Russell King - ARM Linux
2012-08-09 14:01 ` Russell King - ARM Linux
2012-08-09 14:24 ` Shawn Guo
2012-08-09 19:03 ` Matt Sealey
2012-08-09 21:07 ` Russell King - ARM Linux
2012-08-10 13:33 ` Matt Sealey
2012-08-10 13:53 ` Russell King - ARM Linux
2012-08-15 15:07 ` Rob Herring
2012-08-15 21:44 ` Russell King - ARM Linux
2012-08-16 2:31 ` Shawn Guo
2012-08-16 17:21 ` Matt Sealey
2012-08-16 22:34 ` Russell King - ARM Linux
2012-08-17 3:48 ` Shawn Guo
2012-08-17 8:11 ` Hui Wang [this message]
2012-08-19 15:26 ` Shawn Guo
2012-08-16 8:41 ` Catalin Marinas
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=502DFCB4.9050502@gmail.com \
--to=jason77.wang@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 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).