2 switch_to() puzzles

Project BRAVO (bravo@russell.ce.uniroma2.it)
Mon, 7 Dec 1998 16:05:51 +0100


Why the switch_to() macro saves on the stack the values of
ebx, esi and edi (ebp is used by gcc because of the
-fno-omit-frame-pointer option) ?

We tried the following patch (2.1.131) and it worked just fine.

--- include/asm-i386/system.h.orig Mon Dec 7 14:21:45 1998
+++ include/asm-i386/system.h Mon Dec 7 14:22:30 1998
@@ -15,10 +15,7 @@
*/
#define switch_to(prev,next) do { \
unsigned long eax, edx, ecx; \
- asm volatile("pushl %%ebx\n\t" \
- "pushl %%esi\n\t" \
- "pushl %%edi\n\t" \
- "pushl %%ebp\n\t" \
+ asm volatile("pushl %%ebp\n\t" \
"movl %%esp,%0\n\t" /* save ESP */ \
"movl %5,%%esp\n\t" /* restore ESP */ \
"movl $1f,%1\n\t" /* save EIP */ \
@@ -26,9 +23,6 @@
"jmp __switch_to\n" \
"1:\t" \
"popl %%ebp\n\t" \
- "popl %%edi\n\t" \
- "popl %%esi\n\t" \
- "popl %%ebx" \
:"=m" (prev->tss.esp),"=m" (prev->tss.eip), \
"=a" (eax), "=d" (edx), "=c" (ecx) \
:"m" (next->tss.esp),"m" (next->tss.eip), \

By the way, why inserting the following code in the __switch_to() function?
As far as I know, the debug registers can only be accessed in Kernel Mode
and (as far as I could see) Linux doesn't provide any support to change their
values stored in TSSs.

/*
* Now maybe reload the debug registers
*/
if (next->tss.debugreg[7]){
loaddebug(next,0);
loaddebug(next,1);
loaddebug(next,2);
loaddebug(next,3);
loaddebug(next,6);
loaddebug(next,7);
}

Marco Cesati

+---------------------------------------------------------------+
| Computer Engineering - Project BRAVO |
+---------------------------------------------------------------+
| University of Rome "Tor Vergata" |
| Dept. of Computer Science, Systems and Industrial Engineering |
| via di Tor Vergata, 00133 Rome (Italy) |
| e-mail: bravo@russell.ce.uniroma2.it |
+---------------------------------------------------------------+

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/