Subject: [PATCH v3 6/6] arm64: kernel: Add support for Privileged Access Never

From: [email-masked] (Will Deacon)
Date: Thu, 23 Jul 2015 13:00:03 +0100

On Tue, Jul 21, 2015 at 01:38:31PM +0100, Catalin Marinas wrote:
> On Tue, Jul 21, 2015 at 01:23:31PM +0100, James Morse wrote:
> > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> > index 94d98cd1aad8..149a36ea9673 100644
> > --- a/arch/arm64/mm/fault.c
> > +++ b/arch/arm64/mm/fault.c
> > @@ -30,9 +30,11 @@
> >  #include <linux/highmem.h>
> >  #include <linux/perf_event.h>
> >  
> > +#include <asm/cpufeature.h>
> >  #include <asm/exception.h>
> >  #include <asm/debug-monitors.h>
> >  #include <asm/esr.h>
> > +#include <asm/sysreg.h>
> >  #include <asm/system_misc.h>
> >  #include <asm/pgtable.h>
> >  #include <asm/tlbflush.h>
> > @@ -147,6 +149,13 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
> >  		__do_kernel_fault(mm, addr, esr, regs);
> >  }
> >  
> > +static bool pan_enabled(struct pt_regs *regs)
> > +{
> > +	if (IS_ENABLED(CONFIG_ARM64_PAN))
> > +		return ((regs->pstate & PSR_PAN_BIT) != 0);
> 
> Nitpick: no brackets needed for return.

Couldn't we just write this function as:

  return IS_ENABLED(CONFIG_ARM64_PAN) && (regs->pstate & PSR_PAN_BIT);

?

Will