Skip to content

Conversation

@dgarske
Copy link
Contributor

@dgarske dgarske commented Apr 29, 2025

Use a global mutex instead of one that is part of TPM2_CTX. ZD 19771
Add build option WOLFTPM_NO_ACTIVE_THREAD_LS to support no thread local on gActiveTPM.

…lobal mutex instead of one that is part of TPM2_CTX. ZD 19771
@dgarske dgarske self-assigned this Apr 29, 2025
@dgarske dgarske requested a review from Copilot May 2, 2025 19:56
Copy link

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 improves mutex locking protection for concurrent thread usage by replacing per-context locks with a global lock and adds a build option to support configurations without thread local storage for the active TPM2_CTX.

  • Removed TPM2_CTX-specific mutex and lock count fields in favor of a global mutex.
  • Introduced fallback macros in tpm2_types.h for older wolfSSL versions.
  • Updated lock acquisition/release logic in src/tpm2.c to use the global gHwLock and conditionally initialize/free it.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
wolftpm/tpm2_types.h Added fallback definitions for mutex initializer macros to support older wolfSSL.
wolftpm/tpm2.h Removed per-instance mutex and lock count from TPM2_CTX to use a global mutex.
src/tpm2.c Refactored lock functions to use the global gHwLock and updated active context support.

@dgarske dgarske assigned embhorn and unassigned dgarske May 5, 2025
Copy link
Member

@embhorn embhorn left a comment

Choose a reason for hiding this comment

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

TPM2_AcquireLock is so much cleaner. Looks great.

@embhorn embhorn merged commit 3bbed48 into wolfSSL:master May 5, 2025
3 checks passed
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