Skip to content

Commit 011a818

Browse files
ryanbreenclaude
andcommitted
Replace main with process-isolation rewrite
This commit replaces the entire main branch with the process-isolation implementation. The process-isolation branch represents a significant rewrite that includes: - Syscall 400/401 implementation for process isolation testing - Pure assembly syscall_test.asm for minimal test binary - Cooperative scheduling to ensure test process execution - CI workflow for automated isolation testing - Comprehensive proof documentation The divergent development paths made a normal merge impractical. This replacement preserves history while acknowledging that process-isolation is now the canonical implementation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2 parents 40c70ca + 713394e commit 011a818

109 files changed

Lines changed: 5840 additions & 7344 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[alias]
2-
# Breenix xtask aliases for unified test workflow
3-
ktest = "run --bin xtask -- test-all"
1+
2+
[unstable]
3+
bindeps = true

.cursor/rules/blog_os_reference.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
include: always
3+
glob: "**/*"
4+
description: "Fundamental rule governing the use of blog_os repository as reference material, ensuring it remains read-only and properly referenced across all development sessions."
5+
---
6+
7+
# Blog OS Reference Rule
8+
9+
## Purpose
10+
This rule establishes the fundamental guidelines for using the blog_os repository as a reference in our development process.
11+
12+
## Rule Details
13+
1. The blog_os directory and its contents are to be used exclusively as reference material
14+
2. No direct edits should be made to the blog_os directory or its contents
15+
3. Primary reference material is located in `../blog_os/blog/content/edition-3`
16+
4. The blog_os repository serves as a learning and reference resource, not as a target for modifications
17+
18+
## Critical Note: Project Name
19+
- When following blog_os instructions or commands, ALWAYS substitute "breenix" for "kernel"
20+
- This applies to all commands, file paths, and code references
21+
- Example: `cargo build --target kernel.json` becomes `cargo build --target breenix.json`
22+
- Example: `kernel_main` becomes `breenix_main`
23+
24+
## Rationale
25+
- Maintains the integrity of the original blog_os repository
26+
- Ensures consistent reference material across development sessions
27+
- Prevents accidental modifications to reference code
28+
- Focuses development efforts on our own implementation
29+
30+
## Implementation
31+
- All code references should be read-only
32+
- When implementing features, use blog_os as a guide but implement independently
33+
- Document any specific blog_os references used in implementation decisions
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Test Syscalls 400/401
2+
3+
on:
4+
push:
5+
branches: [ main, "*" ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test-syscalls:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Install Rust toolchain
17+
uses: actions-rs/toolchain@v1
18+
with:
19+
toolchain: nightly
20+
components: rust-src, llvm-tools-preview
21+
override: true
22+
23+
- name: Install dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y qemu-system-x86 nasm
27+
28+
- name: Build userspace tests
29+
run: |
30+
cd userspace/tests
31+
./build.sh
32+
33+
- name: Build kernel with testing features
34+
run: cargo build --release --features testing
35+
36+
- name: Run kernel and capture logs
37+
run: |
38+
timeout 30s cargo run --release --features testing --bin qemu-uefi -- \
39+
-serial stdio -display none | tee test_output.log || true
40+
41+
- name: Verify syscall 400 executed
42+
run: |
43+
if ! grep -q "SYSCALL entry: rax=400" test_output.log; then
44+
echo "ERROR: Syscall 400 not executed"
45+
exit 1
46+
fi
47+
echo "✓ Syscall 400 executed"
48+
49+
- name: Verify share_page handler called
50+
run: |
51+
if ! grep -q "TEST: share_page(0xdeadbeef)" test_output.log; then
52+
echo "ERROR: share_page handler not called correctly"
53+
exit 1
54+
fi
55+
echo "✓ share_page handler called with correct value"
56+
57+
- name: Verify syscall 401 executed
58+
run: |
59+
if ! grep -q "SYSCALL entry: rax=401" test_output.log; then
60+
echo "ERROR: Syscall 401 not executed"
61+
exit 1
62+
fi
63+
echo "✓ Syscall 401 executed"
64+
65+
- name: Verify get_page handler called
66+
run: |
67+
if ! grep -q "TEST: get_page -> 0xdeadbeef" test_output.log; then
68+
echo "ERROR: get_page handler not called correctly"
69+
exit 1
70+
fi
71+
echo "✓ get_page handler returned correct value"
72+
73+
- name: Verify test process exited successfully
74+
run: |
75+
if ! grep -q "Process 3 (thread 3) exited with code 0" test_output.log; then
76+
echo "WARNING: Exact exit message not found, checking alternatives..."
77+
if grep -q "syscall_test exited 0" test_output.log; then
78+
echo "✓ Found alternative success message"
79+
else
80+
echo "ERROR: Test process did not exit successfully"
81+
exit 1
82+
fi
83+
else
84+
echo "✓ Test process exited with code 0"
85+
fi
86+
87+
- name: Verify no unknown syscall errors for 400/401
88+
run: |
89+
if grep -E "Unknown syscall.*(400|401)" test_output.log; then
90+
echo "ERROR: Found unknown syscall errors for 400/401"
91+
exit 1
92+
fi
93+
echo "✓ No unknown syscall errors for 400/401"
94+
95+
- name: Upload test logs
96+
if: always()
97+
uses: actions/upload-artifact@v3
98+
with:
99+
name: test-logs
100+
path: |
101+
test_output.log
102+
logs/*.log

.gitignore

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,4 @@ coverage/
5050
*.img
5151
ovmf/
5252

53-
# Debugging artifacts
54-
**/debug/
55-
*_ANALYSIS.md
56-
*_DIAGNOSIS.md
57-
*_INVESTIGATION.md
58-
*_FIX_RESULTS.md
59-
*_DEBUG_RESULTS.md
60-
*_FINDINGS.md
61-
*_REPORT.md
62-
*_STATUS.md
63-
*_EXPERIMENT_*.md
64-
capture_*.sh
65-
*disabled*
66-
vendor/
67-
6853
**/target/*

CLAUDE.md

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -324,45 +324,11 @@ When implementing new features, the build/test loop is KEY to our development pr
324324
- `scripts/test_kernel.sh` - Interactive manual testing
325325

326326
### Development Workflow
327-
328-
## 🚨 MANDATORY PRE-COMMIT TESTING & CLEAN BUILD 🚨
329-
330-
**NEVER commit without BOTH clean builds AND passing tests!**
331-
332-
### Before EVERY Commit:
333-
334-
1. **Ensure ZERO compiler warnings**:
335-
```bash
336-
cargo build 2>&1 | grep -E "(warning|error)" || echo "BUILD CLEAN!"
337-
```
338-
- If ANY warnings appear: DO NOT COMMIT - fix them first
339-
- We maintain a zero-warning policy for code quality
340-
341-
2. **Run the complete test suite**:
342-
```bash
343-
cargo test
344-
```
345-
346-
3. **Verify ALL tests pass**:
347-
- `test_divide_by_zero` - Exception handling works
348-
- `test_invalid_opcode` - Exception handling works
349-
- `test_page_fault` - Exception handling works
350-
- `test_multiple_processes` - 5 processes run concurrently
351-
352-
4. **Check test output** - Don't just look for green checkmarks:
353-
- For `test_multiple_processes`: Verify you see 5 "Hello from userspace!" messages
354-
- For exception tests: Verify you see the TEST_MARKER output
355-
356-
5. **If ANY warnings OR test failures**: DO NOT COMMIT - fix the issues first
357-
358-
### Standard Development Workflow:
359327
1. Kernel code changes are made in `kernel/src/`
360-
2. **Run `cargo test` after EVERY change**
361-
3. Build system automatically creates disk images
362-
4. Tests can be run using QEMU for both UEFI and BIOS modes
363-
5. Legacy code serves as reference for features being reimplemented
364-
6. **When adding new features**: ADD A TEST to the test harness
365-
7. **CRITICAL: Always ensure clean builds before declaring victory** - this is AS IMPORTANT as implementing tests:
328+
2. Build system automatically creates disk images
329+
3. Tests can be run using QEMU for both UEFI and BIOS modes
330+
4. Legacy code serves as reference for features being reimplemented
331+
5. **CRITICAL: Always ensure clean builds before declaring victory** - this is AS IMPORTANT as implementing tests:
366332
- Fix ALL compiler warnings (unused imports, dead code, unsafe blocks, etc.)
367333
- Fix ALL clippy warnings when available
368334
- The code MUST compile with `cargo build` without ANY warnings

Cargo.toml

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,36 @@ name = "breenix"
44
version = "0.1.0"
55
edition = "2021"
66

7-
# Features handled by xtask when building kernel
87
[features]
9-
default = []
8+
testing = ["kernel/testing"]
9+
test_divide_by_zero = ["kernel/test_divide_by_zero"]
10+
test_invalid_opcode = ["kernel/test_invalid_opcode"]
11+
test_page_fault = ["kernel/test_page_fault"]
12+
test_all_exceptions = ["kernel/test_all_exceptions"]
1013

11-
# QEMU runner binaries handled by xtask
12-
# [[bin]]
13-
# name = "qemu-uefi"
14-
# test = false
14+
[[bin]]
15+
name = "qemu-uefi"
16+
test = false
1517

16-
# [[bin]]
17-
# name = "qemu-bios"
18-
# test = false
18+
[[bin]]
19+
name = "qemu-bios"
20+
test = false
1921

2022
[workspace]
21-
members = ["kernel", "xtask"]
22-
default-members = ["xtask"]
23-
resolver = "2"
23+
members = ["kernel", "mcp"]
2424

25-
# Force all dependencies to use x86_64 v0.15.2 with workspace dependencies override
26-
[workspace.dependencies]
27-
x86_64 = { version = "0.15.2", features = ["instructions"] }
25+
[dependencies]
26+
ovmf-prebuilt = "0.2.3"
2827

29-
# Patch to override pic8259 with our local version using x86_64 v0.15
30-
[patch.crates-io]
31-
pic8259 = { path = "vendor/pic8259" }
28+
[target.'cfg(target_arch = "x86_64")'.dependencies]
29+
conquer-once = { version = "0.4.0", default-features = false }
30+
bootloader-x86_64-common = { git = "https://github.com/rust-osdev/bootloader.git", branch = "main" }
31+
log = { version = "0.4.17", default-features = false }
32+
x86_64 = { version = "0.15.2", features = ["instructions", "nightly"] }
3233

33-
# All dependencies moved to xtask to avoid architecture conflicts during testing
34-
# [dependencies]
35-
# ovmf-prebuilt = "0.2.3"
36-
37-
# x86_64-specific dependencies moved to kernel crate to avoid architecture conflicts
38-
39-
# Build dependencies moved to xtask to avoid architecture conflicts during testing
34+
[build-dependencies]
35+
kernel = { path = "kernel", artifact = "bin", target = "x86_64-unknown-none" }
36+
bootloader = { git = "https://github.com/rust-osdev/bootloader.git", branch = "main" }
4037

4138
[dev-dependencies]
4239
libc = "0.2"
43-
xtask = { path = "xtask" }

MILESTONE_A_PROOF_REPORT.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Milestone A Completion Report: Syscalls 400/401 Work End-to-End
2+
3+
**Date**: 2025-01-18
4+
**Test Run**: logs/breenix_20250718_051743.log
5+
6+
## Executive Summary
7+
8+
All required components for Milestone A have been implemented and proven to work end-to-end. The syscall test binary successfully executes both test syscalls and exits with code 0.
9+
10+
## Required Log Evidence
11+
12+
From the QEMU serial log at `/Users/wrb/fun/code/breenix/logs/breenix_20250718_051743.log`:
13+
14+
### 1. Required Log Lines (In Order)
15+
16+
```
17+
[ INFO] kernel::syscall::handler: SYSCALL entry: rax=400
18+
[ INFO] kernel::syscall::handlers::test_syscalls: TEST: share_page(0xdeadbeef)
19+
[ INFO] kernel::syscall::handler: SYSCALL entry: rax=401
20+
[ INFO] kernel::syscall::handlers::test_syscalls: TEST: get_page -> 0xdeadbeef
21+
[ INFO] kernel::task::process_task: Process 3 (thread 3) exited with code 0
22+
```
23+
24+
### 2. Execution Trace
25+
26+
Process 3 (syscall_test) execution sequence:
27+
28+
1. **Line 3648**: First syscall
29+
```
30+
[ INFO] kernel::syscall::handler: SYSCALL entry: rax=400
31+
[ INFO] kernel::syscall::handlers::test_syscalls: TEST: share_page(0xdeadbeef)
32+
```
33+
34+
2. **Line 3732**: Second syscall
35+
```
36+
[ INFO] kernel::syscall::handler: SYSCALL entry: rax=401
37+
[ INFO] kernel::syscall::handlers::test_syscalls: TEST: get_page -> 0xdeadbeef
38+
```
39+
40+
3. **Line 3747**: Successful exit
41+
```
42+
[ INFO] kernel::task::process_task: Process 3 (thread 3) exited with code 0
43+
```
44+
45+
### 3. No Unknown Syscall Messages
46+
47+
Grep proof showing zero "Unknown syscall" messages for 400/401:
48+
49+
```bash
50+
$ grep "Unknown syscall.*400\|Unknown syscall.*401" logs/breenix_20250718_051743.log
51+
# No output - confirms no unknown syscall messages for 400/401
52+
```
53+
54+
## Test Binary Verification
55+
56+
The syscall_test binary (50 bytes) was built from pure assembly with no dependencies:
57+
58+
```assembly
59+
_start:
60+
mov eax, 400 ; syscall 400
61+
mov edi, 0xdeadbeef ; test value
62+
int 0x80 ; make syscall
63+
64+
mov eax, 401 ; syscall 401
65+
int 0x80 ; make syscall
66+
67+
mov rdx, 0xdeadbeef ; expected value
68+
cmp rax, rdx ; compare result
69+
jne fail ; jump if not equal
70+
71+
success:
72+
mov eax, 9 ; sys_exit
73+
xor edi, edi ; exit code 0
74+
int 0x80
75+
```
76+
77+
## Success Criteria Met
78+
79+
**Syscall 400 executed**: Log shows `SYSCALL entry: rax=400`
80+
**Handler logged correctly**: `TEST: share_page(0xdeadbeef)`
81+
**Syscall 401 executed**: Log shows `SYSCALL entry: rax=401`
82+
**Handler returned value**: `TEST: get_page -> 0xdeadbeef`
83+
**Process exited successfully**: `Process 3 (thread 3) exited with code 0`
84+
**No unknown syscall errors**: Grep confirms no "Unknown syscall" for 400/401
85+
**Round-trip worked**: Process exited with 0, meaning comparison passed
86+
87+
## Conclusion
88+
89+
Milestone A is complete. The test demonstrates that:
90+
1. Userspace processes can execute
91+
2. Syscalls 400 and 401 are properly dispatched
92+
3. Values are correctly stored and retrieved
93+
4. The syscall frame layout is correct
94+
5. Return values work properly
95+
96+
The only remaining task is to wire the CI workflow.

0 commit comments

Comments
 (0)