Skip to content
Open
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
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ ksync = { path = "core/ksync" }
ktask = { path = "core/ktask" }
watchdog = { path = "io/watchdog" }
kcpu = { path = "arch/kcpu" }
karch = { path = "arch/karch" }


# x-kernel Crates
alloc-engine = { path = "mm/alloc-engine" }
Expand Down Expand Up @@ -128,7 +130,6 @@ net = { path = "drivers/net" }
pci = { path = "drivers/pci" }
vsock = { path = "drivers/vsock" }
virtio = { path = "drivers/virtio" }
virtio-drivers = { version = "0.12.0", default-features = false }
aarch64-pmuv3 = { path = "drivers/aarch64-pmuv3" }
fatfs = { path = "fs/fatfs", default-features = false }
rsext4 = { path = "fs/rsext4", default-features = false }
Expand All @@ -144,3 +145,4 @@ kbuild_config = { path = "util/kbuild_config" }

kconfig-gen = { path = "xtask/kconfig-gen" }
smoltcp = { version = "0.12.0", package = "x-smoltcp", default-features = false }
virtio-drivers = { version = "0.7.4", default-features = false }
69 changes: 69 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env groovy

pipeline {
agent {
docker {
image 'yeanwang/x-kernel-builder:v1.0'
args '-v /var/run/docker.sock:/var/run/docker.sock --privileged -u root:root' }
}

environment {
CI = 'true'
TEST_HARNESS_REPO = 'https://gitee.com/openkylin/starry-test-harness'
TEST_HARNESS_BRANCH = 'master'
}

stages {
stage('Parallel Architecture Verification') {
failFast true
parallel {
stage('Architecture: aarch64') {
steps {
script { executeBuildAndTest('aarch64') }
}
}
stage('Architecture: x86_64') {
steps {
script { executeBuildAndTest('x86_64') }
}
}
}
}
}

post {
always {
archiveArtifacts artifacts: '**/artifacts/**/*', allowEmptyArchive: true
archiveArtifacts artifacts: '**/logs/**/*', allowEmptyArchive: true
cleanWs()
}
success {
updateGiteeCommitStatus state: 'success', context: 'ci/jenkins'
}
unsuccessful {
updateGiteeCommitStatus state: 'failed', context: 'ci/jenkins'
}
}
}

def executeBuildAndTest(arch) {
ws("${WORKSPACE}/${arch}") {
echo "Verifying architecture: ${arch}"

checkout scm
sh "git config --global --add safe.directory ${pwd()}"
dir('test-harness') {
git branch: "${env.TEST_HARNESS_BRANCH}",
url: "${env.TEST_HARNESS_REPO}",
credentialsId: 'gitee-my-token'

sh "git config --global --add safe.directory ${pwd()}"
}

dir('test-harness') {
withEnv(["XKERNEL_ROOT=${pwd()}/..", "ARCH=${arch}"]) {
sh "make ci-test run"
}
}
}
}
32 changes: 22 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
# Enable unstable features
export RUSTC_BOOTSTRAP := 1
export DWARF := y
export DISK_IMG ?= $(PWD)/disk.img
XCONF = env RUSTFLAGS= CARGO_ENCODED_RUSTFLAGS= cargo run --manifest-path xtask/xconfig/Cargo.toml --bin xconf --

V ?=
LTO ?=
Expand Down Expand Up @@ -94,6 +96,9 @@ GDB ?= gdb
OUT_DIR ?= $(PWD)
LD_SCRIPT ?= $(abspath $(TARGET_DIR)/$(TARGET)/$(MODE)/linker_$(PLAT_NAME).lds)

# Generate Rust const definitions from .config
CONFIG_RS := $(TARGET_DIR)/kbuild/config.rs

APP_NAME := xkernel
OUT_ELF := $(OUT_DIR)/$(APP_NAME)_$(PLAT_NAME).elf
OUT_BIN := $(patsubst %.elf,%.bin,$(OUT_ELF))
Expand All @@ -116,14 +121,14 @@ else ifeq ($(PLAT_NAME), aarch64-bsta1000b)
include scripts/make/bsta1000b-fada.mk
endif

ROOTFS_URL = https://github.com/Starry-OS/rootfs/releases/download/20250917
ROOTFS_URL = https://gitee.com/openkylin/x-kernel-image/releases/download/20260302/
ROOTFS_IMG = rootfs-$(ARCH).img

