Skip to content

Commit

Permalink
powerpc: helper function to read, write AMR, IAMR, UAMOR registers
Browse files Browse the repository at this point in the history
Implements helper functions to read and write the key related
registers; AMR, IAMR, UAMOR.

AMR register tracks the read,write permission of a key
IAMR register tracks the execute permission of a key
UAMOR register enables and disables a key

Acked-by: Balbir Singh <bsingharora@gmail.com>
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Ram Pai authored and Michael Ellerman committed Jan 20, 2018
1 parent 4fb158f commit 1b4037d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions arch/powerpc/mm/pkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,39 @@ void pkey_mm_init(struct mm_struct *mm)
return;
mm_pkey_allocation_map(mm) = initial_allocation_mask;
}

static inline u64 read_amr(void)
{
return mfspr(SPRN_AMR);
}

static inline void write_amr(u64 value)
{
mtspr(SPRN_AMR, value);
}

static inline u64 read_iamr(void)
{
if (!likely(pkey_execute_disable_supported))
return 0x0UL;

return mfspr(SPRN_IAMR);
}

static inline void write_iamr(u64 value)
{
if (!likely(pkey_execute_disable_supported))
return;

mtspr(SPRN_IAMR, value);
}

static inline u64 read_uamor(void)
{
return mfspr(SPRN_UAMOR);
}

static inline void write_uamor(u64 value)
{
mtspr(SPRN_UAMOR, value);
}

0 comments on commit 1b4037d

Please sign in to comment.