Detecting changes to kernel registers Linux/MIPS

Written 2020-12-31

Tags:Interrupt MIPS Exception Linux 

The MIPS processor exception handling sequence uses two reserved general-purpose registers, k0 and k1. When the exception occurs, the core jumps to the exception handler address, then using only k0 and k1, the handler must save enough state to handle the exception.

From userspace, we can poll for changes to k0/k1, and track unique values, like so:

I'm not really sure what these numbers represent - they're only written by the Linux kernel, so they might be something interesting. They don't seem to line up with /proc/self/maps, but they also don't seem to line up with /proc/iomem.