Skip to content

Commit 59dfdc1

Browse files
committed
UNRATIFIED RISC-V: Add Pointer masking extensions and their TENTATIVE CSRs
[DO NOT MERGE] Until Pointer masking extensions are frozen/ratified and the final version number is determined, this patch should not be merged upstream. This commit uses unratified version 0.5(.4) as in the latest PDF documentation (instead of possible 1.0 after ratification). This commit adds pointer masking extensions ('Zjpm', 'Smjpm', 'Ssjpm' and 'Smjpmbare16') and its CSRs based on the latest commit of the RISC-V Pointer Masking draft. <riscv/riscv-j-extension@4839cc5> Specification Notes: 'Smjpm', 'Ssjpm' and 'Zjpm' do not depend each other, allowing selection of per-privilege pointer masking implementation. Although pointer masking is only available (can be enabled) on RV64, pointer masking CSRs are accessible from RV32. That is why those extensions are *not* RV64 only. ***Draft Note*** Because CSR addresses are not fixed yet, this commit uses tentative addresses (a part of custom CSR space). bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets) Add implications to 'Zicsr'. (riscv_supported_std_z_ext): Add 'Zjpm' extension to valid 'Z' extension list. (riscv_supported_std_s_ext): Add 'Smjpm', 'Ssjpm' and 'Smjpmbare16' extensions to valid 'S' extension list. gas/ChangeLog: * config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for pointer masking extensions. (riscv_csr_address): Add handling for new CSR classes. * testsuite/gas/riscv/csr-dw-regnums.d: Add new CSRs. * testsuite/gas/riscv/csr-dw-regnums.s: Likewise. * testsuite/gas/riscv/csr.s: Add new CSRs. * testsuite/gas/riscv/csr-version-1p9p1.d: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.l: Likewise. * testsuite/gas/riscv/csr-version-1p10.d: Likewise. * testsuite/gas/riscv/csr-version-1p10.l: Likewise. * testsuite/gas/riscv/csr-version-1p11.d: Likewise. * testsuite/gas/riscv/csr-version-1p11.l: Likewise. * testsuite/gas/riscv/csr-version-1p12.d: Likewise. * testsuite/gas/riscv/csr-version-1p12.l: Likewise. include/ChangeLog: * opcode/riscv-opc.h (CSR_MPM, CSR_VSPM, CSR_SPM, CSR_UPM): New CSR macros.
1 parent 6085bf5 commit 59dfdc1

File tree

14 files changed

+160
-0
lines changed

14 files changed

+160
-0
lines changed

