mman.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. */
  4. #ifndef _ASM_POWERPC_MMAN_H
  5. #define _ASM_POWERPC_MMAN_H
  6. #include <uapi/asm/mman.h>
  7. #ifdef CONFIG_PPC64
  8. #include <asm/cputable.h>
  9. #include <linux/mm.h>
  10. #include <linux/pkeys.h>
  11. #include <asm/cpu_has_feature.h>
  12. #include <asm/firmware.h>
  13. static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
  14. unsigned long pkey)
  15. {
  16. #ifdef CONFIG_PPC_MEM_KEYS
  17. return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey));
  18. #else
  19. return ((prot & PROT_SAO) ? VM_SAO : 0);
  20. #endif
  21. }
  22. #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
  23. static inline bool arch_validate_prot(unsigned long prot, unsigned long addr)
  24. {
  25. if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
  26. return false;
  27. if (prot & PROT_SAO) {
  28. if (!cpu_has_feature(CPU_FTR_SAO))
  29. return false;
  30. if (firmware_has_feature(FW_FEATURE_LPAR) &&
  31. !IS_ENABLED(CONFIG_PPC_PROT_SAO_LPAR))
  32. return false;
  33. }
  34. return true;
  35. }
  36. #define arch_validate_prot arch_validate_prot
  37. #endif /* CONFIG_PPC64 */
  38. #endif /* _ASM_POWERPC_MMAN_H */