[NSWI004] Trouble with process initiation

Vojtech Horky horky at d3s.mff.cuni.cz
Sun Feb 16 21:05:02 CET 2020


Hello.

Dne 16. 02. 20 v 19:55 Martin Koreček napsal(a):
> We are unable to initiate the userspace processes. We set the $ra and 
> $status in the process thread context and also set the SP, which seems 
> to be the problem.
> It seems like a TLB exception is raised inside cpu_switch_ context when 
> SP should be modified, which maybe makes sense. Using the virtual SP 
> address perhaps isn't a good idea, since cpu_switch_context isn't 
> running in the correct AS yet (or so I think). Neither does using the 
> physical or kernel address.
> Are we doing it completely wrong, or is there a simple fix to make this 
> work?

This problem was mentioned already several times. Setting SP in the 
context_t has no meaning as SP is restored from cpu_switch_context 
parameter.

However, I see the following issues with your code:

Copying the application code: note that the binary itself starts at 
virtual address zero, i.e. the null page and 3 pages of stack are 
already part of the image. Shifting image_ram by ENTRY_POINT without 
shifting image_bin by the same amount is wrong.

Setting userspace stack is probably correct in the end though the naming 
you use is extremely confusing.

I do not see now what is the root cause but you got the TLB exception 
when no entries are in TLB: so it is probably called from another 
exception (?) or you have wrong contents of $status register (?).

Also note that your message contains "badva: 0x" (i.e. the number is 
missing).

- VH


More information about the NSWI004 mailing list