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

gentag and invalid tags #9

Open
janhoogerbrugge-nxp opened this issue Dec 11, 2024 · 3 comments
Open

gentag and invalid tags #9

janhoogerbrugge-nxp opened this issue Dec 11, 2024 · 3 comments

Comments

@janhoogerbrugge-nxp
Copy link

Should we prevent that the random number tag generation generates the invalid tag for pointer_tag_width/mc_tag_width = 4?

@deepak0414
Copy link
Collaborator

Yes I'll add that as clarification note in spec so that its clear to implementers.

@janhoogerbrugge-nxp
Copy link
Author

janhoogerbrugge-nxp commented Jan 6, 2025

I have a few remarks / questions related to this (based on the document from a few days ago):

  • I see the notation rs1[b63:pointer_tag_width]. Shouldn't this be rs1[b63:b63-pointer_tag_width+1]?
  • For gentag I see read that rd is cleared before the tag bits are set. I don't see this for the description of addtag. Should that also start with clearing rd?
  • You might what to mention that in the function epilog t0 is used to restore the tag in the stack pointer.
  • Gentag should generate a tag such that rd xor rs1 is not the invalid tag
  • Addtag should generate a tag such that rd + rs1 is not the invalid tag
  • Is it possible that addtag also copies the address so that the addi that follows in the example is not needed?

@deepak0414
Copy link
Collaborator

deepak0414 commented Jan 7, 2025

I see the notation rs1[b63:pointer_tag_width]. Shouldn't this be rs1[b63:b63-pointer_tag_width+1]?

I was using bit_position:length notation. But I see that riscv priv and unpriv spec use absolute position notation. Will fix it.

For gentag I see read that rd is cleared before the tag bits are set. I don't see this for the description of addtag. Should that also start with clearing rd?

Yeah good catch. Will fix it.

You might what to mention that in the function epilog t0 is used to restore the tag in the stack pointer.

Yeah one more good point. But instead of t0, I think example should use something like frame pointer (s0).
t0 is temp according to calling convention and will be lost across function calls. Using s0 should be more
useful. Will add that.

Gentag should generate a tag such that rd xor rs1 is not the invalid tag

Yes, will fix it.

Addtag should generate a tag such that rd + rs1 is not the invalid tag

Yes, will fix it.

Is it possible that addtag also copies the address so that the addi that follows in the example is not needed?

No this is not possible for the same reason we had to split tag generation gentag + xor
If memory tagging is disabled, then rd will be zero. Thus NULL pointer will get generated for stack objects.

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

No branches or pull requests

2 participants