Research Article

TEE-Watchdog: Mitigating Unauthorized Activities within Trusted Execution Environments in ARM-Based Low-Power IoT Devices

Algorithm 3

Enabling MPU protection using the Procedure Set_Protection
Input:             ⊳ Address of the region and permissions
Output:
Procedure Set_Protection
Set bit 0 of MPU_CTRL to 0           ⊳ Disables MPU
Set bits [31 : 5] of MPU_RBAR to    ⊳ Sets region address to be protected
if AP==ReadWritePriv then
  Set bits [2 : 1] of MPU_RBAR to 00  ⊳ Sets Access Permission of to be Read/Write by privileged code only
else if AP==ReadWrite then
  Set bits [2 : 1] of MPU_RBAR to 01 ⊳ Sets Access Permission of to be Read/Write by any code
else if AP==ReadOnlyPriv then
  Set bits [2 : 1] of MPU_RBAR to 10 ⊳ Sets Access Permission of to be Read Only by privileged code only
else if AP==ReadOnly then
  Set bits [2 : 1] of MPU_RBAR to 11   ⊳ Sets Access Permission of to be Read Only by any code
else
  Set bit 0 of MPU_CTRL to 1      ⊳ Enables MPU protection for the region
  
  return
end
Set bit 0 of MPU_CTRL to 1                    ⊳ Enables MPU protection for the region
                            ⊳ The procedure is successful
return;
End Procedure