Intel P6 vs P7 system call performance
Quoted 4 lines · Linus Torvalds
It shouldn't matter.
NT is only tested by "iret", and if somebody sets NT in user space they get exactly what they deserve.
Indeed. I realized after I sent the previous mail that I had missed the flags save/restore in switch_to :-(
Still, does this mean that there is some micro optimization opportunity in the lcall7/lcall27 handlers to remove the popfl? After all TF is now handled by some magic in do_debug unless I miss (again) something, NT has become irrelevant, and cld in SAVE_ALL takes care of DF.
In short something like the following (I just love patches which only remove code):
===== entry.S 1.51 vs edited =====
entry.S renamed from arch/i386/kernel/entry.S +0 -10
@@ -156,16 +156,6 @@ movl %edx,EIP(%ebp) # Now we move them to their "normal" places movl %ecx,CS(%ebp) # - # - # Call gates don't clear TF and NT in eflags like - # traps do, so we need to do it ourselves. - # %eax already contains eflags (but it may have - # DF set, clear that also) - # - andl $~(DF_MASK | TF_MASK | NT_MASK),%eax - pushl %eax - popfl - andl $-8192, %ebp # GET_THREAD_INFO movl TI_EXEC_DOMAIN(%ebp), %edx # Get the execution domain call *4(%edx) # Call the lcall7 handler for the domain
Quoted 9 lines
Quoted 5 lines
For example, set NT and then execute sysenter with garbage in %eax, the kernel will try to return (
-ENOSYS) with iret and kill the task. As long as it only allows a task to kill itself, it's not a big deal. But NT is not cleared across task switches unless I miss something, and that looks very dangerous.It _is_ cleared by task-switching these days. Or rather, it's saved and restored, so the original NT setter will get it restored when resumed.
Yeah, sorry for the noise.
Quoted 8 lines
Quoted 5 lines
I'm no Ingo, unfortunately, but you'll need at least the following patch (the second hunk is only a typo fix) to the iret exception recovery code, which used push and pops to get the smallest possible code size.
Good job.
That was too easy since I did originally suggest the push/pop sequence :-)
Gabriel.