From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 0/5] Fix Thumb-2 undef handling for mixed-arch kernels
Date: Thu, 11 Aug 2011 14:10:54 +0100 [thread overview]
Message-ID: <20110811131054.GB2336@arm.com> (raw)
In-Reply-To: <1312975897.7800.20.camel@computer2>
On Wed, Aug 10, 2011 at 12:31:37PM +0100, Tixy wrote:
> On Wed, 2011-08-10 at 11:13 +0100, Dave Martin wrote:
> > As a side-effect, this also changes cpu_architecture from a
> > function into a global variable initialised at boot-time, which is
> > probably a sensible idea anyway.
>
> One possible pitfall of this is if the variable didn't get set up before
> it's first use. I have looked at all the uses and this doesn't seem to
> be a problem though.
I thought of that. I believe the code is safe as-is, but it's not too
maintenance-friendly, so...
>
> An alternative to defend against this is to make cpu_architecture() an
> inline function returning the value of the global variable like:
>
> inline int cpu_architecture(void)
> {
> BUG_ON(the_cpu_architecture == CPU_ARCH_UNKNOWN);
> return the_cpu_architecture;
> }
>
> This has the bonus of not needing to change users of the the function.
Sounds like a good idea. I got rid of the function because I didn't like
calling a function from the undef handler entry code, but an inline
function which just reads the variable seems like the best of both worlds.
I would continue to read the variable directly from the undef handler,
but this will not get called until userspace starts -- by which time the
inline C function will have been called a few times from C code.
If cpu_architecture is unexpectedly read as zero from the undef handler,
we will get some unexpected SIGILLs in userspace -- so this will get
noticed (rather than causing silent errors). However, I think the kernel
should always hit BUG() before that point is reached, if using your
suggested inline function.
As you say, it takes away a lot of the patch churn too.
I'll follow up with a revision based on this suggestion.
This also gets rid of the kprobes- and s3c24xx-specific patches.
Cheers
---Dave
next prev parent reply other threads:[~2011-08-11 13:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-10 10:13 [RFC PATCH 0/5] Fix Thumb-2 undef handling for mixed-arch kernels Dave Martin
2011-08-10 10:13 ` [RFC PATCH 1/5] ARM: Make cpu_alignment into a global variable Dave Martin
2011-08-10 11:38 ` Tixy
2011-08-10 10:13 ` [RFC PATCH 2/5] ARM: s3c24xx: Reference cpu_architecture as " Dave Martin
2011-08-10 10:13 ` [RFC PATCH 3/5] ARM: kprobes: " Dave Martin
2011-08-10 11:43 ` Tixy
2011-08-10 10:13 ` [RFC PATCH 4/5] ARM: entry: Remove unnecessary masking when decoding Thumb-2 instructions Dave Martin
2011-08-10 10:13 ` [RFC PATCH 5/5] ARM: entry: Fix Thumb-2 undef handling for multi-CPU kernels Dave Martin
2011-08-10 11:55 ` Tixy
2011-08-11 13:04 ` Dave Martin
2011-09-01 14:52 ` Arnd Bergmann
2011-09-07 10:54 ` Dave Martin
2011-09-12 10:33 ` Dave Martin
2011-08-10 11:31 ` [RFC PATCH 0/5] Fix Thumb-2 undef handling for mixed-arch kernels Tixy
2011-08-11 13:10 ` Dave Martin [this message]
2011-08-15 23:13 ` Nicolas Pitre
2011-08-16 9:04 ` Dave Martin
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=20110811131054.GB2336@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).