Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/book3s64/pkeys: Remove is_pkey_enabled()

There is only one caller to this function and the function is wrongly
named. Avoid further confusion w.r.t name and open code this at the
only call site. Also remove read_uamor(). There are no users for
the same after this.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200709032946.881753-24-aneesh.kumar@linux.ibm.com

authored by

Aneesh Kumar K.V and committed by
Michael Ellerman
482b9b39 3563b9be

+11 -20
+11 -20
arch/powerpc/mm/book3s64/pkeys.c
··· 251 251 mtspr(SPRN_IAMR, value); 252 252 } 253 253 254 - static inline u64 read_uamor(void) 255 - { 256 - return mfspr(SPRN_UAMOR); 257 - } 258 - 259 - static bool is_pkey_enabled(int pkey) 260 - { 261 - u64 uamor = read_uamor(); 262 - u64 pkey_bits = 0x3ul << pkeyshift(pkey); 263 - u64 uamor_pkey_bits = (uamor & pkey_bits); 264 - 265 - /* 266 - * Both the bits in UAMOR corresponding to the key should be set or 267 - * reset. 268 - */ 269 - WARN_ON(uamor_pkey_bits && (uamor_pkey_bits != pkey_bits)); 270 - return !!(uamor_pkey_bits); 271 - } 272 - 273 254 static inline void init_amr(int pkey, u8 init_bits) 274 255 { 275 256 u64 new_amr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey)); ··· 276 295 { 277 296 u64 new_amr_bits = 0x0ul; 278 297 u64 new_iamr_bits = 0x0ul; 298 + u64 pkey_bits, uamor_pkey_bits; 279 299 280 - if (!is_pkey_enabled(pkey)) 300 + /* 301 + * Check whether the key is disabled by UAMOR. 302 + */ 303 + pkey_bits = 0x3ul << pkeyshift(pkey); 304 + uamor_pkey_bits = (default_uamor & pkey_bits); 305 + 306 + /* 307 + * Both the bits in UAMOR corresponding to the key should be set 308 + */ 309 + if (uamor_pkey_bits != pkey_bits) 281 310 return -EINVAL; 282 311 283 312 if (init_val & PKEY_DISABLE_EXECUTE) {