Skip to content

Commit 482b9b3

Browse files
kvaneeshmpe
authored andcommitted
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
1 parent 3563b9b commit 482b9b3

1 file changed

Lines changed: 11 additions & 20 deletions

File tree

‎arch/powerpc/mm/book3s64/pkeys.c‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,6 @@ static inline void write_iamr(u64 value)
251251
mtspr(SPRN_IAMR, value);
252252
}
253253

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-
273254
static inline void init_amr(int pkey, u8 init_bits)
274255
{
275256
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,
295276
{
296277
u64 new_amr_bits = 0x0ul;
297278
u64 new_iamr_bits = 0x0ul;
279+
u64 pkey_bits, uamor_pkey_bits;
298280

299-
if (!is_pkey_enabled(pkey))
281+
/*
282+
* Check whether the key is disabled by UAMOR.
283+
*/
284+
pkey_bits = 0x3ul << pkeyshift(pkey);
285+
uamor_pkey_bits = (default_uamor & pkey_bits);
286+
287+
/*
288+
* Both the bits in UAMOR corresponding to the key should be set
289+
*/
290+
if (uamor_pkey_bits != pkey_bits)
300291
return -EINVAL;
301292

302293
if (init_val & PKEY_DISABLE_EXECUTE) {

0 commit comments

Comments
 (0)