0001
0002 #ifndef __SPARC_MMAN_H__
0003 #define __SPARC_MMAN_H__
0004
0005 #include <uapi/asm/mman.h>
0006
0007 #ifndef __ASSEMBLY__
0008 #define arch_mmap_check(addr,len,flags) sparc_mmap_check(addr,len)
0009 int sparc_mmap_check(unsigned long addr, unsigned long len);
0010
0011 #ifdef CONFIG_SPARC64
0012 #include <asm/adi_64.h>
0013
0014 static inline void ipi_set_tstate_mcde(void *arg)
0015 {
0016 struct mm_struct *mm = arg;
0017
0018
0019
0020
0021
0022 if (current->mm == mm) {
0023 struct pt_regs *regs;
0024
0025 regs = task_pt_regs(current);
0026 regs->tstate |= TSTATE_MCDE;
0027 }
0028 }
0029
0030 #define arch_calc_vm_prot_bits(prot, pkey) sparc_calc_vm_prot_bits(prot)
0031 static inline unsigned long sparc_calc_vm_prot_bits(unsigned long prot)
0032 {
0033 if (adi_capable() && (prot & PROT_ADI)) {
0034 struct pt_regs *regs;
0035
0036 if (!current->mm->context.adi) {
0037 regs = task_pt_regs(current);
0038 regs->tstate |= TSTATE_MCDE;
0039 current->mm->context.adi = true;
0040 on_each_cpu_mask(mm_cpumask(current->mm),
0041 ipi_set_tstate_mcde, current->mm, 0);
0042 }
0043 return VM_SPARC_ADI;
0044 } else {
0045 return 0;
0046 }
0047 }
0048
0049 #define arch_validate_prot(prot, addr) sparc_validate_prot(prot, addr)
0050 static inline int sparc_validate_prot(unsigned long prot, unsigned long addr)
0051 {
0052 if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_ADI))
0053 return 0;
0054 return 1;
0055 }
0056
0057 #define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)
0058
0059
0060
0061 static inline bool arch_validate_flags(unsigned long vm_flags)
0062 {
0063
0064
0065
0066
0067 if (vm_flags & VM_SPARC_ADI) {
0068 if (!adi_capable())
0069 return false;
0070
0071
0072 if (vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
0073 return false;
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 if (vm_flags & VM_MERGEABLE)
0084 return false;
0085 }
0086 return true;
0087 }
0088 #endif
0089
0090 #endif
0091 #endif