File tree 5 files changed +263
-181
lines changed
5 files changed +263
-181
lines changed Original file line number Diff line number Diff line change @@ -12,18 +12,17 @@ pub enum SvsmPlatformType {
12
12
Snp = 1 ,
13
13
}
14
14
15
- impl SvsmPlatformType {
16
- pub fn as_u32 ( & self ) -> u32 {
17
- match self {
18
- Self :: Native => 0 ,
19
- Self :: Snp => 1 ,
20
- }
21
- }
22
-
23
- pub fn from_u32 ( value : u32 ) -> Self {
15
+ impl From < u32 > for SvsmPlatformType {
16
+ fn from ( value : u32 ) -> Self {
24
17
match value {
25
18
1 => Self :: Snp ,
26
19
_ => Self :: Native ,
27
20
}
28
21
}
29
22
}
23
+
24
+ impl From < SvsmPlatformType > for u32 {
25
+ fn from ( p : SvsmPlatformType ) -> u32 {
26
+ p as u32
27
+ }
28
+ }
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ impl Stage2Stack {
47
47
} ;
48
48
49
49
let mut stage2_stack = self . stage2_stack ;
50
- stage2_stack. platform_type = platform . as_u32 ( ) ;
50
+ stage2_stack. platform_type = u32 :: from ( platform ) ;
51
51
52
52
// The native platform does not record VTOM because there is no
53
53
// encryption in native platforms.
Original file line number Diff line number Diff line change @@ -26,10 +26,13 @@ use crate::sev::ghcb::GhcbError;
26
26
use crate :: sev:: msr_protocol:: GhcbMsrError ;
27
27
use crate :: sev:: SevSnpError ;
28
28
use crate :: task:: TaskError ;
29
+ use elf:: ElfError ;
29
30
30
31
/// A generic error during SVSM operation.
31
32
#[ derive( Clone , Copy , Debug ) ]
32
33
pub enum SvsmError {
34
+ /// Errors during ELF parsing and loading.
35
+ Elf ( ElfError ) ,
33
36
/// Errors related to GHCB
34
37
Ghcb ( GhcbError ) ,
35
38
/// Errors related to MSR protocol
@@ -65,3 +68,9 @@ pub enum SvsmError {
65
68
/// Errors from #VC handler
66
69
Vc ( VcError ) ,
67
70
}
71
+
72
+ impl From < ElfError > for SvsmError {
73
+ fn from ( err : ElfError ) -> Self {
74
+ Self :: Elf ( err)
75
+ }
76
+ }
You can’t perform that action at this time.
0 commit comments