Permalink
Commits on Apr 25, 2010
  1. Added a few more syscall related to sockets:

    	-bind
    	-listen
    	-accept
    	-sendmsg
    	-recvmsg
    	-setsockopt
    	-getsockname
    committed Apr 25, 2010
Commits on Jan 22, 2010
  1. lkl: irq: use spin locks to protect the irq queues

    With semaphores the threads don't waste time if they need to wait, but
    here the work is very little and semaphores are an overkill.
    
    More importantly, we can now generate LKL irqs from the guest
    environment even if we're running in an that environment's interrupt
    handling context.
    
    For example:
    
    * if the guest is the Windows NT Kernel, we now can insert LKL IRQs
      from functions running at IRQLs higher than DISPATCH_LEVEL.
    
    * if the guest is another Linux kernel, we now can insert LKL IRQs
      from interrupt handlers.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Jan 22, 2010
Commits on Dec 29, 2009
  1. lkl: LKL_SLAB: update to new SL*B API

    - krealloc() has a generic implementation.
    - kmem_cache->ctor is simplified
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 29, 2009
  2. lkl: drivers: disk: uniform 'devt' naming

    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 28, 2009
Commits on Dec 28, 2009
  1. lkl: drivers: disk: fix lkl_sys_access

    access(path, 0700) always returned -EINVAL
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 28, 2009
  2. lkl: drivers: disk: delete the gendisk in _lkl_disk_del_disk

    The bdev got from bdget() has the bd_disk=NULL.
    
    This leaded to a NULL pointer dereference while accesing
    bdev->bd_disk->major.
    
    We also have to delete the gendisk associated with this dev_t.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 28, 2009
  3. lkl: drivers: disk: update to new block_device_operations->open signa…

    …ture
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 28, 2009
  4. lkl: drivers: disk: use kzalloc

    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 28, 2009
Commits on Dec 27, 2009
  1. lkl: env: ntk: deliver LKL_TIMER_SHUTDOWN only once

    Delivering timer shutdown twice hasn't been tested, nor thought about
    enough. Because the problems that may arrise can manifest in other
    places (e.g.t the IRQ handling code, the timer thread code, etc.) we
    should signal this ASAP.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 27, 2009
  2. lkl: env: ntk: make the timer a SynchronizationTimer

    Before the timer was an NotificationTimer. That kind of timer was
    signaled once when the timer fired and remained fired until someone
    explicitly unsignaled it. The nkt lkl-env never unsignaled the
    timer.
    
    This means that the while() loop that waited on the timer to be
    signaled and triggered an timer IRQ never really waited and generated
    timer IRQs very rapidly.
    
    There causees two problems:
    a) the CPU wasted too many cycles generating timer IRQs
    b) the IRQ semaphore was released too many times.
    
    In some situations (for example when an active kernel thread was
    waiting or doing some slow work) the IRQ semaphore could be released
    too many times, more than it advertised when created, leading to a BSOD.
    
    By changing the timer's type to SynchronizationTimer, the timer gets
    signaled once when the timer fires and gets unsignaled immediatly
    after the first thread waiting on it is scheduled.
    
    This means that the IRQ generating code really does what is thought it
    was doing until now: it *waits* until the timer gets signaled, which
    only happens once in a while, not always as with NotificationTimer.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 27, 2009
  3. lkl: kernel: call do_exit() on threads that exit

    Without this we get a deadlock in this situation:
    1) mount an journaled ext3 fs. This will start the kjournald()
       kthread.
    2) unmount the ext3 fs. This will wait until the kjournald() kthread
       terminates.
    
    The kjournald() thread does no call do_exit() on it's exit
    path. Because of this, the kernel function executed by this kthread
    will return and the current thread will terminate WITHOUT passing the
    control to another thread (_switch_to()).
    
    The kernel is now dead-locked: the only thread that was running has
    left the building, and all other threads are waiting on their
    respective sched-semaphores.
    
    Calling do_exit() on this thread, will lead to a call to schedule(),
    with the ->dead bit set. This will properly exit the current thread,
    and will signal the sched-sem of another thread, preventing the kernel
    from getting stuck.
    
    This is not speciffic to kjournald. Any kthread started the same way,
    and which does not call do_exit() could have dead-locked the kernel.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 27, 2009
  4. lkl: env: posix: add lkl_env_fini

    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 27, 2009
  5. lkl: env: ntk: add tags to allocations

    This will help while debugging.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 13, 2009
  6. lkl: env: ntk: add lkl_env_fini to correctly unload ntk driver

    1. We must cancel the timer before we unload:
    * cancel further launches of the timer: KeCancelTimer
    * wait for any DPC that are currently running timer routines: KeFlushQueuedDpcs
    
    Failure to do this will lead to panics when the kernel wants to run
    the timer routine, but the routines code has been unloaded.
    
    2. Wait for the timer and the init thread to finish.  Again, failure
    to do this will lead to kernel panics due to code for threads being
    unloaded.
    
    3. To be able to terminate the timer thread we need to notify it by
    some other means than the timer object because the timer gets
    deactivated. We use a semaphore 'timer_killer_sem' to issue this
    notification. This is released at timer deactivation, and other places
    would not be good: we must ensure that the timer does not get signaled
    after the timer_killer_sem gets notified.
    
    4. LKL users must call lkl_env_fini() to unload the kernel.
    lkl_sys_halt() is not good because it leaves allocated resources.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    
    ammendme
    luciang committed Dec 9, 2009
