@@ -34,7 +34,8 @@ impl<'a, U: AsRawFd, V: AsRawFd> Launcher<'a, New, U, V> {
34
34
} ;
35
35
36
36
let mut cmd = Command :: from ( launcher. sev , & Init ) ;
37
- INIT . ioctl ( launcher. kvm , & mut cmd) ?;
37
+ INIT . ioctl ( launcher. kvm , & mut cmd)
38
+ . map_err ( |e| cmd. encapsulate ( e) ) ?;
38
39
39
40
Ok ( launcher)
40
41
}
@@ -43,7 +44,9 @@ impl<'a, U: AsRawFd, V: AsRawFd> Launcher<'a, New, U, V> {
43
44
pub fn start ( self , start : Start ) -> Result < Launcher < ' a , Started , U , V > > {
44
45
let mut launch_start = LaunchStart :: new ( & start. policy , & start. cert , & start. session ) ;
45
46
let mut cmd = Command :: from_mut ( self . sev , & mut launch_start) ;
46
- LAUNCH_START . ioctl ( self . kvm , & mut cmd) ?;
47
+ LAUNCH_START
48
+ . ioctl ( self . kvm , & mut cmd)
49
+ . map_err ( |e| cmd. encapsulate ( e) ) ?;
47
50
48
51
let next = Launcher {
49
52
state : Started ( launch_start. into ( ) ) ,
@@ -60,7 +63,9 @@ impl<'a, U: AsRawFd, V: AsRawFd> Launcher<'a, Started, U, V> {
60
63
pub fn update_data ( & mut self , data : & [ u8 ] ) -> Result < ( ) > {
61
64
let launch_update_data = LaunchUpdateData :: new ( data) ;
62
65
let mut cmd = Command :: from ( self . sev , & launch_update_data) ;
63
- LAUNCH_UPDATE_DATA . ioctl ( self . kvm , & mut cmd) ?;
66
+ LAUNCH_UPDATE_DATA
67
+ . ioctl ( self . kvm , & mut cmd)
68
+ . map_err ( |e| cmd. encapsulate ( e) ) ?;
64
69
Ok ( ( ) )
65
70
}
66
71
@@ -69,7 +74,9 @@ impl<'a, U: AsRawFd, V: AsRawFd> Launcher<'a, Started, U, V> {
69
74
let mut measurement = MaybeUninit :: uninit ( ) ;
70
75
let mut launch_measure = LaunchMeasure :: new ( & mut measurement) ;
71
76
let mut cmd = Command :: from_mut ( self . sev , & mut launch_measure) ;
72
- LAUNCH_MEASUREMENT . ioctl ( self . kvm , & mut cmd) ?;
77
+ LAUNCH_MEASUREMENT
78
+ . ioctl ( self . kvm , & mut cmd)
79
+ . map_err ( |e| cmd. encapsulate ( e) ) ?;
73
80
74
81
let next = Launcher {
75
82
state : Measured ( self . state . 0 , unsafe { measurement. assume_init ( ) } ) ,
@@ -95,14 +102,18 @@ impl<'a, U: AsRawFd, V: AsRawFd> Launcher<'a, Measured, U, V> {
95
102
pub fn inject ( & mut self , secret : Secret , guest : usize ) -> Result < ( ) > {
96
103
let launch_secret = LaunchSecret :: new ( & secret. header , guest, & secret. ciphertext [ ..] ) ;
97
104
let mut cmd = Command :: from ( self . sev , & launch_secret) ;
98
- LAUNCH_SECRET . ioctl ( self . kvm , & mut cmd) ?;
105
+ LAUNCH_SECRET
106
+ . ioctl ( self . kvm , & mut cmd)
107
+ . map_err ( |e| cmd. encapsulate ( e) ) ?;
99
108
Ok ( ( ) )
100
109
}
101
110
102
111
/// Complete the SEV launch process.
103
112
pub fn finish ( self ) -> Result < Handle > {
104
113
let mut cmd = Command :: from ( self . sev , & LaunchFinish ) ;
105
- LAUNCH_FINISH . ioctl ( self . kvm , & mut cmd) ?;
114
+ LAUNCH_FINISH
115
+ . ioctl ( self . kvm , & mut cmd)
116
+ . map_err ( |e| cmd. encapsulate ( e) ) ?;
106
117
Ok ( self . state . 0 )
107
118
}
108
119
}
0 commit comments