[PATCH v1 2/2] aarch64: enable Permission Indirection Extension

Mark Rutland mark.rutland at arm.com
Thu Jun 15 08:12:57 PDT 2023


On Tue, Mar 14, 2023 at 04:24:28PM +0000, Mark Brown wrote:
> On Fri, Mar 10, 2023 at 05:36:57PM +0000, Joey Gouly wrote:
> 
> > +	if (mrs_field(ID_AA64MMFR3_EL1, S1PIE))
> > +		scr |= SCR_EL3_PIEN;
> > +
> 
> This is needed for all of S[12]_{PIE,POE} - the rest could be added
> incrementally of course.

Given we know about that now, I'd prefer if we handled them all now, e.g.

	if (mrs_field(ID_AA64MMFR3_EL1, S1PIE) ||
	    mrs_field(ID_AA64MMFR3_EL1, S2PIE) ||
	    mrs_field(ID_AA64MMFR3_EL1, S1POE) ||
	    mrs_field(ID_AA64MMFR3_EL1, S2POE))
		scr |= SCR_EL3_PIEN;

... or do the same as with pauth and have a helper:

static inline bool cpu_has_permission_indirection(void)
{
	const unsigned long mask = ID_AA64MMFR3_EL1_S1PIE |
				   ID_AA64MMFR3_EL1_S2PIE |
				   ID_AA64MMFR3_EL1_S1POE |
				   ID_AA64MMFR3_EL1_S2POE);
	
	return mrs(ID_AA64MMFR3_EL1) & mask
}

.. and then:

	if (cpu_has_permission_indirection())
		scr |= SCR_EL3_PIEN;


For consistency with pauth I guess the second option is best.

Thanks,
Mark.



More information about the linux-arm-kernel mailing list