Skip to content

Commit

Permalink
Merge pull request #7 from francislaus/prefetch_insts
Browse files Browse the repository at this point in the history
Removed that prefetch instructions can throw exceptions
  • Loading branch information
andresag01 authored Jan 23, 2024
2 parents 66b77c4 + 5699b91 commit bfabecf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/insns/prefetch.i.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ effective address is the sum of the base address specified in `cs1` and the
sign-extended offset encoded in imm[11:0], where imm[4:0] equals 0b00000, is
likely to be accessed by an instruction fetch in the near future. The encoding
is only valid if imm[4:0]=0. The authorising capability for this operation is
`cs1`.
`cs1`. This instruction does not throw any exceptions. However, following
<<CHERI_SPEC>>, this instruction does not perform a prefetch if it is
not authorized by `cs1`. This instruction does not perform a memory access
if one or more of the following conditions of `cs1` are met:
* The tag is not set
* The sealed bit is set
* No bytes of the cache line requested is in bounds
* The <<x_perm>> is not set

Legacy Mode Description::
A PREFETCH.I instruction indicates to hardware that the cache block whose
Expand All @@ -46,8 +53,6 @@ likely to be accessed by an instruction fetch in the near future. The encoding
is only valid if imm[4:0]=0. The authorising capability for this operation is
<<ddc>>.

:prefetch_i:
include::cbo_exceptions.adoc[]

Prerequisites for PREFETCH.I.CAP::
Zicbop, {cheri_base_ext_name}
Expand Down
11 changes: 8 additions & 3 deletions src/insns/prefetch.r.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ effective address is the sum of the base address specified in `cs1` and the
sign-extended offset encoded in imm[11:0], where imm[4:0] equals 0b00000, is
likely to be accessed by a data read (i.e. load) in the near future. The
encoding is only valid if imm[4:0]=0. The authorising capability for this
operation is `cs1`.
operation is `cs1`. This instruction does not throw any exceptions. However,
in following <<CHERI_SPEC>>, this instruction does not perform a prefetch
if it is not authorized by `cs1`. This instruction does not perform a memory
access if one or more of the following conditions of `cs1` are met:
* The tag is not set
* The sealed bit is set
* No bytes of the cache line requested is in bounds
* The <<r_perm>> is not set

Legacy Mode Description::
A PREFETCH.R instruction indicates to hardware that the cache block whose
Expand All @@ -46,8 +53,6 @@ likely to be accessed by a data read (i.e. load) in the near future. The
encoding is only valid if imm[4:0]=0. The authorising capability for this
operation is <<ddc>>.

:prefetch_r:
include::cbo_exceptions.adoc[]

Prerequisites for PREFETCH.R.CAP::
Zicbop, {cheri_base_ext_name}
Expand Down
13 changes: 10 additions & 3 deletions src/insns/prefetch.w.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ effective address is the sum of the base address specified in `cs1` and the
sign-extended offset encoded in imm[11:0], where imm[4:0] equals 0b00000, is
likely to be accessed by a data write (i.e. store) in the near future. The
encoding is only valid if imm[4:0]=0. The authorising capability for this
operation is `cs1`.
operation is `cs1`. This instruction does not throw any exceptions. However,
following <<CHERI_SPEC>>, this instruction does not perform a prefetch if it
is not authorized by `cs1`. This instruction does not perform a memory access
if one or more of the following conditions of `cs1` are met:
* The tag is not set
* The sealed bit is set
* No bytes of the cache line requested is in bounds
* The <<w_perm>> is not set

Legacy Mode Description::
A PREFETCH.W instruction indicates to hardware that the cache block whose
Expand All @@ -47,10 +54,10 @@ encoding is only valid if imm[4:0]=0. The authorising capability for this
operation is <<ddc>>.

Prerequisites for PREFETCH.W.CAP::
{cheri_base_ext_name}
Zicbop, {cheri_base_ext_name}

Prerequisites for PREFETCH.W::
{cheri_legacy_ext_name}
Zicbop, {cheri_legacy_ext_name}

Operation::
[source,sail]
Expand Down
7 changes: 7 additions & 0 deletions src/riscv-integration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,13 @@ NOTE: <<CBO.ZERO.CAP>>, <<CBO.ZERO>> issues as a cache line wide store

NOTE: ^1^Other CBOs (<<CBO.FLUSH.CAP>>, <<CBO.FLUSH>>, <<CBO.CLEAN.CAP>>, <<CBO.CLEAN>>, <<CBO.INVAL.CAP>>, <<CBO.INVAL>>) require at least one byte of the access to be in `auth_cap` bounds

[#CHERI_SPEC,reftext="CHERI Exceptions and speculative execution"]
=== CHERI Exceptions and speculative execution

CHERI adds architectural guarantees that can prove to be microarchitecturally useful.
Speculative-execution attacks can -- among other factors -- rely on instructions that fail CHERI permission checks not to take effect.
When implementing any of the extensions proposed here, microarchitects need to carefully consider the interaction of late-exception raising and side-channel attacks.

=== Physical Memory Attributes (PMA)

Typically, the entire memory space need not support tagged data. Therefore, it
Expand Down

0 comments on commit bfabecf

Please sign in to comment.