Skip to contentSkip to conversation

i386: remove IOPL check on task switch

PATCH Chuck Ebbert 4 participants 6 messages Nov 4, 2006

lore
Share & tools
lore
#0 lore raw

In-Reply-To: <[email protected]>

Quoted 5 lines · Zachary Amsden
Quoted 2 lines · Chuck Ebbert

IOPL is implicitly saved and restored on task switch, so explicit check is no longer needed.

Nack. This is used for paravirt-ops kernels that use IOPL'd userspace.

How does that work? In the stock kernel, anything done by the call to set_iopl_mask() (that was removed by the patch) will be nullified by the 'popfl' at the end of the switch_to() macro.

Signature · 2 lines
Chuck
"Even supernovas have their duller moments."
#1 lore raw
Quoted 10 lines · Chuck Ebbert

In-Reply-To: <[email protected]>

Quoted 5 lines · Zachary Amsden
Quoted 3 lines · Chuck Ebbert

IOPL is implicitly saved and restored on task switch, so explicit check is no longer needed.

Quoted 8 lines
Quoted 2 lines

Nack. This is used for paravirt-ops kernels that use IOPL'd userspace.

How does that work? In the stock kernel, anything done by the call to set_iopl_mask() (that was removed by the patch) will be nullified by the 'popfl' at the end of the switch_to() macro.

Who put a popfl back in switch_to? I took it out some time ago. It should not be there. The only reason for it was to stop IOPL leaking from one process to another from a sleep during a sysenter based system call.

Zach

#2 lore raw
Quoted 13 lines · Zachary Amsden
Quoted 12 lines · Chuck Ebbert

In-Reply-To: <[email protected]>

Quoted 6 lines · Zachary Amsden
Quoted 3 lines · Chuck Ebbert

IOPL is implicitly saved and restored on task switch, so explicit check is no longer needed.

Nack. This is used for paravirt-ops kernels that use IOPL'd userspace.

Quoted 7 lines
Quoted 5 lines

How does that work? In the stock kernel, anything done by the call to set_iopl_mask() (that was removed by the patch) will be nullified by the 'popfl' at the end of the switch_to() macro.

Who put a popfl back in switch_to? I took it out some time ago. It should not be there. The only reason for it was to stop IOPL leaking from one process to another from a sleep during a sysenter based system call.

Ok, checking shows Linus put it back to stop NT leakage. This is correct, but unlikely. Would be nice to avoid it unless absolutely necessary. Perhaps xor eflags old and new and only set_system_eflags() if non-ALU bits have changed.

Zach

#3 lore raw
Quoted 4 lines · Zachary Amsden

Ok, checking shows Linus put it back to stop NT leakage. This is correct, but unlikely. Would be nice to avoid it unless absolutely necessary. Perhaps xor eflags old and new and only set_system_eflags() if non-ALU bits have changed.

Not just NT. AC also leaked, and caused crashes in other programs (Wine) that didn't expect AC to be set and did unaligned accesses.

Linus

#4 lore raw
Quoted 8 lines · Linus Torvalds
Quoted 4 lines · Zachary Amsden

Ok, checking shows Linus put it back to stop NT leakage. This is correct, but unlikely. Would be nice to avoid it unless absolutely necessary. Perhaps xor eflags old and new and only set_system_eflags() if non-ALU bits have changed.

Not just NT. AC also leaked, and caused crashes in other programs (Wine) that didn't expect AC to be set and did unaligned accesses.

Yes, AC, NT, IOPL, ID are bad to leak. DF / TF / RF are impossible to leak by privilege contract. SF, ZF, PF, OF, CF can be clobbered.

VM / VIF / VIP are dealt with in separate switch paths (although I have witnessed a VIF leak once from a userspace process that managed to get VIF set). These can't even be set with popf, and require iret to fix.

But 99% of the time, only SF / ZF / PF / OF / CF will be different, so you can avoid the popf.

Zach

#5 lore raw
In reply to Zachary Amsden
Quoted 2 lines

Ok, checking shows Linus put it back to stop NT leakage.

It is also needed to stop AC leakage

Quoted 4 lines

This is
correct, but unlikely. Would be nice to avoid it unless absolutely necessary. Perhaps xor eflags old and new and only set_system_eflags() if non-ALU bits have changed.

If it's worth it...

If it's worth for the context switch i think it would make
more sense to do it for the normal restore_flags() etc. which are much more common (and could be actually handled in most cases with test + jump + sti)

-Andi