You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fiddeling around with usermode and futexes I get a "syscall z_vrfy_k_futex_wait failed check: Memory region 0x200060b0 (size 4) write access denied" which I cant seem to get around. Using k_object_access_grant() goes to no avail. Checking access to my globally declared struct k_futex yields that not even the main thread has access to it. Can fix that by granting access to it. But the user threads still not having access.
Can anyone push me in the right direction?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings,
fiddeling around with usermode and futexes I get a "syscall z_vrfy_k_futex_wait failed check: Memory region 0x200060b0 (size 4) write access denied" which I cant seem to get around. Using k_object_access_grant() goes to no avail. Checking access to my globally declared struct k_futex yields that not even the main thread has access to it. Can fix that by granting access to it. But the user threads still not having access.
Can anyone push me in the right direction?
Following are the main.c and prj.conf
`
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
//#include <zephyr/sys/internal/kobject_internal.h>
#include <zephyr/sys/kobject.h>
LOG_MODULE_REGISTER(futex, LOG_LEVEL_DBG);
struct k_futex running_f = {1};
#define STACK_SIZE 1024
#define STACK_PRIO 5
//create stack and thread area
K_THREAD_STACK_DEFINE(runner_stack, STACK_SIZE);
struct k_thread runner_data;
//runner thread entry point
void runner_thread(void *, void *, void *)
{
// k_object_access_grant(&running_f, k_current_get());
while(1){
LOG_INF("Runner: in %s mode", k_is_user_context() ? "user" : "kernel");
LOG_INF("Runner: before wake");
k_futex_wake(&running_f, false);
LOG_INF("Runner: after wake");
k_msleep(1000);
}
}
K_THREAD_STACK_DEFINE(guard_stack, STACK_SIZE);
struct k_thread guard_data;
void guard_thread(void *, void *, void *)
{
// k_object_access_grant(&running_f, k_current_get());
while(1){
LOG_INF("Guard: in %s mode", k_is_user_context() ? "user" : "kernel");
LOG_INF("Guard: before wait");
k_futex_wait(&running_f, 1, K_FOREVER);
LOG_INF("Guard: after wait");
k_msleep(1000);
}
}
int main(void)
{
}
`
CONFIG_LOG=y CONFIG_USERSPACE=y
*** Booting Zephyr OS build zephyr-v3.5.0-3496-g87d056bd31b1 *** [00:00:00.584,564] <inf> futex: Main: in kernel mode [00:00:00.584,625] <err> os: thread 0x20001070 (5) does not have permission on k_futex 0x200060b0 [00:00:00.584,655] <err> os: permission bitmap 00 00 |.. [00:00:00.584,686] <inf> futex: running_f is no valid object [00:00:00.584,716] <inf> futex: running_f is an valid object [00:00:00.584,716] <inf> futex: Start of main [00:00:00.584,930] <inf> futex: Guard: in user mode [00:00:00.584,930] <inf> futex: Guard: before wait [00:00:00.585,021] <err> os: syscall z_vrfy_k_futex_wait failed check: Memory region 0x200060b0 (size 4) write access denied
Using zephyr v3.5.1.
I cant use k_object_alloc like here #62187 due to k_futex not having an _init function.
Thank in advance.
Beta Was this translation helpful? Give feedback.
All reactions