user_rip
user_cs
user_rflags
user_rsp
user_ss
low -> high
struct trap_frame {
uint64_t user_rip;
uint64_t user_cs;
uint64_t user_rflags;
uint64_t user_rsp;
uint64_t user_ss;
} __attribute__((packed)) tf;
void save_state(){
__asm__ __volatile__ (
".intel_syntax noprefix;"
"mov tf+16, cs;"
"pushf;"
"pop tf+24;"
"mov tf+32, rsp;"
"mov tf+40, ss;"
".att_syntax;"
);
tf.user_rip = (uint64_t)&shell;
}