@@ -13,6 +13,7 @@ use async_io::{AsyncRead, AsyncWrite};
1313use core:: sync:: atomic:: AtomicBool ;
1414#[ cfg( any( feature = "vmcall-interrupt" , feature = "vmcall-raw" ) ) ]
1515use core:: sync:: atomic:: Ordering ;
16+ use core:: time:: Duration ;
1617use core:: { future:: poll_fn, mem:: size_of, task:: Poll } ;
1718#[ cfg( any( feature = "vmcall-interrupt" , feature = "vmcall-raw" ) ) ]
1819use event:: VMCALL_SERVICE_FLAG ;
@@ -847,12 +848,16 @@ pub async fn exchange_msk(info: &MigrationInformation, data: &mut Vec<u8>) -> Re
847848
848849 // Exchange policy firstly because of the message size limitation of TLS protocol
849850 #[ cfg( feature = "policy_v2" ) ]
850- let remote_policy = Box :: pin ( pre_session_data_exchange ( & mut transport) ) . await ?;
851+ const PRE_SESSION_TIMEOUT : Duration = Duration :: from_secs ( 60 ) ; // 60 seconds
852+ #[ cfg( feature = "policy_v2" ) ]
853+ let remote_policy = Box :: pin ( with_timeout (
854+ PRE_SESSION_TIMEOUT ,
855+ pre_session_data_exchange ( & mut transport) ,
856+ ) )
857+ . await ??;
851858
852859 #[ cfg( not( feature = "spdm_attestation" ) ) ]
853860 {
854- use core:: time:: Duration ;
855-
856861 const TLS_TIMEOUT : Duration = Duration :: from_secs ( 60 ) ; // 60 seconds
857862
858863 let mut remote_information = ExchangeInformation :: default ( ) ;
@@ -986,12 +991,15 @@ pub async fn exchange_msk(info: &MigrationInformation, data: &mut Vec<u8>) -> Re
986991 remote_information. key . clear ( ) ;
987992 }
988993
994+ #[ cfg( feature = "spdm_attestation" ) ]
995+ const SPDM_TIMEOUT : Duration = Duration :: from_secs ( 60 ) ; // 60 seconds
996+
989997 #[ cfg( feature = "spdm_attestation" ) ]
990998 if info. is_src ( ) {
991999 let mut spdm_requester =
9921000 spdm:: spdm_requester ( transport) . map_err ( |_| MigrationResult :: SecureSessionError ) ?;
9931001 with_timeout (
994- spdm :: SPDM_TIMEOUT ,
1002+ SPDM_TIMEOUT ,
9951003 spdm:: spdm_requester_transfer_msk (
9961004 & mut spdm_requester,
9971005 & info. mig_info ,
@@ -1006,7 +1014,7 @@ pub async fn exchange_msk(info: &MigrationInformation, data: &mut Vec<u8>) -> Re
10061014 spdm:: spdm_responder ( transport) . map_err ( |_| MigrationResult :: SecureSessionError ) ?;
10071015
10081016 with_timeout (
1009- spdm :: SPDM_TIMEOUT ,
1017+ SPDM_TIMEOUT ,
10101018 spdm:: spdm_responder_transfer_msk (
10111019 & mut spdm_responder,
10121020 & info. mig_info ,
0 commit comments