From: murzin.v@gmail.com (Vladimir Murzin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: add check for global exclusive monitor
Date: Mon, 18 Feb 2013 20:26:50 +0400 [thread overview]
Message-ID: <1361204810-5335-1-git-send-email-murzin.v@gmail.com> (raw)
Since ARMv6 new atomic instructions have been introduced:
ldrex/strex. Several implementation are possible based on (1) global
and local exclusive monitors and (2) local exclusive monitor and snoop
unit.
In case of the 2nd option exclusive store operation on uncached
region may be faulty.
Check for availability of the global monitor to provide some hint about
possible issues.
Signed-off-by: Vladimir Murzin <murzin.v@gmail.com>
---
arch/arm/include/asm/bugs.h | 14 ++++++++++++--
arch/arm/mm/fault-armv.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/arch/arm/include/asm/bugs.h b/arch/arm/include/asm/bugs.h
index a97f1ea..230432e 100644
--- a/arch/arm/include/asm/bugs.h
+++ b/arch/arm/include/asm/bugs.h
@@ -13,9 +13,19 @@
#ifdef CONFIG_MMU
extern void check_writebuffer_bugs(void);
-#define check_bugs() check_writebuffer_bugs()
+#if __LINUX_ARM_ARCH__ < 6
+static void check_gmonitor_bugs(void) {};
#else
-#define check_bugs() do { } while (0)
+extern void check_gmonitor_bugs(void);
+#endif
+
+static inline void check_bugs(void)
+{
+ check_writebuffer_bugs();
+ check_gmonitor_bugs();
+}
+#else
+static inline void check_bugs(void) { }
#endif
#endif
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index 7599e26..c12846b 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -206,6 +206,49 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
__flush_icache_all();
}
}
+#else
+void __init check_gmonitor_bugs(void)
+{
+ struct page *page;
+ const char *reason;
+ unsigned long res = 1;
+
+ printk(KERN_INFO "CPU: Testing for global monitor: ");
+
+ page = alloc_page(GFP_KERNEL);
+ if (page) {
+ unsigned long *p;
+ pgprot_t prot = __pgprot_modify(PAGE_KERNEL,
+ L_PTE_MT_MASK, L_PTE_MT_UNCACHED);
+
+ p = vmap(&page, 1, VM_IOREMAP, prot);
+
+ if (p) {
+ int temp;
+
+ __asm__ __volatile__( \
+ "ldrex %1, [%2]\n" \
+ "strex %0, %1, [%2]" \
+ : "=&r" (res), "=&r" (temp) \
+ : "r" (p) \
+ : "cc", "memory");
+
+ reason = "n\\a (atomic ops may be faulty)";
+ } else {
+ reason = "unable to map memory\n";
+ }
+
+ vunmap(p);
+ put_page(page);
+ } else {
+ reason = "unable to grab page\n";
+ }
+
+ if (res)
+ printk("failed, %s\n", reason);
+ else
+ printk("ok\n");
+}
#endif /* __LINUX_ARM_ARCH__ < 6 */
/*
--
1.7.8.6
next reply other threads:[~2013-02-18 16:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-18 16:26 Vladimir Murzin [this message]
2013-02-18 16:44 ` [PATCH] arm: add check for global exclusive monitor Russell King - ARM Linux
[not found] ` <20130219105534.GA31156@murzin.rnd.samsung.ru>
2013-02-20 4:55 ` Vladimir Murzin
2013-02-20 10:59 ` Russell King - ARM Linux
2013-02-22 16:46 ` Vladimir Murzin
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=1361204810-5335-1-git-send-email-murzin.v@gmail.com \
--to=murzin.v@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).