I would like to implement a piece of code as an SMM handler in LinuxBIOS.
I think the sensible way to do this is write an SMI handler that is controlled by Linux (or other OS). BIOS code should not run once the OS is up.
But SMM code isn't BIOS code -- it is "virtual hardware".
There are lots of OS-dependent issues that a BIOS just can not know about. To pick a simple example: Are you going to ensure that your SMI handler is SMP-safe? If so, how, and for which OS?
SMM is not reentrant, and the SMM hardware takes care of that (modulo some hardware bugs, heh). The SMM code has to go to great pains to ensure following the proper ordering rules for the real and the virtual hardware (most implementations fail miserably here) -- this is really hard to do, the whole SMM concept is such a bad design.
I know of one vendor BIOS (EFI on the LLNL Thunder cluster, an itanium-based machine, from several years ago) that was not re-entrant or SMP-safe, and it was not fun when two CPUs tried to enter this BIOS at once.
Fun eh.
Once the OS is up, the CPU should always be under control of the OS. So, build an SMI handler for linux -- if you really need to do this.
If you're going to implement SMM in the OS, you can just as well simply implement the necessary code in some device drivers. Much easier.
Segher