Commits on Dec 9, 2009
  1. lkl: env: ntk: semaphores must be allocated from resident memory

    The semaphore object must be allocated from a form of resident memory:
    * the device extension of a driver-created device object,
    * the controller extension if it uses a controller object,
    * nonpaged pool allocated by the driver.
    
    These semaphores allocated from lkl_native_operations->sem_alloc are
    allocated dynamically so our only option is the nonpaged pool.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 6, 2009
  2. lkl: env: posix: implement a dummy halt()

    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Nov 30, 2009
  3. lkl: env: posix: implement user dump_stack() callback

    You'll need -rdynamic added to the linker in the kernel to be able to
    see kernel symbols too (though static symbol names won't be exported).
    
    Note: backtrace() and co. are GNU extensions, so this violates the
    posix.c claim to be fully POSIX compatible.
    
    Support for these functions should be detected at compile time to
    retain at least compile-time compatibility with POSIX.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Nov 30, 2009
  4. lkl: kernel: stop the timer at shutdown

    Magic numbers are bad: 0 was used for "start the timer", not "stop the timer".
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed Dec 9, 2009
Commits on Nov 30, 2009
  1. lkl: kernel: cleanup all thread semaphores

    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed with luciang Nov 30, 2009
  2. lkl: kernel: cleanup all remaining syscall semaphores

    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed with luciang Nov 30, 2009
  3. lkl: kernel: cleanup all IRQ semaphores

    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed with luciang Nov 30, 2009
  4. lkl: callbacks: add dump_stack user callback

    The kernel knows about it's symbols only.
    
    The user can know about other kinds of symbols and can provide stack
    traces for the non-kernel code (e.g. libc's backtrace() and
    backtrace_symbols()).
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed with luciang Nov 29, 2009
  5. kernel: add dump_stack()

    This makes BUG() and WARN() spit more useful traces.
    
    Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@cs.pub.ro>
    luciang committed with luciang Nov 29, 2009
Commits on Jun 14, 2009
Commits on Jun 9, 2009
  1. remove magic number

    Impact: code style
    
    TIMER_IRQ is zero, so this does not change any behaviour of the
    kernel.
    luciang committed Jun 9, 2009
  2. rename linux_trigger_irq_with_data to lkl_trigger_irq_with_data

    A similar rename was done sometime ago in the rest of the kernel.
    
    As this is only implemented in ASYNC IO, and ASYNC IO was not tested
    since, it has not generated any problems.
    luciang committed Jun 9, 2009
Commits on Jun 8, 2009
  1. explicitly init no_data_count to 0

    The C standard states that global variables must be initialized to 0.
    I'm not sure how mingw32 sections and the Windows kernel interact, but
    to be sure everything goes OK and not, let's explcityly initialize
    no_data_count to 0.
    luciang committed Jun 8, 2009
Commits on May 29, 2009
  1. lkl: preemptive mingw support :)

    There's no crash or bug related to this :)
    Just replace __attribute((weak)) with __weak to
    prevent such misbehavior.
    luciang committed May 29, 2009
  2. lkl: mingw support

    winedbg is fooled into thinking the culprit is do_fork().
    Careful stepping through the code reveals that the call to
    arch_dup_task_struct() breaks sets EIP to 0.
    
    Fix:
    
    Wine-dbg>
    First chance exception: page fault on read access to 0x00000000 in 32-bit code (0x00000000).
    Register dump:
     CS:0073 SS:007b DS:007b ES:007b FS:0033 GS:003b
     EIP:00000000 ESP:00f8e8ac EBP:00f8e8f8 EFLAGS:00210216(  R- --  I   -A-P- )
     EAX:01f81e80 EBX:01f81e80 ECX:00000000 EDX:01f81e80
     ESI:004b14a0 EDI:004ad368
    Stack dump:
    0x00f8e8ac:  00408ca3 00fc1c80 004b14a0 00000000
    0x00f8e8bc:  00000000 00fc1c80 00000000 00000000
    0x00f8e8cc:  004a7d95 00800b00 00000000 00f8e918
    0x00f8e8dc:  00466fcd 00f8e918 01f81700 00f8e928
    0x00f8e8ec:  00000000 00800b00 004ad368 00f8e948
    0x00f8e8fc:  00409b78 00000000 00000000 00000000
    Backtrace:
    =>0 0x00000000 (0x00f8e8f8)
    fixme:winedbg:print_value ---error
      1 0x00409b78 do_fork+0xcf(clone_flags=8391424, stack_start=4881813, regs=, stack_size=0, parent_tidptr=(nil), child_tidptr=(nil)) [kernel/fork.c:1398] in vfs.nt (0x00f8e948)
      2 0x00401d8e kernel_thread+0x20(fn=0x4a7d95, arg=(nil), flags=2560) [arch/lkl/kernel/threads.c:161] in vfs.nt (0x00f8e978)
      3 0x004a58f7 rest_init+0x17() [init/main.c:457] in vfs.nt (0x00f8e998)
      4 0x004a80ab start_kernel+0x243() [init/main.c:687] in vfs.nt (0x00f8e9c8)
      5 0x004a8397 lkl_start_kernel+0x2c(nops=0x4b7940, fmt="") [arch/lkl/kernel/setup.c:145] in vfs.nt (0x00f8e9f8)
      6 0x004ad380 init_thread@4+0x18(arg=(nil)) [arch/lkl/envs//nt.c:126] in vfs.nt (0x00f8ea18)
      7 0x7bc732ce call_thread_entry_point+0xe() in ntdll (0x00f8ea28)
      8 0x7bc75102 in ntdll (+0x65102) (0x00f8eac8)
      9 0x7bc752d0 in ntdll (+0x652d0) (0x00f8f3b8)
      10 0x600064ff start_thread+0xbf() in libpthread.so.0 (0x00f8f4b8)
      11 0x600fd5ee __clone+0x5e() in libc.so.6 (0x00000000)
    luciang committed May 29, 2009
  3. lkl: more mingw support

    The weak attributes defined with __attribute__((weak)) appear to be nul.
    Calling such a symbol will set EIP to 0 and crash the program.
    
    Fix:
    $ vfs.nt
    wine: Unhandled page fault on read access to 0x00000000 at address (nil) (thread 0017), starting debugger...
    Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00000000).
    Register dump:
     CS:0073 SS:007b DS:007b ES:007b FS:0033 GS:003b
     EIP:00000000 ESP:00f8e96c EBP:00f8e9a8 EFLAGS:00210202(  R- --  I   - - - )
     EAX:00000000 EBX:00f91000 ECX:00000040 EDX:0040e5bb
     ESI:004e80c0 EDI:004ad36c
    Stack dump:
    0x00f8e96c:  004a87c3 00000000 004b33e0 00000064
    0x00f8e97c:  00000000 00f91000 004e80c0 00f8e9a8
    0x00f8e98c:  004a8f3a 00f8e9a8 004a91ff 00000000
    0x00f8e99c:  00f91000 004e80c0 004ad36c 00f8e9c8
    0x00f8e9ac:  004a7ff4 00000000 00000000 00000001
    0x00f8e9bc:  004e80c0 7bc93ff4 00000000 00f8e9f8
    Backtrace:
    =>0 0x00000000 (0x00f8e9a8)
      1 0x004a7ff4 start_kernel+0x18c() [init/main.c:601] in vfs.nt (0x00f8e9c8)
      2 0x004a838f lkl_start_kernel+0x2c(nops=0x4b7940, fmt="") [arch/lkl/kernel/setup.c:145] in vfs.nt (0x00f8e9f8)
      3 0x004ad384 init_thread@4+0x18(arg=(nil)) [arch/lkl/envs//nt.c:126] in vfs.nt (0x00f8ea18)
      4 0x7bc732ce call_thread_entry_point+0xe() in ntdll (0x00f8ea28)
      5 0x7bc75102 in ntdll (+0x65102) (0x00f8eac8)
      6 0x7bc752d0 in ntdll (+0x652d0) (0x00f8f3b8)
      7 0x6015f4ff start_thread+0xbf() in libpthread.so.0 (0x00f8f4b8)
    
      8 0x602565ee __clone+0x5e() in libc.so.6 (0x00000000)
    luciang committed May 29, 2009
  4. lkl: more mingw support

    luciang committed May 29, 2009
  5. lkl: add mingw support

    Fix:
    include/asm-generic/bitops/atomic.h:93: undefined reference to `_sched_clock'
    luciang committed May 29, 2009
  6. lkl: mingw support: provide only one early_irq_init()

    mingw does not handle __weak well.
    early_irq_init() is defined in kernel/irq/handle.c which
    is compiled if CONFIG_GENERIC_HARDIRQS is defined.
    If CONFIG_GENERIC_HARDIRQS is defined do not provide this
    default implementation.
    luciang committed May 29, 2009