From 4383c8fae30c8a44c9fe07b7cef3b86f0c5cd72b Mon Sep 17 00:00:00 2001 From: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Thu, 30 Jul 2020 19:32:31 -0700 Subject: [PATCH] Change the xRunningPrivileged check from "!=true" to "==false" (#109) The expected behaviour of portIS_PRIVILEGED is: - return 0 if the processor is not running privileged. - return 1 if the processor is running privileged. Some TI ports do not return 1 when the processor is running privileged causing the following check to fail: if( xRunningPrivileged != pdTRUE ) This commit change the check to: if( xRunningPrivileged == pdFALSE ). It ensures that the check is successful even on the ports which return incorrect value from portIS_PRIVILEGED when the processor is running privileged. See https://forums.freertos.org/t/kernel-bug-nested-mpu-wrapper-calls-generate-an-exception/10391 Signed-off-by: Gaurav Aggarwal --- portable/Common/mpu_wrappers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/portable/Common/mpu_wrappers.c b/portable/Common/mpu_wrappers.c index ca59b8d41..c29bd2837 100644 --- a/portable/Common/mpu_wrappers.c +++ b/portable/Common/mpu_wrappers.c @@ -68,7 +68,7 @@ BaseType_t xPortRaisePrivilege( void ) /* FREERTOS_SYSTEM_CALL */ xRunningPrivileged = portIS_PRIVILEGED(); /* If the processor is not already privileged, raise privilege. */ - if( xRunningPrivileged != pdTRUE ) + if( xRunningPrivileged == pdFALSE ) { portRAISE_PRIVILEGE(); } @@ -79,7 +79,7 @@ BaseType_t xPortRaisePrivilege( void ) /* FREERTOS_SYSTEM_CALL */ void vPortResetPrivilege( BaseType_t xRunningPrivileged ) { - if( xRunningPrivileged != pdTRUE ) + if( xRunningPrivileged == pdFALSE ) { portRESET_PRIVILEGE(); }