First of all, thank you all for your help! I got it to work. That said, I don't really understand what the problem was.
The function below created a structure containing the address to the function I call (see fn
). This address was later loaded into x19 before I would attempt BLR x19
.
struct task_struct * copy_process(unsigned long fn)
{
struct task_struct *p;
p = (struct task_struct *)get_free_page();
char buff[] = "0000000000000000";
parse_int((unsigned long)fn, buff, 16);
uart_send_string("fn: ");
uart_send_string(buff);
uart_send_string("\n");
// Configure the task struct
p->cpu_context.x19 = fn;
return p;
}
It suffices to comment out parse_int((unsigned long)fn, buff, 16);
and everything works as expected.
Here is what parse_int
looks like:
void parse_int(u64 number, char* str, int base) {
if(base > 36)
return;
int length = 0;
while (str[length] != '\0') {
str[length] = '0';
length++;
}
char remainder;
while(number >= 0 && length >= 0) {
length--;
remainder = (number % base);
if(remainder > 9) {
remainder -= 10;
str[length] = 'A' + remainder;
} else {
str[length] = '0' + remainder;
}
number /= base;
}
}
I guess somehow memory was getting corrupted in this call, I can't see how, though.
If you know the reason, feel free to jump in with an answer to the original problem and I'll mark it as the good one. I will also delete this answer of mine, as this is probably not helpful for someone with the same problem.
Thanks
sp
valid? No idea if that would cause the same exception. – Jesteresr_el1
can be trusted, then according to the manual this would be an "Address size fault, level 0 of translation or translation table base register", suggesting your page tables map to a physical address out of range... otherwise I agree with @Jester: makie sure thatsp
is valid, and additionally check if you have SP alignment checks enabled (and if so, make sure SP is actually 16-byte aligned). – SiguzaanotherFunc
screwed up the stack? Anyway, it seems like it would be useful to have a register dump at the site of theblr x19
, if you have a way to produce one. – Nate Eldredgefunction
rather than where you actually end up jumping to. What if you dump a few words from the absolute address0x80904
and see if they match the machine code of the function? – Nate Eldredge