Hi,
dakami wrote:
Poking at some weird things, figured this might be a good place to ask.
Suppose code running on one core, wanted to change RIP (longjmp) on another core.
Is there a direct way to do that? /proc/kallsyms on Linux has a bunch of interesting stuff in low memory, is anything like a memory map of registers? I can imagine poking interrupt vectors but I'm wondering if there's something not quite so passive.
To do these things (on 80x86); you use the local APIC on one CPU to send an "inter-processor interrupt" (IPI) to the other CPU/s. The other CPUs receive the interrupt and start an interrupt hander, where the interrupt handler can do anything you like.
dakami wrote:
Alternatively, suppose RIP was sitting on a HLT instruction in main memory. If I just rewrite that instruction does the processor just wake up and go, like a PAUSEing spinlock?
Cross-modifying code requires synchronisation (otherwise the CPU can continue executing the old version of the code without realising it was changed). If one CPU is executing HLT and you replace the HLT instruction, then you'd need an interrupt to break out of the "already executing HLT", where the interrupt handler would serialise the instruction pipeline to make sure the CPU notices that the HLT was replaced with something else.
Cheers,
Brendan