lx_emul: set task 'stack' member

Instead of allocating the stack via 'kmalloc' point it to the actual
stack used by the task. This addresses issues with the USB
host-controller driver where sometimes hub port enumeration is not
working.

Fixes #4522.
This commit is contained in:
Josef Söntgen 2022-06-02 14:07:11 +02:00 committed by Christian Helmuth
parent 9375e8d010
commit 9d383037e4
5 changed files with 28 additions and 0 deletions

View File

@ -42,6 +42,8 @@ void lx_emul_task_schedule(int block);
void lx_emul_task_name(struct task_struct * task, const char * name);
void *lx_emul_task_stack(struct task_struct const * task);
#ifdef __cplusplus
}
#endif

View File

@ -73,6 +73,7 @@ class Lx_kit::Task : public Genode::List<Lx_kit::Task>::Element
Name name() const;
void * lx_task() const;
int pid() const;
void * stack() const;
void block();
void unblock();

View File

@ -77,13 +77,22 @@ pid_t kernel_thread(int (* fn)(void *),void * arg,unsigned long flags)
.signal = signal,
};
#ifndef CONFIG_THREAD_INFO_IN_TASK
/* On arm, the 'thread_info' is hidden behind 'task->stack', we must
* therefore initialise the member before calling 'task_thread_info()'. */
task->stack = kmalloc(sizeof(struct thread_info), THREADINFO_GFP);
#endif
#ifndef CONFIG_X86
task_thread_info(task)->preempt_count = 0;
#endif
lx_emul_task_create(task, "kthread", task->pid, fn, arg);
#ifdef CONFIG_THREAD_INFO_IN_TASK
task->stack = lx_emul_task_stack(task);
#endif
return task->pid;
err_task:

View File

@ -87,3 +87,16 @@ extern "C" void lx_emul_task_name(struct task_struct * t, const char * name)
{
Lx_kit::env().scheduler.task((void*)t).name(name);
}
extern "C" void * lx_emul_task_stack(struct task_struct const * t)
{
void * ret = nullptr;
Lx_kit::env().scheduler.for_each_task([&] (Lx_kit::Task const & task) {
if (t == task.lx_task())
ret = task.stack();
});
return ret;
}

View File

@ -50,6 +50,9 @@ Task::Type Task::type() const { return _type; }
void * Task::lx_task() const { return _lx_task; }
void * Task::stack() const { return _stack; }
int Task::pid() const { return _pid; }