Changeset 15

Show
Ignore:
Timestamp:
10/23/05 18:27:49 (6 years ago)
Author:
dkaplan1
Message:

Can now send signals to driver threads. Recognizes threads killed because of
faults

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • arch/i386/kernel/callgate.c

    r14 r15  
    5151#include <linux/irq.h> 
    5252#include <linux/err.h> 
     53#include <linux/sched.h> 
    5354 
    5455#define SAVE_SEG        "pushl %ds\n\t" \ 
     
    258259        return -1; 
    259260    } 
     261    if (tsk->flags & PF_DEAD) { 
     262        printk("Driver thread is dead\n"); 
     263        return -ENODEV; 
     264    } 
    260265    if (!tsk->available) { 
    261266        printk(KERN_ERR "Thread busy...increase size of driver thread pool\n"); 
     
    264269    tsk->available=0; 
    265270    //Set memory map 
    266     if (mm) 
     271    if (mm) { 
     272        atomic_inc(&mm->mm_users); 
     273        atomic_inc(&mm->mm_count); 
    267274        tsk->mm=mm; 
     275        tsk->active_mm=mm; 
     276    } 
    268277 
    269278    //Set new state for thread 
     
    302311    //printk("Going...\n"); 
    303312    //show_regs(regs); 
    304     wake_up_process(tsk);     
     313    /*if (tsk->state==TASK_STOPPED) { 
     314        printk("Waking up driver thread for first time\n"); 
     315        tsk->state=TASK_RUNNING; 
     316    }*/ 
     317    wake_up_process(tsk); 
    305318    interruptible_sleep_on(&tsk->wait_driverfinish); 
    306319    //Free any memory we allocated 
  • arch/i386/kernel/process.c

    r14 r15  
    389389        /* Ok, create the new process.. */ 
    390390  //printk("Calling do_fork"); 
    391         pid=do_fork(flags | CLONE_STOPPED | CLONE_VM | CLONE_UNTRACED, (unsigned long) stack_start, &regs, 0, NULL, NULL); 
     391        pid=do_fork(flags | CLONE_STOPPED | CLONE_VM | CLONE_UNTRACED | CLONE_PARENT, (unsigned long) stack_start, &regs, 0, NULL, NULL); 
    392392  find_task_by_pid(pid)->orig_stack=orig_stack; 
    393393  find_task_by_pid(pid)->available=1; 
  • arch/i386/kernel/signal.c

    r1 r15  
    3030 
    3131#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 
    32  
     32extern int next_signal(struct sigpending *, sigset_t*); 
    3333/* 
    3434 * Atomically swap in the new signal mask, and wait for a signal. 
     
    559559         * if so. 
    560560         */ 
    561         if ((regs->xcs & 3) != 3) 
     561//      if ((regs->xcs & 3) != 3) 
     562  if ((regs->xcs & 3)==1) 
     563      printk("Sending signal to ring 1 driver thread!\n"); 
     564  if (!(regs->xcs & 3)) 
    562565                return 1; 
    563566 
     
    602605        return 0; 
    603606} 
    604  
    605607/* 
    606608 * notification of userspace execution resumption 
     
    619621        if (thread_info_flags & _TIF_SIGPENDING) 
    620622                do_signal(regs,oldset); 
    621          
     623 
     624  if ((regs->xcs & 3)==1) { 
     625      if (next_signal(&current->pending, &current->blocked)==SIGKILL) 
     626          BUG(); 
     627  } 
    622628        clear_thread_flag(TIF_IRET); 
    623629} 
  • arch/i386/kernel/traps.c

    r8 r15  
    437437DO_ERROR(12, SIGBUS,  "stack segment", stack_segment) 
    438438DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, get_cr2()) 
    439  
    440439asmlinkage void do_general_protection(struct pt_regs * regs, long error_code) 
    441440{ 
     
    446445                goto gp_in_vm86; 
    447446 
    448         if (!((regs->xcs & 3)==3)) 
     447        if (!((regs->xcs & 3))) 
    449448                goto gp_in_kernel; 
    450449 
     450  if ((regs->xcs & 3)!=3) { 
     451      //driver thread 
     452      printk("General protection fault in driver thread at %x\n", regs->eip); 
     453      //die("general protection", regs, error_code); 
     454      current->thread.error_code=error_code; 
     455      current->thread.trap_no=13; 
     456      force_sig(SIGKILL, current); 
     457      return; 
     458           
     459  } 
    451460        current->thread.error_code = error_code; 
    452461        current->thread.trap_no = 13; 
  • kernel/exit.c

    r8 r15  
    813813        tsk->exit_code = code; 
    814814        exit_notify(tsk); 
     815  wake_up(&tsk->wait_driverfinish); 
    815816  //NEW 
    816817  //wake_up(&tsk->wait_kernexit); 
  • kernel/fork.c

    r8 r15  
    12021202                         * We'll start up with an immediate SIGSTOP. 
    12031203                         */ 
    1204                       sigaddset(&p->pending.signal, SIGSTOP); 
    1205                         set_tsk_thread_flag(p, TIF_SIGPENDING); 
     1204                /*    sigaddset(&p->pending.signal, SIGSTOP); 
     1205                        set_tsk_thread_flag(p, TIF_SIGPENDING);*/ 
    12061206                } 
    12071207 
    1208               if (!(clone_flags & CLONE_STOPPED)) { 
     1208//            if (!(clone_flags & CLONE_STOPPED)) { 
    12091209                        /* 
    12101210                         * Do the wakeup last. On SMP we treat fork() and 
     
    12221222                        else 
    12231223                                wake_up_forked_process(p); 
    1224                 } else { 
     1224        //      } else { 
     1225if (clone_flags & CLONE_STOPPED) { 
    12251226                        int cpu = get_cpu(); 
    12261227 
  • kernel/module.c

    r14 r15  
    18701870      return -1; 
    18711871  } 
     1872  printk("Invoking init method...\n"); 
    18721873  ret=calldriver((unsigned long) mod->init, NULL, 0, NULL, 0); 
    18731874        if (ret < 0) { 
  • kernel/signal.c

    r1 r15  
    232232/* Given the mask, find the first available signal that should be serviced. */ 
    233233 
    234 static int 
     234//static int 
     235int 
    235236next_signal(struct sigpending *pending, sigset_t *mask) 
    236237{ 
     
    17231724        sigset_t *mask = &current->blocked; 
    17241725        int signr = 0; 
    1725  
     1726/*  if ((regs->xcs & 3)==1 || (regs->xcs & 3)==2) { 
     1727      printk("Sending signal to driver thread in ring %d\n", regs->xcs & 3); 
     1728      if (next_signal(&current->pending, &current->blocked)==SIGKILL) 
     1729          panic("Gonna do SIGKILL now"); 
     1730  } 
     1731*/ 
    17261732relock: 
    17271733        spin_lock_irq(&current->sighand->siglock); 
     
    17901796                if (ka->sa.sa_handler != SIG_DFL) /* Run the handler.  */ 
    17911797                        break; /* will return non-zero "signr" value */ 
    1792  
    17931798                /* 
    17941799                 * Now we are doing the default action for this signal. 
     
    18631868                 * Death signals, no core dump. 
    18641869                 */ 
     1870    if ((regs->xcs & 3)==1 || (regs->xcs & 3)==2) { 
     1871        do_exit(-ENODEV); 
     1872    } 
    18651873                do_group_exit(signr); 
    18661874                /* NOTREACHED */ 
  • .version

    r13 r15  
    1 103 
     1146