Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tdx-tdcall: don't use heap allocated buffers for TD reports #745

Merged

Conversation

Freax13
Copy link
Contributor

@Freax13 Freax13 commented Oct 31, 2024

There's little reason to use a heap-allocated buffer for requesting TD reports putting it behind a global lock. Furthermore, the TDX module doesn't require the additional data to be inside the TD report buffer. Instead, put the buffer on the stack and directly pass a pointer to the additional data.
Note that with and without this patch, the memory passed to the TDX module must be identity-mapped.

There's little reason to use a heap-allocated buffer for requesting TD
reports putting it behind a global lock. Furthermore the TDX module
doesn't require the additional data to be inside the TD report buffer.
Instead, put the buffer on the stack and directly pass a pointer to the
additional data.
Note that with and without this patch, the memory passed to the TDX
module must be identity-mapped.

Signed-off-by: Tom Dohrmann <[email protected]>
Signed-off-by: Tom Dohrmann <[email protected]>
@gaojiaqi7
Copy link
Member

Thanks @Freax13 . The additional data is required to be 64B-aligned. Maybe we can add it in TdxReportBuf or define a new structure with alignment to hold the additional_data.

@Freax13
Copy link
Contributor Author

Freax13 commented Dec 5, 2024

Thanks @Freax13 . The additional data is required to be 64B-aligned. Maybe we can add it in TdxReportBuf or define a new structure with alignment to hold the additional_data.

Good catch. Yeah, we can just create a new wrapper struct and copy the data to the stack.

I no longer have the time to work on this PR. Feel free to update or close it.

Add a wrapper struct to hold the additional data to meet the 64B alignment.

Signed-off-by: Jiaqi Gao <[email protected]>
@jyao1 jyao1 merged commit b4030cf into confidential-containers:main Dec 12, 2024
23 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.

3 participants