@@ -93,8 +93,17 @@ struct SharedProcessorState {
93
93
sint : [ hvdef:: HvSynicSint ; NUM_SINTS ] ,
94
94
}
95
95
96
- impl Default for SharedProcessorState {
97
- fn default ( ) -> Self {
96
+ impl SharedProcessorState {
97
+ fn new ( ) -> Self {
98
+ Self {
99
+ online : false ,
100
+ enabled : false ,
101
+ siefp_page : OverlayPage :: default ( ) ,
102
+ sint : [ hvdef:: HvSynicSint :: new ( ) ; NUM_SINTS ] ,
103
+ }
104
+ }
105
+
106
+ fn at_reset ( ) -> Self {
98
107
Self {
99
108
online : true ,
100
109
enabled : true ,
@@ -201,7 +210,9 @@ impl GlobalSynic {
201
210
/// Returns a new instance of the synthetic interrupt controller.
202
211
pub fn new ( guest_memory : GuestMemory , max_vp_count : u32 ) -> Self {
203
212
Self {
204
- vps : ( 0 ..max_vp_count) . map ( |_| Default :: default ( ) ) . collect ( ) ,
213
+ vps : ( 0 ..max_vp_count)
214
+ . map ( |_| Arc :: new ( RwLock :: new ( SharedProcessorState :: new ( ) ) ) )
215
+ . collect ( ) ,
205
216
guest_memory,
206
217
}
207
218
}
@@ -259,7 +270,7 @@ impl GlobalSynic {
259
270
/// Adds a virtual processor to the synthetic interrupt controller state.
260
271
pub fn add_vp ( & self , vp_index : VpIndex ) -> ProcessorSynic {
261
272
let shared = self . vps [ vp_index. index ( ) as usize ] . clone ( ) ;
262
- let old_shared = std:: mem:: take ( & mut * shared. write ( ) ) ;
273
+ let old_shared = std:: mem:: replace ( & mut * shared. write ( ) , SharedProcessorState :: at_reset ( ) ) ;
263
274
assert ! ( !old_shared. online) ;
264
275
265
276
ProcessorSynic {
@@ -284,7 +295,7 @@ impl ProcessorSynic {
284
295
} = self ;
285
296
* sints = SintState :: default ( ) ;
286
297
* timers = array:: from_fn ( |_| Timer :: default ( ) ) ;
287
- * shared. write ( ) = SharedProcessorState :: default ( ) ;
298
+ * shared. write ( ) = SharedProcessorState :: at_reset ( ) ;
288
299
* vina = HvRegisterVsmVina :: new ( ) ;
289
300
}
290
301
0 commit comments