Skip to content

Commit 8f9c7f7

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. If if memory tagging is not enabled for execution environment then `MTAG` bit is ignored. This allows for setting up tagging and enabling/disabling on sampling basis (without asking OS to clear to the bit when tagging is disabled) Signed-off-by: Deepak Gupta <debug@rivosinc.com>
1 parent a208744 commit 8f9c7f7

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/mte_tag.adoc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,26 +352,27 @@ 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.
359358

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

364-
3. If both rule 2 and rule 1 are applying, rule 2 takes precedence.
366+
4. If both rule 3 and rule 1 are apply, rule 3 shall take precedence.
365367

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

369-
`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.
371+
6. load/store crossing page boundary with differing `MTAG` value assumes
372+
MTAG=1 for both pages.
371373

372374
If memory tagging is not enabled for the execution environment via *envcfg CSR,
373-
then `MTAG` bit in page table entry remains a reserved and if set will raise a
374-
page fault of original access type.
375+
then `MTAG` bit in page table entry is ignored by hart.
375376

376377
[NOTE]
377378
====

0 commit comments

Comments
 (0)