From d74f5af555b9a7ec05c05466ea6f77b92477adaa Mon Sep 17 00:00:00 2001 From: "Emanuele Parisi emanuele.parisi@unibo.it" Date: Tue, 16 Apr 2024 15:47:04 +0200 Subject: [PATCH] Add Zicfiss and Zicfilp CSR definitions --- core/include/riscv_pkg.sv | 40 +++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/core/include/riscv_pkg.sv b/core/include/riscv_pkg.sv index 3e3f70a3ee..089d076677 100644 --- a/core/include/riscv_pkg.sv +++ b/core/include/riscv_pkg.sv @@ -83,9 +83,11 @@ package riscv; typedef struct packed { logic sd; // signal dirty state - read-only - logic [62:34] wpri6; // writes preserved reads ignored + logic [62:34] wpri7; // writes preserved reads ignored xlen_e uxl; // variable user mode xlen - hardwired to zero - logic [11:0] wpri5; // writes preserved reads ignored + logic [7:0] wpri6; // writes preserved reads ignored + logic spelp; // hold previous ELP in S-mode + logic [2:0] wpri5; // writes preserved reads ignored logic mxr; // make executable readable logic sum; // permit supervisor user memory access logic wpri4; // writes preserved reads ignored @@ -123,14 +125,17 @@ package riscv; typedef struct packed { logic sd; // signal dirty state - read-only - logic [62:40] wpri4; // writes preserved reads ignored + logic [62:42] wpri5; // writes preserved reads ignored + logic mpelp; // hold previous ELP in M-mode + logic wpri4; // writes preserved reads ignored logic mpv; // machine previous virtualization mode logic gva; // variable set when trap writes to stval logic mbe; // endianness memory accesses made from M-mode logic sbe; // endianness memory accesses made from S-mode xlen_e sxl; // variable supervisor mode xlen - hardwired to zero xlen_e uxl; // variable user mode xlen - hardwired to zero - logic [8:0] wpri3; // writes preserved reads ignored + logic [7:0] wpri3; // writes preserved reads ignored + logic spelp; // hold previous ELP in S-mode logic tsr; // trap sret logic tw; // time wait logic tvm; // trap virtual memory @@ -152,6 +157,17 @@ package riscv; logic wpri0; // writes preserved reads ignored } mstatus_rv_t; + typedef struct packed { + logic [63:11] wpri1; // writes preserved reads ignored + logic mlpe; // enable Zicfilp in M-mode + logic sseed; // not implemented - requires Zkr extension + logic useed; // not implemented - requires Zkr extension + logic [7:3] wpri0; // writes preserved reads ignored + logic rlb; // not implemented - requires Smepmp extension + logic mmwp; // not implemented - requires Smepmp extension + logic mml; // not implemented - requires Smepmp extension + } mseccfg_t; + typedef struct packed { logic stce; // not implemented - requires Sctc extension logic pbmte; // not implemented - requires Svpbmt extension @@ -159,7 +175,9 @@ package riscv; logic cbze; // not implemented - requires Zicboz extension logic cbcfe; // not implemented - requires Zicbom extension logic [1:0] cbie; // not implemented - requires Zicbom extension - logic [2:0] wpri0; // writes preserved reads ignored + logic sse; // enable Zicfiss in less priviledged modes + logic lpe; // enable Zicfilp in less priviledged modes + logic wpri0; // writes preserved reads ignored logic fiom; // fence of I/O implies memory } envcfg_rv_t; @@ -581,6 +599,8 @@ package riscv; CSR_MCYCLEH = 12'hB80, CSR_MINSTRET = 12'hB02, CSR_MINSTRETH = 12'hB82, + CSR_MSECCFG = 12'h747, + CSR_MSECCFGH = 12'h757, //Performance Counters CSR_MHPM_COUNTER_3 = 12'hB03, CSR_MHPM_COUNTER_4 = 12'hB04, @@ -658,6 +678,8 @@ package riscv; CSR_DPC = 12'h7b1, CSR_DSCRATCH0 = 12'h7b2, // optional CSR_DSCRATCH1 = 12'h7b3, // optional + // Control-Flow Integrity - Zicfiss + CSR_SSP = 12'h011, // Counters and Timers (User Mode - R/O Shadows) CSR_CYCLE = 12'hC00, CSR_CYCLEH = 12'hC80, @@ -736,6 +758,7 @@ package riscv; localparam logic [63:0] SSTATUS_XS = 'h00018000; localparam logic [63:0] SSTATUS_SUM = 'h00040000; localparam logic [63:0] SSTATUS_MXR = 'h00080000; + localparam logic [63:0] SSTATUS_SPELP = 'h00800000; localparam logic [63:0] SSTATUS_UPIE = 'h00000010; localparam logic [63:0] SSTATUS_UXL = 64'h0000000300000000; localparam logic [63:0] SSTATUS_SD = {IS_XLEN64, 31'h00000000, ~IS_XLEN64, 31'h00000000}; @@ -767,14 +790,18 @@ package riscv; localparam logic [63:0] MSTATUS_MPRV = 'h00020000; localparam logic [63:0] MSTATUS_SUM = 'h00040000; localparam logic [63:0] MSTATUS_MXR = 'h00080000; + localparam logic [63:0] MSTATUS_SPELP = 'h00800000; localparam logic [63:0] MSTATUS_TVM = 'h00100000; localparam logic [63:0] MSTATUS_TW = 'h00200000; localparam logic [63:0] MSTATUS_TSR = 'h00400000; localparam logic [63:0] MSTATUS_UXL = {30'h0000000, IS_XLEN64, IS_XLEN64, 32'h00000000}; localparam logic [63:0] MSTATUS_SXL = {28'h0000000, IS_XLEN64, IS_XLEN64, 34'h00000000}; + localparam logic [63:0] MSTATUS_MPELP = 'h0000020000000000; localparam logic [63:0] MSTATUS_SD = {IS_XLEN64, 31'h00000000, ~IS_XLEN64, 31'h00000000}; localparam logic [63:0] MENVCFG_FIOM = 'h00000001; + localparam logic [63:0] MENVCFG_LPE = 'h00000004; + localparam logic [63:0] MENVCFG_SSE = 'h00000008; localparam logic [63:0] MENVCFG_CBIE = 'h00000030; localparam logic [63:0] MENVCFG_CBFE = 'h00000040; localparam logic [63:0] MENVCFG_CBZE = 'h00000080; @@ -847,7 +874,8 @@ package riscv; // ----- typedef struct packed { logic [31:28] xdebugver; - logic [27:18] zero2; + logic [27:19] zero2; + logic pelp; logic ebreakvs; logic ebreakvu; logic ebreakm;