Skip to content

Commit e2e69b7

Browse files
committed
Merge branch 'fs' into dev
2 parents bd366ca + 3078ccb commit e2e69b7

File tree

5 files changed

+421
-85
lines changed

5 files changed

+421
-85
lines changed

Cargo.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kernel/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ intrusive-collections.workspace = true
3939
log = { workspace = true, features = [] }
4040
packit.workspace = true
4141
libmstpm = { workspace = true, optional = true }
42+
num_enum = { version="0.7.3", default-features = false }
4243

4344
[target."x86_64-unknown-none".dev-dependencies]
4445
test.workspace = true

kernel/src/process_manager/process.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::process_manager::process_memory::allocate_page;
2020
use crate::process_manager::allocation::AllocationRange;
2121
use crate::process_manager::process_paging::ProcessPageTableRef;
2222
use crate::process_manager::process_paging::ProcessPageFlags;
23+
use crate::process_runtime::runtime::MmapManager;
2324
use crate::protocols::errors::SvsmReqError;
2425
use crate::protocols::RequestParams;
2526
use crate::sev::RMPFlags;
@@ -80,8 +81,8 @@ impl TrustedProcessStore {
8081
ptr.push(process);
8182
}
8283
pub fn init(&self, size: u32){
83-
let empty_process = TrustedProcess::empty();
8484
for _ in 0..size {
85+
let empty_process = TrustedProcess::empty();
8586
self.push(empty_process);
8687
}
8788
}
@@ -121,7 +122,7 @@ impl ProcessData {
121122
#[derive(Clone,Copy,Debug, Default)]
122123
pub struct ProcessID(pub usize);
123124

124-
#[derive(Clone,Copy,Debug)]
125+
#[derive(Clone,Debug)]
125126
pub struct TrustedProcess {
126127
pub process_type: TrustedProcessType,
127128
pub id: u64,
@@ -130,7 +131,8 @@ pub struct TrustedProcess {
130131
pub measurements: ProcessMeasurements,
131132
#[allow(dead_code)]
132133
pub context: ProcessContext,
133-
//pub channel: MemoryChannel,
134+
pub mmap_manager: MmapManager,
135+
pub pf_target_vaddr: u64,
134136
}
135137

136138
impl TrustedProcess {
@@ -179,6 +181,8 @@ impl TrustedProcess {
179181
base,
180182
measurements,
181183
context: ProcessContext::default(),
184+
mmap_manager: MmapManager::new(),
185+
pf_target_vaddr: 0,
182186
}
183187
}
184188

@@ -196,6 +200,8 @@ impl TrustedProcess {
196200
base,
197201
measurements,
198202
context,
203+
mmap_manager: MmapManager::new(),
204+
pf_target_vaddr: 0,
199205
}
200206

201207
}
@@ -226,6 +232,8 @@ impl TrustedProcess {
226232
base: ProcessBaseContext::default(),
227233
measurements: ProcessMeasurements::default(),
228234
context: ProcessContext::default(),
235+
mmap_manager: MmapManager::new(),
236+
pf_target_vaddr: 0,
229237
}
230238
}
231239

kernel/src/process_manager/process_paging.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ bitflags! {
5353
const COPY_ON_WRITE = 1 << 9; // Use this field to mark CoW pages
5454

5555
const NO_EXECUTE = 1 << 63;
56+
57+
// Special value that indicates to use the flag in the existing entry
58+
const FLAG_REUSE = 1 << 10;
5659
}
5760
}
5861

@@ -572,7 +575,14 @@ impl ProcessPageTableRef {
572575
ProcessTableLevelMapping::PTE(table_phys, index) => {
573576
let (pte_mapping, pte_table) = paddr_as_table!(table_phys);
574577
rmp_adjust(pte_mapping.virt_addr(), RMPFlags::VMPL1 | RMPFlags::RWX , PageSize::Regular).unwrap();
575-
pte_table[index].set(addr, flags);
578+
if flags.contains(ProcessPageFlags::FLAG_REUSE){
579+
// Use the same flags as the existing entry (used for lazy page allocation in the mmaped region)
580+
assert!(flags == ProcessPageFlags::FLAG_REUSE);
581+
let orig_flag = pte_table[index].flags();
582+
pte_table[index].set(addr, orig_flag | ProcessPageFlags::PRESENT);
583+
} else {
584+
pte_table[index].set(addr, flags);
585+
}
576586
finished = true;
577587
},
578588
ProcessTableLevelMapping::PMD(table_phys, index) => {

0 commit comments

Comments
 (0)