Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions nvml-wrapper/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
nvml: &'nvml Nvml,
}

unsafe impl<'nvml> Send for Device<'nvml> {}

Check warning on line 76 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

the following explicit lifetimes could be elided: 'nvml
unsafe impl<'nvml> Sync for Device<'nvml> {}

Check warning on line 77 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

the following explicit lifetimes could be elided: 'nvml

assert_impl_all!(Device: Send, Sync);

Expand Down Expand Up @@ -155,10 +155,10 @@

* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if this `Device` is invalid or the apiType is invalid (may occur if
the C lib changes dramatically?)

Check warning on line 158 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `NotSupported`, if this query is not supported by this `Device` or this `Device`
does not support the feature that is being queried (e.g. enabling/disabling auto

Check warning on line 160 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
boosted clocks is not supported by this `Device`).

Check warning on line 161 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `UnexpectedVariant`, for which you can read the docs for
* `Unknown`, on any unexpected error
Expand Down Expand Up @@ -192,7 +192,7 @@

* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if this `Device` is invalid or the clockType is invalid (may occur
if the C lib changes dramatically?)

Check warning on line 195 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `NotSupported`, if this `Device` does not support this feature
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error
Expand Down Expand Up @@ -432,7 +432,7 @@
* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if this `Device` is invalid or `clock_type` is invalid (shouldn't occur?)
* `NotSupported`, if this `Device` or the `clock_type` on this `Device`
does not support this feature

Check warning on line 435 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error

Expand Down Expand Up @@ -743,6 +743,55 @@
}
}

/**
Fetches the confidential compute attestation report for this [`Device`].

This method retrieves a comprehensive attestation report from the device, which includes:
- A 32-byte nonce
- The attestation report size (as big-endian bytes)
- The attestation report data (up to 8192 bytes)
- A flag indicating if CEC attestation is present (as big-endian bytes)
- The CEC attestation report size (as big-endian bytes)
- The CEC attestation report data (up to 4096 bytes)

The returned vector contains all these components concatenated together in the order listed above.

# Errors

* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if device is invalid or memory is NULL
* `NotSupported`, if this query is not supported by the device
* `Unknown`, on any unexpected error
*/
#[doc(alias = "nvmlDeviceGetAttestationReport")]
pub fn confidential_compute_gpu_attestation_report(
&self,
nonce: [u8; NVML_CC_GPU_CEC_NONCE_SIZE as usize],
) -> Result<ConfidentialComputeGpuAttestationReport, NvmlError> {
let sym = nvml_sym(
self.nvml
.lib
.nvmlDeviceGetConfComputeGpuAttestationReport
.as_ref(),
)?;

unsafe {
let mut report: nvmlConfComputeGpuAttestationReport_st = mem::zeroed();
report.nonce = nonce;

nvml_try(sym(self.device, &mut report))?;

let is_cec_attestation_report_present = report.isCecAttestationReportPresent == 1;
Ok(ConfidentialComputeGpuAttestationReport {
attestation_report_size: report.attestationReportSize,
attestation_report: report.attestationReport.to_vec(),
is_cec_attestation_report_present,
cec_attestation_report_size: report.cecAttestationReportSize,
cec_attestation_report: report.cecAttestationReport.to_vec(),
})
}
}

/**
Gets the current PCIe link generation.

Expand Down Expand Up @@ -1236,7 +1285,7 @@
* `Uninitialized`, if the library has not been successfully initialized
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `UnexpectedVariant`, if an enum variant not defined in this wrapper gets
returned in a field of an `EncoderSessionInfo` struct

Check warning on line 1288 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `Unknown`, on any unexpected error

# Device Support
Expand Down Expand Up @@ -1899,7 +1948,7 @@
* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if `error_type`, `counter_type`, or `location` is invalid (shouldn't occur?)
* `NotSupported`, if this `Device` does not support ECC error reporting for the specified
memory

Check warning on line 1951 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error

Expand Down Expand Up @@ -2821,7 +2870,7 @@

* `Uninitialized`, if the library has not been successfully initialized
* `IncorrectBits`, if NVML returns any bits that do not correspond to flags in
`ThrottleReasons`

Check warning on line 2873 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `NotSupported`, if this `Device` does not support this feature
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error
Expand Down
18 changes: 18 additions & 0 deletions nvml-wrapper/src/structs/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ use crate::enum_wrappers::device::OperationMode;
#[cfg(feature = "serde")]
use serde_derive::{Deserialize, Serialize};

/// Returned from `Device.confidential_compute_gpu_attestation_report_bytes()`
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ConfidentialComputeGpuAttestationReport {
/// The size of the attestation report.
pub attestation_report_size: u32,
/// The attestation report, of size
/// `ffi::bindings::NVML_CC_GPU_ATTESTATION_REPORT_SIZE` == 8192 bytes.
pub attestation_report: Vec<u8>,
/// Whether the CEC attestation report is present.
pub is_cec_attestation_report_present: bool,
/// The size of the CEC attestation report.
pub cec_attestation_report_size: u32,
/// The CEC attestation report, of size
/// `ffi::bindings::NVML_CC_GPU_CEC_ATTESTATION_REPORT_SIZE` == 4096 bytes.
pub cec_attestation_report: Vec<u8>,
}

/// Returned from `Device.auto_boosted_clocks_enabled()`
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Expand Down
Loading