hrev52701 adds 2 changesets to branch 'master'
old head: d52d36aa5d72488a2725d0a52cf0f602251c0fe9
new head: 22ca923f71dd2d59d7f314d186801acb50524106
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=22ca923f71dd+%5Ed52d36aa5d72
----------------------------------------------------------------------------
44a1cfb8d8d5: kernel/x86: Reimplement locking for early boot message output.
The normal locking uses spinlocks that require getting at the current
CPU, which in turn needs a current thread set. This has not been set up
at this point and would simply cause tripple faults.
Use manual locking using atomic ops instead.
Change-Id: Ica894389330ef481eec84b667234139746ac4a46
Reviewed-on: https://review.haiku-os.org/808
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
22ca923f71dd: kernel/x86_64: Fix descriptor index off-by-one in assert.
This was apparently copied from GlobalDescriptorTable::SetTSS() which
needs two table entries and therefore checks for index + 1. For the
SetUserTLS case this isn't needed and would cause aborts when reaching
the maximum CPU count (64 currently).
Change-Id: I27bd777fedadbd3740ac8c791199ec9300b06327
Reviewed-on: https://review.haiku-os.org/809
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
[ Michael Lotz <mmlr@xxxxxxxx> ]
----------------------------------------------------------------------------
2 files changed, 21 insertions(+), 6 deletions(-)
src/system/kernel/arch/x86/64/descriptors.cpp | 2 +-
.../kernel/arch/x86/arch_debug_console.cpp | 25 ++++++++++++++++----
############################################################################
Commit: 44a1cfb8d8d52346d0f616f99f938f3b69852ccf
URL: https://git.haiku-os.org/haiku/commit/?id=44a1cfb8d8d5
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Tue Jan 1 22:26:58 2019 UTC
Committer: waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Wed Jan 2 00:22:14 2019 UTC
kernel/x86: Reimplement locking for early boot message output.
The normal locking uses spinlocks that require getting at the current
CPU, which in turn needs a current thread set. This has not been set up
at this point and would simply cause tripple faults.
Use manual locking using atomic ops instead.
Change-Id: Ica894389330ef481eec84b667234139746ac4a46
Reviewed-on: https://review.haiku-os.org/808
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
----------------------------------------------------------------------------
diff --git a/src/system/kernel/arch/x86/arch_debug_console.cpp
b/src/system/kernel/arch/x86/arch_debug_console.cpp
index 30a1762737..8fdede9223 100644
--- a/src/system/kernel/arch/x86/arch_debug_console.cpp
+++ b/src/system/kernel/arch/x86/arch_debug_console.cpp
@@ -67,6 +67,8 @@ static bool sKeyboardHandlerInstalled = false;
static spinlock sSerialOutputSpinlock = B_SPINLOCK_INITIALIZER;
+static int32 sEarlyBootMessageLock = 0;
+
static void
init_serial_port(uint16 basePort, uint32 baudRate)
@@ -388,6 +390,16 @@ arch_debug_serial_putchar(const char c)
}
+static void
+arch_debug_serial_puts_locked(const char *string)
+{
+ while (*string != '\0') {
+ _arch_debug_serial_putchar(*string);
+ string++;
+ }
+}
+
+
void
arch_debug_serial_puts(const char *s)
{
@@ -397,10 +409,7 @@ arch_debug_serial_puts(const char *s)
acquire_spinlock(&sSerialOutputSpinlock);
}
- while (*s != '\0') {
- _arch_debug_serial_putchar(*s);
- s++;
- }
+ arch_debug_serial_puts_locked(s);
if (!debug_debugger_running()) {
release_spinlock(&sSerialOutputSpinlock);
@@ -414,8 +423,14 @@ arch_debug_serial_early_boot_message(const char *string)
{
// this function will only be called in fatal situations
// ToDo: also enable output via text console?!
+
+ // Normal locking doesn't work this early as it needs a current thread.
+ while (atomic_test_and_set(&sEarlyBootMessageLock, 1, 0) != 0)
+ arch_cpu_pause();
+
arch_debug_console_init(NULL);
- arch_debug_serial_puts(string);
+ arch_debug_serial_puts_locked(string);
+ atomic_set(&sEarlyBootMessageLock, 0);
}
############################################################################
Revision: hrev52701
Commit: 22ca923f71dd2d59d7f314d186801acb50524106
URL: https://git.haiku-os.org/haiku/commit/?id=22ca923f71dd
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Tue Jan 1 20:50:49 2019 UTC
Committer: waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Wed Jan 2 00:22:14 2019 UTC
kernel/x86_64: Fix descriptor index off-by-one in assert.
This was apparently copied from GlobalDescriptorTable::SetTSS() which
needs two table entries and therefore checks for index + 1. For the
SetUserTLS case this isn't needed and would cause aborts when reaching
the maximum CPU count (64 currently).
Change-Id: I27bd777fedadbd3740ac8c791199ec9300b06327
Reviewed-on: https://review.haiku-os.org/809
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
----------------------------------------------------------------------------
diff --git a/src/system/kernel/arch/x86/64/descriptors.cpp
b/src/system/kernel/arch/x86/64/descriptors.cpp
index fd5d6ce68f..758f2c0b6e 100644
--- a/src/system/kernel/arch/x86/64/descriptors.cpp
+++ b/src/system/kernel/arch/x86/64/descriptors.cpp
@@ -280,7 +280,7 @@ unsigned
GlobalDescriptorTable::SetUserTLS(unsigned cpu, uintptr_t base, size_t limit)
{
auto index = kFirstTSS + cpu * 3 + 2;
- ASSERT(index + 1 < kDescriptorCount);
+ ASSERT(index < kDescriptorCount);
UserTLSDescriptor desc(base, limit);
fTable[index] = desc.GetDescriptor();
return index;