Skip to content

Commit 7f200ac

Browse files
committed
Xqccmp extension: fix IDL code for all pop/push instructions for RV64 and add stack range CSRs
Signed-off-by: Albert Yosher <[email protected]>
1 parent b5679a8 commit 7f200ac

File tree

8 files changed

+61
-5
lines changed

8 files changed

+61
-5
lines changed
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ versions:
4242
company: Qualcomm Technologies, Inc.
4343
4444
changes:
45+
- Fix all push and pop instructions description for RV64 (IDL code fix)
4546
- 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
4648
- Add list of supported custom exceptions - stack alignment check and stack range check
4749
- Add stack exception checks in all push/pop instructions
4850
requires:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ operation(): |
5252
5353
XReg size = xlen();
5454
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
55-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
55+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
5656
XReg virtual_address_sp = X[2];
5757
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
5858
XReg virtual_address_base = virtual_address_new_sp - size;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ operation(): |
5252
5353
XReg size = xlen();
5454
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
55-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
55+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
5656
XReg virtual_address_sp = X[2];
5757
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
5858
XReg virtual_address_base = virtual_address_new_sp - size;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ operation(): |
5252
5353
XReg size = xlen();
5454
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
55-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
55+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
5656
XReg virtual_address_sp = X[2];
5757
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
5858
XReg virtual_address_base = virtual_address_new_sp - size;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ operation(): |
5454
5555
XReg size = xlen();
5656
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
57-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
57+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
5858
XReg virtual_address_sp = X[2];
5959
XReg virtual_address_new_sp = virtual_address_sp - stack_aligned_adj - spimm;
6060
XReg virtual_address_base = virtual_address_sp - size;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ operation(): |
5454
5555
XReg size = xlen();
5656
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
57-
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
57+
XReg stack_aligned_adj = (nreg * size + 15) & ~0xF;
5858
XReg virtual_address_sp = X[2];
5959
XReg virtual_address_new_sp = virtual_address_sp - stack_aligned_adj - spimm;
6060
XReg virtual_address_base = virtual_address_sp - size;

0 commit comments

Comments
 (0)