Skip to content

refactor(arch/x86_64): Dynamically allocate XSAVE area #1776

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Gelbpunkt
Copy link
Member

@Gelbpunkt Gelbpunkt commented Jun 17, 2025

The real size of the XSAVE area depends on the enabled features in XCR0. To avoid having to hardcode the order of the save regions, we can instead rely on the raw-cpuid crate's APIs that expose the required size of the area.

However, we cannot fully rely on this and just zero out the memory, since some fields are required to be initialized with non-zero values. Therefore we need to keep the legacy header definition and manually set those.

Additionally, this commit introduces support for XSAVEC and XSAVEOPT, which are both faster and more efficient than XSAVE.

@mkroening mkroening self-requested a review June 17, 2025 13:16
@mkroening mkroening self-assigned this Jun 17, 2025
@Gelbpunkt Gelbpunkt force-pushed the dynamic-xsave branch 2 times, most recently from 91bca3b to 1d7aafc Compare June 17, 2025 14:32
The real size of the XSAVE area depends on the enabled features in XCR0.
To avoid having to hardcode the order of the save regions, we can
instead rely on the raw-cpuid crate's APIs that expose the required size
of the area.

However, we cannot *fully* rely on this and just zero out the memory,
since some fields are required to be initialized with non-zero values.
Therefore we need to keep the legacy header definition and manually set
those.

Additionally, this commit introduces support for XSAVEC and XSAVEOPT,
which are both faster and more efficient than XSAVE.

Signed-off-by: Jens Reidel <[email protected]>
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