Skip to content

netvsp: gdma driver report git commit#2963

Open
erfrimod wants to merge 8 commits intomicrosoft:mainfrom
erfrimod:erfrimod/mana-driver-report-commit
Open

netvsp: gdma driver report git commit#2963
erfrimod wants to merge 8 commits intomicrosoft:mainfrom
erfrimod:erfrimod/mana-driver-report-commit

Conversation

@erfrimod
Copy link
Contributor

@erfrimod erfrimod commented Mar 12, 2026

Soc needs a signal for determining what features are available. During triage, soc logs will provide more information to determine which version of the Gdma driver and OpenHCL was running.

  • OSVersionString1 set to "OpenHCL"
  • OSVersionString2 set to git commit
  • OPENHCL_VERSION split into 4 values and supplied to
    • OSVersionMajor
    • OSVersionMinor
    • OSVersionBuild
    • OSVersionPlatform

@erfrimod erfrimod requested review from a team as code owners March 12, 2026 23:00
Copilot AI review requested due to automatic review settings March 12, 2026 23:00
@erfrimod
Copy link
Contributor Author

erfrimod commented Mar 12, 2026

Tested on a lab machine. socmana log shows OSVersionString2 set to the git commit cb7c8c705ecec62637a8cef51f068093f7284e38

Built binaries with OPENHCL_VERSION="1.2.3.4" cargo xflowey build-igvm x64

[260313 20:03:42.587626-000,003;2205] [gdma v=f1e024 h=0451] [INFO] [vf=3-2 vtl=2 cl=1 act=0xca930003 msg=0x1 err=0x0 ms=0 vm=ErikUhVm] VerifyVFVersion(292): VFId:2 VFVersion:0x0 OSType:0x60 OSVersionMajor:0x1 OSVersionMinor:0x2 OSVersionBuild:0x3 OSVersionPlatform:0x4 ProtocolMin:0x1 ProtocolMax:0x1 Flags1:0x14068 Flags2:0x0 Flags3:0x0 Flags4:0x0 LinuxManaCapabilityEnforcement:0x0
[260313 20:03:42.587632-000,002;2206] [gdma v=f1e024 h=0451] [INFO] [vf=3-2 vtl=2 cl=1 act=0xca930003 msg=0x1 err=0x0 ms=0 vm=ErikUhVm] VerifyVFVersion(302): VFId:2 VFVersion:0x0 OSType:0x60 OSVersionString1:OpenHCL OSVersionString2:cb7c8c705ecec62637a8cef51f068093f7284e38 OSVersionString3: OSVersionString4: LinuxManaCapabilityEnforcement:0x0
commit cb7c8c705ecec62637a8cef51f068093f7284e38 (HEAD -> erfrimod/mana-driver-report-commit, origin/erfrimod/mana-driver-report-commit)
Author: erfrimod <erfrimod@microsoft.com>
Date:   Fri Mar 13 12:43:23 2026 -0700

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds build-time Git revision information to the MANA GDMA VF driver verification request so that the SoC/HWC side can log which driver build is running during triage.

Changes:

  • Populate GdmaVerifyVerReq OS/build identity strings (os_ver_str1/os_ver_str2) with a driver name and BUILD_GIT_SHA.
  • Add a build.rs for mana_driver to emit BUILD_GIT_SHA/BUILD_GIT_BRANCH via build_rs_git_info.
  • Log the received driver name/commit on the GDMA HWC side when handling GDMA_VERIFY_VF_DRIVER_VERSION.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vm/devices/net/mana_driver/src/gdma_driver.rs Fill verify-version request fields with driver name and Git SHA to report to the SoC.
vm/devices/net/mana_driver/build.rs Emit Git metadata at build time for use via option_env!.
vm/devices/net/mana_driver/Cargo.toml Add build_rs_git_info as a build dependency.
vm/devices/net/gdma/src/hwc.rs Parse and log the driver name/commit from the verify-version request.
Cargo.lock Record the new build dependency in the lockfile.

@github-actions
Copy link

#[tracing::instrument(skip(self), level = "debug", err)]
pub async fn verify_vf_driver_version(&mut self) -> anyhow::Result<()> {
let mut req = GdmaVerifyVerReq {
protocol_ver_min: 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets see if we can plumb in the OPENHCL_VERSION value into protocol_ver_min/max

Copilot AI review requested due to automatic review settings March 13, 2026 19:43
@erfrimod erfrimod force-pushed the erfrimod/mana-driver-report-commit branch from efd6945 to cb7c8c7 Compare March 13, 2026 19:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.


/// Parse an OPENHCL_VERSION string of the form "major.minor.build.platform"
/// into four u32 components. Missing or unparseable components default to 0.
fn parse_openhcl_version(version: &str) -> (u32, u32, u32, u32) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This belongs better in the build_rs_git_info crate

let mut parts = version.splitn(4, '.');
let major = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
let minor = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
let build = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justus-camp-microsoft or @maheeraeron - Do you know in the openhcl_version="1.5.10492.0", what do the last two (i.e. 10492.0 in the above example) fields for?

@github-actions github-actions bot added the unsafe Related to unsafe code label Mar 13, 2026
@github-actions
Copy link

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copilot AI review requested due to automatic review settings March 13, 2026 20:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

};

// Identify the driver and build to the SOC
// str1 = OS/driver name, str2 = build identity.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also move this to build_info crate. Rest all looks good to me.

.ok()
.and_then(|c| c.to_str().ok())
.unwrap_or("<invalid>");
tracing::debug!(drv_name, drv_commit, "vf driver version");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can log the other fields here as well and move this to info level as this is good debug info.

// Identify the driver and build to the SOC
// str1 = "OpenHCL", str2 = build identity.
let name = build_info::PRODUCT_NAME.as_bytes();
req.os_ver_str1[..name.len()].copy_from_slice(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs a min length check like below

Copilot AI review requested due to automatic review settings March 13, 2026 22:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

rust-version.workspace = true

[dependencies]
build_info.workspace = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justus-camp-microsoft @Brian-Perkins - Will this be a problem for the reproducible build stuff?

req.os_ver_str1[..len].copy_from_slice(&name.as_bytes()[..len]);

let revision = build_info::get().scm_revision();
let len = revision.len().min(req.os_ver_str2.len() - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, for these you want to use saturating_sub, but its fine for now

sunilmut
sunilmut previously approved these changes Mar 13, 2026
sunilmut
sunilmut previously approved these changes Mar 13, 2026

// Parse the OPENHCL_VERSION string of the form "major.minor.build.platform"
// into four u32 components. Missing or unparseable components default to 0.
pub fn parse_openhcl_version() -> (u32, u32, u32, u32) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be doing this at runtime, we should do it at build time instead (either providing the ints in env vars or using const fn). That way we can also validate at build time that things match the expected format.

Copy link
Contributor

@smalis-msft smalis-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert parsing to a build-time operation, not runtime

@sunilmut
Copy link
Member

Convert parsing to a build-time operation, not runtime

Is it possible to prevent runtime inclusion of the crate so that this can be prevented in future?

@smalis-msft
Copy link
Contributor

I'm not sure what you mean by that. We have to include the crate to call the getters at runtime. I'm just opposed to doing any significant logic at runtime around this data, since it all should be available at build time.

Copilot AI review requested due to automatic review settings March 16, 2026 19:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines 9 to +10
[dependencies]
build_info.workspace = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants