-
Notifications
You must be signed in to change notification settings - Fork 133
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
registers: MXCSR #336
registers: MXCSR #336
Conversation
I'll fix the reported issues! |
It seems like there is a bug in the |
Hi, would it be more sustainable if I dropped that from this PR? It's not super critical as it is just integer that is sealed to be 0x1F80 (documented in Intel SDM). |
I changed it as:
Obviously this means that |
@npmccallum, @haraldh: This essentially the same type as in xsave except
In the original type these were |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
Probably, yes. Perhaps we could add a |
OK, I think I resolved the existing review comments (but obviously can refine more if required). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still needs the proper external_asm
wrappers, but other than that this looks good!
src/registers/mxcsr.rs
Outdated
const ROUNDING_CONTROL_NEGATIVE = 1 << 13; | ||
/// Toward positive infinity | ||
/// | ||
/// Set the both control registers for "toward zero". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make that a separate flag ROUNDING_CONTROL_ZERO
that combines both ROUNDING_CONTROL_NEGATIVE
and ROUNDING_CONTROL_POSITIVE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had that but did not stage that change for external asm part. I'll add the ROUNDING_CONTROL_ZERO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I uploaded new version. My biggest struggle with QA is that I have no idea how to enforce cargo to compile "not inline_asm" flow instead of "inlin_asm" flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI job uses cargo build --no-default-features --features external_asm,instructions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ROUNDING_CONTROL_ZERO
seems to have got removed again.
@Freax13 Is the |
Inline assembly hasn't landed on stable yet, it will be part of Rust 1.59 released at the end of next month. However once that happens, I agree that we could probably only use inline assembly in some (if not all?) cases. |
I sorted my problem out by writing a small script:
Now both code paths work! |
You can make amazingly stupid things if you are coding blind, i.e. no ways neither to compile nor run any tests on code you're working on :-) I can contribute the above script as a workaround, unless there is some smoother way to sort this out. No doubt that is ugly as hell... |
I proposed a solution: #337 I.e. you could then override x86_64_inline_asm even if its default value would be implicitly set based on inline_asm. |
I got the build commands together:
With this I was able to run the tests sequentially through with external asm. |
This can be further simplified to just: cargo test --no-default-features --features external_asm,instructions
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more small changes required, we should be able to merge this soon :-).
The CI job that checks formatting is also still failing, you can run cargo fmt
to fix this.
src/registers/mxcsr.rs
Outdated
const ROUNDING_CONTROL_NEGATIVE = 1 << 13; | ||
/// Toward positive infinity | ||
/// | ||
/// Set the both control registers for "toward zero". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ROUNDING_CONTROL_ZERO
seems to have got removed again.
Thanks, I'll fix these later on today. |
OK, let's see :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last small suggestion, then this should be good to go 🎉
Oh and you need to run |
I'll keep this in mind, thank you. |
So... I guess it is now about right? I bundled everything into a single commit and:
|
Add MxCsr register derived from MxCsr type in enarx/xsave. Provide two unit tests: - mxcsr_default(): Check that the constant matches the value read from the CPU when the process has not yet written anything else to it. - mxcsr_write(): Check that the write operation does not corrupt values. Co-authored-by: Tom Dohrmann <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
Yes. Thank you for your contribution! |
Add MxCsr register derived from MxCsr type in enarx/xsave.
Provide two unit tests:
the CPU when the process has not yet written anything else to it.
Closes: enarx/enarx#1000
Signed-off-by: Jarkko Sakkinen [email protected]