Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/arch/i686/exceptions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
; See the License for the specific language governing permissions and
; limitations under the License.
[BITS 32]
extern cpu_exception
extern __cpu_exception

SECTION .bss
i386_registers:
Expand All @@ -33,7 +33,7 @@ __cpu_except_%1:
push 0
push %1
push i386_registers
call cpu_exception
call __cpu_exception
%endmacro

%macro CPU_EXCEPT_CODE 1
Expand All @@ -50,7 +50,7 @@ __cpu_except_%1:
push edx
push %1
push i386_registers
call cpu_exception
call __cpu_exception
%endmacro

SECTION .text
Expand Down
14 changes: 9 additions & 5 deletions src/arch/x86_64/exceptions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
; See the License for the specific language governing permissions and
; limitations under the License.
[BITS 64]
extern cpu_exception
extern __cpu_exception

SECTION .bss
__amd64_registers:
Expand All @@ -26,14 +26,16 @@ global __cpu_except_%1:function
__cpu_except_%1:
call save_cpu_regs

;; new stack frame
;; reveal origin stack frame
push rbp
mov rbp, rsp
;; re-align stack
and rsp, ~0xF
;; enter panic
mov rdi, __amd64_registers
mov rsi, %1
mov rdx, 0
call cpu_exception
call __cpu_exception
%endmacro

%macro CPU_EXCEPT_CODE 1
Expand All @@ -43,13 +45,15 @@ __cpu_except_%1:

;; pop error code
pop rdx
;; new stack frame
;; reveal origin stack frame
push rbp
mov rbp, rsp
;; re-align stack
and rsp, ~0xF
;; enter panic
mov rdi, __amd64_registers
mov rsi, %1
call cpu_exception
call __cpu_exception
%endmacro

SECTION .text
Expand Down
5 changes: 3 additions & 2 deletions src/platform/x86_pc/idt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void x86_IDT::init()
set_exception_handler(20, __cpu_except_20);
set_exception_handler(30, __cpu_except_30);

for (size_t i = 32; i < INTR_LINES - 1; i++) {
for (size_t i = 32; i < INTR_LINES - 2; i++) {
set_handler(i, unused_interrupt_handler);
}
// spurious interrupt handler
Expand Down Expand Up @@ -260,7 +260,8 @@ static void cpu_dump_regs(uintptr_t* regs)
}

extern "C"
void cpu_exception(uintptr_t* regs, int error, uint32_t code)
__attribute__((noreturn, optnone))
void __cpu_exception(uintptr_t* regs, int error, uint32_t code)
{
cpu_enable_panicking();
SMP::global_lock();
Expand Down
30 changes: 30 additions & 0 deletions test/kernel/integration/exception/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 2.8.9)
if (NOT DEFINED ENV{INCLUDEOS_PREFIX})
set(ENV{INCLUDEOS_PREFIX} /usr/local)
endif()
include($ENV{INCLUDEOS_PREFIX}/includeos/pre.service.cmake)
project (service)

# Human-readable name of your service
set(SERVICE_NAME "CPU exception test")

# Name of your service binary
set(BINARY "service")

# Source files to be linked with OS library parts to form bootable image
set(SOURCES
service.cpp
)

# DRIVERS / PLUGINS:
set(DRIVERS
)

set(PLUGINS )

# STATIC LIBRARIES:
set(LIBRARIES
)

# include service build script
include($ENV{INCLUDEOS_PREFIX}/includeos/post.service.cmake)
28 changes: 28 additions & 0 deletions test/kernel/integration/exception/service.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <service>

void Service::start()
{
// i686
//asm ("movl $0, %eax");
//asm ("idivl %eax");
// x86_64
asm ("movq $0, %rax");
asm ("idivq %rax");
}
24 changes: 24 additions & 0 deletions test/kernel/integration/exception/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /usr/bin/env python
import sys
import os
import socket

includeos_src = os.environ.get('INCLUDEOS_SRC',
os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))).split('/test')[0])
sys.path.insert(0,includeos_src)

