Re: [PATCH v3 14/21] lib: rspdm: Support SPDM get_version

From: Jonathan Cameron

Date: Tue Sep 08 2026 - 19:41:22 EST


On Tue, 1 Sep 2026 11:03:40 +1000
alistair23@xxxxxxxxx wrote:

> From: Alistair Francis <alistair@xxxxxxxxxxxxx>
>
> Support the GET_VERSION SPDM command.
>
> Signed-off-by: Alistair Francis <alistair@xxxxxxxxxxxxx>
From a an SPDM stand point looks good to me.
Reviewed-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>

> diff --git a/lib/rspdm/lib.rs b/lib/rspdm/lib.rs
> index 1883579b817a..58d86ea06fd9 100644
> --- a/lib/rspdm/lib.rs
> +++ b/lib/rspdm/lib.rs
...





> @@ -234,4 +242,59 @@ pub(crate) fn spdm_exchange(
>
> Ok(length)
> }
> +
> + /// Negotiate a supported SPDM version and store the information
> + /// in the `SpdmState`.
> + pub(crate) fn get_version(&mut self) -> Result<(), Error> {

...

> +
> + for i in 0..entry_count as usize {
> + let off = entries_offset + i * core::mem::size_of::<u16>();
> + let entry = u16::from_le_bytes([response_vec[off], response_vec[off + 1]]);
> + let alpha_version = (entry & 0xF) as u8;
> + let version = (entry >> 8) as u8;
> +
> + if alpha_version > 0 {

Can we do != 0 as that matches the spec text?

> + pr_warn!("Alpha version {alpha_version} is not specifically supported\n");
> + }
> +
> + if version >= self.version && version <= SPDM_MAX_VER {
> + self.version = version;
> + foundver = true;
> + }
> + }
> +
> + if !foundver {
> + pr_err!("No common supported version\n");
> + return Err(EPROTO);
> + }
> +
> + Ok(())
> + }
> }