On Fri, Aug 11, 2017 at 03:39:14PM +1000, Michael Ellerman wrote: > Thiago Jung Bauermann <bauer...@linux.vnet.ibm.com> writes: > > > Ram Pai <linux...@us.ibm.com> writes: > >> static inline void pkey_initialize(void) > >> { > >> + int os_reserved, i; > >> + > >> /* disable the pkey system till everything > >> * is in place. A patch further down the > >> * line will enable it. > >> */ > >> pkey_inited = false; > >> + > >> + /* Lets assume 32 keys */ > >> + pkeys_total = 32; > >> + > >> +#ifdef CONFIG_PPC_4K_PAGES > >> + /* > >> + * the OS can manage only 8 pkeys > >> + * due to its inability to represent > >> + * them in the linux 4K-PTE. > >> + */ > >> + os_reserved = pkeys_total-8; > >> +#else > >> + os_reserved = 0; > >> +#endif > >> + /* > >> + * Bits are in LE format. > >> + * NOTE: 1, 0 are reserved. > >> + * key 0 is the default key, which allows read/write/execute. > >> + * key 1 is recommended not to be used. > >> + * PowerISA(3.0) page 1015, programming note. > >> + */ > >> + initial_allocation_mask = ~0x0; > >> + for (i = 2; i < (pkeys_total - os_reserved); i++) > >> + initial_allocation_mask &= ~(0x1<<i); > >> } > >> #endif /*_ASM_PPC64_PKEYS_H */ > > > > In v6, key 31 was also reserved, but it's not in this version. Is this > > intentional? > > That whole thing could be replaced with two constants. > > Except it can't, because we can't just hard code the number of keys. It > needs to come either from the device tree or be based on the CPU we're > running on. > > > Isn't it better for this function to be in pkeys.c? Ideally, functions > > should be in .c files not in headers unless they're very small or > > performance sensitive IMHO. > > Yes. No reason for that to be in a header AFAICS.
Yes can be moved into the pkeys.c file. It was a simple function to begin with....but not so any more. RP