Skip to content

Commit 5330daa

Browse files
authored
[RISCV] Add support for Smepmp 1.0 (llvm#78489)
Smepmp is a supervisor extension that prevents privileged processes from accessing unprivileged program and data. Spec: https://github.com/riscv/riscv-tee/blob/main/Smepmp/Smepmp.pdf
1 parent 2521e97 commit 5330daa

File tree

8 files changed

+24
-0
lines changed

8 files changed

+24
-0
lines changed

clang/test/Preprocessor/riscv-target-features.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// CHECK-NOT: __riscv_muldiv {{.*$}}
2222
// CHECK-NOT: __riscv_smaia {{.*$}}
2323
// CHECK-NOT: __riscv_ssaia {{.*$}}
24+
// CHECK-NOT: __riscv_smepmp {{.*$}}
2425
// CHECK-NOT: __riscv_svinval {{.*$}}
2526
// CHECK-NOT: __riscv_svnapot {{.*$}}
2627
// CHECK-NOT: __riscv_svpbmt {{.*$}}
@@ -1108,6 +1109,14 @@
11081109
// RUN: -o - | FileCheck --check-prefix=CHECK-SSAIA-EXT %s
11091110
// CHECK-SSAIA-EXT: __riscv_ssaia 1000000{{$}}
11101111

1112+
// RUN: %clang --target=riscv32 \
1113+
// RUN: -march=rv32ismepmp1p0 -x c -E -dM %s \
1114+
// RUN: -o - | FileCheck --check-prefix=CHECK-SMEPMP-EXT %s
1115+
// RUN: %clang --target=riscv64 \
1116+
// RUN: -march=rv64ismepmp1p0 -x c -E -dM %s \
1117+
// RUN: -o - | FileCheck --check-prefix=CHECK-SMEPMP-EXT %s
1118+
// CHECK-SMEPMP-EXT: __riscv_smepmp 1000000{{$}}
1119+
11111120
// RUN: %clang --target=riscv32-unknown-linux-gnu \
11121121
// RUN: -march=rv32izfa -x c -E -dM %s \
11131122
// RUN: -o - | FileCheck --check-prefix=CHECK-ZFA-EXT %s

llvm/docs/RISCVUsage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ on support follow.
9292
``H`` Assembly Support
9393
``M`` Supported
9494
``Smaia`` Supported
95+
``Smepmp`` Supported
9596
``Ssaia`` Supported
9697
``Svinval`` Assembly Support
9798
``Svnapot`` Assembly Support

llvm/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ Changes to the RISC-V Backend
160160
* Support was added for the Ziccif, Ziccrse, Ziccamoa, Zicclsm, Za64rs, Za128rs
161161
and Zic64b extensions which were introduced as a part of the RISC-V Profiles
162162
specification.
163+
* The Smepmp 1.0 extension is now supported.
163164

164165
Changes to the WebAssembly Backend
165166
----------------------------------

llvm/lib/Support/RISCVISAInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static const RISCVSupportedExtension SupportedExtensions[] = {
5555
{"m", {2, 0}},
5656

5757
{"smaia", {1, 0}},
58+
{"smepmp", {1, 0}},
5859
{"ssaia", {1, 0}},
5960
{"svinval", {1, 0}},
6061
{"svnapot", {1, 0}},

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,10 @@ def FeatureStdExtSsaia
748748
"'Ssaia' (Advanced Interrupt Architecture Supervisor "
749749
"Level)", []>;
750750

751+
def FeatureStdExtSmepmp
752+
: SubtargetFeature<"smepmp", "HasStdExtSmepmp", "true",
753+
"'Smepmp' (Enhanced Physical Memory Protection)", []>;
754+
751755
def HasHalfFPLoadStoreMove
752756
: Predicate<"Subtarget->hasHalfFPLoadStoreMove()">,
753757
AssemblerPredicate<(any_of FeatureStdExtZfh, FeatureStdExtZfhmin,

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcmop %s -o - | FileCheck --check-prefix=RV32ZCMOP %s
9090
; RUN: llc -mtriple=riscv32 -mattr=+smaia %s -o - | FileCheck --check-prefixes=CHECK,RV32SMAIA %s
9191
; RUN: llc -mtriple=riscv32 -mattr=+ssaia %s -o - | FileCheck --check-prefixes=CHECK,RV32SSAIA %s
92+
; RUN: llc -mtriple=riscv32 -mattr=+smepmp %s -o - | FileCheck --check-prefixes=CHECK,RV32SMEPMP %s
9293
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZFBFMIN %s
9394
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFMIN %s
9495
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFWMA %s
@@ -190,6 +191,7 @@
190191
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcmop %s -o - | FileCheck --check-prefix=RV64ZCMOP %s
191192
; RUN: llc -mtriple=riscv64 -mattr=+smaia %s -o - | FileCheck --check-prefixes=CHECK,RV64SMAIA %s
192193
; RUN: llc -mtriple=riscv64 -mattr=+ssaia %s -o - | FileCheck --check-prefixes=CHECK,RV64SSAIA %s
194+
; RUN: llc -mtriple=riscv64 -mattr=+smepmp %s -o - | FileCheck --check-prefixes=CHECK,RV64SMEPMP %s
193195
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZFBFMIN %s
194196
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFMIN %s
195197
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFWMA %s
@@ -286,6 +288,7 @@
286288
; RV32ZCMOP: .attribute 5, "rv32i2p1_zca1p0_zcmop0p2"
287289
; RV32SMAIA: .attribute 5, "rv32i2p1_smaia1p0"
288290
; RV32SSAIA: .attribute 5, "rv32i2p1_ssaia1p0"
291+
; RV32SMEPMP: .attribute 5, "rv32i2p1_smepmp1p0"
289292
; RV32ZFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0"
290293
; RV32ZVFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0"
291294
; RV32ZVFBFWMA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
@@ -386,6 +389,7 @@
386389
; RV64ZCMOP: .attribute 5, "rv64i2p1_zca1p0_zcmop0p2"
387390
; RV64SMAIA: .attribute 5, "rv64i2p1_smaia1p0"
388391
; RV64SSAIA: .attribute 5, "rv64i2p1_ssaia1p0"
392+
; RV64SMEPMP: .attribute 5, "rv64i2p1_smepmp1p0"
389393
; RV64ZFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0"
390394
; RV64ZVFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0"
391395
; RV64ZVFBFWMA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"

llvm/test/MC/RISCV/attribute-arch.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@
294294
.attribute arch, "rv32i_ssaia1p0"
295295
# CHECK: attribute 5, "rv32i2p1_ssaia1p0"
296296

297+
.attribute arch, "rv32i_smepmp1p0"
298+
# CHECK: attribute 5, "rv32i2p1_smepmp1p0"
299+
297300
.attribute arch, "rv32i_zfbfmin1p0"
298301
# CHECK: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0"
299302

llvm/unittests/Support/RISCVISAInfoTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ R"(All available -march extensions for RISC-V
760760
zhinx 1.0
761761
zhinxmin 1.0
762762
smaia 1.0
763+
smepmp 1.0
763764
ssaia 1.0
764765
svinval 1.0
765766
svnapot 1.0

0 commit comments

Comments
 (0)