Skip to content

Commit 1aaabb9

Browse files
authored
Bump Rust + RefinedRust versions (#112)
* bump RefinedRust + Rust * update readme --------- Signed-off-by: Lennard Gäher <[email protected]>
1 parent 494c83d commit 1aaabb9

File tree

53 files changed

+1094
-350
lines changed

Some content is hidden

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

53 files changed

+1094
-350
lines changed

.github/workflows/verify.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
run: opam init -y
2323
- name: Setup opam switch
2424
run: opam switch create refinedrust-ace --packages=ocaml-variants.4.14.1+options,ocaml-option-flambda
25-
- name: Install coq
26-
run: eval $(opam env) && opam update && opam pin add coq 8.17.1 -y
2725
- name: ls
2826
run: ls -la .
2927
- name: Install openssl dependency
@@ -44,8 +42,6 @@ jobs:
4442
run: cargo --version
4543
- name: Install RefinedRust stdlib
4644
run: eval $(opam env) && REFINEDRUST_ROOT=$PWD/verification/refinedrust ./verification/refinedrust/scripts/install-stdlib.sh
47-
- name: Generate stdlib metadata
48-
run: eval $(opam env) && make -C verification/refinedrust/stdlib generate_stdlib
4945
- name: Exclude RefinedRust from dune build
5046
run: echo "(dirs :standard \ generated_code.bak refinedrust)" > verification/dune
5147
- name: install build dependencies
@@ -59,4 +55,4 @@ jobs:
5955
- name: make devtools
6056
run: source "$HOME/.cargo/env" && eval $(opam env) && make devtools
6157
- name: Translate specified files using RefinedRust and check proofs
62-
run: source "$HOME/.cargo/env" && eval $(opam env) && make verify
58+
run: source "$HOME/.cargo/env" && eval $(opam env) && DUNEFLAGS="-j 1" make verify

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
/target/
44
build/*
55
target/*
6+
**/target
67

7-
tools/cove_tap_tool/target
88
qemu/
9-
security-monitor/target
109

1110
configurations/overlay/root/harness/baremetal
1211
confidential-vms/linux_vm/configurations/package_override.dev
@@ -23,4 +22,4 @@ Cargo.lock
2322
*.ko
2423

2524
# skip log files
26-
*.log
25+
*.log

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export LINUX_IMAGE ?= $(HYPERVISOR_WORK_DIR)/buildroot/images/Image
2626
export TOOLS_SOURCE_DIR ?= $(MAKEFILE_SOURCE_DIR)/tools
2727
export TOOLS_WORK_DIR ?= $(ACE_DIR)/tools
2828

29-
export CROSS_COMPILE = riscv64-unknown-linux-gnu-
29+
export CROSS_COMPILE ?= riscv64-unknown-linux-gnu-
3030
export PLATFORM_RISCV_XLEN = 64
3131
export PLATFORM_RISCV_ISA = rv64gc
3232
export PLATFORM_RISCV_ABI = lp64d

rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-09-15"
3-
targets = [ "riscv64gc-unknown-none-elf" ]
2+
channel = "nightly-2025-09-12"
3+
targets = [ "riscv64gc-unknown-none-elf" ]

security-monitor/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ build: opensbi_bindings fmt
3838
refinedrust: opensbi_bindings
3939
echo "Generating RefinedRust translation" ;\
4040
mkdir -p $(SM_WORK_DIR) ; \
41-
RUSTFLAGS='$(RUSTFLAGS)' CARGO_TARGET_DIR=$(SM_WORK_DIR) INSTALL_DIR=$(ACE_DIR) $(CARGO) refinedrust $(RELEASE) $(TARGET) --features verbose ; \
41+
RUSTFLAGS='$(RUSTFLAGS)' CARGO_TARGET_DIR=$(SM_WORK_DIR) INSTALL_DIR=$(ACE_DIR) $(CARGO) refinedrust -- $(RELEASE) $(TARGET) --features verbose; \
4242
rm -rf $(OPENSBI_WORK_DIR)/
4343

4444
debug: opensbi_bindings

security-monitor/rust-crates/pointers_utility/src/lib.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,25 @@
33
// SPDX-License-Identifier: Apache-2.0
44
#![no_std]
55
#![no_main]
6-
#![feature(pointer_byte_offsets)]
76

87
// used for RefinedRust annotations
98
#![feature(register_tool)]
109
#![register_tool(rr)]
1110
#![feature(custom_inner_attributes)]
1211
#![rr::coq_prefix("ace_ptr")]
12+
#![rr::include("stdlib")]
1313

1414

1515
mod error;
1616
use core::mem::size_of;
1717
pub use crate::error::PointerError;
1818

1919
/// Calculates the offset in bytes between two pointers.
20+
#[rr::only_spec]
21+
#[rr::returns("wrap_to_it (pointer1.2 - pointer2.2) isize")]
2022
pub fn ptr_byte_offset(pointer1: *const usize, pointer2: *const usize) -> isize {
21-
(pointer1 as isize) - (pointer2 as isize)
23+
// TODO: we should use wrapping arithmetic here, as it might overflow
24+
(pointer1.addr() as isize) - (pointer2.addr() as isize)
2225
}
2326

2427
/// Aligns the pointer to specific size while making sure that the aligned pointer
@@ -34,11 +37,9 @@ pub fn ptr_align(pointer: *mut usize, align_in_bytes: usize, owned_region_end: *
3437
/// the one-past-the-end address. The returned pointer is guaranteed to be valid for accesses
3538
/// of size one, if the original pointer is valid. Additional checks are required for making
3639
/// larger memory accesses.
37-
#[rr::skip]
38-
#[rr::params("l", "off", "lmax")]
39-
#[rr::args("l", "off", "lmax")]
40-
#[rr::requires("⌜l.2 + off < lmax.2⌝")]
41-
#[rr::returns("Ok(l +ₗ off)")]
40+
#[rr::ok]
41+
#[rr::requires("pointer.2 + offset_in_bytes < owned_region_end.2")]
42+
#[rr::ensures("ret = (pointer +ₗ offset_in_bytes)")]
4243
pub fn ptr_byte_add_mut(
4344
pointer: *mut usize, offset_in_bytes: usize, owned_region_end: *const usize,
4445
) -> Result<*mut usize, PointerError> {
@@ -59,6 +60,9 @@ pub fn ptr_byte_add_mut(
5960
/// the one-past-the-end address. The returned pointer is guaranteed to be valid for accesses
6061
/// of size one, if the original pointer is valid. Additional checks are required for making
6162
/// larger memory accesses.
63+
#[rr::ok]
64+
#[rr::requires("pointer.2 + offset_in_bytes < owned_region_end.2")]
65+
#[rr::ensures("ret = (pointer +ₗ offset_in_bytes)")]
6266
pub fn ptr_byte_add(
6367
pointer: *const usize, offset_in_bytes: usize, owned_region_end: *const usize,
6468
) -> Result<*const usize, PointerError> {

security-monitor/src/confidential_flow/finite_state_machine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,23 +315,23 @@ impl<'a> ConfidentialFlow<'a> {
315315
self
316316
}
317317

318-
pub fn confidential_vm_id(&'a self) -> ConfidentialVmId {
318+
pub fn confidential_vm_id(&self) -> ConfidentialVmId {
319319
self.confidential_hart().confidential_vm_id().expect(Self::DUMMY_HART_ERROR_MSG)
320320
}
321321

322-
fn confidential_hart_id(&'a self) -> usize {
322+
fn confidential_hart_id(&self) -> usize {
323323
self.confidential_hart().confidential_hart_id()
324324
}
325325

326326
fn confidential_hart_mut(&mut self) -> &mut ConfidentialHart {
327327
self.hardware_hart.confidential_hart_mut()
328328
}
329329

330-
fn confidential_hart(&'a self) -> &ConfidentialHart {
330+
fn confidential_hart(&self) -> &ConfidentialHart {
331331
self.hardware_hart.confidential_hart()
332332
}
333333

334-
fn hypervisor_hart(&'a self) -> &HypervisorHart {
334+
fn hypervisor_hart(&self) -> &HypervisorHart {
335335
&self.hardware_hart.hypervisor_hart()
336336
}
337337
}

security-monitor/src/core/architecture/riscv/mmu/page_size.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-FileContributor: Wojciech Ozga <[email protected]>, IBM Research - Zurich
33
// SPDX-License-Identifier: Apache-2.0
44
#![rr::import("ace.theories.page_allocator", "page")]
5-
#![rr::include("option")]
65

76
// The order of page size in this enum must follow the increasing sizes of page to guarantee that the Ord/PartialOrd are correctly derived
87
// for the `PageSize`.
@@ -30,10 +29,9 @@ impl PageSize {
3029
// and 4KiB).
3130
pub const TYPICAL_NUMBER_OF_PAGES_INSIDE_LARGER_PAGE: usize = 512;
3231

32+
// TODO: need performance optimizations for verifying this
3333
#[rr::trust_me]
34-
#[rr::params("x")]
35-
#[rr::args("#x")]
36-
#[rr::returns("page_size_in_bytes_Z x")]
34+
#[rr::returns("page_size_in_bytes_Z self")]
3735
pub fn in_bytes(&self) -> usize {
3836
match self {
3937
PageSize::Size128TiB => 8 * 512 * 512 * 512 * 512 * 256,
@@ -45,10 +43,7 @@ impl PageSize {
4543
}
4644
}
4745

48-
#[rr::trust_me]
49-
#[rr::params("x")]
50-
#[rr::args("#x")]
51-
#[rr::returns("<#>@{option} page_size_smaller x")]
46+
#[rr::returns("page_size_smaller self")]
5247
pub fn smaller(&self) -> Option<PageSize> {
5348
match self {
5449
PageSize::Size128TiB => Some(PageSize::Size512GiB),
@@ -60,10 +55,7 @@ impl PageSize {
6055
}
6156
}
6257

63-
#[rr::trust_me]
64-
#[rr::params("x")]
65-
#[rr::args("#x")]
66-
#[rr::returns("<#>@{option} page_size_larger x")]
58+
#[rr::returns("page_size_larger self")]
6759
pub fn larger(&self) -> Option<PageSize> {
6860
match self {
6961
PageSize::Size128TiB => None,
@@ -75,10 +67,7 @@ impl PageSize {
7567
}
7668
}
7769

78-
#[rr::trust_me]
79-
#[rr::params("x")]
80-
#[rr::args("#x")]
81-
#[rr::returns("page_size_multiplier x")]
70+
#[rr::returns("number_of_smaller_pages self")]
8271
pub fn number_of_smaller_pages(&self) -> usize {
8372
match self {
8473
PageSize::Size128TiB => 256,

security-monitor/src/core/architecture/riscv/mmu/page_table_level.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ pub enum PageTableLevel {
2020
}
2121

2222
impl PageTableLevel {
23-
#[rr::trust_me]
24-
#[rr::params("x")]
25-
#[rr::args("#x")]
26-
#[rr::returns("<#>@{option} (page_table_level_lower x)")]
23+
#[rr::returns("page_table_level_lower self")]
2724
pub fn lower(&self) -> Option<Self> {
2825
match self {
2926
Self::Level5 => Some(Self::Level4),

security-monitor/src/core/architecture/riscv/mmu/paging_system.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ use crate::core::memory_layout::ConfidentialVmPhysicalAddress;
1111
#[derive(Debug, Copy, Clone)]
1212
#[rr::refined_by("paging_system")]
1313
pub enum PagingSystem {
14+
#[rr::pattern("Sv48")]
1415
Sv48x4,
15-
#[rr::pattern("Sv57x4")]
16+
#[rr::pattern("Sv57")]
1617
Sv57x4,
1718
}
1819

@@ -31,10 +32,7 @@ impl PagingSystem {
3132
}
3233
}
3334

34-
#[rr::skip]
35-
#[rr::params("system")]
36-
#[rr::args("#system")]
37-
#[rr::returns("paging_system_highest_level system")]
35+
#[rr::returns("paging_system_highest_level self")]
3836
pub fn levels(&self) -> PageTableLevel {
3937
match self {
4038
PagingSystem::Sv48x4 => PageTableLevel::Level4,

0 commit comments

Comments
 (0)