If you are making hardware that goes between the CPU and the
rest of the world, then you can keep track of anything that's
going on with some hardware-software combination, external
to the chip you are analyzing. These things exist and they
are called emulators, even though most don't emulate anything,
they use the real chip, but provide the physical and logical
connections to the user. However, in the case of an already-made
machine, you are limited in what you can do on the machine
with software. For instance, to trap every memory access, you
would need a trap-handler and set all the memory to trap
on an access. This would a bit hard to do within the kernel
because all the code on that page would trap as instructions
were fetched. So, some mere "hook" won't do it, you need
a kernel that executes a kernel and I think one for Linux
already exists. So, before you get too involved, you might
want to check that out.