Skip to content

Commit 6c9694b

Browse files
committed
bump: update refinedrust and migrate proofs
Signed-off-by: Sascha Kehrli <sascha.kehrli@gmail.com>
1 parent 7278c21 commit 6c9694b

80 files changed

Lines changed: 527 additions & 262 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.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
// - Maintain lexicographic ordering based on the top-to-bottom declaration to ensure that PartialOrd derivative works correctly.
77
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
88
#[rr::refined_by("page_table_level")]
9+
#[rr::derive_instantiate("PEq" := "λ a b, bool_decide (a = b)")]
10+
#[rr::derive_instantiate("POrd" := "λ a b, Some (Z.compare (page_table_level_index a) (page_table_level_index b))")]
11+
#[rr::derive_instantiate("POrd_eq_cons" := #proof "intros ? [] []; simpl; done")]
912
pub enum PageTableLevel {
1013
#[rr::pattern("PTLevel1")]
1114
Level1,

‎security-monitor/src/core/control_data/confidential_vm_id.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-FileContributor: Wojciech Ozga <woz@zurich.ibm.com>, IBM Research - Zurich
33
// SPDX-License-Identifier: Apache-2.0
44

5+
#[rr::skip]
56
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone, Debug)]
67
pub struct ConfidentialVmId(usize);
78

