Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tracking issue: rust-lang/rust#135413
relevant issue: rust-lang/rust#130869
this PR adds the
is_s390x_feature_detected
macro.Is an ACP needed here?
Below is a bunch of context.
Feature detection
This PR uses only the
getauxval
function. That is sufficient for the current feature flags.Based on the official documents, the
stfl
instruction can/should be used to test for "Facility Indications". Unfortunately, it appears that this instruction can only be executed by the kernel, and in any case stores its result at address200
, that users cannot read. Bummer.There is also the
stfle
instruction, that provides more facility indications. We can actually use that from user space, e.g.But, for now, this is not needed and
getauxval
is sufficient.Feature names
On nightly,
s390x
currently has two target features, introduced in rust-lang/rust#127506:vector
for SIMD capabilitiesbackchain
related to stack unwindingThe "vector" name appears to be an LLVM concept: in
qemu
,clang
and the linux kernel the "vector" extension is calledvx
. There is nothing called "backchain" in the Facility Indications, so it looks like that is not a feature that can be queried for at runtime.Anyway, for now, only
"vector"
is supported by theis_s390x_feature_detected
macro, and it maps internally to thevx
facility indication. For some of the vector instructions, the extensions likevector-enhancements-1
will likely also be needed, but this PR does not include them.This LLVM file lists many more features that are not currently supported.
Testing
I could not find a qemu CPU that works with rust programs and also does not support
vx
. I did test the logic using thevxrs_ext2
field, and a custom CPU:I verified that toggling the
vxeh2
flag is observed by the implementation.Obviously that is not an automated test, so for now the details of the implementation go untested.
cc @taiki-e, hope I'm not stepping on your toes here, but this nerdsniped me.