Abort in reload1.c on 486/586

Michael Eager eager@mvista.com
Tue Dec 3 15:48:00 GMT 2002


Michael Eager wrote:
> 
> There were a couple patches which corrected a reload bug
> for x86.  These are
> 
> http://gcc.gnu.org/ml/gcc-patches/2002-10/msg00947.html
> http://gcc.gnu.org/ml/gcc-patches/2002-10/msg01366.html
> 
> When we cross-compile sched.c for 486/586, the test reload1.c
> in the first patch fails, causing the abort().
> 
> I'm attaching a smaller test case.

sched-ice.c:

typedef struct { volatile int counter; } atomic_t;

static __inline__ void set_bit(int nr, volatile void * addr)
{
        __asm__ __volatile__( ""
                "btsl %1,%0"
                :"=m" ((*(volatile long *) addr))
                :"Ir" (nr));
}

struct thread_struct {
        unsigned long eip;
        unsigned long esp;
};

struct mm_struct {
        unsigned long cpu_vm_mask;
        int baz;
};

struct task_struct {
        int preempt_count;
        struct mm_struct *mm, *active_mm;
        struct thread_struct thread;
};

static inline struct task_struct * get_current(void)
{
        struct task_struct *current;
        __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
        return current;
}

extern void set_ldt_desc(unsigned int n, void *addr, unsigned int size);

static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu)
{
        if (prev != next) {
                if (prev->baz != next->baz)
                        set_ldt_desc(0, 0, 8192);
                set_bit(cpu, &next->cpu_vm_mask);
                set_bit(cpu, &next->baz);
                asm volatile("movl %0,%%cr3": :"r" (((unsigned long)(next)-((unsigned long)(0xC0000000)))));
        }
}
extern inline void __mmdrop(struct mm_struct *) __attribute__((regparm(3)));
static inline void mmdrop(struct mm_struct * mm)
{
                __mmdrop(mm);
}

struct task_struct * func();
 __attribute__((regparm(0))) void schedule(void)
{
        struct task_struct *prev, *next;
        prev = get_current();
        next = func();
        if (((get_current()->preempt_count) & ~0x4000000) == 1)

                func();
        --get_current()->preempt_count;
        __asm__ __volatile__("": : :"memory");
        if (__builtin_expect((get_current()->preempt_count < 1),0))
                func();
        __asm__ __volatile__("sti": : :"memory");
        {
                struct mm_struct *mm = next->mm;
                struct mm_struct *oldmm = prev->active_mm;
                if (mm) {
                        if (next->active_mm != mm) __asm__ __volatile__(".byte 0x0f,0x0b");
                        switch_mm(oldmm, mm, next, 1);
                }
                if (!prev->mm) {
                        mmdrop(oldmm);
                }
        }
        do { asm volatile("" : "=m" (prev->thread.esp),"=m" (prev->thread.eip),
                 "=b" (prev) :"m" (next->thread.esp),"m" (next->thread.eip),
                 "a" (prev), "d" (next), "b" (prev)); } while (0);
        __schedule_tail(prev);
}


--
Michael Eager     eager@mvista.com	408-328-8426	
MontaVista Software, Inc. 1237 E. Arques Ave., Sunnyvale, CA  94085



More information about the Gcc-bugs mailing list