Skip to content

Conversation

@toribioa
Copy link
Member

@toribioa toribioa commented Sep 10, 2025

Description

Add hotpatch support for Windows x64 kernel driver

This PR enables runtime hotpatching capabilities for the MSQuic kernel driver (msquic.sys) in Release|x64 builds by adding the necessary linker flags to msquic.kernel.vcxproj.

Background
Currently, production releases of msquic.sys do not support runtime hotpatching due to missing linker options and function padding required for x64 hotpatch operations. This limitation prevents in-memory updates and affects compatibility with components such as SMBDirect that depend on hotpatch-enabled drivers.

Changes
This PR adds the following linker flags to the Release|x64 configuration:

  • /hotpatchcompatible /profile /incremental:no - Generates PDB records for Vulcan compatibility and enables hotpatch-compatible linking
  • /FUNCTIONPADMIN:6 - Adds 6-byte function padding required for x64 hotpatching trampolines used by hpiload during patch application

Impact

  • Production Deployments: Enables in-memory hotpatching for production MSQuic kernel driver updates
  • Component Compatibility: Ensures compatibility with SMBDirect and other components requiring hotpatch-enabled drivers
  • Operational Benefits: Reduces downtime by supporting runtime driver updates without system restarts

Technical Details

  • The 6-byte padding on x64 functions allows the hotpatch loader (hpiload) to insert trampolines that redirect execution from the baseline binary to the patch binary at runtime, enabling seamless driver updates.

Testing

Completed Verification
✅ Visual Studio Build: Confirmed that locally built msquic.sys for x64 Release configuration contains all required hotpatch prerequisites.
✅ Hotpatch Loading: Successfully loaded and applied a hotpatch to the driver in memory during testing.

✅ GitHub Actions Pipeline: Verify that CI/CD-generated msquic.sys artifact maintain hotpatch compatibility
✅ Release Artifact Testing: Confirm that market-ready msquic.sys binary produced by GitHub pipelines support hotpatch operations

Validation Plan

  1. Download Release-winkernel-windows-2022-x64-schannel artifact from GitHub Actions
    https://github.com/microsoft/msquic/actions/runs/17618956151/job/50059433726?pr=5437
  2. Verify binary contains required function padding and hotpatch metadata
    https://github.com/microsoft/msquic/actions/runs/17618956151/artifacts/3976994659
  3. Perform runtime hotpatch loading test with CI-generated binary
    ✅Successfully loaded and applied a hotpatch to the driver in memory during testing.

Documentation

No user-facing documentation changes required. This is an internal build configuration change that enables existing Windows hotpatch infrastructure. The functionality is transparent to end users and does not modify MSQuic APIs or behavior.

Add hotpatch support for x64 kernel driver

Enable hotpatching capabilities for msquic.sys in Release|x64 builds. This allows SMBDirect and other components to use MSQuic artifacts with runtime hotpatching support enabled.

- Enables function padding for Release|x64 configuration
- Supports runtime hotpatching for production deployments

These linker flags modifications meaning:
- /hotpatchcompatible /profile /incremental:no This adds records to the PDB which lets vulcan understand the binary.
- /FUNCTIONPADMIN:6 This adds padding needed for hotpatching on x64 binaries. The 6 bytes of padding on x64 are used by hpiload at patch load time to trampoline from the baseline binary to the patch binary.
@codecov
Copy link

codecov bot commented Sep 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.73%. Comparing base (ca5c05f) to head (06ec953).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5437      +/-   ##
==========================================
- Coverage   85.90%   84.73%   -1.18%     
==========================================
  Files          59       59              
  Lines       18600    18600              
==========================================
- Hits        15979    15761     -218     
- Misses       2621     2839     +218     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants