forked from epagris/FreeRTOS-Kernel
		
	Make RAM regions non-executable
This commit makes the privileged RAM and stack regions non-executable. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
		
							parent
							
								
									acd9279fc2
								
							
						
					
					
						commit
						c4ad77f694
					
				@ -637,6 +637,7 @@ static void prvSetupMPU( void )
 | 
			
		||||
 | 
			
		||||
        portMPU_REGION_ATTRIBUTE_REG = ( portMPU_REGION_PRIVILEGED_READ_WRITE ) |
 | 
			
		||||
                                       ( portMPU_REGION_CACHEABLE_BUFFERABLE ) |
 | 
			
		||||
                                       ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
                                       prvGetMPURegionSizeSetting( ( uint32_t ) __privileged_data_end__ - ( uint32_t ) __privileged_data_start__ ) |
 | 
			
		||||
                                       ( portMPU_REGION_ENABLE );
 | 
			
		||||
 | 
			
		||||
@ -736,6 +737,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
 | 
			
		||||
        xMPUSettings->xRegion[ 0 ].ulRegionAttribute =
 | 
			
		||||
            ( portMPU_REGION_READ_WRITE ) |
 | 
			
		||||
            ( portMPU_REGION_CACHEABLE_BUFFERABLE ) |
 | 
			
		||||
            ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
            ( prvGetMPURegionSizeSetting( ( uint32_t ) __SRAM_segment_end__ - ( uint32_t ) __SRAM_segment_start__ ) ) |
 | 
			
		||||
            ( portMPU_REGION_ENABLE );
 | 
			
		||||
 | 
			
		||||
@ -761,7 +763,8 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
 | 
			
		||||
                ( portSTACK_REGION ); /* Region number. */
 | 
			
		||||
 | 
			
		||||
            xMPUSettings->xRegion[ 0 ].ulRegionAttribute =
 | 
			
		||||
                ( portMPU_REGION_READ_WRITE ) | /* Read and write. */
 | 
			
		||||
                ( portMPU_REGION_READ_WRITE ) |
 | 
			
		||||
                ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
                ( prvGetMPURegionSizeSetting( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) ) |
 | 
			
		||||
                ( portMPU_REGION_CACHEABLE_BUFFERABLE ) |
 | 
			
		||||
                ( portMPU_REGION_ENABLE );
 | 
			
		||||
 | 
			
		||||
@ -723,6 +723,7 @@ static void prvSetupMPU( void )
 | 
			
		||||
                                          ( portPRIVILEGED_RAM_REGION );
 | 
			
		||||
 | 
			
		||||
        portMPU_REGION_ATTRIBUTE_REG = ( portMPU_REGION_PRIVILEGED_READ_WRITE ) |
 | 
			
		||||
                                       ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
                                       ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
                                       prvGetMPURegionSizeSetting( ( uint32_t ) __privileged_data_end__ - ( uint32_t ) __privileged_data_start__ ) |
 | 
			
		||||
                                       ( portMPU_REGION_ENABLE );
 | 
			
		||||
@ -834,6 +835,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
 | 
			
		||||
 | 
			
		||||
        xMPUSettings->xRegion[ 0 ].ulRegionAttribute =
 | 
			
		||||
            ( portMPU_REGION_READ_WRITE ) |
 | 
			
		||||
            ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
            ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
            ( prvGetMPURegionSizeSetting( ( uint32_t ) __SRAM_segment_end__ - ( uint32_t ) __SRAM_segment_start__ ) ) |
 | 
			
		||||
            ( portMPU_REGION_ENABLE );
 | 
			
		||||
@ -860,7 +862,8 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
 | 
			
		||||
                ( portSTACK_REGION ); /* Region number. */
 | 
			
		||||
 | 
			
		||||
            xMPUSettings->xRegion[ 0 ].ulRegionAttribute =
 | 
			
		||||
                ( portMPU_REGION_READ_WRITE ) | /* Read and write. */
 | 
			
		||||
                ( portMPU_REGION_READ_WRITE ) |
 | 
			
		||||
                ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
                ( prvGetMPURegionSizeSetting( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) ) |
 | 
			
		||||
                ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
                ( portMPU_REGION_ENABLE );
 | 
			
		||||
 | 
			
		||||
@ -562,6 +562,7 @@ static void prvSetupMPU( void )
 | 
			
		||||
                                          ( portPRIVILEGED_RAM_REGION );
 | 
			
		||||
 | 
			
		||||
        portMPU_REGION_ATTRIBUTE_REG = ( portMPU_REGION_PRIVILEGED_READ_WRITE ) |
 | 
			
		||||
                                       ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
                                       ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
                                       prvGetMPURegionSizeSetting( ( uint32_t ) __privileged_data_end__ - ( uint32_t ) __privileged_data_start__ ) |
 | 
			
		||||
                                       ( portMPU_REGION_ENABLE );
 | 
			
		||||
@ -631,6 +632,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
 | 
			
		||||
 | 
			
		||||
        xMPUSettings->xRegion[ 0 ].ulRegionAttribute =
 | 
			
		||||
            ( portMPU_REGION_READ_WRITE ) |
 | 
			
		||||
            ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
            ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
            ( prvGetMPURegionSizeSetting( ( uint32_t ) __SRAM_segment_end__ - ( uint32_t ) __SRAM_segment_start__ ) ) |
 | 
			
		||||
            ( portMPU_REGION_ENABLE );
 | 
			
		||||
@ -657,7 +659,8 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
 | 
			
		||||
                ( portSTACK_REGION ); /* Region number. */
 | 
			
		||||
 | 
			
		||||
            xMPUSettings->xRegion[ 0 ].ulRegionAttribute =
 | 
			
		||||
                ( portMPU_REGION_READ_WRITE ) | /* Read and write. */
 | 
			
		||||
                ( portMPU_REGION_READ_WRITE ) |
 | 
			
		||||
                ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
                ( prvGetMPURegionSizeSetting( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) ) |
 | 
			
		||||
                ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
                ( portMPU_REGION_ENABLE );
 | 
			
		||||
 | 
			
		||||
@ -726,6 +726,7 @@ static void prvSetupMPU( void )
 | 
			
		||||
                                          ( portPRIVILEGED_RAM_REGION );
 | 
			
		||||
 | 
			
		||||
        portMPU_REGION_ATTRIBUTE_REG = ( portMPU_REGION_PRIVILEGED_READ_WRITE ) |
 | 
			
		||||
                                       ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
                                       ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
                                       prvGetMPURegionSizeSetting( ( uint32_t ) __privileged_data_end__ - ( uint32_t ) __privileged_data_start__ ) |
 | 
			
		||||
                                       ( portMPU_REGION_ENABLE );
 | 
			
		||||
@ -825,6 +826,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
 | 
			
		||||
 | 
			
		||||
        xMPUSettings->xRegion[ 0 ].ulRegionAttribute =
 | 
			
		||||
            ( portMPU_REGION_READ_WRITE ) |
 | 
			
		||||
            ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
            ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
            ( prvGetMPURegionSizeSetting( ( uint32_t ) __SRAM_segment_end__ - ( uint32_t ) __SRAM_segment_start__ ) ) |
 | 
			
		||||
            ( portMPU_REGION_ENABLE );
 | 
			
		||||
@ -851,7 +853,8 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
 | 
			
		||||
                ( portSTACK_REGION ); /* Region number. */
 | 
			
		||||
 | 
			
		||||
            xMPUSettings->xRegion[ 0 ].ulRegionAttribute =
 | 
			
		||||
                ( portMPU_REGION_READ_WRITE ) | /* Read and write. */
 | 
			
		||||
                ( portMPU_REGION_READ_WRITE ) |
 | 
			
		||||
                ( portMPU_REGION_EXECUTE_NEVER ) |
 | 
			
		||||
                ( prvGetMPURegionSizeSetting( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) ) |
 | 
			
		||||
                ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
 | 
			
		||||
                ( portMPU_REGION_ENABLE );
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user