IRC channel logs
2026-01-16.log
back to list of logs
<damo22>preserving a register during interrupts/traps is hairy <damo22>youpi: if i need a value saved for determining where to return to at the end of an interrupt or trap, can i just put it on the stack after pusha and PUSH_SEGMENTS? or will eg R_CS(%rsp) be then at the wrong place? <damo22>s/where to return to/whether swapgs is needed or not <damo22>can i store it in a segment register? :P <youpi>you can as well just look at the pushed cs value <youpi>ah, no, because gs might have been switched or not <damo22>yeah i need to save it in the SWAPGS_ENTRY thing <youpi>adding something on the stack is possible, yes, it just needs an update of the offsets <youpi>you can just add it if you need <damo22>does that mean r11 is spare throughout <youpi>we have to, otherwise it'd be a bug <damo22>ah its just nobody referred to it in the code <damo22>why cant i use something like r15 that isnt saved or restored in the ISR? <damo22>and just do an extra save and restore for that? <youpi>I'm not sure what you call ISR <damo22>its seems only a subset are needed for the interrupt/traps? <youpi>all_intrs knows it doesn't have to save r15 because it knows that its callees will not change it <youpi>but otherwise it has to keep it unchanged <youpi>just another segment register (not the default) <youpi>you can just add what you want in i386_interrupt_state <youpi>there is no constraint there <youpi>it just needs to match what you push/pop on interrupt <damo22>if i add r12 that isnt already there, does that mean i can use r12 throughout the interrupt context as long as i push and pop it ? <damo22>if i set r12 near the beginning, will it then survive until the end even with all the stack switching etc and traps or do i need to push it to the stack again with a new value <youpi>it won't be changed by the callees since it's callee-saved <youpi>so you don't need to push it again <damo22>that will save me a lot of headache <youpi>you can just save the value from the interrupted context, and put what you want it in <youpi>it'll stay there, just like previously the value of the interrupted context was staying there <damo22>seems like a waste of a whole register, but it will do <youpi>not of a register, but 8bytes in the isr structure