Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reimplement Lab3 and add anticheat #35

Merged
merged 29 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
38617a1
vcs: lift musl-libc to top-level directories
ToolmanP Sep 22, 2024
7600567
fix(lab3): remove all useless files
ToolmanP Sep 24, 2024
4490717
fix(lab3): disgard lab2 tests
ToolmanP Sep 24, 2024
b31ae53
feat(lab3): migrate to new architecture
ToolmanP Sep 24, 2024
e42b653
fix(lab3): replace all wrong objects and sources
ToolmanP Sep 25, 2024
5796edd
fix(lab3): update all CMakeLists.txt
ToolmanP Sep 25, 2024
eec7d88
fix(lab3): fix stale include files
ToolmanP Sep 25, 2024
6b6811c
fix(lab3): fix user-includes
ToolmanP Sep 25, 2024
6f842b8
fix(lab3): fix linker and bin-image scripts
ToolmanP Sep 25, 2024
1214781
feat: add compile_commands.json merger
ToolmanP Sep 25, 2024
fc891bb
fix(lab3): tweak source files
ToolmanP Sep 25, 2024
400651c
fix(lab3): update CMakeLists.txt
ToolmanP Sep 26, 2024
f190b1c
vcs: ignore clangd related files
ToolmanP Sep 26, 2024
24ae043
fix(lab3): tweak useless ramdisks
ToolmanP Sep 28, 2024
0414dd5
feat(lab3): bump libchcore
ToolmanP Sep 28, 2024
a82de83
feat(lab3): remove fs_base, fsm, tmpfs
ToolmanP Sep 28, 2024
512443c
feat(lab3): bump procmgr
ToolmanP Sep 28, 2024
3d7620b
feat: add anticheat attestation
ToolmanP Sep 29, 2024
01ca983
fix(lab3): use dynamic generated ramdisk
ToolmanP Sep 29, 2024
73d4fe2
feat(lab3): tweak testing sources
ToolmanP Sep 29, 2024
5427c5f
feat(lab3): add anticheat
ToolmanP Sep 29, 2024
1842893
feat(lab3): update lab-defs
ToolmanP Sep 29, 2024
b498258
infra: allow files missing when submitting
ToolmanP Sep 29, 2024
3ec987c
docs: update linux-only warning
ToolmanP Sep 29, 2024
9684f5b
docs: update lab2 docs
ToolmanP Sep 29, 2024
795e57d
fix: back compatibility
ToolmanP Sep 29, 2024
6be63af
feat: tweak libc build cmakefile.txt
ToolmanP Sep 29, 2024
870cb79
docs(lab3): add lab3 docs
ToolmanP Sep 29, 2024
2351b4b
refactor: move musl-libc in the upper dir
ToolmanP Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ infer-out/
book/
**mermaid**
**/index.html
compile_commands.json
.cache/
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[submodule "Lab3/user/chcore-libc/musl-libc"]
path = Lab3/user/chcore-libc/musl-libc
url = git://git.musl-libc.org/musl
[submodule "Lab4/user/chcore-libc/musl-libc"]
path = Lab4/user/chcore-libc/musl-libc
url = git://git.musl-libc.org/musl
[submodule "Lab5/user/chcore-libc/musl-libc"]
path = Lab5/user/chcore-libc/musl-libc
url = git://git.musl-libc.org/musl
[submodule "Lab6/user/chcore-libc/musl-libc"]
path = Lab6/user/chcore-libc/musl-libc
url = git://git.musl-libc.org/musl
[submodule "Thirdparty/musl-libc"]
path = Thirdparty/musl-libc
url = git://git.musl-libc.org/musl
6 changes: 6 additions & 0 deletions Lab1/kernel/arch/aarch64/boot/linker.tpl.ld
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ SECTIONS
}
. = ALIGN(4K);

.init.serial : {
*(.init.serial*)
}
. = ALIGN(4K);
_serial_end = . - KERNEL_VADDR;

.rodata : {
*(.rodata*)
}
Expand Down
Binary file modified Lab1/kernel/arch/aarch64/main.c.dbg.obj
Binary file not shown.
Binary file modified Lab1/kernel/arch/aarch64/main.c.obj
Binary file not shown.
5 changes: 3 additions & 2 deletions Lab1/scores.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[
{
"capture": "Jump to kernel main",
"capture": "Welcome to ChCore shell!",
"msg": "Jump to kernel main",
"proposed": 100
"proposed": 100,
"userland": true
}
]
6 changes: 6 additions & 0 deletions Lab2/kernel/arch/aarch64/boot/linker.tpl.ld
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ SECTIONS
}
. = ALIGN(4K);

.init.serial : {
*(.init.serial*)
}
. = ALIGN(4K);
_serial_end = . - KERNEL_VADDR;

