@@ -186,33 +186,6 @@ pub(crate) trait Hypervisor: Debug + Sync + Send {
186
186
/// Run the vCPU
187
187
fn run ( & mut self ) -> Result < HyperlightExit > ;
188
188
189
- /// Returns a Some(HyperlightExit::AccessViolation(..)) if the given gpa doesn't have
190
- /// access its corresponding region. Returns None otherwise, or if the region is not found.
191
- fn get_memory_access_violation (
192
- & self ,
193
- gpa : usize ,
194
- mem_regions : & [ MemoryRegion ] ,
195
- access_info : MemoryRegionFlags ,
196
- ) -> Option < HyperlightExit > {
197
- // find the region containing the given gpa
198
- let region = mem_regions
199
- . iter ( )
200
- . find ( |region| region. guest_region . contains ( & gpa) ) ;
201
-
202
- if let Some ( region) = region {
203
- if !region. flags . contains ( access_info)
204
- || region. flags . contains ( MemoryRegionFlags :: STACK_GUARD )
205
- {
206
- return Some ( HyperlightExit :: AccessViolation (
207
- gpa as u64 ,
208
- access_info,
209
- region. flags ,
210
- ) ) ;
211
- }
212
- }
213
- None
214
- }
215
-
216
189
/// Get InterruptHandle to underlying VM
217
190
fn interrupt_handle ( & self ) -> Arc < dyn InterruptHandle > ;
218
191
@@ -281,6 +254,30 @@ pub(crate) trait Hypervisor: Debug + Sync + Send {
281
254
fn trace_info_as_mut ( & mut self ) -> & mut TraceInfo ;
282
255
}
283
256
257
+ /// Returns a Some(HyperlightExit::AccessViolation(..)) if the given gpa doesn't have
258
+ /// access its corresponding region. Returns None otherwise, or if the region is not found.
259
+ pub ( crate ) fn get_memory_access_violation < ' a > (
260
+ gpa : usize ,
261
+ mut mem_regions : impl Iterator < Item = & ' a MemoryRegion > ,
262
+ access_info : MemoryRegionFlags ,
263
+ ) -> Option < HyperlightExit > {
264
+ // find the region containing the given gpa
265
+ let region = mem_regions. find ( |region| region. guest_region . contains ( & gpa) ) ;
266
+
267
+ if let Some ( region) = region {
268
+ if !region. flags . contains ( access_info)
269
+ || region. flags . contains ( MemoryRegionFlags :: STACK_GUARD )
270
+ {
271
+ return Some ( HyperlightExit :: AccessViolation (
272
+ gpa as u64 ,
273
+ access_info,
274
+ region. flags ,
275
+ ) ) ;
276
+ }
277
+ }
278
+ None
279
+ }
280
+
284
281
/// A virtual CPU that can be run until an exit occurs
285
282
pub struct VirtualCPU { }
286
283
0 commit comments