Commit Graph

3826 Commits

Author SHA1 Message Date
Ingo Weinhold
e506fde883 wait_if_address_range_is_wired() was leaking a cache reference.
Fixes #5710.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36237 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 21:18:52 +00:00
Ingo Weinhold
5f310d4d0d Added TODO.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36236 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 21:16:23 +00:00
Axel Dörfler
a1b2e9e959 * Removed F8 and F12 keys again, see comments to bug #5163.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36233 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 18:25:56 +00:00
Ingo Weinhold
fc813f1a1a Fixed typo in area name.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36232 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 17:42:10 +00:00
Ingo Weinhold
c3676b54bf * Added vm_debug_copy_page_memory() which copies memory from a potentially not
mapped page.
* debug_{mem,strl}cpy():
  - Added "team" parameter for specifying the address space the address are
    to be interpreted in.
  - When the standard memcpy() (with fault handler) fails, fall back to
    vm_debug_copy_page_memory().
* Added debug_is_debugged_team(): Predicate returning true, if the supplied
  team_id refers to the same team debug_get_debugged_thread() belongs to.
* Added DebuggedThreadSetter class for scope-based debug_set_debugged_thread().
  Made use of it in several debugger functions.
* print_demangled_call() (x86): Fixed unsafe memory access.

Allows KDL stack traces to work correctly again, even if the page daemon has
already unmapped the concerned pages.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36230 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 17:40:15 +00:00
Ingo Weinhold
ca4dd26afd Missed that one in r36228: DebugHasPage() implementation.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36229 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 17:34:32 +00:00
Ingo Weinhold
86875ad9d1 Added VMCache::DebugHasPage() and DebugLookupPage() for use in the kernel
debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36228 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 17:18:57 +00:00
Ingo Weinhold
09418c869b Added DebugGet() method for use in the kernel debugger.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36227 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 17:16:42 +00:00
Michael Lotz
33fbe25496 * Add code to allocate and free interrupt vectors for message signaled
interrupts (MSI).
* Add the remaining IDT entries and redirection functions in the interrupt code.
* Make the PIC end_of_interrupt() return a result to indicate whether the vector
  was handled by this PIC. If it isn't we now issue a apic_end_of_interrupt()
  in the assumption of apic local interrupt, MSI or IPI. This also removes
  the need for the gUsingIOAPIC global and doing manual apic_end_of_interrupt()
  calls in the SMP and timer code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36221 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 14:46:09 +00:00
Michael Lotz
aeae7bf4dc Add ffs() (find first set bit, starting at least significant) to the kernel.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36220 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 14:34:06 +00:00
Axel Dörfler
fefe246c70 * Set the exit status for the main thread as well in _user_exit_team().
* This closes bug #5713.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36215 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 13:29:56 +00:00
Axel Dörfler
2e7bd0169f * The kernel daemon no longer hold its lock when calling the registered hooks.
* This fixes bug #5421.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36209 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 12:09:56 +00:00
Ingo Weinhold
50e4dd9328 axeld + bonefish: X86VMTranslationMap::Protect():
* Removed rounding up the end address to page alignment. It's not necessary
  and could cause an overflow.
* Fixed possible infinite loop triggered by a rare race condition: When two
  threads of a team were accessing the same unmapped page at the same time
  each would trigger a page fault. One thread would map the page again, the
  second would wait until the first one was done and update the page
  protection (unnecessarily but harmlessly). If the first thread accessed the
  page again at an unfortunate time, it would implicitly change the
  accessed/dirty flags of the page's PTE, which was a situation the loop in
  Protect() didn't consider and thus run forever.
  Seen the problem twice today in form of an app server freeze.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36197 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 20:30:49 +00:00
Michael Lotz
3d310bd5f4 * Fix build, the APIC definitions are used in the bootloader too.
* Automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36189 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 15:59:40 +00:00
Ingo Weinhold
aa26d10790 delete_area(): When the address space is the kernel address space, we need to
pass stricter allocation flags to VMAddressSpace::{Remove,Delete}Area() or
could deadlock otherwise.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36188 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 15:25:08 +00:00
Michael Lotz
655f3b4161 Seperate the generic (local) APIC stuff into it's own file and use it from the
other places where previously the same functionality was duplicated. Also
seperated the header which was originally arch_smp.h into apic.h and arch_smp.h
again as some of it is MP and not actually APIC.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36182 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 12:56:13 +00:00
Axel Dörfler
ee0d2be9e4 bonefish+axeld:
* Implemented a tiny bit more sophisticated version of
  estimate_max_scheduling_latency() that uses a syscall that lets the scheduler
  decide.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36170 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-11 20:40:58 +00:00
Ingo Weinhold
813d4cbe94 * Moved created subdirectory src/system/kernel/lock.cpp to new subdirectory
locks.
* Added syscalls for a new kind of mutex. A mutex consists only of an int32 and
  doesn't require any kernel resources. So it's initialization cannot fail
  (it consists only of setting the mutex value to 0). An uncontended lock or
  unlock operation can basically consist of an atomic_*() in userland. The
  syscalls (when the mutex is contended) are a bit more expensive than semaphore
  operations, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36158 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-11 16:07:39 +00:00
