[PATCH v1] arm: Support for the PXN CPU feature on ARMv7
Arnd Bergmann
arnd at arndb.de
Mon Nov 24 07:26:10 PST 2014
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
More information about the linux-arm-kernel
mailing list