Skip to content

Commit 4575bbe

Browse files
authored
Xqccmp Extension version 0.2 (#466)
* Xqccmp extension: version 0.2, fixing qc.cm.pushfp for rlist to be > 4 Signed-off-by: Albert Yosher <[email protected]> * Xqccmp extension: Add stack exceptions and stack exceptions checks to IDL code of push/pop instructions Signed-off-by: Albert Yosher <[email protected]> * Xqccmp extension: fix IDL code for all pop/push instructions for RV64 and add stack range CSRs Signed-off-by: Albert Yosher <[email protected]> * Fix regression for merge queue Signed-off-by: Albert Yosher <[email protected]> * trying to fix regression start on merge queue - take 2 Signed-off-by: Albert Yosher <[email protected]> --------- Signed-off-by: Albert Yosher <[email protected]>
1 parent 28082d3 commit 4575bbe

File tree

9 files changed

+142
-7
lines changed

9 files changed

+142
-7
lines changed

.github/workflows/regress.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Regression test
22
on:
3+
push:
4+
branches:
5+
- main
6+
merge_group: # this is a new line
7+
types: [checks_requested] # this is a new line
38
pull_request:
49
branches:
510
- main
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$schema: csr_schema.json#
2+
kind: csr
3+
name: qc.mstkbottomaddr
4+
long_name: Machine Stack Bottom Limit
5+
address: 0x7c5
6+
base: 32
7+
priv_mode: M
8+
length: MXLEN
9+
description: |
10+
Stack bottom limit register. If the stack pointer (sp == x2) lesser then its value - SpOutOfRange exception occurs
11+
definedBy:
12+
anyOf:
13+
- Xqccmp
14+
- Xqci
15+
- Xqciint
16+
fields:
17+
STKADDR:
18+
location: 31-4
19+
description: |
20+
If the stack pointer (sp == x2) lesser then STKADDR*16 - SpOutOfRange exception occurs
21+
type: RW
22+
reset_value: 0
23+
RESERVED:
24+
location: 3-0
25+
description: Reserved and must be zero
26+
type: RO
27+
reset_value: 0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$schema: csr_schema.json#
2+
kind: csr
3+
name: qc.mstktopaddr
4+
long_name: Machine Stack Top Limit
5+
address: 0x7c4
6+
base: 32
7+
priv_mode: M
8+
length: MXLEN
9+
description: |
10+
Stack top limit register. If the stack pointer (sp == x2) greater then its value - SpOutOfRange exception occurs
11+
definedBy:
12+
anyOf:
13+
- Xqccmp
14+
- Xqci
15+
- Xqciint
16+
fields:
17+
STKADDR:
18+
location: 31-4
19+
description: |
20+
If the stack pointer (sp == x2) greater then STKADDR*16 - SpOutOfRange exception occurs
21+
type: RW
22+
reset_value: 0
23+
RESERVED:
24+
location: 3-0
25+
description: Reserved and must be zero
26+
type: RO
27+
reset_value: 0

cfgs/qc_iu/arch_overlay/ext/Xqccmp.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,38 @@ versions:
2525
requires:
2626
name: Zca
2727
version: ">= 1.0.0"
28+
- version: "0.2.0"
29+
state: development
30+
ratification_date: null
31+
contributors:
32+
- name: Albert Yosher
33+
company: Qualcomm Technologies, Inc.
34+
35+
- name: Derek Hower
36+
company: Qualcomm Technologies, Inc.
37+
38+
- name: Ana Pazos
39+
company: Qualcomm Technologies, Inc.
40+
41+
- name: James Ball
42+
company: Qualcomm Technologies, Inc.
43+
44+
changes:
45+
- Fix all push and pop instructions description for RV64 (IDL code fix)
46+
- Fix qc.cm.pushfp instruction to avoid rlist == 4, since not saving s0 == fp but updating it, should not occur
47+
- Add CSRs qc.mstkbottomaddr and qc.mstktopaddr to support cache range checking
48+
- Add list of supported custom exceptions - stack alignment check and stack range check
49+
- Add stack exception checks in all push/pop instructions
50+
requires:
51+
name: Zca
52+
version: ">= 1.0.0"
53+
exception_codes:
54+
- num: 27
55+
name: Illegal Stack Pointer
56+
var: IllegalStackPointer
57+
- num: 28
58+
name: Stack Pointer Out-Of-Range
59+
var: SpOutOfRange
2860
description: |
2961
The Xqccmp extension is a set of instructions which may be executed as a series of existing 32-bit RISC-V instructions.
3062

cfgs/qc_iu/arch_overlay/inst/Xqccmp/qc.cm.pop.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@ operation(): |
4040
if (implemented?(ExtensionName::Xqccmp) && (CSR[misa].C == 1'b0)) {
4141
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
4242
}
43+
if (X[2] < CSR[qc.mstkbottomaddr]) {
44+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
45+
}
46+
if (X[2] > CSR[qc.mstktopaddr]) {
47+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
48+
}
49+
if (X[2] & 0xf != 0) {
50+
raise(ExceptionCode::IllegalStackPointer, mode(), $encoding);
51+
}
4352
4453
XReg size = xlen();
4554
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
46-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
55+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
4756
XReg virtual_address_sp = X[2];
4857
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
4958
XReg virtual_address_base = virtual_address_new_sp - size;

cfgs/qc_iu/arch_overlay/inst/Xqccmp/qc.cm.popret.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@ operation(): |
4040
if (implemented?(ExtensionName::Xqccmp) && (CSR[misa].C == 1'b0)) {
4141
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
4242
}
43+
if (X[2] < CSR[qc.mstkbottomaddr]) {
44+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
45+
}
46+
if (X[2] > CSR[qc.mstktopaddr]) {
47+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
48+
}
49+
if (X[2] & 0xf != 0) {
50+
raise(ExceptionCode::IllegalStackPointer, mode(), $encoding);
51+
}
4352
4453
XReg size = xlen();
4554
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
46-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
55+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
4756
XReg virtual_address_sp = X[2];
4857
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
4958
XReg virtual_address_base = virtual_address_new_sp - size;

cfgs/qc_iu/arch_overlay/inst/Xqccmp/qc.cm.popretz.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,23 @@ operation(): |
4040
if (implemented?(ExtensionName::Xqccmp) && (CSR[misa].C == 1'b0)) {
4141
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
4242
}
43+
if (X[2] < CSR[qc.mstkbottomaddr]) {
44+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
45+
}
46+
if (X[2] > CSR[qc.mstktopaddr]) {
47+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
48+
}
49+
if (X[2] & 0xf != 0) {
50+
raise(ExceptionCode::IllegalStackPointer, mode(), $encoding);
51+
}
4352
4453
XReg size = xlen();
4554
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
46-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
55+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
4756
XReg virtual_address_sp = X[2];
4857
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
4958
XReg virtual_address_base = virtual_address_new_sp - size;
5059
51-
5260
X[ 1] = read_memory_xlen(virtual_address_base - 0*size, $encoding);
5361
if (nreg > 1) {
5462
X[ 8] = read_memory_xlen(virtual_address_base - 1*size, $encoding);

cfgs/qc_iu/arch_overlay/inst/Xqccmp/qc.cm.push.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,19 @@ operation(): |
4242
if (implemented?(ExtensionName::Xqccmp) && (CSR[misa].C == 1'b0)) {
4343
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
4444
}
45+
if (X[2] < CSR[qc.mstkbottomaddr]) {
46+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
47+
}
48+
if (X[2] > CSR[qc.mstktopaddr]) {
49+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
50+
}
51+
if (X[2] & 0xf != 0) {
52+
raise(ExceptionCode::IllegalStackPointer, mode(), $encoding);
53+
}
4554
4655
XReg size = xlen();
4756
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
48-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
57+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
4958
XReg virtual_address_sp = X[2];
5059
XReg virtual_address_new_sp = virtual_address_sp - stack_aligned_adj - spimm;
5160
XReg virtual_address_base = virtual_address_sp - size;

cfgs/qc_iu/arch_overlay/inst/Xqccmp/qc.cm.pushfp.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ encoding:
3030
variables:
3131
- name: rlist
3232
location: 7-4
33-
not: [0, 1, 2, 3]
33+
not: [0, 1, 2, 3, 4]
3434
- name: spimm
3535
location: 3-2
3636
access:
@@ -42,10 +42,19 @@ operation(): |
4242
if (implemented?(ExtensionName::Xqccmp) && (CSR[misa].C == 1'b0)) {
4343
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
4444
}
45+
if (X[2] < CSR[qc.mstkbottomaddr]) {
46+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
47+
}
48+
if (X[2] > CSR[qc.mstktopaddr]) {
49+
raise(ExceptionCode::SpOutOfRange, mode(), $encoding);
50+
}
51+
if (X[2] & 0xf != 0) {
52+
raise(ExceptionCode::IllegalStackPointer, mode(), $encoding);
53+
}
4554
4655
XReg size = xlen();
4756
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
48-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
57+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
4958
XReg virtual_address_sp = X[2];
5059
XReg virtual_address_new_sp = virtual_address_sp - stack_aligned_adj - spimm;
5160
XReg virtual_address_base = virtual_address_sp - size;

0 commit comments

Comments
 (0)