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

Add feature name (FEAT_) support to AArch64 instructions #5475

Closed
AssadHashmi opened this issue Apr 27, 2022 · 2 comments
Closed

Add feature name (FEAT_) support to AArch64 instructions #5475

AssadHashmi opened this issue Apr 27, 2022 · 2 comments

Comments

@AssadHashmi
Copy link
Contributor

AArch64 instructions are characterised by a feature name starting with FEAT_, see:
https://developer.arm.com/downloads/-/exploration-tools/feature-names-for-a-profile

Implementations of the AArch64 architecture are more accurately described by FEAT_ feature names, than by vX.Y versions, see the explanation at #5334 (comment)

This issue will clarify how FEAT_ should be implemented. The following is proposed:

  • A new enum dr_isa_feat_t similar to dr_isa_mode_t but for AArch64 only.
  • API accessor functions dr_get_isa_feat() and instr_set_isa_feat().
  • The AArch64 codec will specify the FEAT_ for all instructions after base v8.0.
  • The system registers ID_AA64ISAR0_EL1, ID_AA64ISAR1_EL1 and ID_AA64PFR0_EL1 will be read on DynamoRIO startup in order to establish which FEAT_s are implemented by the h/w. During instruction decode and encode, the instruction's FEAT_ will be checked against the FEAT_ list implemented by the h/w, delivering an error message if the FEAT_ is not implemented.
@derekbruening
Copy link
Contributor

derekbruening commented Apr 27, 2022

For improved unsupported/invalid instruction support, xref #431 and #1000

For the features: today we have proc_has_feature() and the feature_bit_t enum of FEATURE_ values https://dynamorio.org/dr__proc_8h.html#a5e226019d68bd13050692da392f6c4bf. What would be the relation between that and the AArch64 features? Should the AArch64 ones be FEATURE_ instead of FEAT_ to match? Would proc_has_feature() be deprecated and dr_get_isa_feat() take its place on x86 too?

There is no x86 connection today between those features and the IR due to early decisions not to include that data in the x86 decode table, which led to the drcpusim tool on x86 using helper functions like instr_is_sse2() which has its own list of opcodes outside of the table. It might be nice to go back and add feature info into the table eventually, so ideally new interfaces we add should be able to apply to x86 without change. (It sounds like that is the case other than the relationship to the existing interface.)

@AssadHashmi
Copy link
Contributor Author

What would be the relation between that and the AArch64 features?

Looking at the FEATURE_ enums in feature_bit_t, I don't see much semantic overlap. Only FEATURE_AES = FEAT_AES and perhaps FEATURE_RDRAND = FEAT_RNG and FEATURE_F16C = FEAT_FP16?

In terms of implementation, I think AArch64 can use the method similar to x86 but reading from system registers like ID_AA64ISAR0_EL1 rather than EBX, ECX, EDX. But there will be numerical clashes with current FEATURE_ enums. So we could either use one instance of feature_bit_t with AArch64 values offset by say 512 or have two instances of feature_bit_t. Latter seems cleaner to me.

Should the AArch64 ones be FEATURE_ instead of FEAT_ to match?

That seems fine to me. I can't imagine users complaining about the longform.

Would proc_has_feature() be deprecated and dr_get_isa_feat() take its place on x86 too?

I don't think so, now that you've made me aware of proc_has_feature() and feature_bit_t ;-)

I'll need to think about our use-cases more, but if possible we should remain consistent and use proc_get_all_feature_bits() with proc_has_feature() for AArch64 as well.

derekbruening added a commit that referenced this issue May 25, 2022
Changes the size of an array added in PR #5491 to be a compile-time C
constant.

Adds -Wvla to the UNIX compile flags to enforce this everywhere.
Fixes one other instances in drfrontendlib, and relaxes for a final
instance in a test.

Issue: #5475
derekbruening added a commit that referenced this issue May 25, 2022
Changes the size of an array added in PR #5491 to be a compile-time C
constant.

Adds -Wvla to the UNIX compile flags to enforce this everywhere.
Fixes one other instances in drfrontendlib, and relaxes for a final
instance in a test.

Issue: #5475
AssadHashmi added a commit that referenced this issue Jul 8, 2022
This patch implements the codec side of the AArch64 FEATURE_ support
patch, PR5491. A feature name field is added to each opcode in
codec_*.txt files which is used to generate feature checks in the
encoder, e.g.

    switch (instr->opcode) {
    case OP_cas:
 #     if !defined(DR_HOST_NOT_TARGET) && !defined(STANDALONE_DECODER)
       if (!proc_has_feature(FEATURE_LSE))
           return ENCFAIL;
 #     endif
       enc = encode_opndsgen_08a07c00_001f03ff(pc, instr,..., di);
       if (enc != ENCFAIL)
           return enc;

Issues: #5475, #1569, #2626
AssadHashmi added a commit that referenced this issue Jul 11, 2022
This patch implements the codec side of the AArch64 FEATURE_ support
patch, PR #5491. A feature name field is added to each opcode in
codec_*.txt files which is used to generate feature checks in the
encoder, e.g.

    switch (instr->opcode) {
    case OP_cas:
 #     if !defined(DR_HOST_NOT_TARGET) && !defined(STANDALONE_DECODER)
       if (!proc_has_feature(FEATURE_LSE))
           return ENCFAIL;
 #     endif
       enc = encode_opndsgen_08a07c00_001f03ff(pc, instr,..., di);
       if (enc != ENCFAIL)
           return enc;

Issues: #5475, #1569, #2626
AssadHashmi added a commit that referenced this issue Jul 18, 2022
The Limited Ordering Regions feature is required for the v8.1
load-acquire and store-release instructions like LDLAR and STLLR which
rely on the hardware providing order between memory accesses to
regions of the physical address map. Read from ID_AA64MMFR1_EL1.

Issues: #5475, #1569
AssadHashmi added a commit that referenced this issue Jul 18, 2022
The Limited Ordering Regions feature is required for the v8.1
load-acquire and store-release instructions like LDLAR and STLLR which
rely on the hardware providing order between memory accesses to
regions of the physical address map. Read from ID_AA64MMFR1_EL1.

Issues: #5475, #1569
AssadHashmi added a commit that referenced this issue Aug 5, 2022
The Reliability, Availability, and Serviceability (RAS) extension and
Statistical Profiling Extension (SPE) feature checks are required for
v8.2 instructions ESB and PSB. Hardware support for these read from
registers ID_AA64PFR0_EL1 and ID_AA64DFR0_EL1.

Issues: #5475, #2626
AssadHashmi added a commit that referenced this issue Aug 8, 2022
The Reliability, Availability, and Serviceability (RAS) extension and
Statistical Profiling Extension (SPE) feature checks are required for
v8.2 instructions ESB and PSB. Hardware support for these read from
registers ID_AA64PFR0_EL1 and ID_AA64DFR0_EL1.

Issues: #5475, #2626
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants