Skip to content

Commit 8eb71fe

Browse files
committed
rebinding: populate UTF-8 reason string on SPDM error paths
The non-SPDM rebinding_old_prepare / rebinding_new_prepare populate the VMM ReportStatus reason buffer (data: &mut Vec<u8>) on transport failures, gated by #[cfg(feature = "vmcall-raw")]. The SPDM-featured counterparts had the parameter spelled _data and never wrote to it, so GHCI 1.5 ReportStatus (p. 47-48, Tables 3-55/3-56) had no diagnostic payload when an SPDM rebind failed. Mirror the non-SPDM pattern at the three SPDM error sites: * spdm_requester / spdm_responder transport setup failure * with_timeout timeout error around spdm_requester_rebind_old / spdm_responder_rebind_new * the SPDM rebind operation itself Each .map_err closure now pushes a one-line UTF-8 reason string (operation name, MigrationResult variant, migration ID in hex) into data, gated by #[cfg(feature = "vmcall-raw")] to match the non-SPDM RA-TLS arms. log::error! calls are preserved verbatim. No behavior change with vmcall-raw off: data is unused (same warning as the existing non-SPDM functions on that configuration). Signed-off-by: Stanislaw Grams <stanislaw.grams@intel.com>
1 parent 089a69e commit 8eb71fe

1 file changed

Lines changed: 50 additions & 2 deletions

File tree

src/migtd/src/migration/rebinding.rs

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,21 @@ pub async fn start_rebinding(
177177
pub async fn rebinding_old_prepare(
178178
transport: TransportType,
179179
info: &MigtdMigrationInformation,
180-
_data: &mut Vec<u8>,
180+
data: &mut Vec<u8>,
181181
#[cfg(feature = "policy_v2")] remote_policy: Vec<u8>,
182182
) -> Result<(), MigrationResult> {
183183
use core::ops::DerefMut;
184184

185185
const SPDM_TIMEOUT: Duration = Duration::from_secs(60); // 60 seconds
186186
let (mut spdm_requester, device_io_ref) = spdm::spdm_requester(transport).map_err(|_e| {
187+
#[cfg(feature = "vmcall-raw")]
188+
data.extend_from_slice(
189+
&format!(
190+
"Error: rebinding_old_prepare(): Failed in spdm_requester transport. Migration ID: {:x}\n",
191+
info.mig_request_id,
192+
)
193+
.into_bytes(),
194+
);
187195
log::error!(
188196
"rebinding: Failed in spdm_requester transport. Migration ID: {}\n",
189197
info.mig_request_id
@@ -201,13 +209,29 @@ pub async fn rebinding_old_prepare(
201209
)
202210
.await
203211
.map_err(|e| {
212+
#[cfg(feature = "vmcall-raw")]
213+
data.extend_from_slice(
214+
&format!(
215+
"Error: rebinding_old_prepare(): spdm_requester_rebind_old timed out ({:?}). Migration ID: {:x}\n",
216+
e, info.mig_request_id,
217+
)
218+
.into_bytes(),
219+
);
204220
log::error!(
205221
"rebinding: spdm_requester_rebind_old timeout error: {:?}\n",
206222
e
207223
);
208224
e
209225
})?
210226
.map_err(|e| {
227+
#[cfg(feature = "vmcall-raw")]
228+
data.extend_from_slice(
229+
&format!(
230+
"Error: rebinding_old_prepare(): spdm_requester_rebind_old failed ({:?}). Migration ID: {:x}\n",
231+
e, info.mig_request_id,
232+
)
233+
.into_bytes(),
234+
);
211235
log::error!("rebinding: spdm_requester_rebind_old error: {:?}\n", e);
212236
e
213237
})?;
@@ -223,13 +247,21 @@ pub async fn rebinding_old_prepare(
223247
pub async fn rebinding_new_prepare(
224248
transport: TransportType,
225249
info: &MigtdMigrationInformation,
226-
_data: &mut Vec<u8>,
250+
data: &mut Vec<u8>,
227251
#[cfg(feature = "policy_v2")] remote_policy: Vec<u8>,
228252
) -> Result<(), MigrationResult> {
229253
use core::ops::DerefMut;
230254

231255
const SPDM_TIMEOUT: Duration = Duration::from_secs(60); // 60 seconds
232256
let (mut spdm_responder, device_io_ref) = spdm::spdm_responder(transport).map_err(|_e| {
257+
#[cfg(feature = "vmcall-raw")]
258+
data.extend_from_slice(
259+
&format!(
260+
"Error: rebinding_new_prepare(): Failed in spdm_responder transport. Migration ID: {:x}\n",
261+
info.mig_request_id,
262+
)
263+
.into_bytes(),
264+
);
233265
log::error!(
234266
"rebinding: Failed in spdm_responder transport. Migration ID: {}\n",
235267
info.mig_request_id
@@ -248,13 +280,29 @@ pub async fn rebinding_new_prepare(
248280
)
249281
.await
250282
.map_err(|e| {
283+
#[cfg(feature = "vmcall-raw")]
284+
data.extend_from_slice(
285+
&format!(
286+
"Error: rebinding_new_prepare(): spdm_responder_rebind_new timed out ({:?}). Migration ID: {:x}\n",
287+
e, info.mig_request_id,
288+
)
289+
.into_bytes(),
290+
);
251291
log::error!(
252292
"rebinding: spdm_responder_rebind_new timeout error: {:?}\n",
253293
e
254294
);
255295
e
256296
})?
257297
.map_err(|e| {
298+
#[cfg(feature = "vmcall-raw")]
299+
data.extend_from_slice(
300+
&format!(
301+
"Error: rebinding_new_prepare(): spdm_responder_rebind_new failed ({:?}). Migration ID: {:x}\n",
302+
e, info.mig_request_id,
303+
)
304+
.into_bytes(),
305+
);
258306
log::error!("rebinding: spdm_responder_rebind_new error: {:?}\n", e);
259307
e
260308
})?;

0 commit comments

Comments
 (0)