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

[#1548][vector crypto] adding register index LMUL alignement checks #1815

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

nibrunieAtSi5
Copy link
Contributor

@nibrunieAtSi5 nibrunieAtSi5 commented Sep 25, 2024

This pull request implement two things:

(a) the EMUL alignment of vector operand/destination (=EMUL for the vector element group operands and the destination) is specified in the main RVV spec; when a vector register group is not EMUL aligned, the behavior is listed as "reserved" and spike has implemented this check to trigger illegal instruction exception when the condition was not met (e.g.

require_align(insn.rd(), P.VU.vflmul); \
)

(b) is not specified clearly in the vector crypto specification (current version https://github.com/riscv/riscv-isa-manual/blob/7023c601443adf21850772e02e3d920bc68b2237/src/vector-crypto.adoc)

The vector crypto specification lists multiple times the intent to allow the vector register group for the scalar-element-group to have EMUL = EGW / VLEN (and to be aligned with this EMUL and not with the global LMUL associated with other vector operands/destination of the instruction).

riscv/zvk_ext_macros.h Outdated Show resolved Hide resolved
Signed-off-by: Nicolas Brunie <[email protected]>
@nibrunie
Copy link

nibrunie commented Oct 12, 2024

Implementing @xinyuwang-starfive's feedback, #1548 (comment), in 028a174

Fixing the no-overlap constraints between vd and vs2 vector register groups for .vs instruction for AES and SM4.

riscv/insns/vsm4r_vs.h Outdated Show resolved Hide resolved
Comment on lines +118 to +121
int vd_emul = P.VU.vflmul < 1.f ? 1 : (int) P.VU.vflmul; \
int aligned_vd = vd / vd_emul; \
int aligned_vs2 = vs2 / vd_emul; \
require(aligned_vd != aligned_vs2); \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be implemented by masking the log2(max(LMUL, 1)) LSBs of the register indices.
Need to check if there is not already a macro to perform this function.

Co-authored-by: Nicolas Brunie <[email protected]>
Signed-off-by: Nicolas Brunie <[email protected]>
YenHaoChen pushed a commit to YenHaoChen/riscv-isa-sim that referenced this pull request Oct 28, 2024
Notice this is a local workaround fix.
Please use riscv-software-src#1815 instead.
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