bfd/elfxx-riscv.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,11 +1182,14 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
11821182
{"zcf", "zca", check_implicit_always},
11831183
{"zcd", "zca", check_implicit_always},
11841184
{"zcb", "zca", check_implicit_always},
1185+
{"zjpm", "zicsr", check_implicit_always},
11851186
{"smaia", "ssaia", check_implicit_always},
1187+
{"smjpm", "zicsr", check_implicit_always},
11861188
{"smstateen", "ssstateen", check_implicit_always},
11871189
{"smepmp", "zicsr", check_implicit_always},
11881190
{"ssaia", "zicsr", check_implicit_always},
11891191
{"sscofpmf", "zicsr", check_implicit_always},
1192+
{"ssjpm", "zicsr", check_implicit_always},
11901193
{"ssstateen", "zicsr", check_implicit_always},
11911194
{"sstc", "zicsr", check_implicit_always},
11921195
{NULL, NULL, NULL}
@@ -1282,6 +1285,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
12821285
{"zksed", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12831286
{"zksh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12841287
{"zkt", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1288+
{"zjpm", ISA_SPEC_CLASS_DRAFT, 0, 5, 0 },
12851289
{"zve32x", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12861290
{"zve32f", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12871291
{"zve32d", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -1329,9 +1333,12 @@ static struct riscv_supported_ext riscv_supported_std_s_ext[] =
13291333
{
13301334
{"smaia", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13311335
{"smepmp", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1336+
{"smjpm", ISA_SPEC_CLASS_DRAFT, 0, 5, 0 },
1337+
{"smjpmbare16", ISA_SPEC_CLASS_DRAFT, 0, 5, 0 },
13321338
{"smstateen", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13331339
{"ssaia", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13341340
{"sscofpmf", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1341+
{"ssjpm", ISA_SPEC_CLASS_DRAFT, 0, 5, 0 },
13351342
{"ssstateen", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13361343
{"sstc", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13371344
{"svinval", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },

gas/config/tc-riscv.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,22 @@ enum riscv_csr_class
6868
CSR_CLASS_I_32, /* rv32 only */
6969
CSR_CLASS_F, /* f-ext only */
7070
CSR_CLASS_ZKR, /* zkr only */
71+
CSR_CLASS_ZJPM, /* zjpm only */
7172
CSR_CLASS_V, /* rvv only */
7273
CSR_CLASS_DEBUG, /* debug CSR */
7374
CSR_CLASS_H, /* hypervisor */
7475
CSR_CLASS_H_32, /* hypervisor, rv32 only */
7576
CSR_CLASS_SMAIA, /* Smaia */
7677
CSR_CLASS_SMAIA_32, /* Smaia, rv32 only */
78+
CSR_CLASS_SMJPM, /* Smjpm */
7779
CSR_CLASS_SMSTATEEN, /* Smstateen only */
7880
CSR_CLASS_SMSTATEEN_32, /* Smstateen RV32 only */
7981
CSR_CLASS_SSAIA, /* Ssaia */
8082
CSR_CLASS_SSAIA_AND_H, /* Ssaia with H */
8183
CSR_CLASS_SSAIA_32, /* Ssaia, rv32 only */
8284
CSR_CLASS_SSAIA_AND_H_32, /* Ssaia with H, rv32 only */
85+
CSR_CLASS_SSJPM, /* Ssjpm */
86+
CSR_CLASS_SSJPM_AND_H, /* Ssjpm with H */
8387
CSR_CLASS_SSSTATEEN, /* S[ms]stateen only */
8488
CSR_CLASS_SSSTATEEN_AND_H, /* S[ms]stateen only (with H) */
8589
CSR_CLASS_SSSTATEEN_AND_H_32, /* S[ms]stateen RV32 only (with H) */
@@ -1043,6 +1047,9 @@ riscv_csr_address (const char *csr_name,
10431047
case CSR_CLASS_ZKR:
10441048
extension = "zkr";
10451049
break;
1050+
case CSR_CLASS_ZJPM:
1051+
extension = "zjpm";
1052+
break;
10461053
case CSR_CLASS_V:
10471054
extension = "zve32x";
10481055
break;
@@ -1052,6 +1059,9 @@ riscv_csr_address (const char *csr_name,
10521059
case CSR_CLASS_SMAIA:
10531060
extension = "smaia";
10541061
break;
1062+
case CSR_CLASS_SMJPM:
1063+
extension = "smjpm";
1064+
break;
10551065
case CSR_CLASS_SMSTATEEN_32:
10561066
is_rv32_only = true;
10571067
/* Fall through. */
@@ -1068,6 +1078,12 @@ riscv_csr_address (const char *csr_name,
10681078
|| csr_class == CSR_CLASS_SSAIA_AND_H_32);
10691079
extension = "ssaia";
10701080
break;
1081+
case CSR_CLASS_SSJPM_AND_H:
1082+
is_h_required = true;
1083+
/* Fall through. */
1084+
case CSR_CLASS_SSJPM:
1085+
extension = "ssjpm";
1086+
break;
10711087
case CSR_CLASS_SSSTATEEN_AND_H_32:
10721088
is_rv32_only = true;
10731089
/* Fall through. */

gas/testsuite/gas/riscv/csr-dw-regnums.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,4 +456,8 @@ Contents of the .* section:
456456
DW_CFA_offset_extended_sf: r7200 \(vl\) at cfa\+12416
457457
DW_CFA_offset_extended_sf: r7201 \(vtype\) at cfa\+12420
458458
DW_CFA_offset_extended_sf: r7202 \(vlenb\) at cfa\+12424
459+
DW_CFA_offset_extended_sf: r6080 \(mpm\) at cfa\+7936
460+
DW_CFA_offset_extended_sf: r5568 \(spm\) at cfa\+5888
461+
DW_CFA_offset_extended_sf: r6336 \(upm\) at cfa\+8960
462+
DW_CFA_offset_extended_sf: r5824 \(vspm\) at cfa\+6912
459463
#...

gas/testsuite/gas/riscv/csr-dw-regnums.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,5 +459,10 @@ _start:
459459
.cfi_offset vl, 12416
460460
.cfi_offset vtype, 12420
461461
.cfi_offset vlenb, 12424
462+
# Zjpm extension (both privileged and unprivileged)
463+
.cfi_offset mpm, 7936
464+
.cfi_offset spm, 5888
465+
.cfi_offset upm, 8960
466+
.cfi_offset vspm, 6912
462467
nop
463468
.cfi_endproc

gas/testsuite/gas/riscv/csr-version-1p10.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,11 @@ Disassembly of section .text:
887887
[ ]+[0-9a-f]+:[ ]+c2159073[ ]+csrw[ ]+vtype,a1
888888
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
889889
[ ]+[0-9a-f]+:[ ]+c2259073[ ]+csrw[ ]+vlenb,a1
890+
[ ]+[0-9a-f]+:[ ]+7c002573[ ]+csrr[ ]+a0,mpm
891+
[ ]+[0-9a-f]+:[ ]+7c059073[ ]+csrw[ ]+mpm,a1
892+
[ ]+[0-9a-f]+:[ ]+5c002573[ ]+csrr[ ]+a0,spm
893+
[ ]+[0-9a-f]+:[ ]+5c059073[ ]+csrw[ ]+spm,a1
894+
[ ]+[0-9a-f]+:[ ]+8c002573[ ]+csrr[ ]+a0,upm
895+
[ ]+[0-9a-f]+:[ ]+8c059073[ ]+csrw[ ]+upm,a1
896+
[ ]+[0-9a-f]+:[ ]+6c002573[ ]+csrr[ ]+a0,vspm
897+
[ ]+[0-9a-f]+:[ ]+6c059073[ ]+csrw[ ]+vspm,a1

gas/testsuite/gas/riscv/csr-version-1p10.l

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,3 +1589,23 @@
15891589
.*Info: macro .*
15901590
.*Warning: read-only CSR is written `csrw vlenb,a1'
15911591
.*Info: macro .*
1592+
.*Warning: invalid CSR `mpm', needs `smjpm' extension
1593+
.*Info: macro .*
1594+
.*Warning: invalid CSR `mpm', needs `smjpm' extension
1595+
.*Info: macro .*
1596+
.*Warning: invalid CSR `spm', needs `ssjpm' extension
1597+
.*Info: macro .*
1598+
.*Warning: invalid CSR `spm', needs `ssjpm' extension
1599+
.*Info: macro .*
1600+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1601+
.*Info: macro .*
1602+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1603+
.*Info: macro .*
1604+
.*Warning: invalid CSR `vspm', needs `h' extension
1605+
.*Info: macro .*
1606+
.*Warning: invalid CSR `vspm', needs `ssjpm' extension
1607+
.*Info: macro .*
1608+
.*Warning: invalid CSR `vspm', needs `h' extension
1609+
.*Info: macro .*
1610+
.*Warning: invalid CSR `vspm', needs `ssjpm' extension
1611+
.*Info: macro .*

gas/testsuite/gas/riscv/csr-version-1p11.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,11 @@ Disassembly of section .text:
887887
[ ]+[0-9a-f]+:[ ]+c2159073[ ]+csrw[ ]+vtype,a1
888888
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
889889
[ ]+[0-9a-f]+:[ ]+c2259073[ ]+csrw[ ]+vlenb,a1
890+
[ ]+[0-9a-f]+:[ ]+7c002573[ ]+csrr[ ]+a0,mpm
891+
[ ]+[0-9a-f]+:[ ]+7c059073[ ]+csrw[ ]+mpm,a1
892+
[ ]+[0-9a-f]+:[ ]+5c002573[ ]+csrr[ ]+a0,spm
893+
[ ]+[0-9a-f]+:[ ]+5c059073[ ]+csrw[ ]+spm,a1
894+
[ ]+[0-9a-f]+:[ ]+8c002573[ ]+csrr[ ]+a0,upm
895+
[ ]+[0-9a-f]+:[ ]+8c059073[ ]+csrw[ ]+upm,a1
896+
[ ]+[0-9a-f]+:[ ]+6c002573[ ]+csrr[ ]+a0,vspm
897+
[ ]+[0-9a-f]+:[ ]+6c059073[ ]+csrw[ ]+vspm,a1

gas/testsuite/gas/riscv/csr-version-1p11.l

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,3 +1585,23 @@
15851585
.*Info: macro .*
15861586
.*Warning: read-only CSR is written `csrw vlenb,a1'
15871587
.*Info: macro .*
1588+
.*Warning: invalid CSR `mpm', needs `smjpm' extension
1589+
.*Info: macro .*
1590+
.*Warning: invalid CSR `mpm', needs `smjpm' extension
1591+
.*Info: macro .*
1592+
.*Warning: invalid CSR `spm', needs `ssjpm' extension
1593+
.*Info: macro .*
1594+
.*Warning: invalid CSR `spm', needs `ssjpm' extension
1595+
.*Info: macro .*
1596+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1597+
.*Info: macro .*
1598+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1599+
.*Info: macro .*
1600+
.*Warning: invalid CSR `vspm', needs `h' extension
1601+
.*Info: macro .*
1602+
.*Warning: invalid CSR `vspm', needs `ssjpm' extension
1603+
.*Info: macro .*
1604+
.*Warning: invalid CSR `vspm', needs `h' extension
1605+
.*Info: macro .*
1606+
.*Warning: invalid CSR `vspm', needs `ssjpm' extension
1607+
.*Info: macro .*

gas/testsuite/gas/riscv/csr-version-1p12.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,11 @@ Disassembly of section .text:
887887
[ ]+[0-9a-f]+:[ ]+c2159073[ ]+csrw[ ]+vtype,a1
888888
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
889889
[ ]+[0-9a-f]+:[ ]+c2259073[ ]+csrw[ ]+vlenb,a1
890+
[ ]+[0-9a-f]+:[ ]+7c002573[ ]+csrr[ ]+a0,mpm
891+
[ ]+[0-9a-f]+:[ ]+7c059073[ ]+csrw[ ]+mpm,a1
892+
[ ]+[0-9a-f]+:[ ]+5c002573[ ]+csrr[ ]+a0,spm
893+
[ ]+[0-9a-f]+:[ ]+5c059073[ ]+csrw[ ]+spm,a1
894+
[ ]+[0-9a-f]+:[ ]+8c002573[ ]+csrr[ ]+a0,upm
895+
[ ]+[0-9a-f]+:[ ]+8c059073[ ]+csrw[ ]+upm,a1
896+
[ ]+[0-9a-f]+:[ ]+6c002573[ ]+csrr[ ]+a0,vspm
897+
[ ]+[0-9a-f]+:[ ]+6c059073[ ]+csrw[ ]+vspm,a1

gas/testsuite/gas/riscv/csr-version-1p12.l

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,3 +1349,23 @@
13491349
.*Info: macro .*
13501350
.*Warning: read-only CSR is written `csrw vlenb,a1'
13511351
.*Info: macro .*
1352+
.*Warning: invalid CSR `mpm', needs `smjpm' extension
1353+
.*Info: macro .*
1354+
.*Warning: invalid CSR `mpm', needs `smjpm' extension
1355+
.*Info: macro .*
1356+
.*Warning: invalid CSR `spm', needs `ssjpm' extension
1357+
.*Info: macro .*
1358+
.*Warning: invalid CSR `spm', needs `ssjpm' extension
1359+
.*Info: macro .*
1360+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1361+
.*Info: macro .*
1362+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1363+
.*Info: macro .*
1364+
.*Warning: invalid CSR `vspm', needs `h' extension
1365+
.*Info: macro .*
1366+
.*Warning: invalid CSR `vspm', needs `ssjpm' extension
1367+
.*Info: macro .*
1368+
.*Warning: invalid CSR `vspm', needs `h' extension
1369+
.*Info: macro .*
1370+
.*Warning: invalid CSR `vspm', needs `ssjpm' extension
1371+
.*Info: macro .*

0 commit comments

Comments
 (0)