@@ -85,7 +85,7 @@ pub enum VcpuExit<'a> {
85
85
/// Corresponds to KVM_EXIT_EPR.
86
86
Epr ,
87
87
/// Corresponds to KVM_EXIT_SYSTEM_EVENT.
88
- SystemEvent ,
88
+ SystemEvent ( u32 /* type */ , u64 /* flags */ ) ,
89
89
/// Corresponds to KVM_EXIT_S390_STSI.
90
90
S390Stsi ,
91
91
/// Corresponds to KVM_EXIT_IOAPIC_EOI.
@@ -1150,7 +1150,15 @@ impl VcpuFd {
1150
1150
KVM_EXIT_WATCHDOG => Ok ( VcpuExit :: Watchdog ) ,
1151
1151
KVM_EXIT_S390_TSCH => Ok ( VcpuExit :: S390Tsch ) ,
1152
1152
KVM_EXIT_EPR => Ok ( VcpuExit :: Epr ) ,
1153
- KVM_EXIT_SYSTEM_EVENT => Ok ( VcpuExit :: SystemEvent ) ,
1153
+ KVM_EXIT_SYSTEM_EVENT => {
1154
+ // Safe because the exit_reason (which comes from the kernel) told us which
1155
+ // union field to use.
1156
+ let system_event = unsafe { & mut run. __bindgen_anon_1 . system_event } ;
1157
+ Ok ( VcpuExit :: SystemEvent (
1158
+ system_event. type_ ,
1159
+ system_event. flags ,
1160
+ ) )
1161
+ }
1154
1162
KVM_EXIT_S390_STSI => Ok ( VcpuExit :: S390Stsi ) ,
1155
1163
KVM_EXIT_IOAPIC_EOI => {
1156
1164
// Safe because the exit_reason (which comes from the kernel) told us which
@@ -1445,6 +1453,9 @@ mod tests {
1445
1453
0x1f , 0x18 , 0x14 , 0x71 , /* cmp w0, #0x506 */
1446
1454
0x20 , 0x00 , 0x82 , 0x1a , /* csel w0, w1, w2, eq */
1447
1455
0x20 , 0x01 , 0x00 , 0xb9 , /* str w0, [x9]; test MMIO write */
1456
+ 0x00 , 0x80 , 0xb0 , 0x52 , /* mov w0, #0x84000000 */
1457
+ 0x00 , 0x00 , 0x1d , 0x32 , /* orr w0, w0, #0x08 */
1458
+ 0x02 , 0x00 , 0x00 , 0xd4 , /* hvc #0x0 */
1448
1459
0x00 , 0x00 , 0x00 , 0x14 , /* b <this address>; shouldn't get here, but if so loop forever */
1449
1460
] ;
1450
1461
@@ -1473,6 +1484,7 @@ mod tests {
1473
1484
let vcpu_fd = vm. create_vcpu ( 0 ) . unwrap ( ) ;
1474
1485
let mut kvi = kvm_bindings:: kvm_vcpu_init:: default ( ) ;
1475
1486
vm. get_preferred_target ( & mut kvi) . unwrap ( ) ;
1487
+ kvi. features [ 0 ] |= 1 << KVM_ARM_VCPU_PSCI_0_2 ;
1476
1488
vcpu_fd. vcpu_init ( & kvi) . unwrap ( ) ;
1477
1489
1478
1490
let core_reg_base: u64 = 0x6030_0000_0010_0000 ;
@@ -1516,6 +1528,10 @@ mod tests {
1516
1528
. map ( |page| page. count_ones ( ) )
1517
1529
. fold ( 0 , |dirty_page_count, i| dirty_page_count + i) ;
1518
1530
assert_eq ! ( dirty_pages, 1 ) ;
1531
+ }
1532
+ VcpuExit :: SystemEvent ( type_, flags) => {
1533
+ assert_eq ! ( type_, KVM_SYSTEM_EVENT_SHUTDOWN ) ;
1534
+ assert_eq ! ( flags, 0 ) ;
1519
1535
break ;
1520
1536
}
1521
1537
r => panic ! ( "unexpected exit reason: {:?}" , r) ,
0 commit comments