So I'm playing around with reading system registers in the kernel and I've recently run into a bit of a roadblock.
In ARM64, certain system registers (e.g. OSECCR_EL1
) are not always implemented. If they are implemented, then trying an mrs instruction is fine - nothing bad happens. But if they AREN'T implemented, then the kernel throws an Oops due to an undefined instruction.
This isn't unreasonable, however, as I'm inside a kernel module while running this mrs
instruction, I don't see an easy way to recover from this oops, or even recognize that a particular system register read was going to fail in the first place.
Is there any easy way to identify beforehand whether a system register is valid, or at the very least, handle a kernel oops in a way that doesn't immediately stop my kernel module function execution?