Signaling/Messaging Userspace from Kernel


Justin Huang
 

Hi,

Could someone shed some light on ways in Zephyr for Kernel to signal, or send a message to, threads running in the userspace?

I see some examples using callback functions, but wonder if that is a good practice: it is generally a security risk to run a function provided by a userspace application in the supervisor mode.

Any thoughts/pointers/suggestions would be greatly appreciated.

Many thanks in advance and 
with kind regards,

Justin


Boie, Andrew P
 

  • I see some examples using callback functions, but wonder if that is a good practice: it is generally a security risk to run a function provided by a userspace application in the supervisor mode.

 

If you look closely you will see that there is no capability for user mode functions to install a callback handler. This type of operation is supervisor mode only.

 

  • Could someone shed some light on ways in Zephyr for Kernel to signal, or send a message to, threads running in the userspace?

 

In the callback handler the application has registered from supervisor mode (typically at application initialization), use an IPC object to wake up a user thread for further processing.

 

There’s some example code in samples/userspace/prod_consumer

 

This is something we’d like to iterate on further so if you can come up with some scenarios that you don’t think are well supported please file GH enhancement tickets and assign to  me for further discussion.

 

HTH,

Andrew

 

 

From: users@... <users@...> On Behalf Of Justin Huang
Sent: Saturday, January 18, 2020 10:38 AM
To: users@...
Subject: [Zephyr-users] Signaling/Messaging Userspace from Kernel

 

Hi,

 

Could someone shed some light on ways in Zephyr for Kernel to signal, or send a message to, threads running in the userspace?

 

I see some examples using callback functions, but wonder if that is a good practice: it is generally a security risk to run a function provided by a userspace application in the supervisor mode.

 

Any thoughts/pointers/suggestions would be greatly appreciated.

 

Many thanks in advance and 

with kind regards,

 

Justin


Justin Huang
 

Thank you Andrew very much for the explanation! Very helpful.

Justin


From: Boie, Andrew P <andrew.p.boie@...>
Sent: Sunday, January 19, 2020 5:49 PM
To: Justin Huang <justin.y.huang@...>; users@... <users@...>
Subject: RE: [Zephyr-users] Signaling/Messaging Userspace from Kernel
 
  • I see some examples using callback functions, but wonder if that is a good practice: it is generally a security risk to run a function provided by a userspace application in the supervisor mode.

 

If you look closely you will see that there is no capability for user mode functions to install a callback handler. This type of operation is supervisor mode only.

 

  • Could someone shed some light on ways in Zephyr for Kernel to signal, or send a message to, threads running in the userspace?

 

In the callback handler the application has registered from supervisor mode (typically at application initialization), use an IPC object to wake up a user thread for further processing.

 

There’s some example code in samples/userspace/prod_consumer

 

This is something we’d like to iterate on further so if you can come up with some scenarios that you don’t think are well supported please file GH enhancement tickets and assign to  me for further discussion.

 

HTH,

Andrew

 

 

From: users@... <users@...> On Behalf Of Justin Huang
Sent: Saturday, January 18, 2020 10:38 AM
To: users@...
Subject: [Zephyr-users] Signaling/Messaging Userspace from Kernel

 

Hi,

 

Could someone shed some light on ways in Zephyr for Kernel to signal, or send a message to, threads running in the userspace?

 

I see some examples using callback functions, but wonder if that is a good practice: it is generally a security risk to run a function provided by a userspace application in the supervisor mode.

 

Any thoughts/pointers/suggestions would be greatly appreciated.

 

Many thanks in advance and 

with kind regards,

 

Justin