Skip to content

Commit e41f634

Browse files
committed
src/mte_tag: tighten the first stage page table conditions for MTAG
Quite often loader or other piece of code might read code pages. If a code page is set as MTAG=1, then those loads (to code page) will look for tags. This change clarifies in specification that loads/stores to pages marked as executable always generate unchecked memory accesses. Setting MTAG for XWR=111 and XWR=010 was disallowed. Instead of raising page fault, raise access-fault exception to signify fatality. Signed-off-by: Deepak Gupta <debug@rivosinc.com>
1 parent a208744 commit e41f634

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/mte_tag.adoc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,22 +352,30 @@ synchronously.
352352
set in page table entry and memory tagging is enabled from *envcfg CSR,
353353
following rules apply:
354354

355-
1. tag checks are enforced on regular load/store to such page (tagged data
356-
page). See <<TAG_CHECKS>> for further checks. Underlying tagged page must
357-
be an idempotent memory else tag look up for referenced virtual memory will
358-
result in load access-fault exception.
355+
1. load/store to a tagged data page generate checked accesses. A tagged data
356+
page has `MTAG` bit set and `RWX` permission bits can be `100` or `110`.
357+
See <<TAG_CHECKS>> for further checks. Underlying tagged page must be an
358+
idempotent memory else tag look up for referenced virtual memory results in
359+
load access-fault exception.
359360

360-
2. fetched instructions from a code page with `MTAG=1` (tag-exempt code page)
361+
2. load/store to a page marked as executable in first stage page table always
362+
generate unchecked memory accesses.
363+
364+
3. fetched instructions from a code page with `MTAG=1` (tag-exempt code page)
361365
generate unchecked load and store. This doesn't have any impact on behavior
362366
of `settag`, `gentag` and `addtag` instructions.
363367

364-
3. If both rule 2 and rule 1 are applying, rule 2 takes precedence.
368+
4. If both rule 3 and rule 1 are applying, rule 3 takes precedence.
365369

366-
4. An instruction crossing a page boundary with differing `MTAG` value, the
370+
5. An instruction crossing a page boundary with differing `MTAG` value, the
367371
instruction behaves as if it was fetched from a page with MTAG=0.
368372

373+
6. load/store crossing page boundary with differing `MTAG` value assumes
374+
MTAG=1 for both pages.
375+
369376
`MTAG` bit in page table entry remains a reserved bit if `XWR == 111` or
370-
`XWR == 010` and if set, will raise a page fault of original access type.
377+
`XWR == 010` and if set, will raise a page access-fault of original access
378+
type.
371379

372380
If memory tagging is not enabled for the execution environment via *envcfg CSR,
373381
then `MTAG` bit in page table entry remains a reserved and if set will raise a

0 commit comments

Comments
 (0)