Skip to contentSkip to conversation

Saving and restoring CPU state

Qemu-devel eady 3 participants 3 messages Apr 12, 2007 – Apr 18, 2007

lore
Share & tools
lore

eady

author
#0 lore raw

I'm still looking for any suggestions on how to save and restore the target cpu state from within a custom instruction in op.c. I basically want a custom instruction to save the cpu state to a data structure and then continue on normally, a second custom instruction would then be used to restore the cpu state from the saved data structure at a later time thereby rolling back the execution of the cpu. I've tried saving and restoring env->eip within my custom instructions but this has no effect.

Thanks,
Nuri

I'm experimenting a bit with QEMU and am in need of a way to save and restore X86 CPU state including the pc so that the processor state can be rolled back to re execute from the previous point. I've found the functions "cpu_x86_fsave" and "cpu_restore_state" but do not understand them well enough to use them. Does anyone have tips on how to store the processor state in an auxiliary data structure and then restore it at a later point?

Thanks
Nuri

#1 lore raw
Quoted 7 lines · eady

I'm still looking for any suggestions on how to save and restore the target cpu state from within a custom instruction in op.c. I basically want a custom instruction to save the cpu state to a data structure and then continue on normally, a second custom instruction would then be used to restore the cpu state from the saved data structure at a later time thereby rolling back the execution of the cpu. I've tried saving and restoring env->eip within my custom instructions but this has no effect.

How do you roll back all the writes to memory and interactions with devices the processor may have done?

Saving and restoring _just_ the processor state is what setjmp/longjmp does, and there's all sorts of restrictions on its' use...

Rob

Signature · 2 lines
Penguicon 5.0 Apr 20-22, Linux Expo/SF Convention.  Bruce Schneier, Christine 
Peterson, Steve Jackson, Randy Milholland, Elizabeth Bear, Charlie Stross...
#2 lore raw
Quoted 9 lines · Rob Landley
Quoted 7 lines · eady

I'm still looking for any suggestions on how to save and restore the target cpu state from within a custom instruction in op.c. I basically want a custom instruction to save the cpu state to a data structure and then continue on normally, a second custom instruction would then be used to restore the cpu state from the saved data structure at a later time thereby rolling back the execution of the cpu. I've tried saving and restoring env->eip within my custom instructions but this has no effect.

Quoted 5 lines

How do you roll back all the writes to memory and interactions with devices the processor may have done?

Saving and restoring _just_ the processor state is what setjmp/longjmp does, and there's all sorts of restrictions on its' use...

Saving and restoring just (part of) the processor state kindof is done by i386 instructions like syscall/sysret, sysenter/sysexit, SMM/RSM stuff and other instructions. Have a look at target-i386/helper.c

HTH,
Andrzej