Commit 482b9b39 authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Michael Ellerman

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: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200709032946.881753-24-aneesh.kumar@linux.ibm.com
parent 3563b9be
...@@ -251,25 +251,6 @@ static inline void write_iamr(u64 value) ...@@ -251,25 +251,6 @@ static inline void write_iamr(u64 value)
mtspr(SPRN_IAMR, 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) static inline void init_amr(int pkey, u8 init_bits)
{ {
u64 new_amr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey)); 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, ...@@ -295,8 +276,18 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
{ {
u64 new_amr_bits = 0x0ul; u64 new_amr_bits = 0x0ul;
u64 new_iamr_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; return -EINVAL;
if (init_val & PKEY_DISABLE_EXECUTE) { if (init_val & PKEY_DISABLE_EXECUTE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment