linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] ARM: Use generic BUG() handler
Date: Wed, 2 Mar 2011 10:59:50 +0000	[thread overview]
Message-ID: <20110302105930.GA2363@arm.com> (raw)
In-Reply-To: <AANLkTinMnZAupxn7oYFhqkN1Y0OD-eyN=UeRpw96no9r@mail.gmail.com>

On Tue, Mar 01, 2011 at 08:34:37AM -0800, Simon Glass wrote:

[...]

> 
> It seems I am lucky with the gcc I am using. I would have thought this
> would be a pretty fundamental feature, but yes I did notice that %c
> wasn't used anywhere.
> 
> Would this kernel feature be acceptable as a selectable config option
> on ARM then?
> 
> Thanks,
> Simon

+/* A suitable undefined instruction to use for ARM bug handling */
+#define BUG_INSTR ".word 0xec000000"

^ This needs to be changed, since it's not an architecturally
undefined encoding -- i.e., it may get used in the future to
mean something real.

See arch/arm/kernel/{ptrace,kprobes}.c for examples of
suitable encodings.



Rather than relying on the %c inline asm feature, can we work
around it?

Since we are writing a macro anyway, we can paste most of the
arguments in when the macro is expanded, rather than relying on
the inline assembler to do it.

This works for everything except sizeof (struct bug_entry)
which the preprocessor obviously can't understand.  But I suspect
we don't really need that: we need to keep the directives that
generate the bug entry in sync with the definition of struct bug_entry
anyway (don't we?) -- so the amount of extra padding needed is
currently zero and should always be a constant.

So, maybe something like this would work:

(Note -- I haven't tested this!)

+
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+#define BUG() __BUG(__FILE__, __LINE__, BUG_INSTR)
+#define __BUG(__file, __line, __bug_instr)			\
+do {								\
+	asm volatile("1:\t" __bug_instr "\n"		q	\
+		     ".pushsection .rodata.str, \"a\"\n"	\
+		     "2:\t.asciz \"" #__file "\"\n"		\
+		     ".popsection\n"				\ 
+		     ".pushsection __bug_table,\"a\"\n"		\
+		     "3:\t.word 1b, 2b\n"			\
+		     "\t.hword " #__line ", 0\n"		\
+		     ".popsection"				\
+	unreachable();						\
+} while (0)

Cheers
---Dave

  parent reply	other threads:[~2011-03-02 10:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-01  0:27 [RFC PATCH] ARM: Use generic BUG() handler Simon Glass
2011-03-01  8:49 ` Russell King - ARM Linux
2011-03-01  8:59   ` Russell King - ARM Linux
2011-03-01  9:12     ` Mikael Pettersson
2011-03-01 10:03       ` Russell King - ARM Linux
2011-03-01 16:34         ` Simon Glass
2011-03-01 20:28           ` Russell King - ARM Linux
2011-03-02 10:59           ` Dave Martin [this message]
2011-03-03 14:11             ` Russell King - ARM Linux
2011-03-03 14:44               ` Dave Martin
2011-03-01 17:48 ` Dave Martin
2011-03-01 20:32 ` Russell King - ARM Linux

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=20110302105930.GA2363@arm.com \
    --to=dave.martin@linaro.org \
    --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).