1
2#ifndef __SPARC_MMAN_H__
3#define __SPARC_MMAN_H__
4
5#include <uapi/asm/mman.h>
6
7#ifndef __ASSEMBLY__
8#define arch_mmap_check(addr,len,flags) sparc_mmap_check(addr,len)
9int sparc_mmap_check(unsigned long addr, unsigned long len);
10
11#ifdef CONFIG_SPARC64
12#include <asm/adi_64.h>
13
14static inline void ipi_set_tstate_mcde(void *arg)
15{
16 struct mm_struct *mm = arg;
17
18
19
20
21
22 if (current->mm == mm) {
23 struct pt_regs *regs;
24
25 regs = task_pt_regs(current);
26 regs->tstate |= TSTATE_MCDE;
27 }
28}
29
30#define arch_calc_vm_prot_bits(prot, pkey) sparc_calc_vm_prot_bits(prot)
31static inline unsigned long sparc_calc_vm_prot_bits(unsigned long prot)
32{
33 if (adi_capable() && (prot & PROT_ADI)) {
34 struct pt_regs *regs;
35
36 if (!current->mm->context.adi) {
37 regs = task_pt_regs(current);
38 regs->tstate |= TSTATE_MCDE;
39 current->mm->context.adi = true;
40 on_each_cpu_mask(mm_cpumask(current->mm),
41 ipi_set_tstate_mcde, current->mm, 0);
42 }
43 return VM_SPARC_ADI;
44 } else {
45 return 0;
46 }
47}
48
49#define arch_vm_get_page_prot(vm_flags) sparc_vm_get_page_prot(vm_flags)
50static inline pgprot_t sparc_vm_get_page_prot(unsigned long vm_flags)
51{
52 return (vm_flags & VM_SPARC_ADI) ? __pgprot(_PAGE_MCD_4V) : __pgprot(0);
53}
54
55#define arch_validate_prot(prot, addr) sparc_validate_prot(prot, addr)
56static inline int sparc_validate_prot(unsigned long prot, unsigned long addr)
57{
58 if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_ADI))
59 return 0;
60 return 1;
61}
62
63#define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)
64
65
66
67static inline bool arch_validate_flags(unsigned long vm_flags)
68{
69
70
71
72
73 if (vm_flags & VM_SPARC_ADI) {
74 if (!adi_capable())
75 return false;
76
77
78 if (vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
79 return false;
80
81
82
83
84
85
86
87
88
89 if (vm_flags & VM_MERGEABLE)
90 return false;
91 }
92 return true;
93}
94#endif
95
96#endif
97#endif
98