From: Rouven Czerwinski <r.czerwin...@pengutronix.de>

Guard the check by IS_ENABLED() to make it possible to verify 32-bit and
64-bit optee headers.

Signed-off-by: Rouven Czerwinski <r.czerwin...@pengutronix.de>
Signed-off-by: Marco Felsch <m.fel...@pengutronix.de>
---
 common/optee.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/common/optee.c b/common/optee.c
index 32a6c0a15b94..fd2b03d06d2d 100644
--- a/common/optee.c
+++ b/common/optee.c
@@ -14,8 +14,14 @@ int optee_verify_header(struct optee_header *hdr)
                return -EINVAL;
        }
 
-       if (hdr->arch != OPTEE_ARCH_ARM32 || hdr->init_load_addr_hi) {
-               pr_err("Only 32bit supported\n");
+       if (IS_ENABLED(CPU_V7) &&
+           (hdr->arch != OPTEE_ARCH_ARM32 || hdr->init_load_addr_hi)) {
+               pr_err("Wrong OP-TEE Arch for ARM v7 CPU\n");
+               return -EINVAL;
+       }
+
+       if (IS_ENABLED(CPU_V8) && hdr->arch != OPTEE_ARCH_ARM64) {
+               pr_err("Wrong OP-TEE Arch for ARM v8 CPU\n");
                return -EINVAL;
        }
 
-- 
2.39.2


Reply via email to