Skip to content

src/mte_tag: HLV/HSV/MPRV support for opt-out based on PTE.MTAG for c…#82

Merged
deepak0414 merged 1 commit intoriscv:mainfrom
deepak0414:always_tagchk_hlv_hsv
Dec 17, 2025
Merged

src/mte_tag: HLV/HSV/MPRV support for opt-out based on PTE.MTAG for c…#82
deepak0414 merged 1 commit intoriscv:mainfrom
deepak0414:always_tagchk_hlv_hsv

Conversation

@deepak0414
Copy link
Collaborator

…odepage

Guest might have set PTE.MTAG for code page and thus wouldn't be expecting tag checks even if data pointer had PTE.MTAG set. On an exit to hypervisor, hypervisor emulating this load/store must do emulation similarly and thus HLVX* is updated to collect to MTAG bit in hstatus. MTAG_I and use that during HLV/HSV.

Similar mechanisms when in M-mode and MPRV=1.

…odepage

Guest might have set PTE.MTAG for code page and thus wouldn't be
expecting tag checks even if data pointer had PTE.MTAG set. On an exit
to hypervisor, hypervisor emulating this load/store must do emulation
similarly and thus HLVX* is updated to collect to MTAG bit in hstatus.
MTAG_I and use that during HLV/HSV.

Similar mechanisms when in M-mode and MPRV=1.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
@deepak0414
Copy link
Collaborator Author

@radimkrcmar @SiFiveHolland

I re-worked the treatment of MTAG from higher priv to lower priv. Please take a look.
Following are changes from earlier

  • MTAG_I is only reported on traps when *tinst is non-zero
  • MTAG_I is not collected/harvested
  • If MTAG_I is clear and first-stage paging rules say "check tags", then tags will be checked.

If guest code page had PTE.MTAG=1, that's fine. HLV/HSV or ld/st with MPRV=1 should still do tagchecks
PTE.MTAG=1 is just an optimization for guest to avoid tag checks. In this case, its already trapped to
higher priv for emulation and it is expected that if PTE.MTAG=1 for data page for guest, its tag must have
been set.

Let me know if this looks ok.

Copy link

@SiFiveHolland SiFiveHolland left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me

@deepak0414 deepak0414 merged commit edab7f8 into riscv:main Dec 17, 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