| 1 | /* |
| 2 | * ARM security space helpers |
| 3 | * |
| 4 | * Provide ARMSecuritySpace and helpers for code that is not tied to CPU. |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | #ifndef HW_ARM_ARM_SECURITY_H |
| 10 | #define HW_ARM_ARM_SECURITY_H |
| 11 | |
| 12 | /* |
| 13 | * ARM v9 security states. |
| 14 | * The ordering of the enumeration corresponds to the low 2 bits |
| 15 | * of the GPI value, and (except for Root) the concat of NSE:NS. |
| 16 | */ |
| 17 | |
| 18 | typedef enum ARMSecuritySpace { |
| 19 | ARMSS_Secure = 0, |
| 20 | ARMSS_NonSecure = 1, |
| 21 | ARMSS_Root = 2, |
| 22 | ARMSS_Realm = 3, |
| 23 | } ARMSecuritySpace; |
| 24 | |
| 25 | /* Return true if @space is secure, in the pre-v9 sense. */ |
| 26 | static inline bool arm_space_is_secure(ARMSecuritySpace space) |
| 27 | { |
| 28 | return space == ARMSS_Secure || space == ARMSS_Root; |
| 29 | } |
| 30 | |
| 31 | /* Return the ARMSecuritySpace for @secure, assuming !RME or EL[0-2]. */ |
| 32 | static inline ARMSecuritySpace arm_secure_to_space(bool secure) |
| 33 | { |
| 34 | return secure ? ARMSS_Secure : ARMSS_NonSecure; |
| 35 | } |
| 36 | |
| 37 | #endif /* HW_ARM_ARM_SECURITY_H */ |