Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #ifndef __SPARC_MMAN_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #define __SPARC_MMAN_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <uapi/asm/mman.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #define arch_mmap_check(addr,len,flags)	sparc_mmap_check(addr,len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) int sparc_mmap_check(unsigned long addr, unsigned long len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifdef CONFIG_SPARC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/adi_64.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static inline void ipi_set_tstate_mcde(void *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	struct mm_struct *mm = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	/* Set TSTATE_MCDE for the task using address map that ADI has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	 * enabled on if the task is running. If not, it will be set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	 * automatically at the next context switch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	if (current->mm == mm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		struct pt_regs *regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		regs = task_pt_regs(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		regs->tstate |= TSTATE_MCDE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define arch_calc_vm_prot_bits(prot, pkey) sparc_calc_vm_prot_bits(prot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static inline unsigned long sparc_calc_vm_prot_bits(unsigned long prot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (adi_capable() && (prot & PROT_ADI)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		struct pt_regs *regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		if (!current->mm->context.adi) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 			regs = task_pt_regs(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 			regs->tstate |= TSTATE_MCDE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 			current->mm->context.adi = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 			on_each_cpu_mask(mm_cpumask(current->mm),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 					 ipi_set_tstate_mcde, current->mm, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		return VM_SPARC_ADI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define arch_vm_get_page_prot(vm_flags) sparc_vm_get_page_prot(vm_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static inline pgprot_t sparc_vm_get_page_prot(unsigned long vm_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	return (vm_flags & VM_SPARC_ADI) ? __pgprot(_PAGE_MCD_4V) : __pgprot(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define arch_validate_prot(prot, addr) sparc_validate_prot(prot, addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static inline int sparc_validate_prot(unsigned long prot, unsigned long addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_ADI))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* arch_validate_flags() - Ensure combination of flags is valid for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)  *	VMA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static inline bool arch_validate_flags(unsigned long vm_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	/* If ADI is being enabled on this VMA, check for ADI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	 * capability on the platform and ensure VMA is suitable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	 * for ADI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	if (vm_flags & VM_SPARC_ADI) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 		if (!adi_capable())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 		/* ADI can not be enabled on PFN mapped pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 		if (vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 		/* Mergeable pages can become unmergeable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 		 * if ADI is enabled on them even if they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 		 * have identical data on them. This can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 		 * because ADI enabled pages with identical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 		 * data may still not have identical ADI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 		 * tags on them. Disallow ADI on mergeable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 		 * pages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 		if (vm_flags & VM_MERGEABLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #endif /* CONFIG_SPARC64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #endif /* __ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #endif /* __SPARC_MMAN_H__ */