ARM Exception Vector Table, high vectors (Raspberry Pi)
Posted: Sat Nov 21, 2020 12:57 pm
Hello everyone,
I ask again for your help as i find myself stuck, and can't understand what to do after i looked everywhere i could.
I'm trying to implement exception handling on my higher half kernel for Raspberry Pi. (ARMv6)
As i mapped the kernel into higher half (0xC0000000), i wanted to enable high vectors, so the exception vectors table is at 0xFFFF0000.
I mapped 1 MiB arround this address, and everything is fine. Now i need to populate the table.
There comes the problem : this table contains 1 instruction per vector. And branch instructions are relative to PC, +- 32 MiB only. (which isnt enough to go to ~0xC000000, where the rest of my kernel code is)
I can't use a bx instruction, cause i would have to load absolute address on a register before, and that would take 2 instructions.
The way i see it, i have only two options, that i don't like :
- Put every exception handler function just below or above 0xFFFF0000, with some kind of memcpy, copying it from ~0xC0000000 to ~+0xFFFF0000
- Put a function containing 2 instructions just below or above 0xFFFF0000, that does an absolute jump to ~0xC0000000 where the actual handling code is, and put a relative jump to that function in the vector table
Those options looks really bad to me : it feels like a dirty hack, and i don't like the idea of copying pieces of code everywhere and having to worry about relative addresses tranlations and such...
Maybe there is something i don't see, or maybe i didn't understand the exception vectors table well ?
Reading dwelch67's code (which isnt in higher half, so he doesnt have the same problem), it seems like he puts 2 instructions in the handler, and i don't understand how... https://github.com/dwelch67/raspberrypi ... tors.s#L63 but maybe i'm just not understanding what he does.
Thank you for reading, and thank you in advance for any help,
Valou3433
EDIT : I also looked at ARMv8 / 64 bits example, but exception handling there doesnt seem to be the same ; and i'm not familiar with that architecture anyway, i'm just beginning low level arm programming...
EDIT 2 : When i say above 0xFFFF0000, i mean above the table
I ask again for your help as i find myself stuck, and can't understand what to do after i looked everywhere i could.
I'm trying to implement exception handling on my higher half kernel for Raspberry Pi. (ARMv6)
As i mapped the kernel into higher half (0xC0000000), i wanted to enable high vectors, so the exception vectors table is at 0xFFFF0000.
I mapped 1 MiB arround this address, and everything is fine. Now i need to populate the table.
There comes the problem : this table contains 1 instruction per vector. And branch instructions are relative to PC, +- 32 MiB only. (which isnt enough to go to ~0xC000000, where the rest of my kernel code is)
I can't use a bx instruction, cause i would have to load absolute address on a register before, and that would take 2 instructions.
The way i see it, i have only two options, that i don't like :
- Put every exception handler function just below or above 0xFFFF0000, with some kind of memcpy, copying it from ~0xC0000000 to ~+0xFFFF0000
- Put a function containing 2 instructions just below or above 0xFFFF0000, that does an absolute jump to ~0xC0000000 where the actual handling code is, and put a relative jump to that function in the vector table
Those options looks really bad to me : it feels like a dirty hack, and i don't like the idea of copying pieces of code everywhere and having to worry about relative addresses tranlations and such...
Maybe there is something i don't see, or maybe i didn't understand the exception vectors table well ?
Reading dwelch67's code (which isnt in higher half, so he doesnt have the same problem), it seems like he puts 2 instructions in the handler, and i don't understand how... https://github.com/dwelch67/raspberrypi ... tors.s#L63 but maybe i'm just not understanding what he does.
Thank you for reading, and thank you in advance for any help,
Valou3433
EDIT : I also looked at ARMv8 / 64 bits example, but exception handling there doesnt seem to be the same ; and i'm not familiar with that architecture anyway, i'm just beginning low level arm programming...
EDIT 2 : When i say above 0xFFFF0000, i mean above the table