from vmrunner import vmrunner
vm = vmrunner.vms[0]

counter = 0
def is_good(line):
global counter
counter += 1
if (counter == 5):
vm.exit(0, "All tests passed")

vm.on_output("\\x15\\x07\\t\*\*\*\* PANIC \*\*\*\*", is_good)
vm.on_output("Divide-by-zero Error", is_good)
vm.on_output("__cpu_exception", is_good)
vm.on_output("Service::start()", is_good)
vm.cmake().boot(20).clean()
4 changes: 4 additions & 0 deletions test/kernel/integration/exception/vm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"description" : "CPU exception test",
"mem" : 48
}
30 changes: 30 additions & 0 deletions test/kernel/integration/tls/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 2.8.9)

# IncludeOS install location
if (NOT DEFINED ENV{INCLUDEOS_PREFIX})
set(ENV{INCLUDEOS_PREFIX} /usr/local)
endif()
include($ENV{INCLUDEOS_PREFIX}/includeos/pre.service.cmake)
project (service)

# Human-readable name of your service
set(SERVICE_NAME "Thread Local Storage test")

# Name of your service binary
set(BINARY "service")

# Source files to be linked with OS library parts to form bootable image
set(SOURCES
service.cpp # ...add more here
)

set(DRIVERS
)

set(PLUGINS
# syslogd # Syslog over UDP
# ...others
)

# include service build script
include($ENV{INCLUDEOS_PREFIX}/includeos/post.service.cmake)
9 changes: 9 additions & 0 deletions test/kernel/integration/tls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### SMP

```
mkdir build
cd build
cmake ..
make
../run.sh smp_example
```
52 changes: 52 additions & 0 deletions test/kernel/integration/tls/service.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <service>
#include <cassert>

// TBSS area
thread_local int test_int = 0;
thread_local char test_char = 0;
// TDATA area
thread_local char test_array[3] = {1, 2, 3};
thread_local int64_t test_i64 = 0x11ABCDEF22ABCDEF;

void Service::start()
{
int bss_local = 0;
int data_local = 1;
// TBSS area
assert(test_int == 0);
assert(test_char == 0);
// modify TBSS
test_int = 1;
assert(test_int == 1);
// TDATA area
assert(test_array[0] == 1);
assert(test_array[1] == 2);
assert(test_array[2] == 3);
assert(test_i64 == 0x11ABCDEF22ABCDEF);
// modify TDATA area
test_array[0] = 44;
assert(test_array[0] == 44);
assert(test_array[1] == 2);
assert(test_array[2] == 3);
// verify locals
assert(bss_local == 0);
assert(data_local == 1);
printf("SUCCESS\n");
}
11 changes: 11 additions & 0 deletions test/kernel/integration/tls/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env python
import sys
import os

includeos_src = os.environ.get('INCLUDEOS_SRC',
os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))).split('/test')[0])
sys.path.insert(0,includeos_src)

from vmrunner import vmrunner
vm = vmrunner.vms[0];
vm.cmake().boot(20).clean()
3 changes: 3 additions & 0 deletions test/kernel/integration/tls/vm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mem" : 32
}
4 changes: 2 additions & 2 deletions test/misc/build_examples/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ script_absolute_dir=$RESULT

errors_present=0
echo -e ">>> Will now attempt to make all examples. Outpt from make will only be present if an error occured"

for dir in `ls -d $script_absolute_dir/../../../examples/*`
test_directories=$(ls -d $script_absolute_dir/../../../examples/* && echo $script_absolute_dir/../../../lib/uplink/starbase)
for dir in $test_directories
do
BREAK=""
cd $dir
Expand Down
3 changes: 0 additions & 3 deletions test/net/integration/router/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
// #define NO_INFO

#include <os>
#include <kernel/irq_manager.hpp>
#include <list>
#include <net/inet4>
#include <net/router.hpp>
#include <timers>
#include <profile>

#define USE_STACK_SAMPLING

Expand Down