2.6.12-rc2-mm3
Hi Ingo.
I have some programs that crash in 2.6.12-rc2-mm3. After seeing this:
http://www.uwsg.iu.edu/hypermail/linux/kernel/0504.1/1091.html
I tried to revert the sched-unlocked-context-switches.patch and indeed the problem goes away. Attached is the (crappy) test-case. If you can make it to say "All OK" then the problem is solved. Apparently the %fs gets trashed somewhere, any ideas?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <linux/unistd.h> #include <asm/ldt.h>
#include <asm/ucontext.h>
_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount)
static int set_ldt_entry(int entry, unsigned long base, unsigned int limit,
int seg_32bit_flag, int contents, int read_only_flag, int limit_in_pages_flag, int seg_not_present, int useable)
{
struct modify_ldt_ldt_s ldt_info;
ldt_info.entry_number = entry;
ldt_info.base_addr = base;
ldt_info.limit = limit;
ldt_info.seg_32bit = seg_32bit_flag;
ldt_info.contents = contents;
ldt_info.read_exec_only = read_only_flag; ldt_info.limit_in_pages = limit_in_pages_flag; ldt_info.seg_not_present = seg_not_present;
ldt_info.useable = useable;
return modify_ldt(1, &ldt_info, sizeof(ldt_info));
}
int main(int argc, char *argv[]) {
unsigned short _ss, new_ss, fs;
/* Get SS */
asm volatile(
"movw %%ss, %0\n"
:"=m"(_ss));
/* Force to LDT */ new_ss = (_ss & 0xffff) | 4; /* Create the LDT entry */ set_ldt_entry(new_ss >> 3, 0, 0xfffff, 0, MODIFY_LDT_CONTENTS_DATA, 0, 1, 0, 0);
asm ("movw %%fs, %0":"=m"(fs)); printf("fs1=0x%hx\n", fs); asm ("movw %0, %%fs"::"a"(new_ss)); asm ("movw %%fs, %0":"=m"(fs)); printf("fs2=0x%hx\n", fs); usleep(0);
asm ("movw %%fs, %0":"=m"(fs)); printf("fs3=0x%hx\n", fs);
if (fs != new_ss)
printf("BUG!\n");
else
printf("All OK\n"); return 0;
}
Quoted 5 lines · Stas Sergeev
Hi Ingo.
I have some programs that crash
in 2.6.12-rc2-mm3. After seeing this:
http://www.uwsg.iu.edu/hypermail/linux/kernel/0504.1/1091.html
does the patch below fix the problem for you? (already in Andrew's tree, should be in the next -mm patch)
Ingo
--
delay the reloading of segment registers into switch_mm(), so that if the LDT size changes we dont get a (silent) fault and a zeroed selector register upon reloading.
arch/i386/kernel/process.c renamed from arch/i386/kernel/process.c.orig +5 -5
@@ -612,12 +612,12 @@ struct task_struct fastcall * __switch_t asmvolatile ("movl %%gs,%0" :"=m" (*(int *)&prev->gs));/* -* Restore %fs and %gs if needed. +* Clear selectors if needed: */ -if (unlikely (prev->fs | prev->gs | next->fs | next->gs)) { -loadsegment (fs, next->fs); -loadsegment (gs, next->gs); - } +if (unlikely ((prev->fs | prev->gs) && !(next->fs | next->gs))) { +loadsegment (fs, next->fs); +loadsegment (gs, next->gs); + }/* * Now maybe reload the debug registers
include/asm-i386/mmu_context.h renamed from include/asm-i386/mmu_context.h.orig +7 -0
@@ -61,6 +61,13 @@ static inline void switch_mm(struct mm_s } }#endif +/* +* Now that we've switched the LDT, load segments: +*/ +if (unlikely (current->thread.fs | current->thread.gs)) { +loadsegment (fs, current->thread.fs); +loadsegment (gs, current->thread.gs); + } }#define deactivate_mm (tsk, mm) \
Hello.
Quoted 1 line · Ingo Molnar
does the patch below fix the problem for you?
Works perfectly, thankyou!