~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/mm/mmap.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/arm64/mm/mmap.c (Version linux-6.12-rc7) and /arch/i386/mm/mmap.c (Version linux-5.3.18)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * Based on arch/arm/mm/mmap.c                    
  4  *                                                
  5  * Copyright (C) 2012 ARM Ltd.                    
  6  */                                               
  7                                                   
  8 #include <linux/io.h>                             
  9 #include <linux/memblock.h>                       
 10 #include <linux/mm.h>                             
 11 #include <linux/types.h>                          
 12                                                   
 13 #include <asm/cpufeature.h>                       
 14 #include <asm/page.h>                             
 15                                                   
 16 static pgprot_t protection_map[16] __ro_after_    
 17         [VM_NONE]                                 
 18         [VM_READ]                                 
 19         [VM_WRITE]                                
 20         [VM_WRITE | VM_READ]                      
 21         /* PAGE_EXECONLY if Enhanced PAN */       
 22         [VM_EXEC]                                 
 23         [VM_EXEC | VM_READ]                       
 24         [VM_EXEC | VM_WRITE]                      
 25         [VM_EXEC | VM_WRITE | VM_READ]            
 26         [VM_SHARED]                               
 27         [VM_SHARED | VM_READ]                     
 28         [VM_SHARED | VM_WRITE]                    
 29         [VM_SHARED | VM_WRITE | VM_READ]          
 30         /* PAGE_EXECONLY if Enhanced PAN */       
 31         [VM_SHARED | VM_EXEC]                     
 32         [VM_SHARED | VM_EXEC | VM_READ]           
 33         [VM_SHARED | VM_EXEC | VM_WRITE]          
 34         [VM_SHARED | VM_EXEC | VM_WRITE | VM_R    
 35 };                                                
 36                                                   
 37 /*                                                
 38  * You really shouldn't be using read() or wri    
 39  * away in the future.                            
 40  */                                               
 41 int valid_phys_addr_range(phys_addr_t addr, si    
 42 {                                                 
 43         /*                                        
 44          * Check whether addr is covered by a     
 45          * MEMBLOCK_NOMAP attribute, and wheth    
 46          * entire range. In theory, this could    
 47          * if the range is covered by distinct    
 48          * that only differ in other attribute    
 49          * attributes have been defined, and i    
 50          * follows that /dev/mem read() calls     
 51          * such boundaries.                       
 52          */                                       
 53         return memblock_is_region_memory(addr,    
 54                memblock_is_map_memory(addr);      
 55 }                                                 
 56                                                   
 57 /*                                                
 58  * Do not allow /dev/mem mappings beyond the s    
 59  */                                               
 60 int valid_mmap_phys_addr_range(unsigned long p    
 61 {                                                 
 62         return !(((pfn << PAGE_SHIFT) + size)     
 63 }                                                 
 64                                                   
 65 static int __init adjust_protection_map(void)     
 66 {                                                 
 67         /*                                        
 68          * With Enhanced PAN we can honour the    
 69          * there is no PAN override with such     
 70          */                                       
 71         if (cpus_have_cap(ARM64_HAS_EPAN)) {      
 72                 protection_map[VM_EXEC] = PAGE    
 73                 protection_map[VM_EXEC | VM_SH    
 74         }                                         
 75                                                   
 76         if (lpa2_is_enabled())                    
 77                 for (int i = 0; i < ARRAY_SIZE    
 78                         pgprot_val(protection_    
 79                                                   
 80         return 0;                                 
 81 }                                                 
 82 arch_initcall(adjust_protection_map);             
 83                                                   
 84 pgprot_t vm_get_page_prot(unsigned long vm_fla    
 85 {                                                 
 86         pteval_t prot = pgprot_val(protection_    
 87                                    (VM_READ|VM    
 88                                                   
 89         if (vm_flags & VM_ARM64_BTI)              
 90                 prot |= PTE_GP;                   
 91                                                   
 92         /*                                        
 93          * There are two conditions required f    
 94          * memory type: (1) the user requested    
 95          * mmap() or mprotect() and (2) the co    
 96          * register (1) as VM_MTE in the vma->    
 97          * VM_MTE_ALLOWED. Note that the latte    
 98          * mmap() call since mprotect() does n    
 99          * Checking for VM_MTE only is suffici    
100          * does not permit (VM_MTE & !VM_MTE_A    
101          */                                       
102         if (vm_flags & VM_MTE)                    
103                 prot |= PTE_ATTRINDX(MT_NORMAL    
104                                                   
105 #ifdef CONFIG_ARCH_HAS_PKEYS                      
106         if (system_supports_poe()) {              
107                 if (vm_flags & VM_PKEY_BIT0)      
108                         prot |= PTE_PO_IDX_0;     
109                 if (vm_flags & VM_PKEY_BIT1)      
110                         prot |= PTE_PO_IDX_1;     
111                 if (vm_flags & VM_PKEY_BIT2)      
112                         prot |= PTE_PO_IDX_2;     
113         }                                         
114 #endif                                            
115                                                   
116         return __pgprot(prot);                    
117 }                                                 
118 EXPORT_SYMBOL(vm_get_page_prot);                  
119                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php