@@ -155,7 +155,7 @@ impl Print for SgxCpuConfiguration {
155155struct EnclaveAttributes {
156156 standard_attributes : bool ,
157157 kss : bool ,
158- cpuid_12h_1 : Result < Cpuid12h1 , Rc < Error > >
158+ cpuid_12h_1 : Result < Cpuid12h1 , Rc < Error > > ,
159159}
160160
161161#[ dependency]
@@ -198,8 +198,16 @@ impl Print for EnclaveAttributes {
198198#[ optional_inner]
199199#[ derive( Clone , Update ) ]
200200struct EnclavePageCache {
201- total_size : u64 ,
201+ // Total size of confidentiality and integrity protected EPC
202+ total_size_cip : u64 ,
203+
204+ // Total size of confidentiality protected only EPC
205+ total_size_cpo : u64 ,
206+
207+ // Whether any pages were identified as unknown
202208 any_unknown : bool ,
209+
210+ // Intel SGX Capability Enumeration Leaf
203211 cpuid_12h_epc : Result < Vec < Cpuid12hEnum > , Rc < Error > > ,
204212}
205213
@@ -210,30 +218,38 @@ impl Dependency<SgxCpuSupport> for EnclavePageCache {
210218 fn update_dependency ( & mut self , dependency : & SgxCpuSupport , support : & SgxSupport ) {
211219 self . inner = match ( & dependency. inner , & support. cpuid_12h_epc ) {
212220 ( Some ( SgxCpuSupportInner { sgx : Ok ( true ) } ) , Ok ( c) ) => {
213- let mut total_size = 0 ;
221+ let mut total_size_cip = 0 ;
222+ let mut total_size_cpo = 0 ;
214223 let mut any_unknown = false ;
215224 for section in c {
216225 match section {
217226 Cpuid12hEnum :: Epc {
218227 ty : EpcType :: ConfidentialityIntegrityProtected ,
219228 phys_size,
220229 ..
221- } => total_size += phys_size,
230+ } => total_size_cip += phys_size,
231+ Cpuid12hEnum :: Epc {
232+ ty : EpcType :: ConfidentialityProtectedOnly ,
233+ phys_size,
234+ ..
235+ } => total_size_cpo += phys_size,
222236 Cpuid12hEnum :: Invalid => unreachable ! ( ) ,
223237 _ => any_unknown = true ,
224238 }
225239 }
226240
227241 Some ( EnclavePageCacheInner {
228- total_size,
242+ total_size_cip,
243+ total_size_cpo,
229244 any_unknown,
230- cpuid_12h_epc : Ok ( c. clone ( ) )
245+ cpuid_12h_epc : Ok ( c. clone ( ) ) ,
231246 } )
232- } ,
247+ }
233248 ( Some ( _) , c) => Some ( EnclavePageCacheInner {
234- total_size : 0 ,
249+ total_size_cip : 0 ,
250+ total_size_cpo : 0 ,
235251 any_unknown : true ,
236- cpuid_12h_epc : c. clone ( )
252+ cpuid_12h_epc : c. clone ( ) ,
237253 } ) ,
238254 _ => None ,
239255 } ;
@@ -249,7 +265,7 @@ impl Print for EnclavePageCache {
249265 fn supported ( & self ) -> Status {
250266 match self . inner {
251267 // Minimum useful EPC size: 1 VA + 1 SECS + 2 REG + 1 TCS
252- Some ( EnclavePageCacheInner { total_size , .. } ) if total_size >= 0x5000 => {
268+ Some ( EnclavePageCacheInner { total_size_cip , total_size_cpo , .. } ) if total_size_cip >= 0x5000 || total_size_cpo >= 0x5000 => {
253269 Status :: Supported
254270 }
255271 Some ( EnclavePageCacheInner {
@@ -336,14 +352,27 @@ impl Print for EpcSize {
336352 }
337353
338354 fn print ( & self , level : usize ) {
355+ fn epc_size_unit ( total_size : u64 ) -> ( f64 , & ' static str ) {
356+ let mut epc_size = total_size as f64 / 1024.0 / 1024.0 ;
357+ let mut epc_unit = "MiB" ;
358+ if epc_size >= 1024.0 {
359+ epc_size /= 1024.0 ;
360+ epc_unit = "GiB" ;
361+ }
362+ ( epc_size, epc_unit)
363+ }
364+
339365 if let Some ( epc) = & self . epc {
340- println ! (
341- "{:width$}{}: {:.1}MiB" ,
342- "" ,
343- self . name( ) ,
344- epc. total_size as f64 / ( 1048576. ) ,
345- width = level * 2
346- ) ;
366+ print ! ( "{:width$}{}:" , "" , self . name( ) , width = level * 2 ) ;
367+ if epc. total_size_cip > 0 {
368+ let ( epc_size, epc_unit) = epc_size_unit ( epc. total_size_cip ) ;
369+ print ! ( " {:.1}{}" , epc_size, epc_unit) ;
370+ }
371+ if epc. total_size_cpo > 0 {
372+ let ( epc_size, epc_unit) = epc_size_unit ( epc. total_size_cpo ) ;
373+ print ! ( " {:.1}{} (no integrity protection)" , epc_size, epc_unit) ;
374+ }
375+ println ! ( ) ;
347376 }
348377 }
349378}
@@ -398,7 +427,7 @@ impl Print for FlcCpuSupport {
398427#[ derive( Clone , Default , Update ) ]
399428struct FlcCpuConfiguration {
400429 sgx_conf : Status ,
401- msr_3ah : Option < Result < Msr3ah , Rc < Error > > >
430+ msr_3ah : Option < Result < Msr3ah , Rc < Error > > > ,
402431}
403432
404433#[ dependency]
@@ -533,7 +562,7 @@ impl Update for DeviceLoader {
533562 } ,
534563 #[ cfg( windows) ]
535564 devpath : Err ( Rc :: new ( IoError :: new ( ErrorKind :: NotFound , "Device Driver Path not supported in Windows" ) . into ( ) ) ) ,
536- modstatus : support. sgxdev_status . clone ( )
565+ modstatus : support. sgxdev_status . clone ( ) ,
537566 } ) ;
538567 }
539568}
@@ -877,7 +906,7 @@ struct EnclaveManager {
877906 version : Result < String , Rc < Error > > ,
878907}
879908
880- impl Update for EnclaveManager {
909+ impl Update for EnclaveManager {
881910 fn update ( & mut self , support : & SgxSupport ) {
882911 self . inner = Some ( EnclaveManagerInner {
883912 version : match support. node_agent . clone ( ) {
@@ -894,7 +923,7 @@ impl Print for EnclaveManager {
894923 }
895924
896925 fn print ( & self , level : usize ) {
897- if self . supported ( ) == Status :: Supported {
926+ if self . supported ( ) == Status :: Supported {
898927 println ! ( "{:width$}{}{} ({})" , "" , self . supported( ) . paint( ) , self . name( ) , self . inner. as_ref( ) . map( |inner| inner. version. clone( ) . unwrap( ) ) . unwrap( ) , width = level * 2 ) ;
899928 } else {
900929 println ! ( "{:width$}{}{}" , "" , self . supported( ) . paint( ) , self . name( ) , width = level * 2 ) ;
@@ -908,7 +937,7 @@ struct PermDaemon {
908937 service : Result < ( ) , Rc < Error > > ,
909938}
910939
911- impl Update for PermDaemon {
940+ impl Update for PermDaemon {
912941 fn update ( & mut self , support : & SgxSupport ) {
913942 self . inner = Some ( PermDaemonInner {
914943 service : support. perm_daemon . clone ( )
@@ -923,7 +952,7 @@ impl Print for PermDaemon {
923952
924953 fn print ( & self , level : usize ) {
925954 if self . supported ( ) == Status :: Supported {
926- println ! ( "{:width$}{}{}" , "" , self . supported( ) . paint( ) , self . name( ) , width = level * 2 ) ;
955+ println ! ( "{:width$}{}{}" , "" , self . supported( ) . paint( ) , self . name( ) , width = level * 2 ) ;
927956 } else {
928957 println ! ( "{:width$}{}{} {}" , "" , self . supported( ) . paint( ) , self . name( ) , "(Okay if container runtime is CRI-O (openshift))" , width = level * 2 ) ;
929958 }
0 commit comments