por.h 635 B

123456789101112131415161718192021222324252627282930313233
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2023 Arm Ltd.
  4. */
  5. #ifndef _ASM_ARM64_POR_H
  6. #define _ASM_ARM64_POR_H
  7. #define POR_BITS_PER_PKEY 4
  8. #define POR_ELx_IDX(por_elx, idx) (((por_elx) >> ((idx) * POR_BITS_PER_PKEY)) & 0xf)
  9. static inline bool por_elx_allows_read(u64 por, u8 pkey)
  10. {
  11. u8 perm = POR_ELx_IDX(por, pkey);
  12. return perm & POE_R;
  13. }
  14. static inline bool por_elx_allows_write(u64 por, u8 pkey)
  15. {
  16. u8 perm = POR_ELx_IDX(por, pkey);
  17. return perm & POE_W;
  18. }
  19. static inline bool por_elx_allows_exec(u64 por, u8 pkey)
  20. {
  21. u8 perm = POR_ELx_IDX(por, pkey);
  22. return perm & POE_X;
  23. }
  24. #endif /* _ASM_ARM64_POR_H */