Ingo Weinhold
349039ff2e Added vm_[un]wire_page(), which are essentially versions of
[un]lock_memory_etc() optimized for a single page.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36156 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-11 15:07:06 +00:00
Ingo Weinhold
713bede839 full_scan_inactive_pages(): Don't call DEBUG_PAGE_ACCESS_START() before
checking whether the page is busy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36155 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-11 14:49:06 +00:00
Clemens Zeidler
ad0b28334d Fix spelling, pointed out by Stefano and Axel.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36139 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-11 09:52:42 +00:00
Ingo Weinhold
9d3e718801 We must not resize the area hash table while holding an address space lock,
since it could be the kernel address space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36091 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-08 18:30:22 +00:00
Ingo Weinhold
16b4b2c13b Fixed broken sprintf() invocation.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36087 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-08 17:06:56 +00:00
Ingo Weinhold
078dbb2d0e Defined more sysconf() and _POSIX_* constants required by POSIX.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36074 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-07 18:52:25 +00:00
Ingo Weinhold
f603ab3c58 Disabled more unused code (the cache allocation is disabled, so no need for
deallocation).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36073 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-07 18:51:00 +00:00
Clemens Zeidler
cb58e3f784 Rescue acpi irq stuff from my defect laptop. Code is disabled and should't to any harm.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36059 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-07 12:50:55 +00:00
Ingo Weinhold
6f33e7286f Handle sigaction[_etc]() return value correctly (it's not an error code).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36056 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-06 20:24:23 +00:00
Ingo Weinhold
2be99447d8 * Added some comments to the thread flags.
* Added new thread flag THREAD_FLAGS_ALWAYS_RESTART_SYSCALL. If set, it forces
  syscall restart even when a signal handler without SA_RESTART was invoked.
* Fixed sigwait(): If one of requested signals wasn't already pending it would
  never wake up. Also, the syscall always needs to be restarted, if interrupted
  by another signal.
* Renamed a bunch of the POSIX signal function implementations which did return
  an error code directly (instead via errno). Added correct POSIX functions
  where needed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36054 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-06 20:23:18 +00:00
Ingo Weinhold
5a0b30dbda Don't cancel the alarm on exec*(). POSIX alarm() requires that. The BeBook
doesn't mention the expected set_alarm() behavior. Tests under BeOS R5 Bone
crash the system in either case, though, so I guess we're free to go with the
expected POSIX behavior.
This make detection of hanging tests in the Open POSIX Test Suite work.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36046 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-06 17:06:08 +00:00
Ingo Weinhold
4f774c503c * VMArea::Unwire(addr_t, size_t, bool): Don't delete the removed range, but
return it.
* lock_memory_etc(): On error the VMAreaWiredRange object could be leaked.
* [un]lock_memory_etc(): Call VMArea::Unwire() with the cache locked and
  explicitly delete the range object after unlocking the cache to avoid
  potential deadlocks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36035 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-05 12:12:36 +00:00
Ingo Weinhold
369111e741 * Removed the VMArea::Wire() version that has to allocate a VMAreaWiredRange.
Since the requirement is that the area's top cache is locked, allocating
  memory isn't allowed.
* lock_memory_etc(): Create the VMAreaWiredRange object explicitly before
  locking the area's top cache.

Fixes #5680 (deadlocks when using the slab as malloc() backend).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36033 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-05 11:08:01 +00:00
Ingo Weinhold
550376ffb8 * vm_delete_areas(): Changed return type to void (was status_t and not used).
* _user_map_file(), _user_unmap_memory(): Verify that the address (if given) is
  page aligned.
* Reworked memory locking (wiring):
  - VMArea does now have a list of wired memory ranges and supports waiting for
    a range to be removed.
  - vm_soft_fault():
    - Added "wirePage" parameter that, if given, makes the function wire the
      page and return it.
    - Added "wiredRange" parameter (for calls from lock_memory_etc()) and made
      sure we never unmap wired pages. This could e.g. happen when a page from a
      lower cache was read-mapped and a write fault occurred. Now in such a
      situation the function waits for the page to be unwired and restarts.
  - All functions that manipulate areas in a way that could affect wired ranges
    do now either require the caller to make sure there are no wired ranges in
    the way or do that themselves. Added a few wait_if_*_is_wired() helper
    functions for that purpose.
  - lock_memory_etc():
    - Does now also work correctly when the range spans more than one area.
    - Adds VMAreaWiredRanges to the affected VMAreas and retains an address
      space reference (so that the address space won't be deleted as long as a
      wired range exists).
    - Resolved TODO: The area's caches are now locked when
      increment_page_wired_count() is called.
    - Resolved TODO: The race condition due to missing locking after looking up
      the page mapping is now prevented. We hold the cache locks (in case the
      page is already mapped) and the new vm_soft_fault() parameter allows us
      to get the page wired.
  - unlock_memory_etc(): Changes symmetrical to those in lock_memory_etc() and
    resolved all TODOs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36030 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-03 18:01:29 +00:00
Ingo Weinhold
21ff565f76 AddressSpaceWriteLocker: Added VMAddressSpace* constructor and SetTo()
versions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36029 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-03 16:11:47 +00:00
Ingo Weinhold
345730da43 Fixed gcc 2 build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35981 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-27 20:16:10 +00:00
Ingo Weinhold
25bca18888 Moved setting the debug syslog default to main(). Previously that was done
only when the boot loader menu was entered.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35977 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-27 18:15:17 +00:00
Ingo Weinhold
c81e68b2b2 "syslog" debugger command: By default it now ignores the output added to the
syslog in the current KDL session. Added option "-k" for the former behavior.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35976 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-27 18:13:11 +00:00
Ingo Weinhold
feddedab0c x86:
Added fields for temporary storage of the debug registers dr6 and dr7 to the
arch_cpu_info structure. The actual registers are stored at the beginning of
x86_exit_user_debug_at_kernel_entry() and read in
x86_handle_debug_exception().
The problem was that x86_exit_user_debug_at_kernel_entry() itself overwrote
dr7 and, if kernel breakpoints were enabled, dr6 could be overwritten anytime
after. So x86_handle_debug_exception() would find incorrect values in the
registers (definitely in dr7) and thus interpret the detected debug condition
incorrectly. Usually watchpoints were recognized as breakpoints.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35951 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-26 00:03:53 +00:00
Ingo Weinhold
a959bc5b23 _user_wait_for_objects(): Don't copy the infos back to userland when an error
occurred. This fixes the automatic syscall restart case (would wait forever)
and aligns the behavior with poll().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35948 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-25 15:57:38 +00:00
Ingo Weinhold
a369198603 kernel_debugger_loop(): We need to use a dedicated jmp_buf for the call of
arch_debug_stack_trace() through debug_call_with_fault_handler(), since the
one in the CPU structure can only be used for debug_{strl,mem}cpy(), which do
not potentially have nested debug_call_with_fault_handler() calls.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35920 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-19 21:30:27 +00:00
Ingo Weinhold
4f339c2ce1 preload_image(): Removed erroneous rld_unlock() in error case. Fixes #5599.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35919 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-19 19:21:41 +00:00
Ingo Weinhold
c561bf792b block_cache::NewBlock(): Allocate cached_block::current_data only when the
block was freshly allocated. A block returned by _GetUnusedBlock() already
has current_data and we would leak it before.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35918 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-19 19:07:18 +00:00
Ingo Weinhold
59a4ec37b5 Changed the names of the block allocator object caches to avoid confusion
with the ones of the block cache.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35917 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-19 18:27:28 +00:00
Ingo Weinhold
cfefeee3f8 * Changed arch_debug_save_registers() to take an arch-specific structure
arch_debug_registers instead.
* Call arch_debug_save_registers() on all CPUs when entering the kernel
  debugger.
* Added debug_get_debug_registers() to return a specified CPU's saved
  registers.
* x86:
  - Replaced the previous arch_debug_save_registers() implementation. Disabled
    getting the registers via the gdb interface for the time being.
  - Fixed the "sc", "call", and "calling" commands to also work for threads
    running on another CPU.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 17:20:06 +00:00
Ingo Weinhold
d80af65fd8 The "page" and the "cache" kernel debugger commands set a few temporary
variables, now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35903 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 16:18:16 +00:00
Ingo Weinhold
2d2b6b1f1a * Unconditionally print a stack trace when we entered KDL via panic().
* Print the initial stack trace safely, i.e. in a setjmp() + fault handler
  environment.
* Disable pagination while executing the executing the panic() commands. This
  way even when it is not possible to use the keyboard we get the full output.
* Added "panic_commands" kernel debugger command, to execute the panic()
  commands again (with pagination enabled).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35902 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 16:17:15 +00:00
Ingo Weinhold
976e52595e Added blue_screen_paging_enabled() and blue_screen_set_paging() to get/set
pagination mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35901 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 16:11:29 +00:00
Stefano Ceccherini
43e738bd36 Style fixes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35897 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 06:31:01 +00:00
Ingo Weinhold
64c15cfc27 * sCurrentKernelDebuggerMessageArgs is no longer used directly. Whenever it
is passed to some v*printf(), we clone it first. This way we can use it
  repeatedly. It worked only on certain architectures correctly before.
* Changed the panic() semantics a bit: When the format contains the
  (hopefully unusual enough) string "@!" only the part before it is
  considered to belong to the panic message. The part after it is interpreted
  as a command line to be executed directly after entering KDL. This way it
  is possible to provide helpful command invocations only developers somewhat
  familiar with the subsystem might come up with. E.g.:
    panic("dec_vnode_ref_count: called on busy vnode %p"
      "@! vnode -p %p; mount _mount", vnode, vnode);


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35896 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 00:47:43 +00:00
Ingo Weinhold
6365627b33 * Added support for giving multiple kernel debugger commands in a single
line, separated by ";".
* Fixed incorrect parsing when "|" was not separated by a space from the
  previous argument.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35895 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-17 22:56:07 +00:00
Stefano Ceccherini
33e11f7c0f Squashed todo: only compute the numEntries once, and made it static.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35889 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-17 12:19:34 +00:00