endif # end of IS_BUILD


menuconfig:
@xconf menuconfig -k Kconfig -s .
@$(XCONF) menuconfig -k Kconfig -s .
@if [ -f .config ]; then \
echo "✅ Configuration saved to .config"; \
else \
Expand All @@ -142,27 +147,32 @@ teefs:
$(MAKE) -C tee_apps ARCH=$(ARCH)

defconfig:
@xconf saveconfig -o .config -k Kconfig -s .
@$(XCONF) saveconfig -o .config -k Kconfig -s .
@echo "✅ Default configuration saved to .config"

saveconfig:
@xconf saveconfig -o .config -k Kconfig -s .
@$(XCONF) saveconfig -o .config -k Kconfig -s .

oldconfig:
@if [ ! -f .config ]; then \
echo "$(RED_C)Error$(END_C): .config not found."; \
echo "Please run 'make defconfig' or 'make menuconfig' first."; \
exit 1; \
fi
@xconf oldconfig -c .config -k Kconfig -s .
@$(XCONF) oldconfig -c .config -k Kconfig -s .

# Generate const definitions before build
gen-const: .config

# 只在 .config 更新时才生成
$(CONFIG_RS): .config
@echo "📝 Generating Rust const definitions from .config..."
@xconf gen-const
@$(XCONF) gen-const
@echo "✅ Generated config.rs"

build: gen-const $(OUT_DIR) $(FINAL_IMG)

# Generate const definitions before build
gen-const: $(CONFIG_RS)

build: $(CONFIG_RS) $(OUT_DIR) $(FINAL_IMG)

disasm:
$(OBJDUMP) $(OUT_ELF) | less
Expand All @@ -180,7 +190,7 @@ debug: build
-ex 'continue' \
-ex 'disp /16i $$pc'

clippy: gen-const
clippy: $(CONFIG_RS)
ifeq ($(origin ARCH), command line)
$(call cargo_clippy,--target $(TARGET))
else
Expand Down Expand Up @@ -221,6 +231,8 @@ distclean: clean
clean_c::
rm -rf $(app-objs)

# Note: gen-const is kept as PHONY to allow manual invocation,
# but the actual dependency is on $(CONFIG_RS) which is file-based
.PHONY: all defconfig oldconfig menuconfig saveconfig gen-const \
build disasm run justrun debug \
clippy doc doc_check_missing fmt fmt_c unittest unittest_no_fail_fast \
Expand Down
7 changes: 7 additions & 0 deletions api/kapi/src/tee/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# tee

rust implement for tee core

## arch

hygon_csv_bindings.rs is auto generated by repo https://gitee.com/kylinyubo/rust-csv-guest-module-tools.
4 changes: 4 additions & 0 deletions api/kapi/src/tee/arch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2025 KylinSoft Co., Ltd. <https://www.kylinos.cn/>
// See LICENSES for license details.

#[cfg(target_arch = "x86_64")]
pub mod x86_64;
2 changes: 1 addition & 1 deletion api/kapi/src/tee/arch/x86_64/hygon_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn get_huk_key(huk_key: &mut [u8]) -> TeeResult {
let salt = "Hygon CSV Sealing Key";
Hkdf::hkdf(MdType::SM3, &salt.as_bytes(), sealing_key, &[], huk_key)
.map_err(|_| TEE_ERROR_BAD_PARAMETERS)?;
warn!("get_huk_key: huk_key: {:?}", slice_fmt(huk_key));
// warn!("get_huk_key: huk_key: {:?}", slice_fmt(huk_key));
Ok(())
}

Expand Down
4 changes: 4 additions & 0 deletions api/kapi/src/tee/arch/x86_64/hygon_csv_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2025 KylinSoft Co., Ltd. <https://www.kylinos.cn/>
// See LICENSES for license details.

// automatically generated by rust-bindgen 0.69.5

#[repr(C)]
Expand Down
4 changes: 4 additions & 0 deletions api/kapi/src/tee/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2025 KylinSoft Co., Ltd. <https://www.kylinos.cn/>
// See LICENSES for license details.

#[cfg(feature = "x86_csv")]
pub mod hygon_csv;
#[cfg(feature = "x86_csv")]
Expand Down
Loading