.rodata : {
*(.rodata*)
. = ALIGN(4K);
Expand Down
5 changes: 5 additions & 0 deletions Lab2/kernel/arch/aarch64/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ struct lock big_kernel_lock;
ALIGN(PAGE_SIZE)
char empty_page[4096] = {0};

__attribute__((section(".init.serial")))
ALIGN(PAGE_SIZE)
char serial_number[4096] = "0xDEADBEEF";

/* Kernel Test */
void run_test(void);

Expand Down Expand Up @@ -120,6 +124,7 @@ void main(paddr_t boot_flag, void *info)
/* Create initial thread here, which use the `init.bin` */
create_root_thread();
kinfo("[ChCore] create initial thread done\n");
kinfo("End of Kernel Checkpoints: %s\n", serial_number);

/* Leave the scheduler to do its job */
sched();
Expand Down
2 changes: 1 addition & 1 deletion Lab2/kernel/tests/runtime/lab2.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ TEST_SUITE(lab2, test_page_table)

free_page_table(pgtbl);
}
TEST("Map & unmap huge pages")
TEST("Map & unmap huge range")
{
void *pgtbl = get_pages(0);
paddr_t pa;
Expand Down
3 changes: 2 additions & 1 deletion Lab2/kernel/tests/runtime/tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
#ifndef KERNEL_TESTS_RUNTIME_TESTS_H
#define KERNEL_TESTS_RUNTIME_TESTS_H

extern char serial_number[4096];
#define TEST_SUITE(lab, name) void lab##_##name(void)
#define TEST(name) \
for (const char *test_name = (name); \
printk("[TEST] %s: OK\n", test_name),0;)
printk("[TEST] %s: OK: %s\n", test_name, serial_number),0;)
#define ASSERT(expr) \
do { \
if (!(expr)) \
Expand Down
3 changes: 2 additions & 1 deletion Lab2/scores.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
{
"capture": "Welcome to ChCore shell!",
"msg": "Page fault",
"proposed": 30
"proposed": 30,
"userland": true
}
]
2 changes: 2 additions & 0 deletions Lab3/.clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
CompilationDatabase: ./
6 changes: 0 additions & 6 deletions Lab3/.gdbinit

This file was deleted.

29 changes: 29 additions & 0 deletions Lab3/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "QEMU (cppdbg)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/kernel.img",
"args": [],
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"stopAtEntry": true,
"stopAtConnect": true,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
],
"MIMode": "gdb",
"targetArchitecture": "arm64",
"miDebuggerServerAddress": "localhost:1234",
"miDebuggerPath": "/usr/local/bin/gdb",
"preLaunchTask": "Setup QEMU"
}
]
}
6 changes: 6 additions & 0 deletions Lab3/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"clangd.arguments": [
"--compile-commands-dir=./"
],
"debug.allowBreakpointsEverywhere": true
}
21 changes: 21 additions & 0 deletions Lab3/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Setup QEMU",
"type": "shell",
"isBackground": true,
"command": "make qemu-gdb",
"problemMatcher": {
"pattern": {
"regexp": "^\\[QEMU\\] Waiting for GDB Connection"
},
"background": {
"activeOnStart": true,
"beginsPattern": "^\\[QEMU\\] Waiting for GDB Connection",
"endsPattern": "^\\[QEMU\\] Waiting for GDB Connection",
}
}
}
]
}
28 changes: 16 additions & 12 deletions Lab3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cmake_minimum_required(VERSION 3.14)
project(ChCore)

set(_cmake_script_dir ${CMAKE_CURRENT_SOURCE_DIR}/scripts/build/cmake)
set(_cmake_script_dir ${CMAKE_CURRENT_SOURCE_DIR}/../Scripts/build/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_cmake_script_dir}/Modules)
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}/user)

Expand Down Expand Up @@ -63,6 +63,7 @@ chcore_add_subproject(
INSTALL_DIR ${_libc_install_dir}
CMAKE_ARGS
${_common_args}
${_cache_args}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
CMAKE_CACHE_ARGS ${_cache_args}
INSTALL_COMMAND echo "Performed in CMake"
Expand Down Expand Up @@ -166,6 +167,7 @@ chcore_add_subproject(
INSTALL_DIR ${_system_services_install_dir}
CMAKE_ARGS
${_common_args}
${_cache_args}
-DCHCORE_MUSL_LIBC_INSTALL_DIR=${_libc_install_dir} # used by user.cmake toolchain to find `musl-gcc`
-DCHCORE_RAMDISK_DIR=${build_ramdisk_dir}
# -DCHCORE_CI_CONFIG_DIR=${_ci_config_dir}
Expand Down Expand Up @@ -199,13 +201,15 @@ chcore_add_subproject(
INSTALL_DIR ${_kernel_install_dir}
CMAKE_ARGS
${_common_args}
${_cache_args}
-DCHCORE_USER_INSTALL_DIR=${_system_services_install_dir} # used by kernel/CMakeLists.txt to incbin cpio files
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_TOOLCHAIN_FILE=${_cmake_script_dir}/Toolchains/kernel.cmake
CMAKE_CACHE_ARGS ${_cache_args}
DEPENDS system-services kernel-clean-incbin
BUILD_ALWAYS TRUE)


# Generate toolchain file
configure_file(${_cmake_script_dir}/Toolchains/toolchain_tpl.cmake
toolchain.cmake
Expand Down Expand Up @@ -234,17 +238,17 @@ add_dependencies(clean-all libc-clean-trigger system-services-clean-trigger)

# --- Update Submodules (always run in local env) ---

add_custom_target(update-submodules)

macro(_update_submodule _target _subproject_path _module_rel_path)
add_custom_target(
${_target}
WORKING_DIRECTORY ${_subproject_path}
COMMAND echo "Updating ${_subproject_path}/${_module_rel_path}..."
COMMAND git submodule update --init
--recursive --depth=1 ${_module_rel_path})
add_dependencies(update-submodules ${_target})
endmacro()
# add_custom_target(update-submodules)
#
# macro(_update_submodule _target _subproject_path _module_rel_path)
# add_custom_target(
# ${_target}
# WORKING_DIRECTORY ${_subproject_path}
# COMMAND echo "Updating ${_subproject_path}/${_module_rel_path}..."
# COMMAND git submodule update --init
# --recursive --depth=1 ${_module_rel_path})
# add_dependencies(update-submodules ${_target})
# endmacro()

# _update_submodule(update-musl-libc ${_system_services_source_dir} chcore-libc/musl-libc)

Expand Down
127 changes: 0 additions & 127 deletions Lab3/LICENSE

This file was deleted.

Loading