Skip to content

Conversation

deepak0414
Copy link
Collaborator

No description provided.

src/mte_tag.adoc Outdated
starting at virtual address `rs1`. If any of the loaded `mc_tag` value(s)
mismatches with the `pointer_tag` specified in `rs1`, then software check
exception is raised with tval = 4. If memory tagging is enabled in the
execution environment then `checktag` instruction always makes the check
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an interesting consideration. Can you give your rational for ignoring the PTE.MTAG of the data?

Copy link
Collaborator Author

@deepak0414 deepak0414 Aug 13, 2025

Choose a reason for hiding this comment

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

Multiple reasons

  • Technically all that is needed is whether this pointer is valid, there is no need to touch the virtual address. So one less page walk. one less tlb lookup. Thus ignoring PTE.MTAG is a good optimization here for CPU.

  • Compiler put it there because it actually wanted to know pointer validity. So what's the point of honoring MTAG bit here.

Let me know if you don't want it to do check for tags if ITLB.MTAG=1 or PTE.MTAG=1 for codepage.
That's the instruction-side of things then. We can specify a rule here that checktag reverts to zimop behavior
if fetched from a codepage with PTE.MTAG=1 or ITLB.MTAG=1

I am assuming that's where you were heading with this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can specify a rule here that checktag reverts to zimop behavior if fetched from a codepage with PTE.MTAG=1 or ITLB.MTAG=1

No, that would defeat the whole point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok then we can specify that checktag always checks for the tag irrespective of setting PTE.MTAG on data or code page.
Sounds okay?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Take a look now.

Copy link
Collaborator Author

@deepak0414 deepak0414 Aug 15, 2025

Choose a reason for hiding this comment

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

Did another minor update.

@fmayer
looks okay to you?

@deepak0414 deepak0414 force-pushed the checktag branch 2 times, most recently from fbc14d4 to 5d35235 Compare August 15, 2025 23:12
src/mte_tag.adoc Outdated
extension, `checktag rs1, #chunk_count` which extracts `pointer_tag` from `rs1`
and performs load tag operation for memory chunks (count = `#chunk_count`)
starting at virtual address `rs1`. If any of the loaded `mc_tag` value(s)
mismatches with the `pointer_tag` specified in `rs1`, then software check
Copy link
Collaborator

Choose a reason for hiding this comment

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

Improve wording. first it says

rforms load tag operation for memory chunks (count = #chunk_count)
starting at virtual address rs1. If any of the loaded mc_tag value(s)
mismatches with the pointer_tag specified in rs1, then software check
exception is raised

but then it clarifies that it doesn't if memtag is off.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Take a look at wordings now.

@deepak0414 deepak0414 merged commit 9ed1802 into riscv:main Aug 26, 2025
2 checks passed
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