[RFC v7 25/25] powerpc: Enable pkey subsystem
Michael Ellerman
mpe at ellerman.id.au
Fri Aug 18 15:07:16 AEST 2017
Ram Pai <linuxram at us.ibm.com> writes:
> On Thu, Aug 17, 2017 at 05:30:27PM -0300, Thiago Jung Bauermann wrote:
>> Ram Pai <linuxram at us.ibm.com> writes:
>> > On Thu, Aug 10, 2017 at 06:27:34PM -0300, Thiago Jung Bauermann wrote:
>> >> Ram Pai <linuxram at us.ibm.com> writes:
>> >> > @@ -227,6 +229,24 @@ static inline void pkey_mm_init(struct mm_struct *mm)
>> >> > mm->context.execute_only_pkey = -1;
>> >> > }
>> >> >
>> >> > +static inline void pkey_mmu_values(int total_data, int total_execute)
>> >> > +{
>> >> > + /*
>> >> > + * since any pkey can be used for data or execute, we
>> >> > + * will just treat all keys as equal and track them
>> >> > + * as one entity.
>> >> > + */
>> >> > + pkeys_total = total_data + total_execute;
>> >> > +}
>> >>
>> >> Right now this works because the firmware reports 0 execute keys in the
>> >> device tree, but if (when?) it is fixed to report 32 execute keys as
>> >> well as 32 data keys (which are the same keys), any place using
>> >> pkeys_total expecting it to mean the number of keys that are available
>> >> will be broken. This includes pkey_initialize and mm_pkey_is_allocated.
>> >
>> > Good point. we should just ignore total_execute. It should
>> > be the same value as total_data on the latest platforms.
>> > On older platforms it will continue to be zero.
>>
>> Indeed. There should just be a special case to disable execute
>> protection for P7.
>
> Ok. we should disable execute protection for P7 and earlier generations of CPU.
You should do what the device tree says you can do.
If it says there are no execute keys then you shouldn't touch the IAMR.
If you don't want to handle the case where there are 0 execute keys but
some data keys then you should do:
total_keys = min(data_keys, exec_keys);
cheers
More information about the Linuxppc-dev
mailing list