From 080c16088ea56237c9e1590f6b7f20936208d5dc Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Aug 2017 11:52:52 +0200 Subject: [PATCH 01/11] add option to disable mwait support --- arch/x86/kernel/tasks.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/tasks.c b/arch/x86/kernel/tasks.c index 81d38aeca..656dbc820 100644 --- a/arch/x86/kernel/tasks.c +++ b/arch/x86/kernel/tasks.c @@ -193,9 +193,11 @@ int create_default_frame(task_t* task, entry_point_t ep, void* arg, uint32_t cor return 0; } +#define USE_MWAIT + void wait_for_task(void) { -#if 1 +#ifndef USE_MWAIT HALT; #else if (!has_mwait()) { @@ -214,7 +216,7 @@ void wait_for_task(void) void wakeup_core(uint32_t core_id) { -#if 0 +#ifdef USE_MWAIT // if mwait is available, an IPI isn't required to wakeup the core if (has_mwait()) return; From df256cc6c1eaa697824ac69a63907a978691beff Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Aug 2017 13:50:44 +0200 Subject: [PATCH 02/11] use unsigned operation instead of signed --- arch/x86/kernel/entry.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index a4c68e835..4fb92acc2 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -202,9 +202,9 @@ Lremap: add rdi, 8 ; note: the whole code segement has to fit in the first pgd cmp rcx, rsi - jnb Lno_pml4_init + jnl Lno_pml4_init cmp rcx, r11 - jb Lremap + jl Lremap Lno_pml4_init: ; Set CR3 From 901caa81c074b13204465fe48aeec46e3ce4b15f Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Aug 2017 13:54:20 +0200 Subject: [PATCH 03/11] increase kernel stack size --- cmake/HermitCore-Configuration.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/HermitCore-Configuration.cmake b/cmake/HermitCore-Configuration.cmake index bd5753eef..2e6f14874 100644 --- a/cmake/HermitCore-Configuration.cmake +++ b/cmake/HermitCore-Configuration.cmake @@ -13,7 +13,7 @@ set(MAX_ISLE "8" CACHE STRING set(MAX_FNAME "128" CACHE STRING "Define the maximum length of a file name") -set(KERNEL_STACK_SIZE 8192 CACHE STRING +set(KERNEL_STACK_SIZE 16384 CACHE STRING "Kernel stack size in bytes") set(DEFAULT_STACK_SIZE 262144 CACHE STRING From abeae7ac0b760813eb297c877218ceed28badd11 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Aug 2017 15:18:43 +0200 Subject: [PATCH 04/11] remove obsolete global variable "kernel_stack" --- arch/x86/kernel/entry.asm | 1 - arch/x86/kernel/tasks.c | 1 - include/hermit/stddef.h | 3 --- kernel/tasks.c | 3 --- 4 files changed, 8 deletions(-) diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index 4fb92acc2..6375533da 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -416,7 +416,6 @@ extern irq_handler extern get_current_stack extern finish_task_switch extern syscall_handler -extern kernel_stack global getcontext align 64 diff --git a/arch/x86/kernel/tasks.c b/arch/x86/kernel/tasks.c index 656dbc820..4a3a89045 100644 --- a/arch/x86/kernel/tasks.c +++ b/arch/x86/kernel/tasks.c @@ -126,7 +126,6 @@ size_t* get_current_stack(void) else stptr = (stptr + DEFAULT_STACK_SIZE - sizeof(size_t)) & ~0x1F; - set_per_core(kernel_stack, stptr); set_tss(stptr, (size_t) curr_task->ist_addr + KERNEL_STACK_SIZE - 0x10); return curr_task->last_stack_pointer; diff --git a/include/hermit/stddef.h b/include/hermit/stddef.h index 5b1531cbb..818ad5fc8 100644 --- a/include/hermit/stddef.h +++ b/include/hermit/stddef.h @@ -83,9 +83,6 @@ typedef unsigned int tid_t; struct task; DECLARE_PER_CORE(struct task*, current_task); -/* allows fast access to the kernel stack */ -DECLARE_PER_CORE(char*, kernel_stack); - #if MAX_CORES > 1 /* allows fast access to the core id */ DECLARE_PER_CORE(uint32_t, __core_id); diff --git a/kernel/tasks.c b/kernel/tasks.c index 47655cb0d..f886fc0a2 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -67,7 +67,6 @@ static readyqueues_t readyqueues[1] = {[0] = {task_table+0, NULL, 0, 0, 0, {[0 . #endif DEFINE_PER_CORE(task_t*, current_task, task_table+0); -DEFINE_PER_CORE(char*, kernel_stack, NULL); #if MAX_CORES > 1 DEFINE_PER_CORE(uint32_t, __core_id, 0); @@ -282,7 +281,6 @@ int multitasking_init(void) task_table[0].prio = IDLE_PRIO; task_table[0].stack = (char*) ((size_t)&boot_stack + core_id * KERNEL_STACK_SIZE); task_table[0].ist_addr = (char*)&boot_ist; - set_per_core(kernel_stack, task_table[0].stack + KERNEL_STACK_SIZE - 0x10); set_per_core(current_task, task_table+0); arch_init_task(task_table+0); @@ -307,7 +305,6 @@ int set_idle_task(void) task_table[i].last_stack_pointer = NULL; task_table[i].stack = (char*) ((size_t)&boot_stack + core_id * KERNEL_STACK_SIZE); task_table[i].ist_addr = create_stack(KERNEL_STACK_SIZE); - set_per_core(kernel_stack, task_table[i].stack + KERNEL_STACK_SIZE - 0x10); task_table[i].prio = IDLE_PRIO; task_table[i].heap = NULL; readyqueues[core_id].idle = task_table+i; From 3d570f744cf6bd29a4e02a0bf7c56ae9ccbdf250 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Aug 2017 19:30:34 +0200 Subject: [PATCH 05/11] reduce kernel stack size to 8 kib --- cmake/HermitCore-Configuration.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/HermitCore-Configuration.cmake b/cmake/HermitCore-Configuration.cmake index 2e6f14874..bd5753eef 100644 --- a/cmake/HermitCore-Configuration.cmake +++ b/cmake/HermitCore-Configuration.cmake @@ -13,7 +13,7 @@ set(MAX_ISLE "8" CACHE STRING set(MAX_FNAME "128" CACHE STRING "Define the maximum length of a file name") -set(KERNEL_STACK_SIZE 16384 CACHE STRING +set(KERNEL_STACK_SIZE 8192 CACHE STRING "Kernel stack size in bytes") set(DEFAULT_STACK_SIZE 262144 CACHE STRING From 4c8c6b00c454f4490470e203666d175721413e59 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Aug 2017 19:33:50 +0200 Subject: [PATCH 06/11] in a multikernel environment we should'nt wait for HermitCore --- tools/proxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/proxy.c b/tools/proxy.c index d36d01cdc..8c5adf472 100644 --- a/tools/proxy.c +++ b/tools/proxy.c @@ -522,7 +522,7 @@ static int multi_init(char *path) free(result); // wait until HermitCore is sucessfully booted - wait_hermit_available(); + //wait_hermit_available(); return 0; } From 7f6bdd72b1260396f2e2ea0efde8cfb3ca7f56d4 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Aug 2017 22:30:30 +0200 Subject: [PATCH 07/11] add option to enable e1000 driver --- drivers/net/e1000.c | 4 ++++ drivers/net/e1000.h | 4 ++++ kernel/main.c | 2 ++ 3 files changed, 10 insertions(+) diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index c460f96f6..330c16f5c 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -45,6 +45,8 @@ #include #include +#if USE_E1000 + #define RX_BUF_LEN (2048) #define TX_BUF_LEN (1792) @@ -603,3 +605,5 @@ oom: return ERR_MEM; } + +#endif diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h index 08f0d886f..49ade1225 100644 --- a/drivers/net/e1000.h +++ b/drivers/net/e1000.h @@ -32,6 +32,8 @@ #include #include +#ifdef USE_E1000 + #define NUM_RX_DESCRIPTORS 64 #define NUM_TX_DESCRIPTORS 64 @@ -324,3 +326,5 @@ typedef struct e1000if { err_t e1000if_init(struct netif* netif); #endif + +#endif diff --git a/kernel/main.c b/kernel/main.c index d2fe61327..b5c0bf214 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -206,8 +206,10 @@ static int init_netifs(void) goto success; if ((err = netifapi_netif_add(&default_netif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw), NULL, rtl8139if_init, ethernet_input)) == ERR_OK) goto success; +#ifdef USE_E1000 if ((err = netifapi_netif_add(&default_netif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw), NULL, e1000if_init, ethernet_input)) == ERR_OK) goto success; +#endif LOG_ERROR("Unable to add the network interface: err = %d\n", err); From ba7291314340f26cb00964b5b5c48c58075689f3 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Aug 2017 22:47:08 +0200 Subject: [PATCH 08/11] enable LWIP_CORE_LOCKING_INPUT --- lwip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lwip b/lwip index 51d48fe0c..c21d911aa 160000 --- a/lwip +++ b/lwip @@ -1 +1 @@ -Subproject commit 51d48fe0c67131da346c9ef280b2019c77f6e607 +Subproject commit c21d911aa4f178563dc102f595d1d97dd8471458 From d785b1b89c72e32a7533c288a5fe371110a689d4 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Fri, 4 Aug 2017 10:07:07 +0200 Subject: [PATCH 09/11] initialize APIC after the intialization of IDT & GDT - fix problems with Qemu --- arch/x86/kernel/apic.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 1192490b8..f75d7fff7 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -905,12 +905,7 @@ extern int set_idle_task(void); #if MAX_CORES > 1 int smp_start(void) { - x2apic_enable(); - - // reset APIC and set id - lapic_reset(); - - LOG_DEBUG("Processor %d (local id %d) is entering its idle task\n", apic_cpu_id(), atomic_int32_read(¤t_boot_id)); + LOG_DEBUG("Try to initialize processor (local id %d)\n", atomic_int32_read(¤t_boot_id)); // use the same gdt like the boot processors gdt_flush(); @@ -921,6 +916,12 @@ int smp_start(void) // enable additional cpu features cpu_detection(); + x2apic_enable(); + + // reset APIC + lapic_reset(); + + LOG_DEBUG("Processor %d (local id %d) is entering its idle task\n", apic_cpu_id(), atomic_int32_read(¤t_boot_id)); LOG_DEBUG("CR0 of core %u: 0x%x\n", atomic_int32_read(¤t_boot_id), read_cr0()); online[atomic_int32_read(¤t_boot_id)] = 1; From 241fa2bfdc561bba6ce1d473a628d2fcdf176039 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Fri, 4 Aug 2017 10:12:52 +0200 Subject: [PATCH 10/11] add tests with 2 CPUs --- tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests.sh b/tests.sh index 3cabbadbe..a4e8f0639 100755 --- a/tests.sh +++ b/tests.sh @@ -9,6 +9,8 @@ PROXY=build/local_prefix/opt/hermit/bin/proxy for f in $FILES; do echo "check $f..."; HERMIT_ISLE=qemu HERMIT_CPUS=1 HERMIT_KVM=0 HERMIT_VERBOSE=1 timeout --kill-after=5m 5m $PROXY $f || exit 1; done +for f in $FILES; do echo "check $f..."; HERMIT_ISLE=qemu HERMIT_CPUS=2 HERMIT_KVM=0 HERMIT_VERBOSE=1 timeout --kill-after=5m 5m $PROXY $f || exit 1; done + # test echo server at port 8000 HERMIT_ISLE=qemu HERMIT_CPUS=1 HERMIT_KVM=0 HERMIT_VERBOSE=1 HERMIT_APP_PORT=8000 $PROXY $TDIR/tests/server & sleep 10 From 8016a757a9453d5e2e423f8e9b95c6196081e633 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Fri, 4 Aug 2017 10:35:16 +0200 Subject: [PATCH 11/11] increase version number --- .bintray_descriptor.json | 2 +- CMakeLists.txt | 2 +- cmake/HermitCore-Configuration.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bintray_descriptor.json b/.bintray_descriptor.json index 5d244a4f7..ff3e91669 100644 --- a/.bintray_descriptor.json +++ b/.bintray_descriptor.json @@ -13,7 +13,7 @@ }, "version": { - "name": "0.2.1", + "name": "0.2.2", "desc": "HermitCore's kernel as libOS", "gpgSign": false }, diff --git a/CMakeLists.txt b/CMakeLists.txt index 65cdc03cd..7383b462b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ set(CPACK_SYSTEM_NAME all) set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 2) -set(CPACK_PACKAGE_VERSION_PATCH 1) +set(CPACK_PACKAGE_VERSION_PATCH 2) set(CPACK_PACKAGE_CONTACT "Stefan Lankes ") diff --git a/cmake/HermitCore-Configuration.cmake b/cmake/HermitCore-Configuration.cmake index bd5753eef..c38566f8c 100644 --- a/cmake/HermitCore-Configuration.cmake +++ b/cmake/HermitCore-Configuration.cmake @@ -1,4 +1,4 @@ -set(PACKAGE_VERSION "0.2.1" CACHE STRING +set(PACKAGE_VERSION "0.2.2" CACHE STRING "HermitCore current version") set(MAX_CORES "512" CACHE STRING