From a267f17ca645ceae1728e10680c6d1377589eef1 Mon Sep 17 00:00:00 2001 From: X512 Date: Sat, 14 Aug 2021 12:16:20 +0900 Subject: [PATCH] kernel/vm: fix several vm bugs in riscv64 team.cpp address_space change is needed in arch_thread_init_kthread_stack to set initial thread page translation map. It also allows to simplify some debugger code. DEBUG_PAGE_ACCESS check is currently incorrectly implemented in RISCV64VMTranslationMap and disabled to avoid panic. gHtifRegs = 0 change is needed to avoid using HTIF when it is not available. gHtifRegs != NULL check is used to detect that HTIF is present. 0x40008000 is TinyEMU HTIF address. HTIF is emulator specific device that provide serial IO and shutdown capability (and maybe something else depending on virtual machine). Change-Id: Ic4d567b28c49799ae0f55223dd983a752823bab4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4328 Reviewed-by: Alex von Gluck IV Tested-by: Commit checker robot --- build/config_headers/kernel_debug_config.h | 2 ++ src/system/kernel/arch/riscv64/arch_platform.cpp | 2 +- src/system/kernel/team.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build/config_headers/kernel_debug_config.h b/build/config_headers/kernel_debug_config.h index 2a0b4d653f..b4a6f84848 100644 --- a/build/config_headers/kernel_debug_config.h +++ b/build/config_headers/kernel_debug_config.h @@ -93,7 +93,9 @@ // Enables the vm_page::access_count field, which is used to detect invalid // concurrent access to the page. +#ifndef __riscv #define DEBUG_PAGE_ACCESS KDEBUG_LEVEL_2 +#endif // Enables a global list of all vm_cache structures. #define DEBUG_CACHE_LIST KDEBUG_LEVEL_2 diff --git a/src/system/kernel/arch/riscv64/arch_platform.cpp b/src/system/kernel/arch/riscv64/arch_platform.cpp index 455208634a..aed73643fb 100644 --- a/src/system/kernel/arch/riscv64/arch_platform.cpp +++ b/src/system/kernel/arch/riscv64/arch_platform.cpp @@ -17,7 +17,7 @@ uint32 gPlatform; void* gFDT = NULL; -HtifRegs *volatile gHtifRegs = (HtifRegs *volatile)0x40008000; +HtifRegs *volatile gHtifRegs = (HtifRegs *volatile)0; PlicRegs *volatile gPlicRegs; ClintRegs *volatile gClintRegs; diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 51421eb595..431edd09aa 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -444,7 +444,7 @@ Team::Team(team_id id, bool kernel) fArgs[0] = '\0'; num_threads = 0; io_context = NULL; - address_space = NULL; + address_space = kernel ? VMAddressSpace::Kernel() : NULL; realtime_sem_context = NULL; xsi_sem_context = NULL; thread_list = NULL;