From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1] arm: Support for the PXN CPU feature on ARMv7
Date: Mon, 24 Nov 2014 16:26:10 +0100 [thread overview]
Message-ID: <2837195.5EVM7cu8cA@wuerfel> (raw)
In-Reply-To: <20141124150652.GF15872@e104818-lin.cambridge.arm.com>
On Monday 24 November 2014 15:06:53 Catalin Marinas wrote:
> On Sat, Nov 22, 2014 at 10:42:36AM +0000, Jungseung Lee wrote:
> > diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
> In general we put the #ifdef outside the function:
>
> #if __LINUX_ARM_ARCH__ >= 7 && !defined(CONFIG_ARM_LPAE)
> static inline bool cpu_has_classic_pxn(void)
> {
> unsigned int vmsa = (read_cpuid_ext(CPUID_EXT_MMFR0) & 0xf) >> 0;
> return vmsa == 4;
> }
> #else
> static inline bool cpu_has_classic_pxn(void)
> {
> return false;
> }
> #endif
>
> I used __LINUX_ARM_ARCH__ instead of CONFIG_CPU_V7 to cope with kernel
> images built for both v6 and v7. You could also check for
> cpu_architecture() >= 7, though with a bit of performance impact.
Regarding the style, I think the best way to express it is
if (__LINUX_ARM_ARCH__ >= 7 && !IS_ENABLED(CONFIG_ARM_LPAE) && (vmsa == 4))
return true;
return false;
This way you can avoid the #ifdef and still get the compile-time
optimization.
Checking for (__LINUX_ARM_ARCH__ >= 6 && cpu_architecture >= 7) would
also make it work for a combined armv6/v7 kernel.
Arnd
next prev parent reply other threads:[~2014-11-24 15:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-22 10:42 [PATCH v1] arm: Support for the PXN CPU feature on ARMv7 Jungseung Lee
2014-11-24 15:06 ` Catalin Marinas
2014-11-24 15:26 ` Arnd Bergmann [this message]
2014-11-24 15:57 ` Catalin Marinas
2014-11-25 16:21 ` Jungseung Lee
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=2837195.5EVM7cu8cA@wuerfel \
--to=arnd@arndb.de \
--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).