Skip to content

Commit bafd728

Browse files
authored
Fix CI pipeline, podman container build (#36)
* Update Rust version * Dev container: fix cacheFrom for podman * Fix kani compilation Also restoring MIN_RANGE_SIZE that seems to have been deleted accidentally in 86e35b2 * Use latest tag
1 parent c9a6753 commit bafd728

6 files changed

Lines changed: 47 additions & 34 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ENV CARGO_HOME=/usr/local/cargo
8585
ENV KANI_HOME=/usr/local/kani
8686
ENV PATH="/usr/local/cargo/bin:${PATH}"
8787

88-
ARG RUST_VERSION=1.90.0
88+
ARG RUST_VERSION=1.93.1
8989
RUN --mount=type=cache,target=/usr/local/cargo/registry \
9090
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
9191
| sh -s -- -y --no-modify-path --default-toolchain ${RUST_VERSION} && \

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"dockerfile": "Dockerfile",
66
"context": "..",
77
"cacheFrom": [
8-
"ghcr.io/osirisrtos/osiris/devcontainer:main",
9-
"ghcr.io/osirisrtos/osiris/devcontainer:main-cache"
8+
"ghcr.io/osirisrtos/osiris/devcontainer",
109
]
1110
},
1211
"privileged": false,

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
id: set_output
4040
run: |
4141
REPO=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
42-
CONTAINER_NAME="ghcr.io/${REPO}/devcontainer:main"
42+
CONTAINER_NAME="ghcr.io/${REPO}/devcontainer:latest"
4343
echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT
4444
echo "container_without_tag=ghcr.io/${REPO}/devcontainer" >> $GITHUB_OUTPUT
4545

interface/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ pub struct MemMapEntry {
1717
pub ty: u32,
1818
}
1919

20+
#[cfg(kani)]
21+
impl kani::Arbitrary for MemMapEntry {
22+
fn any() -> Self {
23+
let size: u32 = kani::any_where(|&x| x % size_of::<MemMapEntry>() as u32 == 0);
24+
let length = kani::any();
25+
let addr = kani::any();
26+
27+
kani::assume(addr > 0);
28+
29+
MemMapEntry {
30+
size,
31+
addr,
32+
length,
33+
ty: kani::any(),
34+
}
35+
}
36+
37+
fn any_array<const MAX_ARRAY_LENGTH: usize>() -> [Self; MAX_ARRAY_LENGTH] {
38+
[(); MAX_ARRAY_LENGTH].map(|_| Self::any())
39+
}
40+
}
41+
2042
#[repr(C)]
2143
#[derive(Debug, Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
2244
pub struct InitDescriptor {

src/mem.rs

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -95,35 +95,10 @@ pub fn align_up(size: usize) -> usize {
9595
// VERIFICATION -------------------------------------------------------------------------------------------------------
9696
#[cfg(kani)]
9797
mod verification {
98-
use crate::MemMapEntry;
98+
use crate::mem::alloc::MAX_ADDR;
9999

100100
use super::*;
101-
use kani::Arbitrary;
102-
103-
impl Arbitrary for MemMapEntry {
104-
fn any() -> Self {
105-
let size = size_of::<MemMapEntry>() as u32;
106-
let length = kani::any();
107-
let addr = kani::any();
108-
109-
kani::assume(
110-
length < alloc::MAX_ADDR as u64
111-
&& length > alloc::BestFitAllocator::MIN_RANGE_SIZE as u64,
112-
);
113-
kani::assume(addr < alloc::MAX_ADDR as u64 - length && addr > 0);
114-
115-
MemMapEntry {
116-
size,
117-
addr,
118-
length,
119-
ty: kani::any(),
120-
}
121-
}
122-
123-
fn any_array<const MAX_ARRAY_LENGTH: usize>() -> [Self; MAX_ARRAY_LENGTH] {
124-
[(); MAX_ARRAY_LENGTH].map(|_| Self::any())
125-
}
126-
}
101+
use interface::{Args, InitDescriptor, MemMapEntry};
127102

128103
fn mock_ptr_write<T>(dst: *mut T, src: T) {
129104
// Just a noop
@@ -135,13 +110,22 @@ mod verification {
135110
let mmap: [MemMapEntry; _] = kani::any();
136111

137112
kani::assume(mmap.len() > 0 && mmap.len() <= 8);
113+
// Apply constraints to all
138114
for entry in mmap.iter() {
139115
// Ensure aligned.
140116
kani::assume(entry.addr % align_of::<u128>() as u64 == 0);
141117
// Ensure valid range.
142118
kani::assume(entry.addr > 0);
143119
kani::assume(entry.length > 0);
144120

121+
kani::assume(
122+
entry.length < alloc::MAX_ADDR as u64
123+
&& entry.length > alloc::BestFitAllocator::MIN_RANGE_SIZE as u64,
124+
);
125+
kani::assume(entry.addr < alloc::MAX_ADDR as u64 - entry.length && entry.addr > 0);
126+
}
127+
128+
for entry in mmap.iter() {
145129
// Ensure non overlapping entries
146130
for other in mmap.iter() {
147131
if entry.addr != other.addr {
@@ -153,13 +137,20 @@ mod verification {
153137
}
154138
}
155139

156-
let mmap_len = mmap.len();
140+
let mmap_len = mmap.len() as u64;
157141

158142
let boot_info = BootInfo {
159-
implementer: core::ptr::null(),
160-
variant: core::ptr::null(),
143+
magic: interface::BOOT_INFO_MAGIC,
144+
version: kani::any(),
161145
mmap,
162146
mmap_len,
147+
args: Args {
148+
init: InitDescriptor {
149+
begin: kani::any(),
150+
len: kani::any(),
151+
entry_offset: kani::any(),
152+
},
153+
},
163154
};
164155

165156
assert!(init_memory(&boot_info).is_ok());

src/mem/alloc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub struct BestFitAllocator {
4545

4646
/// Implementation of the BestFitAllocator.
4747
impl BestFitAllocator {
48+
pub const MIN_RANGE_SIZE: usize = size_of::<BestFitMeta>() + Self::align_up() + 1;
4849
/// Creates a new BestFitAllocator.
4950
///
5051
/// Returns the new BestFitAllocator.

0 commit comments

Comments
 (0)