Skip to content

Commit d962f9c

Browse files
Merge branch 'coconut-svsm:main' into main
2 parents a22e314 + abefae4 commit d962f9c

186 files changed

Lines changed: 2447 additions & 1094 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.lock

Lines changed: 18 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ members = [
3939
"tools/cbit",
4040
]
4141

42+
[workspace.package]
43+
edition = "2024"
4244

4345
[workspace.dependencies]
4446
# internal library crates
@@ -79,6 +81,7 @@ kbs-types = { version = "0.14.0", default-features = false }
7981
libfuzzer-sys = "0.4"
8082
log = "0.4.17"
8183
p384 = { version = "0.13.0" }
84+
rustc-demangle = { version = "0.1.26" }
8285
serde = { version = "1.0.215", default-features = false }
8386
serde_json = { version = "1.0", default-features = false }
8487
sha2 = { version = "0.10.8", default-features = false }

Documentation/docs/developer/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Coding Style
3939
Submitted changes must be checked with ```rustfmt``` before submitting
4040
and submitted code must not introduce new warnings in the build process.
4141

42-
Make sure to format the code according to Rust edition 2021. There is a
42+
Make sure to format the code according to Rust edition 2024. There is a
4343
git-hook in the scripts directory which checks any changes with rustfmt
4444
before allowing them to be committed. It can be installed by running
4545

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SVSM_ARGS += --features ${FEATURES}
44
XBUILD_ARGS += -f ${FEATURES}
55
endif
66

7-
FEATURES_TEST ?= vtpm,virtio-drivers
7+
FEATURES_TEST ?= vtpm,virtio-drivers,block
88
SVSM_ARGS_TEST += --no-default-features
99
ifneq ($(FEATURES_TEST),)
1010
SVSM_ARGS_TEST += --features ${FEATURES_TEST}
@@ -20,8 +20,10 @@ ifdef RELEASE
2020
TARGET_PATH=release
2121
CARGO_ARGS += --release
2222
XBUILD_ARGS += --release
23+
OBJCOPY_ELF_ARGS := --strip-unneeded
2324
else
2425
TARGET_PATH=debug
26+
OBJCOPY_ELF_ARGS := --strip-debug
2527
endif
2628

2729
ifdef OFFLINE
@@ -145,7 +147,7 @@ bin/stage2.bin: bin
145147

146148
bin/svsm-kernel.elf: bin
147149
cargo build --package svsm --bin svsm ${CARGO_ARGS} ${SVSM_ARGS} --target=x86_64-unknown-none
148-
objcopy -O elf64-x86-64 --strip-unneeded ${SVSM_KERNEL_ELF} $@
150+
objcopy -O elf64-x86-64 ${OBJCOPY_ELF_ARGS} ${SVSM_KERNEL_ELF} $@
149151

150152
bin/test-kernel.elf: bin
151153
# RUSTDOC=true removes doctests, which is necessary as they do not work with

bootlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bootlib"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition.workspace = true
55

66
[dependencies]
77
uuid.workspace = true

bootlib/src/firmware.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Author: Carlos López <carlos.lopezr4096@gmail.com>
44

5-
use uuid::{uuid, Uuid};
5+
use uuid::{Uuid, uuid};
66

77
pub const OVMF_RESET_VECTOR_GUID: Uuid = uuid!("813d7b2c-9558-4d88-8b31-1427a85abe69");
88
pub const OVMF_SEV_METADATA_GUID: Uuid = uuid!("dc886566-984a-4798-a75e-5585a7bf67cc");

bootlib/src/kernel_launch.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
//
55
// Author: Joerg Roedel <jroedel@suse.de>
66

7-
use crate::platform::SvsmPlatformType;
7+
use crate::{platform::SvsmPlatformType, symbols::KSym};
88
use core::mem::size_of;
99
use zerocopy::{FromBytes, Immutable, IntoBytes};
1010

1111
// The SIPI stub is placed immediately below the stage 2 heap.
1212
pub const SIPI_STUB_GPA: u32 = 0xF000;
1313

14+
// Two pages below the SIPI stub are used for low memory page tables.
15+
pub const SIPI_STUB_PT_GPA: u32 = 0xD000;
16+
1417
// The first 640 KB of RAM (low memory)
1518
pub const LOWMEM_END: u32 = 0xA0000;
1619

@@ -39,18 +42,18 @@ pub struct KernelLaunchInfo {
3942
pub heap_area_allocated: u64,
4043
pub kernel_region_virt_start: u64,
4144
pub heap_area_virt_start: u64, // Start of virtual heap area mapping.
42-
pub kernel_elf_stage2_virt_start: u64, // Virtual address of kernel ELF in Stage2 mapping.
43-
pub kernel_elf_stage2_virt_end: u64,
4445
pub kernel_fs_start: u64,
4546
pub kernel_fs_end: u64,
4647
pub stage2_start: u64,
47-
pub stage2_end: u64,
4848
pub cpuid_page: u64,
4949
pub secrets_page: u64,
50-
pub stage2_igvm_params_phys_addr: u64,
51-
pub stage2_igvm_params_size: u64,
5250
pub igvm_params_virt_addr: u64,
51+
pub kernel_symtab_start: *const KSym,
52+
pub kernel_symtab_len: u64,
53+
pub kernel_strtab_start: *const u8,
54+
pub kernel_strtab_len: u64,
5355
pub vtom: u64,
56+
pub kernel_page_table_vaddr: u64,
5457
pub debug_serial_port: u16,
5558
pub use_alternate_injection: bool,
5659
pub suppress_svsm_interrupts: bool,

bootlib/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ pub mod firmware;
1414
pub mod igvm_params;
1515
pub mod kernel_launch;
1616
pub mod platform;
17+
pub mod symbols;

bootlib/src/symbols.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
//
3+
// Copyright (c) 2026 SUSE LLC
4+
//
5+
// Author: Carlos López <clopez@suse.de>
6+
7+
use zerocopy::{FromBytes, Immutable, IntoBytes};
8+
9+
/// A smaller version of `Elf64Sym`.
10+
///
11+
/// Defines the format of the symbol information passed to the SVSM kernel to be
12+
/// able to perform address to symbol resolution.
13+
#[repr(C)]
14+
#[derive(Clone, Copy, Debug, IntoBytes, Immutable, FromBytes)]
15+
pub struct KSym {
16+
/// The starting address of the symbol.
17+
pub addr: usize,
18+
/// The span of the symbol in the address space.
19+
pub size: u32,
20+
/// The name of the symbol, as an index into the `strtab`.
21+
pub name: u32,
22+
}
23+
24+
impl KSym {
25+
pub const fn new(addr: usize, size: u32, name: u32) -> Self {
26+
Self { addr, size, name }
27+
}
28+
29+
/// Checks whether a given address falls within the span of this symbol.
30+
pub const fn contains(&self, addr: usize) -> bool {
31+
let end = self.addr + self.size as usize;
32+
self.addr <= addr && addr < end
33+
}
34+
}

cpuarch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "cpuarch"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition.workspace = true
55

66
[dependencies]
77
bitfield-struct.workspace = true

0 commit comments

Comments
 (0)