]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
powerpc/book3s64/pkeys: Remove is_pkey_enabled()
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Thu, 9 Jul 2020 03:29:46 +0000 (08:59 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 21 Jul 2020 14:01:22 +0000 (00:01 +1000)
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
arch/powerpc/mm/book3s64/pkeys.c

index d45864a77066b1ea425b4a271b0e73ff0476ee55..792b36aa9619e184add4ffba31607f9b3a346c49 100644 (file)
@@ -251,25 +251,6 @@ static inline void write_iamr(u64 value)
        mtspr(SPRN_IAMR, value);
 }
 
-static inline u64 read_uamor(void)
-{
-       return mfspr(SPRN_UAMOR);
-}
-
-static bool is_pkey_enabled(int pkey)
-{
-       u64 uamor = read_uamor();
-       u64 pkey_bits = 0x3ul << pkeyshift(pkey);
-       u64 uamor_pkey_bits = (uamor & pkey_bits);
-
-       /*
-        * Both the bits in UAMOR corresponding to the key should be set or
-        * reset.
-        */
-       WARN_ON(uamor_pkey_bits && (uamor_pkey_bits != pkey_bits));
-       return !!(uamor_pkey_bits);
-}
-
 static inline void init_amr(int pkey, u8 init_bits)
 {
        u64 new_amr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey));
@@ -295,8 +276,18 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
 {
        u64 new_amr_bits = 0x0ul;
        u64 new_iamr_bits = 0x0ul;
+       u64 pkey_bits, uamor_pkey_bits;
 
-       if (!is_pkey_enabled(pkey))
+       /*
+        * Check whether the key is disabled by UAMOR.
+        */
+       pkey_bits = 0x3ul << pkeyshift(pkey);
+       uamor_pkey_bits = (default_uamor & pkey_bits);
+
+       /*
+        * Both the bits in UAMOR corresponding to the key should be set
+        */
+       if (uamor_pkey_bits != pkey_bits)
                return -EINVAL;
 
        if (init_val & PKEY_DISABLE_EXECUTE) {