Trace Hook Macros and MPU

Hello,

I am a university student and I am investigating security hardening capabilities on FreeRTOS for my thesis. I am planning to use an MPU to separate the kernel and application code into privileged and unprivileged regions.

During runtime, I would like to collect timing metadata for every task execution using the traceTASK_SWITCH_IN and traceTASK_SWITCHED_OUT macros (e.g. by using a high-precision hardware timer peripheral) and store the calculated execution time in a privileged section of memory. I was wondering if these macros are being executed within the privileged context of the scheduler which would enable me to do this.

Yes, that is how it is typically done. You may want to try Tracealyzer from Percepio (my company). This is free for academic use, just apply for an academic license.

2 Likes

Yes, these macros are called from vTaskSwitchContext which executes with elevated privilege. So you should be able to track timing as you proposed. Let us know if you face any problem.

1 Like