@@ -28,6 +28,7 @@ use cpuarch::vmsa::VMSA;
28
28
use core:: mem:: replace;
29
29
30
30
use super :: memory_channels:: MemoryChannel ;
31
+ use crate :: attestation:: monitor:: { ProcessMeasurements , measure} ;
31
32
32
33
trait FromVAddr {
33
34
fn from_virt_addr ( v : VirtAddr ) -> & ' static mut VMSA ;
@@ -114,7 +115,9 @@ pub struct ProcessID(pub usize);
114
115
pub struct TrustedProcess {
115
116
pub process_type : TrustedProcessType ,
116
117
pub id : u64 ,
118
+ pub parent_id : u64 ,
117
119
pub base : ProcessBaseContext ,
120
+ pub measurements : ProcessMeasurements ,
118
121
#[ allow( dead_code) ]
119
122
pub context : ProcessContext ,
120
123
//pub channel: MemoryChannel,
@@ -138,36 +141,47 @@ impl TrustedProcess {
138
141
let libos_size= zygote_data_struct[ 5 ] ;
139
142
140
143
141
- // The allocation is always starting at the same virtual address which is why only one allocaiton is valid
144
+ // The allocation (AllocationRange) is always starting at the same virtual address which is why only one allocaiton is valid
142
145
// at the same time. TODO: Allow for different start addresses
143
- let ( pal_data, pal_range) = ProcessPageTableRef :: copy_data_from_guest ( pal, pal_size, pgt) ;
144
146
let mut base = ProcessBaseContext :: default ( ) ;
147
+ let mut measurements = ProcessMeasurements :: default ( ) ;
148
+
149
+ let ( pal_data, pal_range) = ProcessPageTableRef :: copy_data_from_guest ( pal, pal_size, pgt) ;
145
150
base. init_with_data ( pal_data, pal_size, pal_range) ;
151
+ measurements. init_measurement = measure ( pal_data. into ( ) , pal_size) ;
152
+
146
153
let ( manifest_data, manifest_range) = ProcessPageTableRef :: copy_data_from_guest ( manifest, manifest_size, pgt) ;
147
154
base. add_manifest ( manifest_data, manifest_size, manifest_range) ;
155
+ measurements. manifest_measurement = measure ( manifest_data. into ( ) , manifest_size) ;
156
+
148
157
let ( libos_data, libos_range) = ProcessPageTableRef :: copy_data_from_guest ( libos, libos_size, pgt) ;
149
158
base. add_libos ( libos_data, libos_size, libos_range) ;
150
-
159
+ measurements . libos_measurement = measure ( libos_data . into ( ) , libos_size ) ;
151
160
152
161
// TODO: Free zygote data
153
162
Self {
154
163
process_type : TrustedProcessType :: Zygote ,
155
164
id : 0 ,
165
+ parent_id : 0 ,
156
166
base,
167
+ measurements,
157
168
context : ProcessContext :: default ( ) ,
158
169
}
159
170
}
160
171
161
172
fn dublicate ( pid : ProcessID ) -> TrustedProcess {
162
173
let process = PROCESS_STORE . get ( pid) ;
163
174
let base: ProcessBaseContext = process. base ;
175
+ let measurements: ProcessMeasurements = process. measurements ;
164
176
let mut context = ProcessContext :: default ( ) ;
165
- context. init ( base) ;
177
+ context. init ( base, measurements ) ;
166
178
167
179
TrustedProcess {
168
180
process_type : TrustedProcessType :: Trustlet ,
169
181
id : 0 ,
182
+ parent_id : pid. 0 as u64 , // set the id of the parent zygote
170
183
base,
184
+ measurements,
171
185
context,
172
186
}
173
187
@@ -189,7 +203,9 @@ impl TrustedProcess {
189
203
Self {
190
204
process_type : TrustedProcessType :: Undefined ,
191
205
id : 0 ,
206
+ parent_id : 0 ,
192
207
base : ProcessBaseContext :: default ( ) ,
208
+ measurements : ProcessMeasurements :: default ( ) ,
193
209
context : ProcessContext :: default ( ) ,
194
210
}
195
211
}
@@ -337,9 +353,9 @@ impl ProcessBaseContext {
337
353
self . alloc_range_manifest = data;
338
354
}
339
355
340
- pub fn add_libos ( & mut self , manifest : VirtAddr , size : u64 , data : AllocationRange ) {
356
+ pub fn add_libos ( & mut self , libos : VirtAddr , size : u64 , data : AllocationRange ) {
341
357
let size = ( 4096 - ( size & 0xFFF ) ) + size;
342
- self . page_table_ref . add_libos ( manifest , size) ;
358
+ self . page_table_ref . add_libos ( libos , size) ;
343
359
self . alloc_range_libos = data;
344
360
}
345
361
@@ -356,6 +372,7 @@ pub struct ProcessContext {
356
372
pub vmsa : PhysAddr ,
357
373
pub channel : MemoryChannel ,
358
374
pub sev_features : u64 ,
375
+ pub measurements : ProcessMeasurements ,
359
376
}
360
377
361
378
impl Default for ProcessContext {
@@ -365,14 +382,15 @@ impl Default for ProcessContext {
365
382
vmsa : PhysAddr :: null ( ) ,
366
383
channel : MemoryChannel :: default ( ) ,
367
384
sev_features : 0 ,
385
+ measurements : ProcessMeasurements :: default ( ) ,
368
386
}
369
387
}
370
388
}
371
389
372
390
373
391
impl ProcessContext {
374
392
375
- pub fn init ( & mut self , base : ProcessBaseContext ) {
393
+ pub fn init ( & mut self , base : ProcessBaseContext , measurements : ProcessMeasurements ) {
376
394
377
395
//Creating new VMSA for the Process
378
396
let new_vmsa_page = allocate_page ( ) ;
@@ -424,7 +442,7 @@ impl ProcessContext {
424
442
self . vmsa = new_vmsa_page;
425
443
self . sev_features = vmsa. sev_features ;
426
444
self . base = base;
427
-
445
+ self . measurements = measurements ;
428
446
}
429
447
430
448
pub fn add_function ( & mut self , function : VirtAddr , size : u64 ) {
0 commit comments