‎security-monitor/src/core/memory_layout/confidential_memory_address.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use pointers_utility::{ptr_byte_add_mut, ptr_byte_offset};
88
/// The wrapper over a raw pointer that is guaranteed to be an address located in the confidential memory region.
99
#[repr(transparent)]
1010
#[derive(Debug, PartialEq, Clone, Copy)]
11+
#[rr::derive_instantiate("PEq" := "λ a b, bool_decide (a.(loc_a) = b.(loc_a))")]
1112
/// Model: The memory address is represented by the location in memory.
1213
#[rr::refined_by("l" : "loc")]
1314
/// We require the ghost state for the global memory layout to be available.
@@ -17,7 +18,7 @@ use pointers_utility::{ptr_byte_add_mut, ptr_byte_offset};
1718
#[rr::invariant(#iris "once_status \"MEMORY_LAYOUT\" (Some MEMORY_CONFIG)")]
1819
/// Invariant: The address is in the confidential part of the memory layout.
1920
#[rr::invariant("(MEMORY_CONFIG.(conf_start).(loc_a) ≤ l.(loc_a) < MEMORY_CONFIG.(conf_end).(loc_a))%Z")]
20-
pub struct ConfidentialMemoryAddress(#[rr::field("l")] *mut usize);
21+
pub struct ConfidentialMemoryAddress(#[rr::field("#(l)")] *mut usize);
2122

2223
/// Verification: We require the ghost state for the global memory layout to be available.
2324
#[rr::context("onceG Σ memory_layout")]

‎security-monitor/src/core/memory_layout/confidential_vm_physical_address.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
// SPDX-License-Identifier: Apache-2.0
44
use crate::error::Error;
55

6+
#[rr::refined_by("a" : "Z")]
67
#[derive(PartialEq, PartialOrd, Clone, Copy)]
7-
pub struct ConfidentialVmPhysicalAddress(usize);
8+
#[rr::derive_instantiate("PEq" := "λ a b, bool_decide (a = b)")]
9+
#[rr::derive_instantiate("POrd" := "λ a b, Some (Z.compare a b)")]
10+
#[rr::derive_instantiate("POrd_eq_cons" := #proof "intros ? ? ?; solve_goal")]
11+
pub struct ConfidentialVmPhysicalAddress(#[rr::field("#(a)")] usize);
812

913
impl ConfidentialVmPhysicalAddress {
1014
pub fn new(confidential_vm_physical_address: usize) -> Result<Self, Error> {

‎security-monitor/src/core/memory_layout/mod.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ static MEMORY_LAYOUT: Once<MemoryLayout> = Once::new();
3737
#[rr::invariant("ml.(conf_start) `aligned_to` (page_size_in_bytes_nat Size4KiB)")]
3838
#[rr::invariant("ml.(conf_end) `aligned_to` (page_size_in_bytes_nat Size4KiB)")]
3939
pub struct MemoryLayout {
40-
#[rr::field("ml.(non_conf_start)")]
40+
#[rr::field("#(ml.(non_conf_start))")]
4141
non_confidential_memory_start: *mut usize,
42-
#[rr::field("ml.(non_conf_end)")]
42+
#[rr::field("#(ml.(non_conf_end))")]
4343
non_confidential_memory_end: *const usize,
44-
#[rr::field("ml.(conf_start)")]
44+
#[rr::field("#(ml.(conf_start))")]
4545
confidential_memory_start: *mut usize,
46-
#[rr::field("ml.(conf_end)")]
46+
#[rr::field("#(ml.(conf_end))")]
4747
confidential_memory_end: *const usize,
4848
}
4949

‎security-monitor/src/core/memory_layout/non_confidential_memory_address.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use pointers_utility::ptr_byte_add_mut;
1717
#[rr::invariant(#iris "once_status \"MEMORY_LAYOUT\" (Some MEMORY_CONFIG)")]
1818
/// Invariant: The address is in non-confidential memory.
1919
#[rr::invariant("(MEMORY_CONFIG.(non_conf_start).(loc_a) ≤ l.(loc_a) < MEMORY_CONFIG.(non_conf_end).(loc_a))%Z")]
20-
pub struct NonConfidentialMemoryAddress(#[rr::field("l")] *mut usize);
20+
pub struct NonConfidentialMemoryAddress(#[rr::field("#(l)")] *mut usize);
2121

2222
#[rr::context("onceG Σ memory_layout")]
2323
impl NonConfidentialMemoryAddress {

‎security-monitor/src/core/page_allocator/allocator.rs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ static PAGE_ALLOCATOR: Once<RwLock<PageAllocator>> = Once::new();
3636
#[rr::invariant("node_size = node.(max_node_size)")]
3737
#[rr::invariant("base_addr = node.(base_address)")]
3838
pub struct PageAllocator {
39-
#[rr::field("base_addr")]
39+
#[rr::field("#(base_addr)")]
4040
base_address: usize,
41-
#[rr::field("node_size")]
41+
#[rr::field("#(node_size)")]
4242
page_size: PageSize,
43-
#[rr::field("node")]
43+
#[rr::field("#(node)")]
4444
root: PageStorageTreeNode,
4545
}
4646

@@ -312,6 +312,7 @@ impl PageAllocator {
312312
#[rr::params("p")]
313313
#[rr::requires(#iris "once_initialized π \"PAGE_ALLOCATOR\" (Some ())")]
314314
#[rr::requires(#iris "□ ∀ x, {O::Pre} π p op x")]
315+
#[rr::requires("Hno_unwind": "closure_may_unwind {O::UnwindCondition} → False")]
315316
#[rr::exists("x")]
316317
#[rr::ensures(#iris "{O::Post} π p op x ret")]
317318
fn try_write<F, O>(op: O) -> Result<F, Error>
@@ -337,15 +338,15 @@ impl PageAllocator {
337338
struct PageStorageTreeNode {
338339
// Page token owned by this node. `None` means that this page token has already been allocated or that it has been divided into smaller
339340
// pages token that were stored in this node's children.
340-
#[rr::field("<#>@{{ option }} maybe_page_token")]
341+
#[rr::field("#(<#>@{{ option }} maybe_page_token)")]
341342
page_token: Option<Page<UnAllocated>>,
342343
// Specifies what size of the page token can be allocated by exploring the tree starting at this node.
343344
// Invariant: if page token exist, then the its size is the max allocable size. Otherwise, the max allocable page size is the max
344345
// allocable page size of children
345-
#[rr::field("<#>@{{ option }} max_sz")]
346+
#[rr::field("#(<#>@{{ option }} max_sz)")]
346347
max_allocable_page_size: Option<PageSize>,
347348
// Invariant: Children store page tokens smaller than the page token stored in the parent node
348-
#[rr::field("<#> children")]
349+
#[rr::field("#(<#> children)")]
349350
children: Vec<Self>,
350351
}
351352

‎security-monitor/src/core/page_allocator/page.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ impl PageState for Allocated {}
4848
#[rr::invariant("p.(page_loc).(loc_p) = ProvAlloc machine_memory_prov")]
4949
pub struct Page<S: PageState> {
5050
/// Specification: the `address` has mathematical value `l`.
51-
#[rr::field("p.(page_loc)")]
51+
#[rr::field("#(p.(page_loc))")]
5252
address: ConfidentialMemoryAddress,
5353
/// Specification: the `size` has mathematical value `sz`.
54-
#[rr::field("p.(page_sz)")]
54+
#[rr::field("#(p.(page_sz))")]
5555
size: PageSize,
5656
/// Specification: the `_marker` has no relevance for the verification.
57-
#[rr::field("tt")]
57+
#[rr::field("#(tt)")]
5858
_marker: PhantomData<S>,
5959
}
6060

‎verification/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ log
44
rustc-ice-*
55
generated_code.bak
66
_CoqProject
7+
_RocqProject
78
.lia.cache
89
.nia.cache

‎verification/RefinedRust.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ output_dir = "./rust_proofs"
44
run_check = false
55
admit_proofs = false
66
skip_unsupported_features = false
7+
register_all_adts = false
78
extra_specs = "./extra_specs.v"
89
generate_dune_project = false
910
lib_load_paths = ["./refinedrust/stdlib/", "./rust_proofs"]

0 commit comments

Comments
 (0)