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
82 changes: 82 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,50 @@ jobs:
- name: Setup build environment
uses: ./.github/actions/setup-build-env

- name: Install cross-compilation dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends lld

- name: Add musl target
run: rustup target add x86_64-unknown-linux-musl

- name: Add FreeBSD x86_64 target
run: rustup target add x86_64-unknown-freebsd

- name: Install FreeBSD test prerequisites
run: sudo apt-get install -y --no-install-recommends libarchive-tools

- name: Build FreeBSD sysroot and init
run: make BUILD_BSD_INIT=1 -- init/init-freebsd

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 'stable'

- name: Build and cache gvproxy (x86_64)
uses: actions/cache@v4
id: gvproxy-cache
with:
path: /tmp/gvproxy-bin/
key: gvproxy-x86_64-c09fb7d

- name: Build gvproxy
if: steps.gvproxy-cache.outputs.cache-hit != 'true'
run: |
GVPROXY_BUILD_DIR=$(mktemp -d)
git clone https://github.com/containers/gvisor-tap-vsock.git "$GVPROXY_BUILD_DIR"
cd "$GVPROXY_BUILD_DIR"
git checkout c09fb7d0a9e08260d238066c3c4311498d15311e
mkdir -p /tmp/gvproxy-bin
make
cp bin/gvproxy /tmp/gvproxy-bin/gvproxy-x86_64

- name: Install gvproxy to PATH
run: |
sudo cp /tmp/gvproxy-bin/gvproxy-x86_64 /usr/local/bin/gvproxy

- name: Build and install libkrun to test prefix
run: make test-prefix NET=1

Expand Down Expand Up @@ -80,9 +121,50 @@ jobs:
- name: Setup build environment
uses: ./.github/actions/setup-build-env

- name: Install cross-compilation dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang lld

- name: Add musl target
run: rustup target add aarch64-unknown-linux-musl

- name: Install nightly toolchain with rust-src for FreeBSD aarch64
run: rustup +nightly-2026-01-25 component add rust-src

- name: Install FreeBSD test prerequisites
run: sudo apt-get install -y --no-install-recommends libarchive-tools

- name: Build FreeBSD sysroot and init
run: make BUILD_BSD_INIT=1 -- init/init-freebsd

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 'stable'

- name: Build and cache gvproxy (aarch64)
uses: actions/cache@v4
id: gvproxy-cache
with:
path: /tmp/gvproxy-bin/
key: gvproxy-aarch64-c09fb7d

- name: Build gvproxy
if: steps.gvproxy-cache.outputs.cache-hit != 'true'
run: |
GVPROXY_BUILD_DIR=$(mktemp -d)
git clone https://github.com/containers/gvisor-tap-vsock.git "$GVPROXY_BUILD_DIR"
cd "$GVPROXY_BUILD_DIR"
git checkout c09fb7d0a9e08260d238066c3c4311498d15311e
mkdir -p /tmp/gvproxy-bin
make
cp bin/gvproxy /tmp/gvproxy-bin/gvproxy-aarch64

- name: Install gvproxy to PATH
run: |
sudo cp /tmp/gvproxy-bin/gvproxy-aarch64 /usr/local/bin/gvproxy

- name: Build and install libkrun to test prefix
run: make test-prefix NET=1

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ endif
ifeq ($(VIRGL_RESOURCE_MAP2),1)
FEATURE_FLAGS += --features virgl_resource_map2
endif
# Test targets require the block device (BLK) feature for FreeBSD disk tests
# and the NET feature for gvproxy-based network tests.
# Enable automatically unless the user explicitly set them to a value.
ifeq ($(BLK),)
ifneq ($(filter test test-prefix,$(MAKECMDGOALS)),)
BLK := 1
endif
endif
ifeq ($(NET),)
ifneq ($(filter test test-prefix,$(MAKECMDGOALS)),)
NET := 1
endif
endif
ifeq ($(BLK),1)
FEATURE_FLAGS += --features blk
endif
Expand Down
3 changes: 3 additions & 0 deletions src/arch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ kvm-bindings = { version = "0.12", features = ["fam-wrappers"] }
kvm-ioctls = "0.22"
tdx = { version = "0.1.0", optional = true }

[target.'cfg(target_arch = "x86_64")'.dependencies]
linux-loader = { version = "0.13.2", features = ["elf"] }

[dev-dependencies]
utils = { package = "krun-utils", version = "=0.1.0-1.18.0", path = "../utils" }
11 changes: 9 additions & 2 deletions src/arch/src/x86_64/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ fn get_base(entry: u64) -> u64 {
}

fn get_limit(entry: u64) -> u32 {
((((entry) & 0x000F_0000_0000_0000) >> 32) | ((entry) & 0x0000_0000_0000_FFFF)) as u32
let limit =
((((entry) & 0x000F_0000_0000_0000) >> 32) | ((entry) & 0x0000_0000_0000_FFFF)) as u32;

if get_g(entry) == 1 {
(limit << 12) | 0xFFF
} else {
limit
}
}

fn get_g(entry: u64) -> u8 {
Expand Down Expand Up @@ -109,7 +116,7 @@ mod tests {
assert_eq!(0xB, seg.type_);
// base and limit
assert_eq!(0x10_0000, seg.base);
assert_eq!(0xfffff, seg.limit);
assert_eq!(0xffffffff, seg.limit);
assert_eq!(0x0, seg.unusable);
}
}
15 changes: 15 additions & 0 deletions src/arch/src/x86_64/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ pub const IRQ_MAX: u32 = 15;
/// Address for the TSS setup.
pub const KVM_TSS_ADDRESS: u64 = 0xfffb_d000;

/// Address of the hvm_start_info struct used in PVH boot.
/// Mutually exclusive with SNP_CPUID_START (TEE only).
pub const PVH_INFO_START: u64 = 0x6000;

/// Starting address of array of modules of hvm_modlist_entry type.
/// Used to enable initrd support using the PVH boot ABI.
pub const MODLIST_START: u64 = 0x6040;

/// Address of memory map table used in PVH boot. Can overlap
/// with the zero page address since they are mutually exclusive.
pub const MEMMAP_START: u64 = 0x7000;

/// Location of RSDP pointer in x86 machines.
pub const RSDP_ADDR: u64 = 0x000e_0000;

/// The 'zero page', a.k.a linux kernel bootparams.
pub const ZERO_PAGE_START: u64 = 0x7000;

Expand Down
Loading
Loading