1 | From: Alistair Francis <alistair.francis@wdc.com> | 1 | The following changes since commit e4f3ede95ce813d5705c65e1c0e1c80c70739ebb: |
---|---|---|---|
2 | 2 | ||
3 | The following changes since commit c5fbdd60cf1fb52f01bdfe342b6fa65d5343e1b1: | 3 | Merge remote-tracking branch 'remotes/kraxel/tags/usb-20210505-pull-request' into staging (2021-05-10 19:55:06 +0100) |
4 | |||
5 | Merge tag 'qemu-sparc-20211121' of git://github.com/mcayland/qemu into staging (2021-11-21 14:12:25 +0100) | ||
6 | 4 | ||
7 | are available in the Git repository at: | 5 | are available in the Git repository at: |
8 | 6 | ||
9 | git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20211122 | 7 | git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20210511 |
10 | 8 | ||
11 | for you to fetch changes up to 526e7443027c71fe7b04c29df529e1f9f425f9e3: | 9 | for you to fetch changes up to c30a0757f094c107e491820e3d35224eb68859c7: |
12 | 10 | ||
13 | hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset (2021-11-22 10:46:22 +1000) | 11 | target/riscv: Fix the RV64H decode comment (2021-05-11 20:02:07 +1000) |
14 | 12 | ||
15 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
16 | Seventh RISC-V PR for QEMU 6.2 | 14 | A large collection of RISC-V fixes, improvements and features |
17 | 15 | ||
18 | - Deprecate IF_NONE for SiFive OTP | 16 | - Clenaup some left over v1.9 code |
19 | - Don't reset SiFive OTP content | 17 | - Documentation improvements |
18 | - Support for the shakti_c machine | ||
19 | - Internal cleanup of the CSR accesses | ||
20 | - Updates to the OpenTitan platform | ||
21 | - Support for the virtio-vga | ||
22 | - Fix for the saturate subtract in vector extensions | ||
23 | - Experimental support for the ePMP spec | ||
24 | - A range of other internal code cleanups and bug fixes | ||
20 | 25 | ||
21 | ---------------------------------------------------------------- | 26 | ---------------------------------------------------------------- |
22 | Philippe Mathieu-Daudé (1): | 27 | Alexander Wagner (1): |
23 | hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset | 28 | hw/riscv: Fix OT IBEX reset vector |
24 | 29 | ||
25 | Thomas Huth (1): | 30 | Alistair Francis (22): |
26 | hw/misc/sifive_u_otp: Use IF_PFLASH for the OTP device instead of IF_NONE | 31 | target/riscv: Convert the RISC-V exceptions to an enum |
32 | target/riscv: Use the RISCVException enum for CSR predicates | ||
33 | target/riscv: Fix 32-bit HS mode access permissions | ||
34 | target/riscv: Use the RISCVException enum for CSR operations | ||
35 | target/riscv: Use RISCVException enum for CSR access | ||
36 | MAINTAINERS: Update the RISC-V CPU Maintainers | ||
37 | hw/opentitan: Update the interrupt layout | ||
38 | hw/riscv: Enable VIRTIO_VGA for RISC-V virt machine | ||
39 | target/riscv: Fix the PMP is locked check when using TOR | ||
40 | target/riscv: Add the ePMP feature | ||
41 | target/riscv/pmp: Remove outdated comment | ||
42 | target/riscv: Add ePMP support for the Ibex CPU | ||
43 | target/riscv: Remove the hardcoded RVXLEN macro | ||
44 | target/riscv: Remove the hardcoded SSTATUS_SD macro | ||
45 | target/riscv: Remove the hardcoded HGATP_MODE macro | ||
46 | target/riscv: Remove the hardcoded MSTATUS_SD macro | ||
47 | target/riscv: Remove the hardcoded SATP_MODE macro | ||
48 | target/riscv: Remove the unused HSTATUS_WPRI macro | ||
49 | target/riscv: Remove an unused CASE_OP_32_64 macro | ||
50 | target/riscv: Consolidate RV32/64 32-bit instructions | ||
51 | target/riscv: Consolidate RV32/64 16-bit instructions | ||
52 | target/riscv: Fix the RV64H decode comment | ||
27 | 53 | ||
28 | docs/about/deprecated.rst | 6 ++++++ | 54 | Atish Patra (1): |
29 | hw/misc/sifive_u_otp.c | 22 +++++++++++++--------- | 55 | target/riscv: Remove privilege v1.9 specific CSR related code |
30 | 2 files changed, 19 insertions(+), 9 deletions(-) | ||
31 | 56 | ||
57 | Axel Heider (1): | ||
58 | docs/system/generic-loader.rst: Fix style | ||
59 | |||
60 | Bin Meng (1): | ||
61 | hw/riscv: sifive_e: Add 'const' to sifive_e_memmap[] | ||
62 | |||
63 | Dylan Jhong (1): | ||
64 | target/riscv: Align the data type of reset vector address | ||
65 | |||
66 | Emmanuel Blot (2): | ||
67 | target/riscv: fix exception index on instruction access fault | ||
68 | target/riscv: fix a typo with interrupt names | ||
69 | |||
70 | Frank Chang (2): | ||
71 | target/riscv: fix vrgather macro index variable type bug | ||
72 | fpu/softfloat: set invalid excp flag for RISC-V muladd instructions | ||
73 | |||
74 | Hou Weiying (4): | ||
75 | target/riscv: Define ePMP mseccfg | ||
76 | target/riscv: Add ePMP CSR access functions | ||
77 | target/riscv: Implementation of enhanced PMP (ePMP) | ||
78 | target/riscv: Add a config option for ePMP | ||
79 | |||
80 | Jade Fink (1): | ||
81 | riscv: don't look at SUM when accessing memory from a debugger context | ||
82 | |||
83 | LIU Zhiwei (1): | ||
84 | target/riscv: Fixup saturate subtract function | ||
85 | |||
86 | Vijai Kumar K (5): | ||
87 | target/riscv: Add Shakti C class CPU | ||
88 | riscv: Add initial support for Shakti C machine | ||
89 | hw/char: Add Shakti UART emulation | ||
90 | hw/riscv: Connect Shakti UART to Shakti platform | ||
91 | docs: Add documentation for shakti_c machine | ||
92 | |||
93 | docs/system/generic-loader.rst | 9 +- | ||
94 | docs/system/riscv/shakti-c.rst | 82 +++ | ||
95 | docs/system/target-riscv.rst | 1 + | ||
96 | default-configs/devices/riscv64-softmmu.mak | 1 + | ||
97 | include/hw/char/shakti_uart.h | 74 +++ | ||
98 | include/hw/riscv/opentitan.h | 16 +- | ||
99 | include/hw/riscv/shakti_c.h | 75 +++ | ||
100 | target/riscv/cpu.h | 42 +- | ||
101 | target/riscv/cpu_bits.h | 114 +--- | ||
102 | target/riscv/helper.h | 18 +- | ||
103 | target/riscv/pmp.h | 14 + | ||
104 | target/riscv/insn16-32.decode | 28 - | ||
105 | target/riscv/insn16-64.decode | 36 -- | ||
106 | target/riscv/insn16.decode | 30 + | ||
107 | target/riscv/insn32-64.decode | 88 --- | ||
108 | target/riscv/insn32.decode | 67 ++- | ||
109 | hw/char/shakti_uart.c | 185 +++++++ | ||
110 | hw/intc/ibex_plic.c | 20 +- | ||
111 | hw/riscv/opentitan.c | 10 +- | ||
112 | hw/riscv/shakti_c.c | 181 ++++++ | ||
113 | hw/riscv/sifive_e.c | 2 +- | ||
114 | target/riscv/cpu.c | 26 +- | ||
115 | target/riscv/cpu_helper.c | 88 ++- | ||
116 | target/riscv/csr.c | 824 +++++++++++++++++----------- | ||
117 | target/riscv/fpu_helper.c | 16 +- | ||
118 | target/riscv/gdbstub.c | 8 +- | ||
119 | target/riscv/machine.c | 8 +- | ||
120 | target/riscv/monitor.c | 22 +- | ||
121 | target/riscv/op_helper.c | 18 +- | ||
122 | target/riscv/pmp.c | 218 +++++++- | ||
123 | target/riscv/translate.c | 38 +- | ||
124 | target/riscv/vector_helper.c | 18 +- | ||
125 | fpu/softfloat-specialize.c.inc | 6 + | ||
126 | target/riscv/insn_trans/trans_rva.c.inc | 14 +- | ||
127 | target/riscv/insn_trans/trans_rvd.c.inc | 17 +- | ||
128 | target/riscv/insn_trans/trans_rvf.c.inc | 6 +- | ||
129 | target/riscv/insn_trans/trans_rvh.c.inc | 8 +- | ||
130 | target/riscv/insn_trans/trans_rvi.c.inc | 22 +- | ||
131 | target/riscv/insn_trans/trans_rvm.c.inc | 12 +- | ||
132 | target/riscv/insn_trans/trans_rvv.c.inc | 39 +- | ||
133 | MAINTAINERS | 14 +- | ||
134 | hw/char/meson.build | 1 + | ||
135 | hw/char/trace-events | 4 + | ||
136 | hw/riscv/Kconfig | 11 + | ||
137 | hw/riscv/meson.build | 1 + | ||
138 | target/riscv/meson.build | 13 +- | ||
139 | target/riscv/trace-events | 3 + | ||
140 | 47 files changed, 1759 insertions(+), 789 deletions(-) | ||
141 | create mode 100644 docs/system/riscv/shakti-c.rst | ||
142 | create mode 100644 include/hw/char/shakti_uart.h | ||
143 | create mode 100644 include/hw/riscv/shakti_c.h | ||
144 | delete mode 100644 target/riscv/insn16-32.decode | ||
145 | delete mode 100644 target/riscv/insn16-64.decode | ||
146 | delete mode 100644 target/riscv/insn32-64.decode | ||
147 | create mode 100644 hw/char/shakti_uart.c | ||
148 | create mode 100644 hw/riscv/shakti_c.c | ||
149 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Atish Patra <atish.patra@wdc.com> | |
2 | |||
3 | Qemu doesn't support RISC-V privilege specification v1.9. Remove the | ||
4 | remaining v1.9 specific references from the implementation. | ||
5 | |||
6 | Signed-off-by: Atish Patra <atish.patra@wdc.com> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-Id: <20210319194534.2082397-2-atish.patra@wdc.com> | ||
9 | [Changes by AF: | ||
10 | - Rebase on latest patches | ||
11 | - Bump the vmstate_riscv_cpu version_id and minimum_version_id | ||
12 | ] | ||
13 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | --- | ||
15 | target/riscv/cpu.h | 4 +--- | ||
16 | target/riscv/cpu_bits.h | 23 --------------------- | ||
17 | target/riscv/cpu.c | 2 +- | ||
18 | target/riscv/cpu_helper.c | 12 +++++------ | ||
19 | target/riscv/csr.c | 42 ++++++++++----------------------------- | ||
20 | target/riscv/machine.c | 8 +++----- | ||
21 | target/riscv/translate.c | 4 ++-- | ||
22 | 7 files changed, 23 insertions(+), 72 deletions(-) | ||
23 | |||
24 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/riscv/cpu.h | ||
27 | +++ b/target/riscv/cpu.h | ||
28 | @@ -XXX,XX +XXX,XX @@ struct CPURISCVState { | ||
29 | target_ulong mie; | ||
30 | target_ulong mideleg; | ||
31 | |||
32 | - target_ulong sptbr; /* until: priv-1.9.1 */ | ||
33 | target_ulong satp; /* since: priv-1.10.0 */ | ||
34 | - target_ulong sbadaddr; | ||
35 | - target_ulong mbadaddr; | ||
36 | + target_ulong stval; | ||
37 | target_ulong medeleg; | ||
38 | |||
39 | target_ulong stvec; | ||
40 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/riscv/cpu_bits.h | ||
43 | +++ b/target/riscv/cpu_bits.h | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | /* 32-bit only */ | ||
46 | #define CSR_MSTATUSH 0x310 | ||
47 | |||
48 | -/* Legacy Counter Setup (priv v1.9.1) */ | ||
49 | -/* Update to #define CSR_MCOUNTINHIBIT 0x320 for 1.11.0 */ | ||
50 | -#define CSR_MUCOUNTEREN 0x320 | ||
51 | -#define CSR_MSCOUNTEREN 0x321 | ||
52 | -#define CSR_MHCOUNTEREN 0x322 | ||
53 | - | ||
54 | /* Machine Trap Handling */ | ||
55 | #define CSR_MSCRATCH 0x340 | ||
56 | #define CSR_MEPC 0x341 | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | #define CSR_MTVAL 0x343 | ||
59 | #define CSR_MIP 0x344 | ||
60 | |||
61 | -/* Legacy Machine Trap Handling (priv v1.9.1) */ | ||
62 | -#define CSR_MBADADDR 0x343 | ||
63 | - | ||
64 | /* Supervisor Trap Setup */ | ||
65 | #define CSR_SSTATUS 0x100 | ||
66 | #define CSR_SEDELEG 0x102 | ||
67 | @@ -XXX,XX +XXX,XX @@ | ||
68 | #define CSR_STVAL 0x143 | ||
69 | #define CSR_SIP 0x144 | ||
70 | |||
71 | -/* Legacy Supervisor Trap Handling (priv v1.9.1) */ | ||
72 | -#define CSR_SBADADDR 0x143 | ||
73 | - | ||
74 | /* Supervisor Protection and Translation */ | ||
75 | #define CSR_SPTBR 0x180 | ||
76 | #define CSR_SATP 0x180 | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | #define CSR_MHPMCOUNTER30H 0xb9e | ||
79 | #define CSR_MHPMCOUNTER31H 0xb9f | ||
80 | |||
81 | -/* Legacy Machine Protection and Translation (priv v1.9.1) */ | ||
82 | -#define CSR_MBASE 0x380 | ||
83 | -#define CSR_MBOUND 0x381 | ||
84 | -#define CSR_MIBASE 0x382 | ||
85 | -#define CSR_MIBOUND 0x383 | ||
86 | -#define CSR_MDBASE 0x384 | ||
87 | -#define CSR_MDBOUND 0x385 | ||
88 | - | ||
89 | /* mstatus CSR bits */ | ||
90 | #define MSTATUS_UIE 0x00000001 | ||
91 | #define MSTATUS_SIE 0x00000002 | ||
92 | @@ -XXX,XX +XXX,XX @@ | ||
93 | #define MSTATUS_FS 0x00006000 | ||
94 | #define MSTATUS_XS 0x00018000 | ||
95 | #define MSTATUS_MPRV 0x00020000 | ||
96 | -#define MSTATUS_PUM 0x00040000 /* until: priv-1.9.1 */ | ||
97 | #define MSTATUS_SUM 0x00040000 /* since: priv-1.10 */ | ||
98 | #define MSTATUS_MXR 0x00080000 | ||
99 | -#define MSTATUS_VM 0x1F000000 /* until: priv-1.9.1 */ | ||
100 | #define MSTATUS_TVM 0x00100000 /* since: priv-1.10 */ | ||
101 | #define MSTATUS_TW 0x00200000 /* since: priv-1.10 */ | ||
102 | #define MSTATUS_TSR 0x00400000 /* since: priv-1.10 */ | ||
103 | @@ -XXX,XX +XXX,XX @@ | ||
104 | #define SSTATUS_SPP 0x00000100 | ||
105 | #define SSTATUS_FS 0x00006000 | ||
106 | #define SSTATUS_XS 0x00018000 | ||
107 | -#define SSTATUS_PUM 0x00040000 /* until: priv-1.9.1 */ | ||
108 | #define SSTATUS_SUM 0x00040000 /* since: priv-1.10 */ | ||
109 | #define SSTATUS_MXR 0x00080000 | ||
110 | |||
111 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/riscv/cpu.c | ||
114 | +++ b/target/riscv/cpu.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
116 | qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vscause ", env->vscause); | ||
117 | } | ||
118 | qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval); | ||
119 | - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->sbadaddr); | ||
120 | + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval); | ||
121 | if (riscv_has_ext(env, RVH)) { | ||
122 | qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval); | ||
123 | qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2); | ||
124 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/target/riscv/cpu_helper.c | ||
127 | +++ b/target/riscv/cpu_helper.c | ||
128 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) | ||
129 | env->vscause = env->scause; | ||
130 | env->scause = env->scause_hs; | ||
131 | |||
132 | - env->vstval = env->sbadaddr; | ||
133 | - env->sbadaddr = env->stval_hs; | ||
134 | + env->vstval = env->stval; | ||
135 | + env->stval = env->stval_hs; | ||
136 | |||
137 | env->vsatp = env->satp; | ||
138 | env->satp = env->satp_hs; | ||
139 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) | ||
140 | env->scause_hs = env->scause; | ||
141 | env->scause = env->vscause; | ||
142 | |||
143 | - env->stval_hs = env->sbadaddr; | ||
144 | - env->sbadaddr = env->vstval; | ||
145 | + env->stval_hs = env->stval; | ||
146 | + env->stval = env->vstval; | ||
147 | |||
148 | env->satp_hs = env->satp; | ||
149 | env->satp = env->vsatp; | ||
150 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs) | ||
151 | env->mstatus = s; | ||
152 | env->scause = cause | ((target_ulong)async << (TARGET_LONG_BITS - 1)); | ||
153 | env->sepc = env->pc; | ||
154 | - env->sbadaddr = tval; | ||
155 | + env->stval = tval; | ||
156 | env->htval = htval; | ||
157 | env->pc = (env->stvec >> 2 << 2) + | ||
158 | ((async && (env->stvec & 3) == 1) ? cause * 4 : 0); | ||
159 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs) | ||
160 | env->mstatus = s; | ||
161 | env->mcause = cause | ~(((target_ulong)-1) >> async); | ||
162 | env->mepc = env->pc; | ||
163 | - env->mbadaddr = tval; | ||
164 | + env->mtval = tval; | ||
165 | env->mtval2 = mtval2; | ||
166 | env->pc = (env->mtvec >> 2 << 2) + | ||
167 | ((async && (env->mtvec & 3) == 1) ? cause * 4 : 0); | ||
168 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
169 | index XXXXXXX..XXXXXXX 100644 | ||
170 | --- a/target/riscv/csr.c | ||
171 | +++ b/target/riscv/csr.c | ||
172 | @@ -XXX,XX +XXX,XX @@ static int write_mcounteren(CPURISCVState *env, int csrno, target_ulong val) | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | -/* This regiser is replaced with CSR_MCOUNTINHIBIT in 1.11.0 */ | ||
177 | -static int read_mscounteren(CPURISCVState *env, int csrno, target_ulong *val) | ||
178 | -{ | ||
179 | - if (env->priv_ver < PRIV_VERSION_1_11_0) { | ||
180 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
181 | - } | ||
182 | - *val = env->mcounteren; | ||
183 | - return 0; | ||
184 | -} | ||
185 | - | ||
186 | -/* This regiser is replaced with CSR_MCOUNTINHIBIT in 1.11.0 */ | ||
187 | -static int write_mscounteren(CPURISCVState *env, int csrno, target_ulong val) | ||
188 | -{ | ||
189 | - if (env->priv_ver < PRIV_VERSION_1_11_0) { | ||
190 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
191 | - } | ||
192 | - env->mcounteren = val; | ||
193 | - return 0; | ||
194 | -} | ||
195 | - | ||
196 | /* Machine Trap Handling */ | ||
197 | static int read_mscratch(CPURISCVState *env, int csrno, target_ulong *val) | ||
198 | { | ||
199 | @@ -XXX,XX +XXX,XX @@ static int write_mcause(CPURISCVState *env, int csrno, target_ulong val) | ||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | -static int read_mbadaddr(CPURISCVState *env, int csrno, target_ulong *val) | ||
204 | +static int read_mtval(CPURISCVState *env, int csrno, target_ulong *val) | ||
205 | { | ||
206 | - *val = env->mbadaddr; | ||
207 | + *val = env->mtval; | ||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | -static int write_mbadaddr(CPURISCVState *env, int csrno, target_ulong val) | ||
212 | +static int write_mtval(CPURISCVState *env, int csrno, target_ulong val) | ||
213 | { | ||
214 | - env->mbadaddr = val; | ||
215 | + env->mtval = val; | ||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | @@ -XXX,XX +XXX,XX @@ static int write_scause(CPURISCVState *env, int csrno, target_ulong val) | ||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | -static int read_sbadaddr(CPURISCVState *env, int csrno, target_ulong *val) | ||
224 | +static int read_stval(CPURISCVState *env, int csrno, target_ulong *val) | ||
225 | { | ||
226 | - *val = env->sbadaddr; | ||
227 | + *val = env->stval; | ||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | -static int write_sbadaddr(CPURISCVState *env, int csrno, target_ulong val) | ||
232 | +static int write_stval(CPURISCVState *env, int csrno, target_ulong val) | ||
233 | { | ||
234 | - env->sbadaddr = val; | ||
235 | + env->stval = val; | ||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | @@ -XXX,XX +XXX,XX @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { | ||
240 | |||
241 | [CSR_MSTATUSH] = { "mstatush", any32, read_mstatush, write_mstatush }, | ||
242 | |||
243 | - [CSR_MSCOUNTEREN] = { "msounteren", any, read_mscounteren, write_mscounteren }, | ||
244 | - | ||
245 | /* Machine Trap Handling */ | ||
246 | [CSR_MSCRATCH] = { "mscratch", any, read_mscratch, write_mscratch }, | ||
247 | [CSR_MEPC] = { "mepc", any, read_mepc, write_mepc }, | ||
248 | [CSR_MCAUSE] = { "mcause", any, read_mcause, write_mcause }, | ||
249 | - [CSR_MBADADDR] = { "mbadaddr", any, read_mbadaddr, write_mbadaddr }, | ||
250 | + [CSR_MTVAL] = { "mtval", any, read_mtval, write_mtval }, | ||
251 | [CSR_MIP] = { "mip", any, NULL, NULL, rmw_mip }, | ||
252 | |||
253 | /* Supervisor Trap Setup */ | ||
254 | @@ -XXX,XX +XXX,XX @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { | ||
255 | [CSR_SSCRATCH] = { "sscratch", smode, read_sscratch, write_sscratch }, | ||
256 | [CSR_SEPC] = { "sepc", smode, read_sepc, write_sepc }, | ||
257 | [CSR_SCAUSE] = { "scause", smode, read_scause, write_scause }, | ||
258 | - [CSR_SBADADDR] = { "sbadaddr", smode, read_sbadaddr, write_sbadaddr }, | ||
259 | + [CSR_STVAL] = { "stval", smode, read_stval, write_stval }, | ||
260 | [CSR_SIP] = { "sip", smode, NULL, NULL, rmw_sip }, | ||
261 | |||
262 | /* Supervisor Protection and Translation */ | ||
263 | diff --git a/target/riscv/machine.c b/target/riscv/machine.c | ||
264 | index XXXXXXX..XXXXXXX 100644 | ||
265 | --- a/target/riscv/machine.c | ||
266 | +++ b/target/riscv/machine.c | ||
267 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_hyper = { | ||
268 | |||
269 | const VMStateDescription vmstate_riscv_cpu = { | ||
270 | .name = "cpu", | ||
271 | - .version_id = 1, | ||
272 | - .minimum_version_id = 1, | ||
273 | + .version_id = 2, | ||
274 | + .minimum_version_id = 2, | ||
275 | .fields = (VMStateField[]) { | ||
276 | VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), | ||
277 | VMSTATE_UINT64_ARRAY(env.fpr, RISCVCPU, 32), | ||
278 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_riscv_cpu = { | ||
279 | VMSTATE_UINT32(env.miclaim, RISCVCPU), | ||
280 | VMSTATE_UINTTL(env.mie, RISCVCPU), | ||
281 | VMSTATE_UINTTL(env.mideleg, RISCVCPU), | ||
282 | - VMSTATE_UINTTL(env.sptbr, RISCVCPU), | ||
283 | VMSTATE_UINTTL(env.satp, RISCVCPU), | ||
284 | - VMSTATE_UINTTL(env.sbadaddr, RISCVCPU), | ||
285 | - VMSTATE_UINTTL(env.mbadaddr, RISCVCPU), | ||
286 | + VMSTATE_UINTTL(env.stval, RISCVCPU), | ||
287 | VMSTATE_UINTTL(env.medeleg, RISCVCPU), | ||
288 | VMSTATE_UINTTL(env.stvec, RISCVCPU), | ||
289 | VMSTATE_UINTTL(env.sepc, RISCVCPU), | ||
290 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | ||
291 | index XXXXXXX..XXXXXXX 100644 | ||
292 | --- a/target/riscv/translate.c | ||
293 | +++ b/target/riscv/translate.c | ||
294 | @@ -XXX,XX +XXX,XX @@ static void generate_exception(DisasContext *ctx, int excp) | ||
295 | ctx->base.is_jmp = DISAS_NORETURN; | ||
296 | } | ||
297 | |||
298 | -static void generate_exception_mbadaddr(DisasContext *ctx, int excp) | ||
299 | +static void generate_exception_mtval(DisasContext *ctx, int excp) | ||
300 | { | ||
301 | tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); | ||
302 | tcg_gen_st_tl(cpu_pc, cpu_env, offsetof(CPURISCVState, badaddr)); | ||
303 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_illegal(DisasContext *ctx) | ||
304 | |||
305 | static void gen_exception_inst_addr_mis(DisasContext *ctx) | ||
306 | { | ||
307 | - generate_exception_mbadaddr(ctx, RISCV_EXCP_INST_ADDR_MIS); | ||
308 | + generate_exception_mtval(ctx, RISCV_EXCP_INST_ADDR_MIS); | ||
309 | } | ||
310 | |||
311 | static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest) | ||
312 | -- | ||
313 | 2.31.1 | ||
314 | |||
315 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Axel Heider <axelheider@gmx.de> | ||
1 | 2 | ||
3 | Fix style to have a proper description of the parameter 'force-raw'. | ||
4 | |||
5 | Signed-off-by: Axel Heider <axelheider@gmx.de> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Message-id: a7e50a64-1c7c-2d41-96d3-d8a417a659ac@gmx.de | ||
8 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | --- | ||
10 | docs/system/generic-loader.rst | 9 ++++++--- | ||
11 | 1 file changed, 6 insertions(+), 3 deletions(-) | ||
12 | |||
13 | diff --git a/docs/system/generic-loader.rst b/docs/system/generic-loader.rst | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/docs/system/generic-loader.rst | ||
16 | +++ b/docs/system/generic-loader.rst | ||
17 | @@ -XXX,XX +XXX,XX @@ shown below: | ||
18 | specified in the executable format header. This option should only | ||
19 | be used for the boot image. This will also cause the image to be | ||
20 | written to the specified CPU's address space. If not specified, the | ||
21 | - default is CPU 0. <force-raw> - Setting force-raw=on forces the file | ||
22 | - to be treated as a raw image. This can be used to load supported | ||
23 | - executable formats as if they were raw. | ||
24 | + default is CPU 0. | ||
25 | + | ||
26 | +``<force-raw>`` | ||
27 | + Setting 'force-raw=on' forces the file to be treated as a raw image. | ||
28 | + This can be used to load supported executable formats as if they | ||
29 | + were raw. | ||
30 | |||
31 | All values are parsed using the standard QemuOpts parsing. This allows the user | ||
32 | to specify any values in any format supported. By default the values | ||
33 | -- | ||
34 | 2.31.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Dylan Jhong <dylan@andestech.com> | ||
1 | 2 | ||
3 | Use target_ulong to instead of uint64_t on reset vector address | ||
4 | to adapt on both 32/64 machine. | ||
5 | |||
6 | Signed-off-by: Dylan Jhong <dylan@andestech.com> | ||
7 | Signed-off-by: Ruinland ChuanTzu Tsai <ruinland@andestech.com> | ||
8 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20210329034801.22667-1-dylan@andestech.com | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | --- | ||
13 | target/riscv/cpu.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/riscv/cpu.c | ||
19 | +++ b/target/riscv/cpu.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void set_feature(CPURISCVState *env, int feature) | ||
21 | env->features |= (1ULL << feature); | ||
22 | } | ||
23 | |||
24 | -static void set_resetvec(CPURISCVState *env, int resetvec) | ||
25 | +static void set_resetvec(CPURISCVState *env, target_ulong resetvec) | ||
26 | { | ||
27 | #ifndef CONFIG_USER_ONLY | ||
28 | env->resetvec = resetvec; | ||
29 | -- | ||
30 | 2.31.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bin Meng <bmeng.cn@gmail.com> | ||
1 | 2 | ||
3 | This was accidentally dropped before. Add it back. | ||
4 | |||
5 | Fixes: 732612856a8 ("hw/riscv: Drop 'struct MemmapEntry'") | ||
6 | Reported-by: Emmanuel Blot <eblot.ml@gmail.com> | ||
7 | Signed-off-by: Bin Meng <bmeng.cn@gmail.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20210331103612.654261-1-bmeng.cn@gmail.com | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | --- | ||
13 | hw/riscv/sifive_e.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/riscv/sifive_e.c | ||
19 | +++ b/hw/riscv/sifive_e.c | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "sysemu/arch_init.h" | ||
22 | #include "sysemu/sysemu.h" | ||
23 | |||
24 | -static MemMapEntry sifive_e_memmap[] = { | ||
25 | +static const MemMapEntry sifive_e_memmap[] = { | ||
26 | [SIFIVE_E_DEV_DEBUG] = { 0x0, 0x1000 }, | ||
27 | [SIFIVE_E_DEV_MROM] = { 0x1000, 0x2000 }, | ||
28 | [SIFIVE_E_DEV_OTP] = { 0x20000, 0x2000 }, | ||
29 | -- | ||
30 | 2.31.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Vijai Kumar K <vijai@behindbytes.com> | ||
1 | 2 | ||
3 | C-Class is a member of the SHAKTI family of processors from IIT-M. | ||
4 | |||
5 | It is an extremely configurable and commercial-grade 5-stage in-order | ||
6 | core supporting the standard RV64GCSUN ISA extensions. | ||
7 | |||
8 | Signed-off-by: Vijai Kumar K <vijai@behindbytes.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20210401181457.73039-2-vijai@behindbytes.com | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | --- | ||
13 | target/riscv/cpu.h | 1 + | ||
14 | target/riscv/cpu.c | 1 + | ||
15 | 2 files changed, 2 insertions(+) | ||
16 | |||
17 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/riscv/cpu.h | ||
20 | +++ b/target/riscv/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | #define TYPE_RISCV_CPU_BASE32 RISCV_CPU_TYPE_NAME("rv32") | ||
23 | #define TYPE_RISCV_CPU_BASE64 RISCV_CPU_TYPE_NAME("rv64") | ||
24 | #define TYPE_RISCV_CPU_IBEX RISCV_CPU_TYPE_NAME("lowrisc-ibex") | ||
25 | +#define TYPE_RISCV_CPU_SHAKTI_C RISCV_CPU_TYPE_NAME("shakti-c") | ||
26 | #define TYPE_RISCV_CPU_SIFIVE_E31 RISCV_CPU_TYPE_NAME("sifive-e31") | ||
27 | #define TYPE_RISCV_CPU_SIFIVE_E34 RISCV_CPU_TYPE_NAME("sifive-e34") | ||
28 | #define TYPE_RISCV_CPU_SIFIVE_E51 RISCV_CPU_TYPE_NAME("sifive-e51") | ||
29 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/riscv/cpu.c | ||
32 | +++ b/target/riscv/cpu.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo riscv_cpu_type_infos[] = { | ||
34 | DEFINE_CPU(TYPE_RISCV_CPU_BASE64, rv64_base_cpu_init), | ||
35 | DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rv64_sifive_e_cpu_init), | ||
36 | DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rv64_sifive_u_cpu_init), | ||
37 | + DEFINE_CPU(TYPE_RISCV_CPU_SHAKTI_C, rv64_sifive_u_cpu_init), | ||
38 | #endif | ||
39 | }; | ||
40 | |||
41 | -- | ||
42 | 2.31.1 | ||
43 | |||
44 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Vijai Kumar K <vijai@behindbytes.com> | |
2 | |||
3 | Add support for emulating Shakti reference platform based on C-class | ||
4 | running on arty-100T board. | ||
5 | |||
6 | https://gitlab.com/shaktiproject/cores/shakti-soc/-/blob/master/README.rst | ||
7 | |||
8 | Signed-off-by: Vijai Kumar K <vijai@behindbytes.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20210401181457.73039-3-vijai@behindbytes.com | ||
11 | [Changes by AF: | ||
12 | - Check for mstate->firmware before loading it | ||
13 | ] | ||
14 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
15 | --- | ||
16 | default-configs/devices/riscv64-softmmu.mak | 1 + | ||
17 | include/hw/riscv/shakti_c.h | 73 +++++++++ | ||
18 | hw/riscv/shakti_c.c | 173 ++++++++++++++++++++ | ||
19 | MAINTAINERS | 7 + | ||
20 | hw/riscv/Kconfig | 10 ++ | ||
21 | hw/riscv/meson.build | 1 + | ||
22 | 6 files changed, 265 insertions(+) | ||
23 | create mode 100644 include/hw/riscv/shakti_c.h | ||
24 | create mode 100644 hw/riscv/shakti_c.c | ||
25 | |||
26 | diff --git a/default-configs/devices/riscv64-softmmu.mak b/default-configs/devices/riscv64-softmmu.mak | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/default-configs/devices/riscv64-softmmu.mak | ||
29 | +++ b/default-configs/devices/riscv64-softmmu.mak | ||
30 | @@ -XXX,XX +XXX,XX @@ CONFIG_SIFIVE_E=y | ||
31 | CONFIG_SIFIVE_U=y | ||
32 | CONFIG_RISCV_VIRT=y | ||
33 | CONFIG_MICROCHIP_PFSOC=y | ||
34 | +CONFIG_SHAKTI_C=y | ||
35 | diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h | ||
36 | new file mode 100644 | ||
37 | index XXXXXXX..XXXXXXX | ||
38 | --- /dev/null | ||
39 | +++ b/include/hw/riscv/shakti_c.h | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | +/* | ||
42 | + * Shakti C-class SoC emulation | ||
43 | + * | ||
44 | + * Copyright (c) 2021 Vijai Kumar K <vijai@behindbytes.com> | ||
45 | + * | ||
46 | + * This program is free software; you can redistribute it and/or modify it | ||
47 | + * under the terms and conditions of the GNU General Public License, | ||
48 | + * version 2 or later, as published by the Free Software Foundation. | ||
49 | + * | ||
50 | + * This program is distributed in the hope it will be useful, but WITHOUT | ||
51 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
52 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
53 | + * more details. | ||
54 | + * | ||
55 | + * You should have received a copy of the GNU General Public License along with | ||
56 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
57 | + */ | ||
58 | + | ||
59 | +#ifndef HW_SHAKTI_H | ||
60 | +#define HW_SHAKTI_H | ||
61 | + | ||
62 | +#include "hw/riscv/riscv_hart.h" | ||
63 | +#include "hw/boards.h" | ||
64 | + | ||
65 | +#define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc" | ||
66 | +#define RISCV_SHAKTI_SOC(obj) \ | ||
67 | + OBJECT_CHECK(ShaktiCSoCState, (obj), TYPE_RISCV_SHAKTI_SOC) | ||
68 | + | ||
69 | +typedef struct ShaktiCSoCState { | ||
70 | + /*< private >*/ | ||
71 | + DeviceState parent_obj; | ||
72 | + | ||
73 | + /*< public >*/ | ||
74 | + RISCVHartArrayState cpus; | ||
75 | + DeviceState *plic; | ||
76 | + MemoryRegion rom; | ||
77 | + | ||
78 | +} ShaktiCSoCState; | ||
79 | + | ||
80 | +#define TYPE_RISCV_SHAKTI_MACHINE MACHINE_TYPE_NAME("shakti_c") | ||
81 | +#define RISCV_SHAKTI_MACHINE(obj) \ | ||
82 | + OBJECT_CHECK(ShaktiCMachineState, (obj), TYPE_RISCV_SHAKTI_MACHINE) | ||
83 | +typedef struct ShaktiCMachineState { | ||
84 | + /*< private >*/ | ||
85 | + MachineState parent_obj; | ||
86 | + | ||
87 | + /*< public >*/ | ||
88 | + ShaktiCSoCState soc; | ||
89 | +} ShaktiCMachineState; | ||
90 | + | ||
91 | +enum { | ||
92 | + SHAKTI_C_ROM, | ||
93 | + SHAKTI_C_RAM, | ||
94 | + SHAKTI_C_UART, | ||
95 | + SHAKTI_C_GPIO, | ||
96 | + SHAKTI_C_PLIC, | ||
97 | + SHAKTI_C_CLINT, | ||
98 | + SHAKTI_C_I2C, | ||
99 | +}; | ||
100 | + | ||
101 | +#define SHAKTI_C_PLIC_HART_CONFIG "MS" | ||
102 | +/* Including Interrupt ID 0 (no interrupt)*/ | ||
103 | +#define SHAKTI_C_PLIC_NUM_SOURCES 28 | ||
104 | +/* Excluding Priority 0 */ | ||
105 | +#define SHAKTI_C_PLIC_NUM_PRIORITIES 2 | ||
106 | +#define SHAKTI_C_PLIC_PRIORITY_BASE 0x04 | ||
107 | +#define SHAKTI_C_PLIC_PENDING_BASE 0x1000 | ||
108 | +#define SHAKTI_C_PLIC_ENABLE_BASE 0x2000 | ||
109 | +#define SHAKTI_C_PLIC_ENABLE_STRIDE 0x80 | ||
110 | +#define SHAKTI_C_PLIC_CONTEXT_BASE 0x200000 | ||
111 | +#define SHAKTI_C_PLIC_CONTEXT_STRIDE 0x1000 | ||
112 | + | ||
113 | +#endif | ||
114 | diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c | ||
115 | new file mode 100644 | ||
116 | index XXXXXXX..XXXXXXX | ||
117 | --- /dev/null | ||
118 | +++ b/hw/riscv/shakti_c.c | ||
119 | @@ -XXX,XX +XXX,XX @@ | ||
120 | +/* | ||
121 | + * Shakti C-class SoC emulation | ||
122 | + * | ||
123 | + * Copyright (c) 2021 Vijai Kumar K <vijai@behindbytes.com> | ||
124 | + * | ||
125 | + * This program is free software; you can redistribute it and/or modify it | ||
126 | + * under the terms and conditions of the GNU General Public License, | ||
127 | + * version 2 or later, as published by the Free Software Foundation. | ||
128 | + * | ||
129 | + * This program is distributed in the hope it will be useful, but WITHOUT | ||
130 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
131 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
132 | + * more details. | ||
133 | + * | ||
134 | + * You should have received a copy of the GNU General Public License along with | ||
135 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
136 | + */ | ||
137 | + | ||
138 | +#include "qemu/osdep.h" | ||
139 | +#include "hw/boards.h" | ||
140 | +#include "hw/riscv/shakti_c.h" | ||
141 | +#include "qapi/error.h" | ||
142 | +#include "hw/intc/sifive_plic.h" | ||
143 | +#include "hw/intc/sifive_clint.h" | ||
144 | +#include "sysemu/sysemu.h" | ||
145 | +#include "hw/qdev-properties.h" | ||
146 | +#include "exec/address-spaces.h" | ||
147 | +#include "hw/riscv/boot.h" | ||
148 | + | ||
149 | + | ||
150 | +static const struct MemmapEntry { | ||
151 | + hwaddr base; | ||
152 | + hwaddr size; | ||
153 | +} shakti_c_memmap[] = { | ||
154 | + [SHAKTI_C_ROM] = { 0x00001000, 0x2000 }, | ||
155 | + [SHAKTI_C_RAM] = { 0x80000000, 0x0 }, | ||
156 | + [SHAKTI_C_UART] = { 0x00011300, 0x00040 }, | ||
157 | + [SHAKTI_C_GPIO] = { 0x020d0000, 0x00100 }, | ||
158 | + [SHAKTI_C_PLIC] = { 0x0c000000, 0x20000 }, | ||
159 | + [SHAKTI_C_CLINT] = { 0x02000000, 0xc0000 }, | ||
160 | + [SHAKTI_C_I2C] = { 0x20c00000, 0x00100 }, | ||
161 | +}; | ||
162 | + | ||
163 | +static void shakti_c_machine_state_init(MachineState *mstate) | ||
164 | +{ | ||
165 | + ShaktiCMachineState *sms = RISCV_SHAKTI_MACHINE(mstate); | ||
166 | + MemoryRegion *system_memory = get_system_memory(); | ||
167 | + MemoryRegion *main_mem = g_new(MemoryRegion, 1); | ||
168 | + | ||
169 | + /* Allow only Shakti C CPU for this platform */ | ||
170 | + if (strcmp(mstate->cpu_type, TYPE_RISCV_CPU_SHAKTI_C) != 0) { | ||
171 | + error_report("This board can only be used with Shakti C CPU"); | ||
172 | + exit(1); | ||
173 | + } | ||
174 | + | ||
175 | + /* Initialize SoC */ | ||
176 | + object_initialize_child(OBJECT(mstate), "soc", &sms->soc, | ||
177 | + TYPE_RISCV_SHAKTI_SOC); | ||
178 | + qdev_realize(DEVICE(&sms->soc), NULL, &error_abort); | ||
179 | + | ||
180 | + /* register RAM */ | ||
181 | + memory_region_init_ram(main_mem, NULL, "riscv.shakti.c.ram", | ||
182 | + mstate->ram_size, &error_fatal); | ||
183 | + memory_region_add_subregion(system_memory, | ||
184 | + shakti_c_memmap[SHAKTI_C_RAM].base, | ||
185 | + main_mem); | ||
186 | + | ||
187 | + /* ROM reset vector */ | ||
188 | + riscv_setup_rom_reset_vec(mstate, &sms->soc.cpus, | ||
189 | + shakti_c_memmap[SHAKTI_C_RAM].base, | ||
190 | + shakti_c_memmap[SHAKTI_C_ROM].base, | ||
191 | + shakti_c_memmap[SHAKTI_C_ROM].size, 0, 0, | ||
192 | + NULL); | ||
193 | + if (mstate->firmware) { | ||
194 | + riscv_load_firmware(mstate->firmware, | ||
195 | + shakti_c_memmap[SHAKTI_C_RAM].base, | ||
196 | + NULL); | ||
197 | + } | ||
198 | +} | ||
199 | + | ||
200 | +static void shakti_c_machine_instance_init(Object *obj) | ||
201 | +{ | ||
202 | +} | ||
203 | + | ||
204 | +static void shakti_c_machine_class_init(ObjectClass *klass, void *data) | ||
205 | +{ | ||
206 | + MachineClass *mc = MACHINE_CLASS(klass); | ||
207 | + mc->desc = "RISC-V Board compatible with Shakti SDK"; | ||
208 | + mc->init = shakti_c_machine_state_init; | ||
209 | + mc->default_cpu_type = TYPE_RISCV_CPU_SHAKTI_C; | ||
210 | +} | ||
211 | + | ||
212 | +static const TypeInfo shakti_c_machine_type_info = { | ||
213 | + .name = TYPE_RISCV_SHAKTI_MACHINE, | ||
214 | + .parent = TYPE_MACHINE, | ||
215 | + .class_init = shakti_c_machine_class_init, | ||
216 | + .instance_init = shakti_c_machine_instance_init, | ||
217 | + .instance_size = sizeof(ShaktiCMachineState), | ||
218 | +}; | ||
219 | + | ||
220 | +static void shakti_c_machine_type_info_register(void) | ||
221 | +{ | ||
222 | + type_register_static(&shakti_c_machine_type_info); | ||
223 | +} | ||
224 | +type_init(shakti_c_machine_type_info_register) | ||
225 | + | ||
226 | +static void shakti_c_soc_state_realize(DeviceState *dev, Error **errp) | ||
227 | +{ | ||
228 | + ShaktiCSoCState *sss = RISCV_SHAKTI_SOC(dev); | ||
229 | + MemoryRegion *system_memory = get_system_memory(); | ||
230 | + | ||
231 | + sysbus_realize(SYS_BUS_DEVICE(&sss->cpus), &error_abort); | ||
232 | + | ||
233 | + sss->plic = sifive_plic_create(shakti_c_memmap[SHAKTI_C_PLIC].base, | ||
234 | + (char *)SHAKTI_C_PLIC_HART_CONFIG, 0, | ||
235 | + SHAKTI_C_PLIC_NUM_SOURCES, | ||
236 | + SHAKTI_C_PLIC_NUM_PRIORITIES, | ||
237 | + SHAKTI_C_PLIC_PRIORITY_BASE, | ||
238 | + SHAKTI_C_PLIC_PENDING_BASE, | ||
239 | + SHAKTI_C_PLIC_ENABLE_BASE, | ||
240 | + SHAKTI_C_PLIC_ENABLE_STRIDE, | ||
241 | + SHAKTI_C_PLIC_CONTEXT_BASE, | ||
242 | + SHAKTI_C_PLIC_CONTEXT_STRIDE, | ||
243 | + shakti_c_memmap[SHAKTI_C_PLIC].size); | ||
244 | + | ||
245 | + sifive_clint_create(shakti_c_memmap[SHAKTI_C_CLINT].base, | ||
246 | + shakti_c_memmap[SHAKTI_C_CLINT].size, 0, 1, | ||
247 | + SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, | ||
248 | + SIFIVE_CLINT_TIMEBASE_FREQ, false); | ||
249 | + | ||
250 | + /* ROM */ | ||
251 | + memory_region_init_rom(&sss->rom, OBJECT(dev), "riscv.shakti.c.rom", | ||
252 | + shakti_c_memmap[SHAKTI_C_ROM].size, &error_fatal); | ||
253 | + memory_region_add_subregion(system_memory, | ||
254 | + shakti_c_memmap[SHAKTI_C_ROM].base, &sss->rom); | ||
255 | +} | ||
256 | + | ||
257 | +static void shakti_c_soc_class_init(ObjectClass *klass, void *data) | ||
258 | +{ | ||
259 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
260 | + dc->realize = shakti_c_soc_state_realize; | ||
261 | +} | ||
262 | + | ||
263 | +static void shakti_c_soc_instance_init(Object *obj) | ||
264 | +{ | ||
265 | + ShaktiCSoCState *sss = RISCV_SHAKTI_SOC(obj); | ||
266 | + | ||
267 | + object_initialize_child(obj, "cpus", &sss->cpus, TYPE_RISCV_HART_ARRAY); | ||
268 | + | ||
269 | + /* | ||
270 | + * CPU type is fixed and we are not supporting passing from commandline yet. | ||
271 | + * So let it be in instance_init. When supported should use ms->cpu_type | ||
272 | + * instead of TYPE_RISCV_CPU_SHAKTI_C | ||
273 | + */ | ||
274 | + object_property_set_str(OBJECT(&sss->cpus), "cpu-type", | ||
275 | + TYPE_RISCV_CPU_SHAKTI_C, &error_abort); | ||
276 | + object_property_set_int(OBJECT(&sss->cpus), "num-harts", 1, | ||
277 | + &error_abort); | ||
278 | +} | ||
279 | + | ||
280 | +static const TypeInfo shakti_c_type_info = { | ||
281 | + .name = TYPE_RISCV_SHAKTI_SOC, | ||
282 | + .parent = TYPE_DEVICE, | ||
283 | + .class_init = shakti_c_soc_class_init, | ||
284 | + .instance_init = shakti_c_soc_instance_init, | ||
285 | + .instance_size = sizeof(ShaktiCSoCState), | ||
286 | +}; | ||
287 | + | ||
288 | +static void shakti_c_type_info_register(void) | ||
289 | +{ | ||
290 | + type_register_static(&shakti_c_type_info); | ||
291 | +} | ||
292 | +type_init(shakti_c_type_info_register) | ||
293 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
294 | index XXXXXXX..XXXXXXX 100644 | ||
295 | --- a/MAINTAINERS | ||
296 | +++ b/MAINTAINERS | ||
297 | @@ -XXX,XX +XXX,XX @@ F: include/hw/misc/mchp_pfsoc_dmc.h | ||
298 | F: include/hw/misc/mchp_pfsoc_ioscb.h | ||
299 | F: include/hw/misc/mchp_pfsoc_sysreg.h | ||
300 | |||
301 | +Shakti C class SoC | ||
302 | +M: Vijai Kumar K <vijai@behindbytes.com> | ||
303 | +L: qemu-riscv@nongnu.org | ||
304 | +S: Supported | ||
305 | +F: hw/riscv/shakti_c.c | ||
306 | +F: include/hw/riscv/shakti_c.h | ||
307 | + | ||
308 | SiFive Machines | ||
309 | M: Alistair Francis <Alistair.Francis@wdc.com> | ||
310 | M: Bin Meng <bin.meng@windriver.com> | ||
311 | diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig | ||
312 | index XXXXXXX..XXXXXXX 100644 | ||
313 | --- a/hw/riscv/Kconfig | ||
314 | +++ b/hw/riscv/Kconfig | ||
315 | @@ -XXX,XX +XXX,XX @@ config OPENTITAN | ||
316 | select IBEX | ||
317 | select UNIMP | ||
318 | |||
319 | +config SHAKTI | ||
320 | + bool | ||
321 | + | ||
322 | +config SHAKTI_C | ||
323 | + bool | ||
324 | + select UNIMP | ||
325 | + select SHAKTI | ||
326 | + select SIFIVE_CLINT | ||
327 | + select SIFIVE_PLIC | ||
328 | + | ||
329 | config RISCV_VIRT | ||
330 | bool | ||
331 | imply PCI_DEVICES | ||
332 | diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build | ||
333 | index XXXXXXX..XXXXXXX 100644 | ||
334 | --- a/hw/riscv/meson.build | ||
335 | +++ b/hw/riscv/meson.build | ||
336 | @@ -XXX,XX +XXX,XX @@ riscv_ss.add(files('numa.c')) | ||
337 | riscv_ss.add(files('riscv_hart.c')) | ||
338 | riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c')) | ||
339 | riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c')) | ||
340 | +riscv_ss.add(when: 'CONFIG_SHAKTI_C', if_true: files('shakti_c.c')) | ||
341 | riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c')) | ||
342 | riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c')) | ||
343 | riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c')) | ||
344 | -- | ||
345 | 2.31.1 | ||
346 | |||
347 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Vijai Kumar K <vijai@behindbytes.com> | |
2 | |||
3 | This is the initial implementation of Shakti UART. | ||
4 | |||
5 | Signed-off-by: Vijai Kumar K <vijai@behindbytes.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Message-id: 20210401181457.73039-4-vijai@behindbytes.com | ||
8 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | --- | ||
10 | include/hw/char/shakti_uart.h | 74 ++++++++++++++ | ||
11 | hw/char/shakti_uart.c | 185 ++++++++++++++++++++++++++++++++++ | ||
12 | MAINTAINERS | 2 + | ||
13 | hw/char/meson.build | 1 + | ||
14 | hw/char/trace-events | 4 + | ||
15 | 5 files changed, 266 insertions(+) | ||
16 | create mode 100644 include/hw/char/shakti_uart.h | ||
17 | create mode 100644 hw/char/shakti_uart.c | ||
18 | |||
19 | diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h | ||
20 | new file mode 100644 | ||
21 | index XXXXXXX..XXXXXXX | ||
22 | --- /dev/null | ||
23 | +++ b/include/hw/char/shakti_uart.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | +/* | ||
26 | + * SHAKTI UART | ||
27 | + * | ||
28 | + * Copyright (c) 2021 Vijai Kumar K <vijai@behindbytes.com> | ||
29 | + * | ||
30 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
31 | + * of this software and associated documentation files (the "Software"), to deal | ||
32 | + * in the Software without restriction, including without limitation the rights | ||
33 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
34 | + * copies of the Software, and to permit persons to whom the Software is | ||
35 | + * furnished to do so, subject to the following conditions: | ||
36 | + * | ||
37 | + * The above copyright notice and this permission notice shall be included in | ||
38 | + * all copies or substantial portions of the Software. | ||
39 | + * | ||
40 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
41 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
42 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
43 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
44 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
45 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
46 | + * THE SOFTWARE. | ||
47 | + */ | ||
48 | + | ||
49 | +#ifndef HW_SHAKTI_UART_H | ||
50 | +#define HW_SHAKTI_UART_H | ||
51 | + | ||
52 | +#include "hw/sysbus.h" | ||
53 | +#include "chardev/char-fe.h" | ||
54 | + | ||
55 | +#define SHAKTI_UART_BAUD 0x00 | ||
56 | +#define SHAKTI_UART_TX 0x04 | ||
57 | +#define SHAKTI_UART_RX 0x08 | ||
58 | +#define SHAKTI_UART_STATUS 0x0C | ||
59 | +#define SHAKTI_UART_DELAY 0x10 | ||
60 | +#define SHAKTI_UART_CONTROL 0x14 | ||
61 | +#define SHAKTI_UART_INT_EN 0x18 | ||
62 | +#define SHAKTI_UART_IQ_CYCLES 0x1C | ||
63 | +#define SHAKTI_UART_RX_THRES 0x20 | ||
64 | + | ||
65 | +#define SHAKTI_UART_STATUS_TX_EMPTY (1 << 0) | ||
66 | +#define SHAKTI_UART_STATUS_TX_FULL (1 << 1) | ||
67 | +#define SHAKTI_UART_STATUS_RX_NOT_EMPTY (1 << 2) | ||
68 | +#define SHAKTI_UART_STATUS_RX_FULL (1 << 3) | ||
69 | +/* 9600 8N1 is the default setting */ | ||
70 | +/* Reg value = (50000000 Hz)/(16 * 9600)*/ | ||
71 | +#define SHAKTI_UART_BAUD_DEFAULT 0x0145 | ||
72 | +#define SHAKTI_UART_CONTROL_DEFAULT 0x0100 | ||
73 | + | ||
74 | +#define TYPE_SHAKTI_UART "shakti-uart" | ||
75 | +#define SHAKTI_UART(obj) \ | ||
76 | + OBJECT_CHECK(ShaktiUartState, (obj), TYPE_SHAKTI_UART) | ||
77 | + | ||
78 | +typedef struct { | ||
79 | + /* <private> */ | ||
80 | + SysBusDevice parent_obj; | ||
81 | + | ||
82 | + /* <public> */ | ||
83 | + MemoryRegion mmio; | ||
84 | + | ||
85 | + uint32_t uart_baud; | ||
86 | + uint32_t uart_tx; | ||
87 | + uint32_t uart_rx; | ||
88 | + uint32_t uart_status; | ||
89 | + uint32_t uart_delay; | ||
90 | + uint32_t uart_control; | ||
91 | + uint32_t uart_interrupt; | ||
92 | + uint32_t uart_iq_cycles; | ||
93 | + uint32_t uart_rx_threshold; | ||
94 | + | ||
95 | + CharBackend chr; | ||
96 | +} ShaktiUartState; | ||
97 | + | ||
98 | +#endif /* HW_SHAKTI_UART_H */ | ||
99 | diff --git a/hw/char/shakti_uart.c b/hw/char/shakti_uart.c | ||
100 | new file mode 100644 | ||
101 | index XXXXXXX..XXXXXXX | ||
102 | --- /dev/null | ||
103 | +++ b/hw/char/shakti_uart.c | ||
104 | @@ -XXX,XX +XXX,XX @@ | ||
105 | +/* | ||
106 | + * SHAKTI UART | ||
107 | + * | ||
108 | + * Copyright (c) 2021 Vijai Kumar K <vijai@behindbytes.com> | ||
109 | + * | ||
110 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
111 | + * of this software and associated documentation files (the "Software"), to deal | ||
112 | + * in the Software without restriction, including without limitation the rights | ||
113 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
114 | + * copies of the Software, and to permit persons to whom the Software is | ||
115 | + * furnished to do so, subject to the following conditions: | ||
116 | + * | ||
117 | + * The above copyright notice and this permission notice shall be included in | ||
118 | + * all copies or substantial portions of the Software. | ||
119 | + * | ||
120 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
121 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
122 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
123 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
124 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
125 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
126 | + * THE SOFTWARE. | ||
127 | + */ | ||
128 | + | ||
129 | +#include "qemu/osdep.h" | ||
130 | +#include "hw/char/shakti_uart.h" | ||
131 | +#include "hw/qdev-properties.h" | ||
132 | +#include "hw/qdev-properties-system.h" | ||
133 | +#include "qemu/log.h" | ||
134 | + | ||
135 | +static uint64_t shakti_uart_read(void *opaque, hwaddr addr, unsigned size) | ||
136 | +{ | ||
137 | + ShaktiUartState *s = opaque; | ||
138 | + | ||
139 | + switch (addr) { | ||
140 | + case SHAKTI_UART_BAUD: | ||
141 | + return s->uart_baud; | ||
142 | + case SHAKTI_UART_RX: | ||
143 | + qemu_chr_fe_accept_input(&s->chr); | ||
144 | + s->uart_status &= ~SHAKTI_UART_STATUS_RX_NOT_EMPTY; | ||
145 | + return s->uart_rx; | ||
146 | + case SHAKTI_UART_STATUS: | ||
147 | + return s->uart_status; | ||
148 | + case SHAKTI_UART_DELAY: | ||
149 | + return s->uart_delay; | ||
150 | + case SHAKTI_UART_CONTROL: | ||
151 | + return s->uart_control; | ||
152 | + case SHAKTI_UART_INT_EN: | ||
153 | + return s->uart_interrupt; | ||
154 | + case SHAKTI_UART_IQ_CYCLES: | ||
155 | + return s->uart_iq_cycles; | ||
156 | + case SHAKTI_UART_RX_THRES: | ||
157 | + return s->uart_rx_threshold; | ||
158 | + default: | ||
159 | + /* Also handles TX REG which is write only */ | ||
160 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
161 | + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); | ||
162 | + } | ||
163 | + | ||
164 | + return 0; | ||
165 | +} | ||
166 | + | ||
167 | +static void shakti_uart_write(void *opaque, hwaddr addr, | ||
168 | + uint64_t data, unsigned size) | ||
169 | +{ | ||
170 | + ShaktiUartState *s = opaque; | ||
171 | + uint32_t value = data; | ||
172 | + uint8_t ch; | ||
173 | + | ||
174 | + switch (addr) { | ||
175 | + case SHAKTI_UART_BAUD: | ||
176 | + s->uart_baud = value; | ||
177 | + break; | ||
178 | + case SHAKTI_UART_TX: | ||
179 | + ch = value; | ||
180 | + qemu_chr_fe_write_all(&s->chr, &ch, 1); | ||
181 | + s->uart_status &= ~SHAKTI_UART_STATUS_TX_FULL; | ||
182 | + break; | ||
183 | + case SHAKTI_UART_STATUS: | ||
184 | + s->uart_status = value; | ||
185 | + break; | ||
186 | + case SHAKTI_UART_DELAY: | ||
187 | + s->uart_delay = value; | ||
188 | + break; | ||
189 | + case SHAKTI_UART_CONTROL: | ||
190 | + s->uart_control = value; | ||
191 | + break; | ||
192 | + case SHAKTI_UART_INT_EN: | ||
193 | + s->uart_interrupt = value; | ||
194 | + break; | ||
195 | + case SHAKTI_UART_IQ_CYCLES: | ||
196 | + s->uart_iq_cycles = value; | ||
197 | + break; | ||
198 | + case SHAKTI_UART_RX_THRES: | ||
199 | + s->uart_rx_threshold = value; | ||
200 | + break; | ||
201 | + default: | ||
202 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
203 | + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); | ||
204 | + } | ||
205 | +} | ||
206 | + | ||
207 | +static const MemoryRegionOps shakti_uart_ops = { | ||
208 | + .read = shakti_uart_read, | ||
209 | + .write = shakti_uart_write, | ||
210 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
211 | + .impl = {.min_access_size = 1, .max_access_size = 4}, | ||
212 | + .valid = {.min_access_size = 1, .max_access_size = 4}, | ||
213 | +}; | ||
214 | + | ||
215 | +static void shakti_uart_reset(DeviceState *dev) | ||
216 | +{ | ||
217 | + ShaktiUartState *s = SHAKTI_UART(dev); | ||
218 | + | ||
219 | + s->uart_baud = SHAKTI_UART_BAUD_DEFAULT; | ||
220 | + s->uart_tx = 0x0; | ||
221 | + s->uart_rx = 0x0; | ||
222 | + s->uart_status = 0x0000; | ||
223 | + s->uart_delay = 0x0000; | ||
224 | + s->uart_control = SHAKTI_UART_CONTROL_DEFAULT; | ||
225 | + s->uart_interrupt = 0x0000; | ||
226 | + s->uart_iq_cycles = 0x00; | ||
227 | + s->uart_rx_threshold = 0x00; | ||
228 | +} | ||
229 | + | ||
230 | +static int shakti_uart_can_receive(void *opaque) | ||
231 | +{ | ||
232 | + ShaktiUartState *s = opaque; | ||
233 | + | ||
234 | + return !(s->uart_status & SHAKTI_UART_STATUS_RX_NOT_EMPTY); | ||
235 | +} | ||
236 | + | ||
237 | +static void shakti_uart_receive(void *opaque, const uint8_t *buf, int size) | ||
238 | +{ | ||
239 | + ShaktiUartState *s = opaque; | ||
240 | + | ||
241 | + s->uart_rx = *buf; | ||
242 | + s->uart_status |= SHAKTI_UART_STATUS_RX_NOT_EMPTY; | ||
243 | +} | ||
244 | + | ||
245 | +static void shakti_uart_realize(DeviceState *dev, Error **errp) | ||
246 | +{ | ||
247 | + ShaktiUartState *sus = SHAKTI_UART(dev); | ||
248 | + qemu_chr_fe_set_handlers(&sus->chr, shakti_uart_can_receive, | ||
249 | + shakti_uart_receive, NULL, NULL, sus, NULL, true); | ||
250 | +} | ||
251 | + | ||
252 | +static void shakti_uart_instance_init(Object *obj) | ||
253 | +{ | ||
254 | + ShaktiUartState *sus = SHAKTI_UART(obj); | ||
255 | + memory_region_init_io(&sus->mmio, | ||
256 | + obj, | ||
257 | + &shakti_uart_ops, | ||
258 | + sus, | ||
259 | + TYPE_SHAKTI_UART, | ||
260 | + 0x1000); | ||
261 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &sus->mmio); | ||
262 | +} | ||
263 | + | ||
264 | +static Property shakti_uart_properties[] = { | ||
265 | + DEFINE_PROP_CHR("chardev", ShaktiUartState, chr), | ||
266 | + DEFINE_PROP_END_OF_LIST(), | ||
267 | +}; | ||
268 | + | ||
269 | +static void shakti_uart_class_init(ObjectClass *klass, void *data) | ||
270 | +{ | ||
271 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
272 | + dc->reset = shakti_uart_reset; | ||
273 | + dc->realize = shakti_uart_realize; | ||
274 | + device_class_set_props(dc, shakti_uart_properties); | ||
275 | +} | ||
276 | + | ||
277 | +static const TypeInfo shakti_uart_info = { | ||
278 | + .name = TYPE_SHAKTI_UART, | ||
279 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
280 | + .instance_size = sizeof(ShaktiUartState), | ||
281 | + .class_init = shakti_uart_class_init, | ||
282 | + .instance_init = shakti_uart_instance_init, | ||
283 | +}; | ||
284 | + | ||
285 | +static void shakti_uart_register_types(void) | ||
286 | +{ | ||
287 | + type_register_static(&shakti_uart_info); | ||
288 | +} | ||
289 | +type_init(shakti_uart_register_types) | ||
290 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
291 | index XXXXXXX..XXXXXXX 100644 | ||
292 | --- a/MAINTAINERS | ||
293 | +++ b/MAINTAINERS | ||
294 | @@ -XXX,XX +XXX,XX @@ M: Vijai Kumar K <vijai@behindbytes.com> | ||
295 | L: qemu-riscv@nongnu.org | ||
296 | S: Supported | ||
297 | F: hw/riscv/shakti_c.c | ||
298 | +F: hw/char/shakti_uart.c | ||
299 | F: include/hw/riscv/shakti_c.h | ||
300 | +F: include/hw/char/shakti_uart.h | ||
301 | |||
302 | SiFive Machines | ||
303 | M: Alistair Francis <Alistair.Francis@wdc.com> | ||
304 | diff --git a/hw/char/meson.build b/hw/char/meson.build | ||
305 | index XXXXXXX..XXXXXXX 100644 | ||
306 | --- a/hw/char/meson.build | ||
307 | +++ b/hw/char/meson.build | ||
308 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SERIAL', if_true: files('serial.c')) | ||
309 | softmmu_ss.add(when: 'CONFIG_SERIAL_ISA', if_true: files('serial-isa.c')) | ||
310 | softmmu_ss.add(when: 'CONFIG_SERIAL_PCI', if_true: files('serial-pci.c')) | ||
311 | softmmu_ss.add(when: 'CONFIG_SERIAL_PCI_MULTI', if_true: files('serial-pci-multi.c')) | ||
312 | +softmmu_ss.add(when: 'CONFIG_SHAKTI', if_true: files('shakti_uart.c')) | ||
313 | softmmu_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true: files('virtio-console.c')) | ||
314 | softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen_console.c')) | ||
315 | softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_uartlite.c')) | ||
316 | diff --git a/hw/char/trace-events b/hw/char/trace-events | ||
317 | index XXXXXXX..XXXXXXX 100644 | ||
318 | --- a/hw/char/trace-events | ||
319 | +++ b/hw/char/trace-events | ||
320 | @@ -XXX,XX +XXX,XX @@ cmsdk_apb_uart_set_params(int speed) "CMSDK APB UART: params set to %d 8N1" | ||
321 | nrf51_uart_read(uint64_t addr, uint64_t r, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx64 " size %u" | ||
322 | nrf51_uart_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx64 " size %u" | ||
323 | |||
324 | +# shakti_uart.c | ||
325 | +shakti_uart_read(uint64_t addr, uint16_t r, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx16 " size %u" | ||
326 | +shakti_uart_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx64 " size %u" | ||
327 | + | ||
328 | # exynos4210_uart.c | ||
329 | exynos_uart_dmabusy(uint32_t channel) "UART%d: DMA busy (Rx buffer empty)" | ||
330 | exynos_uart_dmaready(uint32_t channel) "UART%d: DMA ready" | ||
331 | -- | ||
332 | 2.31.1 | ||
333 | |||
334 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Vijai Kumar K <vijai@behindbytes.com> | ||
1 | 2 | ||
3 | Connect one shakti uart to the shakti_c machine. | ||
4 | |||
5 | Signed-off-by: Vijai Kumar K <vijai@behindbytes.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Message-id: 20210401181457.73039-5-vijai@behindbytes.com | ||
8 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | --- | ||
10 | include/hw/riscv/shakti_c.h | 2 ++ | ||
11 | hw/riscv/shakti_c.c | 8 ++++++++ | ||
12 | 2 files changed, 10 insertions(+) | ||
13 | |||
14 | diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/riscv/shakti_c.h | ||
17 | +++ b/include/hw/riscv/shakti_c.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | #include "hw/riscv/riscv_hart.h" | ||
21 | #include "hw/boards.h" | ||
22 | +#include "hw/char/shakti_uart.h" | ||
23 | |||
24 | #define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc" | ||
25 | #define RISCV_SHAKTI_SOC(obj) \ | ||
26 | @@ -XXX,XX +XXX,XX @@ typedef struct ShaktiCSoCState { | ||
27 | /*< public >*/ | ||
28 | RISCVHartArrayState cpus; | ||
29 | DeviceState *plic; | ||
30 | + ShaktiUartState uart; | ||
31 | MemoryRegion rom; | ||
32 | |||
33 | } ShaktiCSoCState; | ||
34 | diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/riscv/shakti_c.c | ||
37 | +++ b/hw/riscv/shakti_c.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void shakti_c_soc_state_realize(DeviceState *dev, Error **errp) | ||
39 | SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, | ||
40 | SIFIVE_CLINT_TIMEBASE_FREQ, false); | ||
41 | |||
42 | + qdev_prop_set_chr(DEVICE(&(sss->uart)), "chardev", serial_hd(0)); | ||
43 | + if (!sysbus_realize(SYS_BUS_DEVICE(&sss->uart), errp)) { | ||
44 | + return; | ||
45 | + } | ||
46 | + sysbus_mmio_map(SYS_BUS_DEVICE(&sss->uart), 0, | ||
47 | + shakti_c_memmap[SHAKTI_C_UART].base); | ||
48 | + | ||
49 | /* ROM */ | ||
50 | memory_region_init_rom(&sss->rom, OBJECT(dev), "riscv.shakti.c.rom", | ||
51 | shakti_c_memmap[SHAKTI_C_ROM].size, &error_fatal); | ||
52 | @@ -XXX,XX +XXX,XX @@ static void shakti_c_soc_instance_init(Object *obj) | ||
53 | ShaktiCSoCState *sss = RISCV_SHAKTI_SOC(obj); | ||
54 | |||
55 | object_initialize_child(obj, "cpus", &sss->cpus, TYPE_RISCV_HART_ARRAY); | ||
56 | + object_initialize_child(obj, "uart", &sss->uart, TYPE_SHAKTI_UART); | ||
57 | |||
58 | /* | ||
59 | * CPU type is fixed and we are not supporting passing from commandline yet. | ||
60 | -- | ||
61 | 2.31.1 | ||
62 | |||
63 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: f191dcf08bf413a822e743a7c7f824d68879a527.1617290165.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/cpu_bits.h | 44 ++++++++++++++++++++------------------- | ||
7 | target/riscv/cpu.c | 2 +- | ||
8 | target/riscv/cpu_helper.c | 4 ++-- | ||
9 | 3 files changed, 26 insertions(+), 24 deletions(-) | ||
1 | 10 | ||
11 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/riscv/cpu_bits.h | ||
14 | +++ b/target/riscv/cpu_bits.h | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | #define DEFAULT_RSTVEC 0x1000 | ||
17 | |||
18 | /* Exception causes */ | ||
19 | -#define EXCP_NONE -1 /* sentinel value */ | ||
20 | -#define RISCV_EXCP_INST_ADDR_MIS 0x0 | ||
21 | -#define RISCV_EXCP_INST_ACCESS_FAULT 0x1 | ||
22 | -#define RISCV_EXCP_ILLEGAL_INST 0x2 | ||
23 | -#define RISCV_EXCP_BREAKPOINT 0x3 | ||
24 | -#define RISCV_EXCP_LOAD_ADDR_MIS 0x4 | ||
25 | -#define RISCV_EXCP_LOAD_ACCESS_FAULT 0x5 | ||
26 | -#define RISCV_EXCP_STORE_AMO_ADDR_MIS 0x6 | ||
27 | -#define RISCV_EXCP_STORE_AMO_ACCESS_FAULT 0x7 | ||
28 | -#define RISCV_EXCP_U_ECALL 0x8 | ||
29 | -#define RISCV_EXCP_S_ECALL 0x9 | ||
30 | -#define RISCV_EXCP_VS_ECALL 0xa | ||
31 | -#define RISCV_EXCP_M_ECALL 0xb | ||
32 | -#define RISCV_EXCP_INST_PAGE_FAULT 0xc /* since: priv-1.10.0 */ | ||
33 | -#define RISCV_EXCP_LOAD_PAGE_FAULT 0xd /* since: priv-1.10.0 */ | ||
34 | -#define RISCV_EXCP_STORE_PAGE_FAULT 0xf /* since: priv-1.10.0 */ | ||
35 | -#define RISCV_EXCP_SEMIHOST 0x10 | ||
36 | -#define RISCV_EXCP_INST_GUEST_PAGE_FAULT 0x14 | ||
37 | -#define RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT 0x15 | ||
38 | -#define RISCV_EXCP_VIRT_INSTRUCTION_FAULT 0x16 | ||
39 | -#define RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT 0x17 | ||
40 | +typedef enum RISCVException { | ||
41 | + RISCV_EXCP_NONE = -1, /* sentinel value */ | ||
42 | + RISCV_EXCP_INST_ADDR_MIS = 0x0, | ||
43 | + RISCV_EXCP_INST_ACCESS_FAULT = 0x1, | ||
44 | + RISCV_EXCP_ILLEGAL_INST = 0x2, | ||
45 | + RISCV_EXCP_BREAKPOINT = 0x3, | ||
46 | + RISCV_EXCP_LOAD_ADDR_MIS = 0x4, | ||
47 | + RISCV_EXCP_LOAD_ACCESS_FAULT = 0x5, | ||
48 | + RISCV_EXCP_STORE_AMO_ADDR_MIS = 0x6, | ||
49 | + RISCV_EXCP_STORE_AMO_ACCESS_FAULT = 0x7, | ||
50 | + RISCV_EXCP_U_ECALL = 0x8, | ||
51 | + RISCV_EXCP_S_ECALL = 0x9, | ||
52 | + RISCV_EXCP_VS_ECALL = 0xa, | ||
53 | + RISCV_EXCP_M_ECALL = 0xb, | ||
54 | + RISCV_EXCP_INST_PAGE_FAULT = 0xc, /* since: priv-1.10.0 */ | ||
55 | + RISCV_EXCP_LOAD_PAGE_FAULT = 0xd, /* since: priv-1.10.0 */ | ||
56 | + RISCV_EXCP_STORE_PAGE_FAULT = 0xf, /* since: priv-1.10.0 */ | ||
57 | + RISCV_EXCP_SEMIHOST = 0x10, | ||
58 | + RISCV_EXCP_INST_GUEST_PAGE_FAULT = 0x14, | ||
59 | + RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT = 0x15, | ||
60 | + RISCV_EXCP_VIRT_INSTRUCTION_FAULT = 0x16, | ||
61 | + RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT = 0x17, | ||
62 | +} RISCVException; | ||
63 | |||
64 | #define RISCV_EXCP_INT_FLAG 0x80000000 | ||
65 | #define RISCV_EXCP_INT_MASK 0x7fffffff | ||
66 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/riscv/cpu.c | ||
69 | +++ b/target/riscv/cpu.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset(DeviceState *dev) | ||
71 | env->pc = env->resetvec; | ||
72 | env->two_stage_lookup = false; | ||
73 | #endif | ||
74 | - cs->exception_index = EXCP_NONE; | ||
75 | + cs->exception_index = RISCV_EXCP_NONE; | ||
76 | env->load_res = -1; | ||
77 | set_default_nan_mode(1, &env->fp_status); | ||
78 | } | ||
79 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/riscv/cpu_helper.c | ||
82 | +++ b/target/riscv/cpu_helper.c | ||
83 | @@ -XXX,XX +XXX,XX @@ static int riscv_cpu_local_irq_pending(CPURISCVState *env) | ||
84 | if (irqs) { | ||
85 | return ctz64(irqs); /* since non-zero */ | ||
86 | } else { | ||
87 | - return EXCP_NONE; /* indicates no pending interrupt */ | ||
88 | + return RISCV_EXCP_NONE; /* indicates no pending interrupt */ | ||
89 | } | ||
90 | } | ||
91 | #endif | ||
92 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs) | ||
93 | |||
94 | env->two_stage_lookup = false; | ||
95 | #endif | ||
96 | - cs->exception_index = EXCP_NONE; /* mark handled to qemu */ | ||
97 | + cs->exception_index = RISCV_EXCP_NONE; /* mark handled to qemu */ | ||
98 | } | ||
99 | -- | ||
100 | 2.31.1 | ||
101 | |||
102 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
4 | Message-id: 187261fa671c3a77cf5aa482adb2a558c02a7cad.1617290165.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/cpu.h | 3 +- | ||
7 | target/riscv/csr.c | 80 +++++++++++++++++++++++++--------------------- | ||
8 | 2 files changed, 46 insertions(+), 37 deletions(-) | ||
1 | 9 | ||
10 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/riscv/cpu.h | ||
13 | +++ b/target/riscv/cpu.h | ||
14 | @@ -XXX,XX +XXX,XX @@ static inline target_ulong riscv_csr_read(CPURISCVState *env, int csrno) | ||
15 | return val; | ||
16 | } | ||
17 | |||
18 | -typedef int (*riscv_csr_predicate_fn)(CPURISCVState *env, int csrno); | ||
19 | +typedef RISCVException (*riscv_csr_predicate_fn)(CPURISCVState *env, | ||
20 | + int csrno); | ||
21 | typedef int (*riscv_csr_read_fn)(CPURISCVState *env, int csrno, | ||
22 | target_ulong *ret_value); | ||
23 | typedef int (*riscv_csr_write_fn)(CPURISCVState *env, int csrno, | ||
24 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/riscv/csr.c | ||
27 | +++ b/target/riscv/csr.c | ||
28 | @@ -XXX,XX +XXX,XX @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops) | ||
29 | } | ||
30 | |||
31 | /* Predicates */ | ||
32 | -static int fs(CPURISCVState *env, int csrno) | ||
33 | +static RISCVException fs(CPURISCVState *env, int csrno) | ||
34 | { | ||
35 | #if !defined(CONFIG_USER_ONLY) | ||
36 | /* loose check condition for fcsr in vector extension */ | ||
37 | if ((csrno == CSR_FCSR) && (env->misa & RVV)) { | ||
38 | - return 0; | ||
39 | + return RISCV_EXCP_NONE; | ||
40 | } | ||
41 | if (!env->debugger && !riscv_cpu_fp_enabled(env)) { | ||
42 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
43 | + return RISCV_EXCP_ILLEGAL_INST; | ||
44 | } | ||
45 | #endif | ||
46 | - return 0; | ||
47 | + return RISCV_EXCP_NONE; | ||
48 | } | ||
49 | |||
50 | -static int vs(CPURISCVState *env, int csrno) | ||
51 | +static RISCVException vs(CPURISCVState *env, int csrno) | ||
52 | { | ||
53 | if (env->misa & RVV) { | ||
54 | - return 0; | ||
55 | + return RISCV_EXCP_NONE; | ||
56 | } | ||
57 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
58 | + return RISCV_EXCP_ILLEGAL_INST; | ||
59 | } | ||
60 | |||
61 | -static int ctr(CPURISCVState *env, int csrno) | ||
62 | +static RISCVException ctr(CPURISCVState *env, int csrno) | ||
63 | { | ||
64 | #if !defined(CONFIG_USER_ONLY) | ||
65 | CPUState *cs = env_cpu(env); | ||
66 | @@ -XXX,XX +XXX,XX @@ static int ctr(CPURISCVState *env, int csrno) | ||
67 | |||
68 | if (!cpu->cfg.ext_counters) { | ||
69 | /* The Counters extensions is not enabled */ | ||
70 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
71 | + return RISCV_EXCP_ILLEGAL_INST; | ||
72 | } | ||
73 | |||
74 | if (riscv_cpu_virt_enabled(env)) { | ||
75 | @@ -XXX,XX +XXX,XX @@ static int ctr(CPURISCVState *env, int csrno) | ||
76 | case CSR_CYCLE: | ||
77 | if (!get_field(env->hcounteren, HCOUNTEREN_CY) && | ||
78 | get_field(env->mcounteren, HCOUNTEREN_CY)) { | ||
79 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
80 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
81 | } | ||
82 | break; | ||
83 | case CSR_TIME: | ||
84 | if (!get_field(env->hcounteren, HCOUNTEREN_TM) && | ||
85 | get_field(env->mcounteren, HCOUNTEREN_TM)) { | ||
86 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
87 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
88 | } | ||
89 | break; | ||
90 | case CSR_INSTRET: | ||
91 | if (!get_field(env->hcounteren, HCOUNTEREN_IR) && | ||
92 | get_field(env->mcounteren, HCOUNTEREN_IR)) { | ||
93 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
94 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
95 | } | ||
96 | break; | ||
97 | case CSR_HPMCOUNTER3...CSR_HPMCOUNTER31: | ||
98 | if (!get_field(env->hcounteren, 1 << (csrno - CSR_HPMCOUNTER3)) && | ||
99 | get_field(env->mcounteren, 1 << (csrno - CSR_HPMCOUNTER3))) { | ||
100 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
101 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
102 | } | ||
103 | break; | ||
104 | } | ||
105 | @@ -XXX,XX +XXX,XX @@ static int ctr(CPURISCVState *env, int csrno) | ||
106 | case CSR_CYCLEH: | ||
107 | if (!get_field(env->hcounteren, HCOUNTEREN_CY) && | ||
108 | get_field(env->mcounteren, HCOUNTEREN_CY)) { | ||
109 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
110 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
111 | } | ||
112 | break; | ||
113 | case CSR_TIMEH: | ||
114 | if (!get_field(env->hcounteren, HCOUNTEREN_TM) && | ||
115 | get_field(env->mcounteren, HCOUNTEREN_TM)) { | ||
116 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
117 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
118 | } | ||
119 | break; | ||
120 | case CSR_INSTRETH: | ||
121 | if (!get_field(env->hcounteren, HCOUNTEREN_IR) && | ||
122 | get_field(env->mcounteren, HCOUNTEREN_IR)) { | ||
123 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
124 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
125 | } | ||
126 | break; | ||
127 | case CSR_HPMCOUNTER3H...CSR_HPMCOUNTER31H: | ||
128 | if (!get_field(env->hcounteren, 1 << (csrno - CSR_HPMCOUNTER3H)) && | ||
129 | get_field(env->mcounteren, 1 << (csrno - CSR_HPMCOUNTER3H))) { | ||
130 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
131 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
132 | } | ||
133 | break; | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | #endif | ||
138 | - return 0; | ||
139 | + return RISCV_EXCP_NONE; | ||
140 | } | ||
141 | |||
142 | -static int ctr32(CPURISCVState *env, int csrno) | ||
143 | +static RISCVException ctr32(CPURISCVState *env, int csrno) | ||
144 | { | ||
145 | if (!riscv_cpu_is_32bit(env)) { | ||
146 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
147 | + return RISCV_EXCP_ILLEGAL_INST; | ||
148 | } | ||
149 | |||
150 | return ctr(env, csrno); | ||
151 | } | ||
152 | |||
153 | #if !defined(CONFIG_USER_ONLY) | ||
154 | -static int any(CPURISCVState *env, int csrno) | ||
155 | +static RISCVException any(CPURISCVState *env, int csrno) | ||
156 | { | ||
157 | - return 0; | ||
158 | + return RISCV_EXCP_NONE; | ||
159 | } | ||
160 | |||
161 | -static int any32(CPURISCVState *env, int csrno) | ||
162 | +static RISCVException any32(CPURISCVState *env, int csrno) | ||
163 | { | ||
164 | if (!riscv_cpu_is_32bit(env)) { | ||
165 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
166 | + return RISCV_EXCP_ILLEGAL_INST; | ||
167 | } | ||
168 | |||
169 | return any(env, csrno); | ||
170 | |||
171 | } | ||
172 | |||
173 | -static int smode(CPURISCVState *env, int csrno) | ||
174 | +static RISCVException smode(CPURISCVState *env, int csrno) | ||
175 | { | ||
176 | - return -!riscv_has_ext(env, RVS); | ||
177 | + if (riscv_has_ext(env, RVS)) { | ||
178 | + return RISCV_EXCP_NONE; | ||
179 | + } | ||
180 | + | ||
181 | + return RISCV_EXCP_ILLEGAL_INST; | ||
182 | } | ||
183 | |||
184 | -static int hmode(CPURISCVState *env, int csrno) | ||
185 | +static RISCVException hmode(CPURISCVState *env, int csrno) | ||
186 | { | ||
187 | if (riscv_has_ext(env, RVS) && | ||
188 | riscv_has_ext(env, RVH)) { | ||
189 | /* Hypervisor extension is supported */ | ||
190 | if ((env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) || | ||
191 | env->priv == PRV_M) { | ||
192 | - return 0; | ||
193 | + return RISCV_EXCP_NONE; | ||
194 | } else { | ||
195 | - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
196 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
197 | } | ||
198 | } | ||
199 | |||
200 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
201 | + return RISCV_EXCP_ILLEGAL_INST; | ||
202 | } | ||
203 | |||
204 | -static int hmode32(CPURISCVState *env, int csrno) | ||
205 | +static RISCVException hmode32(CPURISCVState *env, int csrno) | ||
206 | { | ||
207 | if (!riscv_cpu_is_32bit(env)) { | ||
208 | - return 0; | ||
209 | + return RISCV_EXCP_NONE; | ||
210 | } | ||
211 | |||
212 | return hmode(env, csrno); | ||
213 | |||
214 | } | ||
215 | |||
216 | -static int pmp(CPURISCVState *env, int csrno) | ||
217 | +static RISCVException pmp(CPURISCVState *env, int csrno) | ||
218 | { | ||
219 | - return -!riscv_feature(env, RISCV_FEATURE_PMP); | ||
220 | + if (riscv_feature(env, RISCV_FEATURE_PMP)) { | ||
221 | + return RISCV_EXCP_NONE; | ||
222 | + } | ||
223 | + | ||
224 | + return RISCV_EXCP_ILLEGAL_INST; | ||
225 | } | ||
226 | #endif | ||
227 | |||
228 | @@ -XXX,XX +XXX,XX @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
229 | return -RISCV_EXCP_ILLEGAL_INST; | ||
230 | } | ||
231 | ret = csr_ops[csrno].predicate(env, csrno); | ||
232 | - if (ret < 0) { | ||
233 | - return ret; | ||
234 | + if (ret != RISCV_EXCP_NONE) { | ||
235 | + return -ret; | ||
236 | } | ||
237 | |||
238 | /* execute combined read/write operation if it exists */ | ||
239 | -- | ||
240 | 2.31.1 | ||
241 | |||
242 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
4 | Message-id: cb1ef2061547dc9028ce3cf4f6622588f9c09149.1617290165.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/csr.c | 6 +++++- | ||
7 | 1 file changed, 5 insertions(+), 1 deletion(-) | ||
1 | 8 | ||
9 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/target/riscv/csr.c | ||
12 | +++ b/target/riscv/csr.c | ||
13 | @@ -XXX,XX +XXX,XX @@ static RISCVException hmode(CPURISCVState *env, int csrno) | ||
14 | static RISCVException hmode32(CPURISCVState *env, int csrno) | ||
15 | { | ||
16 | if (!riscv_cpu_is_32bit(env)) { | ||
17 | - return RISCV_EXCP_NONE; | ||
18 | + if (riscv_cpu_virt_enabled(env)) { | ||
19 | + return RISCV_EXCP_ILLEGAL_INST; | ||
20 | + } else { | ||
21 | + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
22 | + } | ||
23 | } | ||
24 | |||
25 | return hmode(env, csrno); | ||
26 | -- | ||
27 | 2.31.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
4 | Message-id: 8566c4c271723f27f3ae8fc2429f906a459f17ce.1617290165.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/cpu.h | 14 +- | ||
7 | target/riscv/csr.c | 629 +++++++++++++++++++++++++++------------------ | ||
8 | 2 files changed, 382 insertions(+), 261 deletions(-) | ||
1 | 9 | ||
10 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/riscv/cpu.h | ||
13 | +++ b/target/riscv/cpu.h | ||
14 | @@ -XXX,XX +XXX,XX @@ static inline target_ulong riscv_csr_read(CPURISCVState *env, int csrno) | ||
15 | |||
16 | typedef RISCVException (*riscv_csr_predicate_fn)(CPURISCVState *env, | ||
17 | int csrno); | ||
18 | -typedef int (*riscv_csr_read_fn)(CPURISCVState *env, int csrno, | ||
19 | - target_ulong *ret_value); | ||
20 | -typedef int (*riscv_csr_write_fn)(CPURISCVState *env, int csrno, | ||
21 | - target_ulong new_value); | ||
22 | -typedef int (*riscv_csr_op_fn)(CPURISCVState *env, int csrno, | ||
23 | - target_ulong *ret_value, target_ulong new_value, target_ulong write_mask); | ||
24 | +typedef RISCVException (*riscv_csr_read_fn)(CPURISCVState *env, int csrno, | ||
25 | + target_ulong *ret_value); | ||
26 | +typedef RISCVException (*riscv_csr_write_fn)(CPURISCVState *env, int csrno, | ||
27 | + target_ulong new_value); | ||
28 | +typedef RISCVException (*riscv_csr_op_fn)(CPURISCVState *env, int csrno, | ||
29 | + target_ulong *ret_value, | ||
30 | + target_ulong new_value, | ||
31 | + target_ulong write_mask); | ||
32 | |||
33 | typedef struct { | ||
34 | const char *name; | ||
35 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/riscv/csr.c | ||
38 | +++ b/target/riscv/csr.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static RISCVException pmp(CPURISCVState *env, int csrno) | ||
40 | #endif | ||
41 | |||
42 | /* User Floating-Point CSRs */ | ||
43 | -static int read_fflags(CPURISCVState *env, int csrno, target_ulong *val) | ||
44 | +static RISCVException read_fflags(CPURISCVState *env, int csrno, | ||
45 | + target_ulong *val) | ||
46 | { | ||
47 | #if !defined(CONFIG_USER_ONLY) | ||
48 | if (!env->debugger && !riscv_cpu_fp_enabled(env)) { | ||
49 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
50 | + return RISCV_EXCP_ILLEGAL_INST; | ||
51 | } | ||
52 | #endif | ||
53 | *val = riscv_cpu_get_fflags(env); | ||
54 | - return 0; | ||
55 | + return RISCV_EXCP_NONE; | ||
56 | } | ||
57 | |||
58 | -static int write_fflags(CPURISCVState *env, int csrno, target_ulong val) | ||
59 | +static RISCVException write_fflags(CPURISCVState *env, int csrno, | ||
60 | + target_ulong val) | ||
61 | { | ||
62 | #if !defined(CONFIG_USER_ONLY) | ||
63 | if (!env->debugger && !riscv_cpu_fp_enabled(env)) { | ||
64 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
65 | + return RISCV_EXCP_ILLEGAL_INST; | ||
66 | } | ||
67 | env->mstatus |= MSTATUS_FS; | ||
68 | #endif | ||
69 | riscv_cpu_set_fflags(env, val & (FSR_AEXC >> FSR_AEXC_SHIFT)); | ||
70 | - return 0; | ||
71 | + return RISCV_EXCP_NONE; | ||
72 | } | ||
73 | |||
74 | -static int read_frm(CPURISCVState *env, int csrno, target_ulong *val) | ||
75 | +static RISCVException read_frm(CPURISCVState *env, int csrno, | ||
76 | + target_ulong *val) | ||
77 | { | ||
78 | #if !defined(CONFIG_USER_ONLY) | ||
79 | if (!env->debugger && !riscv_cpu_fp_enabled(env)) { | ||
80 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
81 | + return RISCV_EXCP_ILLEGAL_INST; | ||
82 | } | ||
83 | #endif | ||
84 | *val = env->frm; | ||
85 | - return 0; | ||
86 | + return RISCV_EXCP_NONE; | ||
87 | } | ||
88 | |||
89 | -static int write_frm(CPURISCVState *env, int csrno, target_ulong val) | ||
90 | +static RISCVException write_frm(CPURISCVState *env, int csrno, | ||
91 | + target_ulong val) | ||
92 | { | ||
93 | #if !defined(CONFIG_USER_ONLY) | ||
94 | if (!env->debugger && !riscv_cpu_fp_enabled(env)) { | ||
95 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
96 | + return RISCV_EXCP_ILLEGAL_INST; | ||
97 | } | ||
98 | env->mstatus |= MSTATUS_FS; | ||
99 | #endif | ||
100 | env->frm = val & (FSR_RD >> FSR_RD_SHIFT); | ||
101 | - return 0; | ||
102 | + return RISCV_EXCP_NONE; | ||
103 | } | ||
104 | |||
105 | -static int read_fcsr(CPURISCVState *env, int csrno, target_ulong *val) | ||
106 | +static RISCVException read_fcsr(CPURISCVState *env, int csrno, | ||
107 | + target_ulong *val) | ||
108 | { | ||
109 | #if !defined(CONFIG_USER_ONLY) | ||
110 | if (!env->debugger && !riscv_cpu_fp_enabled(env)) { | ||
111 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
112 | + return RISCV_EXCP_ILLEGAL_INST; | ||
113 | } | ||
114 | #endif | ||
115 | *val = (riscv_cpu_get_fflags(env) << FSR_AEXC_SHIFT) | ||
116 | @@ -XXX,XX +XXX,XX @@ static int read_fcsr(CPURISCVState *env, int csrno, target_ulong *val) | ||
117 | *val |= (env->vxrm << FSR_VXRM_SHIFT) | ||
118 | | (env->vxsat << FSR_VXSAT_SHIFT); | ||
119 | } | ||
120 | - return 0; | ||
121 | + return RISCV_EXCP_NONE; | ||
122 | } | ||
123 | |||
124 | -static int write_fcsr(CPURISCVState *env, int csrno, target_ulong val) | ||
125 | +static RISCVException write_fcsr(CPURISCVState *env, int csrno, | ||
126 | + target_ulong val) | ||
127 | { | ||
128 | #if !defined(CONFIG_USER_ONLY) | ||
129 | if (!env->debugger && !riscv_cpu_fp_enabled(env)) { | ||
130 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
131 | + return RISCV_EXCP_ILLEGAL_INST; | ||
132 | } | ||
133 | env->mstatus |= MSTATUS_FS; | ||
134 | #endif | ||
135 | @@ -XXX,XX +XXX,XX @@ static int write_fcsr(CPURISCVState *env, int csrno, target_ulong val) | ||
136 | env->vxsat = (val & FSR_VXSAT) >> FSR_VXSAT_SHIFT; | ||
137 | } | ||
138 | riscv_cpu_set_fflags(env, (val & FSR_AEXC) >> FSR_AEXC_SHIFT); | ||
139 | - return 0; | ||
140 | + return RISCV_EXCP_NONE; | ||
141 | } | ||
142 | |||
143 | -static int read_vtype(CPURISCVState *env, int csrno, target_ulong *val) | ||
144 | +static RISCVException read_vtype(CPURISCVState *env, int csrno, | ||
145 | + target_ulong *val) | ||
146 | { | ||
147 | *val = env->vtype; | ||
148 | - return 0; | ||
149 | + return RISCV_EXCP_NONE; | ||
150 | } | ||
151 | |||
152 | -static int read_vl(CPURISCVState *env, int csrno, target_ulong *val) | ||
153 | +static RISCVException read_vl(CPURISCVState *env, int csrno, | ||
154 | + target_ulong *val) | ||
155 | { | ||
156 | *val = env->vl; | ||
157 | - return 0; | ||
158 | + return RISCV_EXCP_NONE; | ||
159 | } | ||
160 | |||
161 | -static int read_vxrm(CPURISCVState *env, int csrno, target_ulong *val) | ||
162 | +static RISCVException read_vxrm(CPURISCVState *env, int csrno, | ||
163 | + target_ulong *val) | ||
164 | { | ||
165 | *val = env->vxrm; | ||
166 | - return 0; | ||
167 | + return RISCV_EXCP_NONE; | ||
168 | } | ||
169 | |||
170 | -static int write_vxrm(CPURISCVState *env, int csrno, target_ulong val) | ||
171 | +static RISCVException write_vxrm(CPURISCVState *env, int csrno, | ||
172 | + target_ulong val) | ||
173 | { | ||
174 | env->vxrm = val; | ||
175 | - return 0; | ||
176 | + return RISCV_EXCP_NONE; | ||
177 | } | ||
178 | |||
179 | -static int read_vxsat(CPURISCVState *env, int csrno, target_ulong *val) | ||
180 | +static RISCVException read_vxsat(CPURISCVState *env, int csrno, | ||
181 | + target_ulong *val) | ||
182 | { | ||
183 | *val = env->vxsat; | ||
184 | - return 0; | ||
185 | + return RISCV_EXCP_NONE; | ||
186 | } | ||
187 | |||
188 | -static int write_vxsat(CPURISCVState *env, int csrno, target_ulong val) | ||
189 | +static RISCVException write_vxsat(CPURISCVState *env, int csrno, | ||
190 | + target_ulong val) | ||
191 | { | ||
192 | env->vxsat = val; | ||
193 | - return 0; | ||
194 | + return RISCV_EXCP_NONE; | ||
195 | } | ||
196 | |||
197 | -static int read_vstart(CPURISCVState *env, int csrno, target_ulong *val) | ||
198 | +static RISCVException read_vstart(CPURISCVState *env, int csrno, | ||
199 | + target_ulong *val) | ||
200 | { | ||
201 | *val = env->vstart; | ||
202 | - return 0; | ||
203 | + return RISCV_EXCP_NONE; | ||
204 | } | ||
205 | |||
206 | -static int write_vstart(CPURISCVState *env, int csrno, target_ulong val) | ||
207 | +static RISCVException write_vstart(CPURISCVState *env, int csrno, | ||
208 | + target_ulong val) | ||
209 | { | ||
210 | env->vstart = val; | ||
211 | - return 0; | ||
212 | + return RISCV_EXCP_NONE; | ||
213 | } | ||
214 | |||
215 | /* User Timers and Counters */ | ||
216 | -static int read_instret(CPURISCVState *env, int csrno, target_ulong *val) | ||
217 | +static RISCVException read_instret(CPURISCVState *env, int csrno, | ||
218 | + target_ulong *val) | ||
219 | { | ||
220 | #if !defined(CONFIG_USER_ONLY) | ||
221 | if (icount_enabled()) { | ||
222 | @@ -XXX,XX +XXX,XX @@ static int read_instret(CPURISCVState *env, int csrno, target_ulong *val) | ||
223 | #else | ||
224 | *val = cpu_get_host_ticks(); | ||
225 | #endif | ||
226 | - return 0; | ||
227 | + return RISCV_EXCP_NONE; | ||
228 | } | ||
229 | |||
230 | -static int read_instreth(CPURISCVState *env, int csrno, target_ulong *val) | ||
231 | +static RISCVException read_instreth(CPURISCVState *env, int csrno, | ||
232 | + target_ulong *val) | ||
233 | { | ||
234 | #if !defined(CONFIG_USER_ONLY) | ||
235 | if (icount_enabled()) { | ||
236 | @@ -XXX,XX +XXX,XX @@ static int read_instreth(CPURISCVState *env, int csrno, target_ulong *val) | ||
237 | #else | ||
238 | *val = cpu_get_host_ticks() >> 32; | ||
239 | #endif | ||
240 | - return 0; | ||
241 | + return RISCV_EXCP_NONE; | ||
242 | } | ||
243 | |||
244 | #if defined(CONFIG_USER_ONLY) | ||
245 | -static int read_time(CPURISCVState *env, int csrno, target_ulong *val) | ||
246 | +static RISCVException read_time(CPURISCVState *env, int csrno, | ||
247 | + target_ulong *val) | ||
248 | { | ||
249 | *val = cpu_get_host_ticks(); | ||
250 | - return 0; | ||
251 | + return RISCV_EXCP_NONE; | ||
252 | } | ||
253 | |||
254 | -static int read_timeh(CPURISCVState *env, int csrno, target_ulong *val) | ||
255 | +static RISCVException read_timeh(CPURISCVState *env, int csrno, | ||
256 | + target_ulong *val) | ||
257 | { | ||
258 | *val = cpu_get_host_ticks() >> 32; | ||
259 | - return 0; | ||
260 | + return RISCV_EXCP_NONE; | ||
261 | } | ||
262 | |||
263 | #else /* CONFIG_USER_ONLY */ | ||
264 | |||
265 | -static int read_time(CPURISCVState *env, int csrno, target_ulong *val) | ||
266 | +static RISCVException read_time(CPURISCVState *env, int csrno, | ||
267 | + target_ulong *val) | ||
268 | { | ||
269 | uint64_t delta = riscv_cpu_virt_enabled(env) ? env->htimedelta : 0; | ||
270 | |||
271 | if (!env->rdtime_fn) { | ||
272 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
273 | + return RISCV_EXCP_ILLEGAL_INST; | ||
274 | } | ||
275 | |||
276 | *val = env->rdtime_fn(env->rdtime_fn_arg) + delta; | ||
277 | - return 0; | ||
278 | + return RISCV_EXCP_NONE; | ||
279 | } | ||
280 | |||
281 | -static int read_timeh(CPURISCVState *env, int csrno, target_ulong *val) | ||
282 | +static RISCVException read_timeh(CPURISCVState *env, int csrno, | ||
283 | + target_ulong *val) | ||
284 | { | ||
285 | uint64_t delta = riscv_cpu_virt_enabled(env) ? env->htimedelta : 0; | ||
286 | |||
287 | if (!env->rdtime_fn) { | ||
288 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
289 | + return RISCV_EXCP_ILLEGAL_INST; | ||
290 | } | ||
291 | |||
292 | *val = (env->rdtime_fn(env->rdtime_fn_arg) + delta) >> 32; | ||
293 | - return 0; | ||
294 | + return RISCV_EXCP_NONE; | ||
295 | } | ||
296 | |||
297 | /* Machine constants */ | ||
298 | @@ -XXX,XX +XXX,XX @@ static const char valid_vm_1_10_64[16] = { | ||
299 | }; | ||
300 | |||
301 | /* Machine Information Registers */ | ||
302 | -static int read_zero(CPURISCVState *env, int csrno, target_ulong *val) | ||
303 | +static RISCVException read_zero(CPURISCVState *env, int csrno, | ||
304 | + target_ulong *val) | ||
305 | { | ||
306 | - return *val = 0; | ||
307 | + *val = 0; | ||
308 | + return RISCV_EXCP_NONE; | ||
309 | } | ||
310 | |||
311 | -static int read_mhartid(CPURISCVState *env, int csrno, target_ulong *val) | ||
312 | +static RISCVException read_mhartid(CPURISCVState *env, int csrno, | ||
313 | + target_ulong *val) | ||
314 | { | ||
315 | *val = env->mhartid; | ||
316 | - return 0; | ||
317 | + return RISCV_EXCP_NONE; | ||
318 | } | ||
319 | |||
320 | /* Machine Trap Setup */ | ||
321 | -static int read_mstatus(CPURISCVState *env, int csrno, target_ulong *val) | ||
322 | +static RISCVException read_mstatus(CPURISCVState *env, int csrno, | ||
323 | + target_ulong *val) | ||
324 | { | ||
325 | *val = env->mstatus; | ||
326 | - return 0; | ||
327 | + return RISCV_EXCP_NONE; | ||
328 | } | ||
329 | |||
330 | static int validate_vm(CPURISCVState *env, target_ulong vm) | ||
331 | @@ -XXX,XX +XXX,XX @@ static int validate_vm(CPURISCVState *env, target_ulong vm) | ||
332 | } | ||
333 | } | ||
334 | |||
335 | -static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) | ||
336 | +static RISCVException write_mstatus(CPURISCVState *env, int csrno, | ||
337 | + target_ulong val) | ||
338 | { | ||
339 | uint64_t mstatus = env->mstatus; | ||
340 | uint64_t mask = 0; | ||
341 | @@ -XXX,XX +XXX,XX @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) | ||
342 | mstatus = set_field(mstatus, MSTATUS_SD, dirty); | ||
343 | env->mstatus = mstatus; | ||
344 | |||
345 | - return 0; | ||
346 | + return RISCV_EXCP_NONE; | ||
347 | } | ||
348 | |||
349 | -static int read_mstatush(CPURISCVState *env, int csrno, target_ulong *val) | ||
350 | +static RISCVException read_mstatush(CPURISCVState *env, int csrno, | ||
351 | + target_ulong *val) | ||
352 | { | ||
353 | *val = env->mstatus >> 32; | ||
354 | - return 0; | ||
355 | + return RISCV_EXCP_NONE; | ||
356 | } | ||
357 | |||
358 | -static int write_mstatush(CPURISCVState *env, int csrno, target_ulong val) | ||
359 | +static RISCVException write_mstatush(CPURISCVState *env, int csrno, | ||
360 | + target_ulong val) | ||
361 | { | ||
362 | uint64_t valh = (uint64_t)val << 32; | ||
363 | uint64_t mask = MSTATUS_MPV | MSTATUS_GVA; | ||
364 | @@ -XXX,XX +XXX,XX @@ static int write_mstatush(CPURISCVState *env, int csrno, target_ulong val) | ||
365 | |||
366 | env->mstatus = (env->mstatus & ~mask) | (valh & mask); | ||
367 | |||
368 | - return 0; | ||
369 | + return RISCV_EXCP_NONE; | ||
370 | } | ||
371 | |||
372 | -static int read_misa(CPURISCVState *env, int csrno, target_ulong *val) | ||
373 | +static RISCVException read_misa(CPURISCVState *env, int csrno, | ||
374 | + target_ulong *val) | ||
375 | { | ||
376 | *val = env->misa; | ||
377 | - return 0; | ||
378 | + return RISCV_EXCP_NONE; | ||
379 | } | ||
380 | |||
381 | -static int write_misa(CPURISCVState *env, int csrno, target_ulong val) | ||
382 | +static RISCVException write_misa(CPURISCVState *env, int csrno, | ||
383 | + target_ulong val) | ||
384 | { | ||
385 | if (!riscv_feature(env, RISCV_FEATURE_MISA)) { | ||
386 | /* drop write to misa */ | ||
387 | - return 0; | ||
388 | + return RISCV_EXCP_NONE; | ||
389 | } | ||
390 | |||
391 | /* 'I' or 'E' must be present */ | ||
392 | if (!(val & (RVI | RVE))) { | ||
393 | /* It is not, drop write to misa */ | ||
394 | - return 0; | ||
395 | + return RISCV_EXCP_NONE; | ||
396 | } | ||
397 | |||
398 | /* 'E' excludes all other extensions */ | ||
399 | @@ -XXX,XX +XXX,XX @@ static int write_misa(CPURISCVState *env, int csrno, target_ulong val) | ||
400 | /* when we support 'E' we can do "val = RVE;" however | ||
401 | * for now we just drop writes if 'E' is present. | ||
402 | */ | ||
403 | - return 0; | ||
404 | + return RISCV_EXCP_NONE; | ||
405 | } | ||
406 | |||
407 | /* Mask extensions that are not supported by this hart */ | ||
408 | @@ -XXX,XX +XXX,XX @@ static int write_misa(CPURISCVState *env, int csrno, target_ulong val) | ||
409 | |||
410 | env->misa = val; | ||
411 | |||
412 | - return 0; | ||
413 | + return RISCV_EXCP_NONE; | ||
414 | } | ||
415 | |||
416 | -static int read_medeleg(CPURISCVState *env, int csrno, target_ulong *val) | ||
417 | +static RISCVException read_medeleg(CPURISCVState *env, int csrno, | ||
418 | + target_ulong *val) | ||
419 | { | ||
420 | *val = env->medeleg; | ||
421 | - return 0; | ||
422 | + return RISCV_EXCP_NONE; | ||
423 | } | ||
424 | |||
425 | -static int write_medeleg(CPURISCVState *env, int csrno, target_ulong val) | ||
426 | +static RISCVException write_medeleg(CPURISCVState *env, int csrno, | ||
427 | + target_ulong val) | ||
428 | { | ||
429 | env->medeleg = (env->medeleg & ~delegable_excps) | (val & delegable_excps); | ||
430 | - return 0; | ||
431 | + return RISCV_EXCP_NONE; | ||
432 | } | ||
433 | |||
434 | -static int read_mideleg(CPURISCVState *env, int csrno, target_ulong *val) | ||
435 | +static RISCVException read_mideleg(CPURISCVState *env, int csrno, | ||
436 | + target_ulong *val) | ||
437 | { | ||
438 | *val = env->mideleg; | ||
439 | - return 0; | ||
440 | + return RISCV_EXCP_NONE; | ||
441 | } | ||
442 | |||
443 | -static int write_mideleg(CPURISCVState *env, int csrno, target_ulong val) | ||
444 | +static RISCVException write_mideleg(CPURISCVState *env, int csrno, | ||
445 | + target_ulong val) | ||
446 | { | ||
447 | env->mideleg = (env->mideleg & ~delegable_ints) | (val & delegable_ints); | ||
448 | if (riscv_has_ext(env, RVH)) { | ||
449 | env->mideleg |= VS_MODE_INTERRUPTS; | ||
450 | } | ||
451 | - return 0; | ||
452 | + return RISCV_EXCP_NONE; | ||
453 | } | ||
454 | |||
455 | -static int read_mie(CPURISCVState *env, int csrno, target_ulong *val) | ||
456 | +static RISCVException read_mie(CPURISCVState *env, int csrno, | ||
457 | + target_ulong *val) | ||
458 | { | ||
459 | *val = env->mie; | ||
460 | - return 0; | ||
461 | + return RISCV_EXCP_NONE; | ||
462 | } | ||
463 | |||
464 | -static int write_mie(CPURISCVState *env, int csrno, target_ulong val) | ||
465 | +static RISCVException write_mie(CPURISCVState *env, int csrno, | ||
466 | + target_ulong val) | ||
467 | { | ||
468 | env->mie = (env->mie & ~all_ints) | (val & all_ints); | ||
469 | - return 0; | ||
470 | + return RISCV_EXCP_NONE; | ||
471 | } | ||
472 | |||
473 | -static int read_mtvec(CPURISCVState *env, int csrno, target_ulong *val) | ||
474 | +static RISCVException read_mtvec(CPURISCVState *env, int csrno, | ||
475 | + target_ulong *val) | ||
476 | { | ||
477 | *val = env->mtvec; | ||
478 | - return 0; | ||
479 | + return RISCV_EXCP_NONE; | ||
480 | } | ||
481 | |||
482 | -static int write_mtvec(CPURISCVState *env, int csrno, target_ulong val) | ||
483 | +static RISCVException write_mtvec(CPURISCVState *env, int csrno, | ||
484 | + target_ulong val) | ||
485 | { | ||
486 | /* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ | ||
487 | if ((val & 3) < 2) { | ||
488 | @@ -XXX,XX +XXX,XX @@ static int write_mtvec(CPURISCVState *env, int csrno, target_ulong val) | ||
489 | } else { | ||
490 | qemu_log_mask(LOG_UNIMP, "CSR_MTVEC: reserved mode not supported\n"); | ||
491 | } | ||
492 | - return 0; | ||
493 | + return RISCV_EXCP_NONE; | ||
494 | } | ||
495 | |||
496 | -static int read_mcounteren(CPURISCVState *env, int csrno, target_ulong *val) | ||
497 | +static RISCVException read_mcounteren(CPURISCVState *env, int csrno, | ||
498 | + target_ulong *val) | ||
499 | { | ||
500 | *val = env->mcounteren; | ||
501 | - return 0; | ||
502 | + return RISCV_EXCP_NONE; | ||
503 | } | ||
504 | |||
505 | -static int write_mcounteren(CPURISCVState *env, int csrno, target_ulong val) | ||
506 | +static RISCVException write_mcounteren(CPURISCVState *env, int csrno, | ||
507 | + target_ulong val) | ||
508 | { | ||
509 | env->mcounteren = val; | ||
510 | - return 0; | ||
511 | + return RISCV_EXCP_NONE; | ||
512 | } | ||
513 | |||
514 | /* Machine Trap Handling */ | ||
515 | -static int read_mscratch(CPURISCVState *env, int csrno, target_ulong *val) | ||
516 | +static RISCVException read_mscratch(CPURISCVState *env, int csrno, | ||
517 | + target_ulong *val) | ||
518 | { | ||
519 | *val = env->mscratch; | ||
520 | - return 0; | ||
521 | + return RISCV_EXCP_NONE; | ||
522 | } | ||
523 | |||
524 | -static int write_mscratch(CPURISCVState *env, int csrno, target_ulong val) | ||
525 | +static RISCVException write_mscratch(CPURISCVState *env, int csrno, | ||
526 | + target_ulong val) | ||
527 | { | ||
528 | env->mscratch = val; | ||
529 | - return 0; | ||
530 | + return RISCV_EXCP_NONE; | ||
531 | } | ||
532 | |||
533 | -static int read_mepc(CPURISCVState *env, int csrno, target_ulong *val) | ||
534 | +static RISCVException read_mepc(CPURISCVState *env, int csrno, | ||
535 | + target_ulong *val) | ||
536 | { | ||
537 | *val = env->mepc; | ||
538 | - return 0; | ||
539 | + return RISCV_EXCP_NONE; | ||
540 | } | ||
541 | |||
542 | -static int write_mepc(CPURISCVState *env, int csrno, target_ulong val) | ||
543 | +static RISCVException write_mepc(CPURISCVState *env, int csrno, | ||
544 | + target_ulong val) | ||
545 | { | ||
546 | env->mepc = val; | ||
547 | - return 0; | ||
548 | + return RISCV_EXCP_NONE; | ||
549 | } | ||
550 | |||
551 | -static int read_mcause(CPURISCVState *env, int csrno, target_ulong *val) | ||
552 | +static RISCVException read_mcause(CPURISCVState *env, int csrno, | ||
553 | + target_ulong *val) | ||
554 | { | ||
555 | *val = env->mcause; | ||
556 | - return 0; | ||
557 | + return RISCV_EXCP_NONE; | ||
558 | } | ||
559 | |||
560 | -static int write_mcause(CPURISCVState *env, int csrno, target_ulong val) | ||
561 | +static RISCVException write_mcause(CPURISCVState *env, int csrno, | ||
562 | + target_ulong val) | ||
563 | { | ||
564 | env->mcause = val; | ||
565 | - return 0; | ||
566 | + return RISCV_EXCP_NONE; | ||
567 | } | ||
568 | |||
569 | -static int read_mtval(CPURISCVState *env, int csrno, target_ulong *val) | ||
570 | +static RISCVException read_mtval(CPURISCVState *env, int csrno, | ||
571 | + target_ulong *val) | ||
572 | { | ||
573 | *val = env->mtval; | ||
574 | - return 0; | ||
575 | + return RISCV_EXCP_NONE; | ||
576 | } | ||
577 | |||
578 | -static int write_mtval(CPURISCVState *env, int csrno, target_ulong val) | ||
579 | +static RISCVException write_mtval(CPURISCVState *env, int csrno, | ||
580 | + target_ulong val) | ||
581 | { | ||
582 | env->mtval = val; | ||
583 | - return 0; | ||
584 | + return RISCV_EXCP_NONE; | ||
585 | } | ||
586 | |||
587 | -static int rmw_mip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
588 | - target_ulong new_value, target_ulong write_mask) | ||
589 | +static RISCVException rmw_mip(CPURISCVState *env, int csrno, | ||
590 | + target_ulong *ret_value, | ||
591 | + target_ulong new_value, target_ulong write_mask) | ||
592 | { | ||
593 | RISCVCPU *cpu = env_archcpu(env); | ||
594 | /* Allow software control of delegable interrupts not claimed by hardware */ | ||
595 | @@ -XXX,XX +XXX,XX @@ static int rmw_mip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
596 | *ret_value = old_mip; | ||
597 | } | ||
598 | |||
599 | - return 0; | ||
600 | + return RISCV_EXCP_NONE; | ||
601 | } | ||
602 | |||
603 | /* Supervisor Trap Setup */ | ||
604 | -static int read_sstatus(CPURISCVState *env, int csrno, target_ulong *val) | ||
605 | +static RISCVException read_sstatus(CPURISCVState *env, int csrno, | ||
606 | + target_ulong *val) | ||
607 | { | ||
608 | target_ulong mask = (sstatus_v1_10_mask); | ||
609 | *val = env->mstatus & mask; | ||
610 | - return 0; | ||
611 | + return RISCV_EXCP_NONE; | ||
612 | } | ||
613 | |||
614 | -static int write_sstatus(CPURISCVState *env, int csrno, target_ulong val) | ||
615 | +static RISCVException write_sstatus(CPURISCVState *env, int csrno, | ||
616 | + target_ulong val) | ||
617 | { | ||
618 | target_ulong mask = (sstatus_v1_10_mask); | ||
619 | target_ulong newval = (env->mstatus & ~mask) | (val & mask); | ||
620 | return write_mstatus(env, CSR_MSTATUS, newval); | ||
621 | } | ||
622 | |||
623 | -static int read_vsie(CPURISCVState *env, int csrno, target_ulong *val) | ||
624 | +static RISCVException read_vsie(CPURISCVState *env, int csrno, | ||
625 | + target_ulong *val) | ||
626 | { | ||
627 | /* Shift the VS bits to their S bit location in vsie */ | ||
628 | *val = (env->mie & env->hideleg & VS_MODE_INTERRUPTS) >> 1; | ||
629 | - return 0; | ||
630 | + return RISCV_EXCP_NONE; | ||
631 | } | ||
632 | |||
633 | -static int read_sie(CPURISCVState *env, int csrno, target_ulong *val) | ||
634 | +static RISCVException read_sie(CPURISCVState *env, int csrno, | ||
635 | + target_ulong *val) | ||
636 | { | ||
637 | if (riscv_cpu_virt_enabled(env)) { | ||
638 | read_vsie(env, CSR_VSIE, val); | ||
639 | } else { | ||
640 | *val = env->mie & env->mideleg; | ||
641 | } | ||
642 | - return 0; | ||
643 | + return RISCV_EXCP_NONE; | ||
644 | } | ||
645 | |||
646 | -static int write_vsie(CPURISCVState *env, int csrno, target_ulong val) | ||
647 | +static RISCVException write_vsie(CPURISCVState *env, int csrno, | ||
648 | + target_ulong val) | ||
649 | { | ||
650 | /* Shift the S bits to their VS bit location in mie */ | ||
651 | target_ulong newval = (env->mie & ~VS_MODE_INTERRUPTS) | | ||
652 | @@ -XXX,XX +XXX,XX @@ static int write_sie(CPURISCVState *env, int csrno, target_ulong val) | ||
653 | write_mie(env, CSR_MIE, newval); | ||
654 | } | ||
655 | |||
656 | - return 0; | ||
657 | + return RISCV_EXCP_NONE; | ||
658 | } | ||
659 | |||
660 | -static int read_stvec(CPURISCVState *env, int csrno, target_ulong *val) | ||
661 | +static RISCVException read_stvec(CPURISCVState *env, int csrno, | ||
662 | + target_ulong *val) | ||
663 | { | ||
664 | *val = env->stvec; | ||
665 | - return 0; | ||
666 | + return RISCV_EXCP_NONE; | ||
667 | } | ||
668 | |||
669 | -static int write_stvec(CPURISCVState *env, int csrno, target_ulong val) | ||
670 | +static RISCVException write_stvec(CPURISCVState *env, int csrno, | ||
671 | + target_ulong val) | ||
672 | { | ||
673 | /* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ | ||
674 | if ((val & 3) < 2) { | ||
675 | @@ -XXX,XX +XXX,XX @@ static int write_stvec(CPURISCVState *env, int csrno, target_ulong val) | ||
676 | } else { | ||
677 | qemu_log_mask(LOG_UNIMP, "CSR_STVEC: reserved mode not supported\n"); | ||
678 | } | ||
679 | - return 0; | ||
680 | + return RISCV_EXCP_NONE; | ||
681 | } | ||
682 | |||
683 | -static int read_scounteren(CPURISCVState *env, int csrno, target_ulong *val) | ||
684 | +static RISCVException read_scounteren(CPURISCVState *env, int csrno, | ||
685 | + target_ulong *val) | ||
686 | { | ||
687 | *val = env->scounteren; | ||
688 | - return 0; | ||
689 | + return RISCV_EXCP_NONE; | ||
690 | } | ||
691 | |||
692 | -static int write_scounteren(CPURISCVState *env, int csrno, target_ulong val) | ||
693 | +static RISCVException write_scounteren(CPURISCVState *env, int csrno, | ||
694 | + target_ulong val) | ||
695 | { | ||
696 | env->scounteren = val; | ||
697 | - return 0; | ||
698 | + return RISCV_EXCP_NONE; | ||
699 | } | ||
700 | |||
701 | /* Supervisor Trap Handling */ | ||
702 | -static int read_sscratch(CPURISCVState *env, int csrno, target_ulong *val) | ||
703 | +static RISCVException read_sscratch(CPURISCVState *env, int csrno, | ||
704 | + target_ulong *val) | ||
705 | { | ||
706 | *val = env->sscratch; | ||
707 | - return 0; | ||
708 | + return RISCV_EXCP_NONE; | ||
709 | } | ||
710 | |||
711 | -static int write_sscratch(CPURISCVState *env, int csrno, target_ulong val) | ||
712 | +static RISCVException write_sscratch(CPURISCVState *env, int csrno, | ||
713 | + target_ulong val) | ||
714 | { | ||
715 | env->sscratch = val; | ||
716 | - return 0; | ||
717 | + return RISCV_EXCP_NONE; | ||
718 | } | ||
719 | |||
720 | -static int read_sepc(CPURISCVState *env, int csrno, target_ulong *val) | ||
721 | +static RISCVException read_sepc(CPURISCVState *env, int csrno, | ||
722 | + target_ulong *val) | ||
723 | { | ||
724 | *val = env->sepc; | ||
725 | - return 0; | ||
726 | + return RISCV_EXCP_NONE; | ||
727 | } | ||
728 | |||
729 | -static int write_sepc(CPURISCVState *env, int csrno, target_ulong val) | ||
730 | +static RISCVException write_sepc(CPURISCVState *env, int csrno, | ||
731 | + target_ulong val) | ||
732 | { | ||
733 | env->sepc = val; | ||
734 | - return 0; | ||
735 | + return RISCV_EXCP_NONE; | ||
736 | } | ||
737 | |||
738 | -static int read_scause(CPURISCVState *env, int csrno, target_ulong *val) | ||
739 | +static RISCVException read_scause(CPURISCVState *env, int csrno, | ||
740 | + target_ulong *val) | ||
741 | { | ||
742 | *val = env->scause; | ||
743 | - return 0; | ||
744 | + return RISCV_EXCP_NONE; | ||
745 | } | ||
746 | |||
747 | -static int write_scause(CPURISCVState *env, int csrno, target_ulong val) | ||
748 | +static RISCVException write_scause(CPURISCVState *env, int csrno, | ||
749 | + target_ulong val) | ||
750 | { | ||
751 | env->scause = val; | ||
752 | - return 0; | ||
753 | + return RISCV_EXCP_NONE; | ||
754 | } | ||
755 | |||
756 | -static int read_stval(CPURISCVState *env, int csrno, target_ulong *val) | ||
757 | +static RISCVException read_stval(CPURISCVState *env, int csrno, | ||
758 | + target_ulong *val) | ||
759 | { | ||
760 | *val = env->stval; | ||
761 | - return 0; | ||
762 | + return RISCV_EXCP_NONE; | ||
763 | } | ||
764 | |||
765 | -static int write_stval(CPURISCVState *env, int csrno, target_ulong val) | ||
766 | +static RISCVException write_stval(CPURISCVState *env, int csrno, | ||
767 | + target_ulong val) | ||
768 | { | ||
769 | env->stval = val; | ||
770 | - return 0; | ||
771 | + return RISCV_EXCP_NONE; | ||
772 | } | ||
773 | |||
774 | -static int rmw_vsip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
775 | - target_ulong new_value, target_ulong write_mask) | ||
776 | +static RISCVException rmw_vsip(CPURISCVState *env, int csrno, | ||
777 | + target_ulong *ret_value, | ||
778 | + target_ulong new_value, target_ulong write_mask) | ||
779 | { | ||
780 | /* Shift the S bits to their VS bit location in mip */ | ||
781 | int ret = rmw_mip(env, 0, ret_value, new_value << 1, | ||
782 | @@ -XXX,XX +XXX,XX @@ static int rmw_vsip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
783 | return ret; | ||
784 | } | ||
785 | |||
786 | -static int rmw_sip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
787 | - target_ulong new_value, target_ulong write_mask) | ||
788 | +static RISCVException rmw_sip(CPURISCVState *env, int csrno, | ||
789 | + target_ulong *ret_value, | ||
790 | + target_ulong new_value, target_ulong write_mask) | ||
791 | { | ||
792 | int ret; | ||
793 | |||
794 | @@ -XXX,XX +XXX,XX @@ static int rmw_sip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
795 | } | ||
796 | |||
797 | /* Supervisor Protection and Translation */ | ||
798 | -static int read_satp(CPURISCVState *env, int csrno, target_ulong *val) | ||
799 | +static RISCVException read_satp(CPURISCVState *env, int csrno, | ||
800 | + target_ulong *val) | ||
801 | { | ||
802 | if (!riscv_feature(env, RISCV_FEATURE_MMU)) { | ||
803 | *val = 0; | ||
804 | - return 0; | ||
805 | + return RISCV_EXCP_NONE; | ||
806 | } | ||
807 | |||
808 | if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { | ||
809 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
810 | + return RISCV_EXCP_ILLEGAL_INST; | ||
811 | } else { | ||
812 | *val = env->satp; | ||
813 | } | ||
814 | |||
815 | - return 0; | ||
816 | + return RISCV_EXCP_NONE; | ||
817 | } | ||
818 | |||
819 | -static int write_satp(CPURISCVState *env, int csrno, target_ulong val) | ||
820 | +static RISCVException write_satp(CPURISCVState *env, int csrno, | ||
821 | + target_ulong val) | ||
822 | { | ||
823 | if (!riscv_feature(env, RISCV_FEATURE_MMU)) { | ||
824 | - return 0; | ||
825 | + return RISCV_EXCP_NONE; | ||
826 | } | ||
827 | if (validate_vm(env, get_field(val, SATP_MODE)) && | ||
828 | ((val ^ env->satp) & (SATP_MODE | SATP_ASID | SATP_PPN))) | ||
829 | { | ||
830 | if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { | ||
831 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
832 | + return RISCV_EXCP_ILLEGAL_INST; | ||
833 | } else { | ||
834 | if ((val ^ env->satp) & SATP_ASID) { | ||
835 | tlb_flush(env_cpu(env)); | ||
836 | @@ -XXX,XX +XXX,XX @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val) | ||
837 | env->satp = val; | ||
838 | } | ||
839 | } | ||
840 | - return 0; | ||
841 | + return RISCV_EXCP_NONE; | ||
842 | } | ||
843 | |||
844 | /* Hypervisor Extensions */ | ||
845 | -static int read_hstatus(CPURISCVState *env, int csrno, target_ulong *val) | ||
846 | +static RISCVException read_hstatus(CPURISCVState *env, int csrno, | ||
847 | + target_ulong *val) | ||
848 | { | ||
849 | *val = env->hstatus; | ||
850 | if (!riscv_cpu_is_32bit(env)) { | ||
851 | @@ -XXX,XX +XXX,XX @@ static int read_hstatus(CPURISCVState *env, int csrno, target_ulong *val) | ||
852 | } | ||
853 | /* We only support little endian */ | ||
854 | *val = set_field(*val, HSTATUS_VSBE, 0); | ||
855 | - return 0; | ||
856 | + return RISCV_EXCP_NONE; | ||
857 | } | ||
858 | |||
859 | -static int write_hstatus(CPURISCVState *env, int csrno, target_ulong val) | ||
860 | +static RISCVException write_hstatus(CPURISCVState *env, int csrno, | ||
861 | + target_ulong val) | ||
862 | { | ||
863 | env->hstatus = val; | ||
864 | if (!riscv_cpu_is_32bit(env) && get_field(val, HSTATUS_VSXL) != 2) { | ||
865 | @@ -XXX,XX +XXX,XX @@ static int write_hstatus(CPURISCVState *env, int csrno, target_ulong val) | ||
866 | if (get_field(val, HSTATUS_VSBE) != 0) { | ||
867 | qemu_log_mask(LOG_UNIMP, "QEMU does not support big endian guests."); | ||
868 | } | ||
869 | - return 0; | ||
870 | + return RISCV_EXCP_NONE; | ||
871 | } | ||
872 | |||
873 | -static int read_hedeleg(CPURISCVState *env, int csrno, target_ulong *val) | ||
874 | +static RISCVException read_hedeleg(CPURISCVState *env, int csrno, | ||
875 | + target_ulong *val) | ||
876 | { | ||
877 | *val = env->hedeleg; | ||
878 | - return 0; | ||
879 | + return RISCV_EXCP_NONE; | ||
880 | } | ||
881 | |||
882 | -static int write_hedeleg(CPURISCVState *env, int csrno, target_ulong val) | ||
883 | +static RISCVException write_hedeleg(CPURISCVState *env, int csrno, | ||
884 | + target_ulong val) | ||
885 | { | ||
886 | env->hedeleg = val; | ||
887 | - return 0; | ||
888 | + return RISCV_EXCP_NONE; | ||
889 | } | ||
890 | |||
891 | -static int read_hideleg(CPURISCVState *env, int csrno, target_ulong *val) | ||
892 | +static RISCVException read_hideleg(CPURISCVState *env, int csrno, | ||
893 | + target_ulong *val) | ||
894 | { | ||
895 | *val = env->hideleg; | ||
896 | - return 0; | ||
897 | + return RISCV_EXCP_NONE; | ||
898 | } | ||
899 | |||
900 | -static int write_hideleg(CPURISCVState *env, int csrno, target_ulong val) | ||
901 | +static RISCVException write_hideleg(CPURISCVState *env, int csrno, | ||
902 | + target_ulong val) | ||
903 | { | ||
904 | env->hideleg = val; | ||
905 | - return 0; | ||
906 | + return RISCV_EXCP_NONE; | ||
907 | } | ||
908 | |||
909 | -static int rmw_hvip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
910 | - target_ulong new_value, target_ulong write_mask) | ||
911 | +static RISCVException rmw_hvip(CPURISCVState *env, int csrno, | ||
912 | + target_ulong *ret_value, | ||
913 | + target_ulong new_value, target_ulong write_mask) | ||
914 | { | ||
915 | int ret = rmw_mip(env, 0, ret_value, new_value, | ||
916 | write_mask & hvip_writable_mask); | ||
917 | @@ -XXX,XX +XXX,XX @@ static int rmw_hvip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
918 | return ret; | ||
919 | } | ||
920 | |||
921 | -static int rmw_hip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
922 | - target_ulong new_value, target_ulong write_mask) | ||
923 | +static RISCVException rmw_hip(CPURISCVState *env, int csrno, | ||
924 | + target_ulong *ret_value, | ||
925 | + target_ulong new_value, target_ulong write_mask) | ||
926 | { | ||
927 | int ret = rmw_mip(env, 0, ret_value, new_value, | ||
928 | write_mask & hip_writable_mask); | ||
929 | @@ -XXX,XX +XXX,XX @@ static int rmw_hip(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
930 | return ret; | ||
931 | } | ||
932 | |||
933 | -static int read_hie(CPURISCVState *env, int csrno, target_ulong *val) | ||
934 | +static RISCVException read_hie(CPURISCVState *env, int csrno, | ||
935 | + target_ulong *val) | ||
936 | { | ||
937 | *val = env->mie & VS_MODE_INTERRUPTS; | ||
938 | - return 0; | ||
939 | + return RISCV_EXCP_NONE; | ||
940 | } | ||
941 | |||
942 | -static int write_hie(CPURISCVState *env, int csrno, target_ulong val) | ||
943 | +static RISCVException write_hie(CPURISCVState *env, int csrno, | ||
944 | + target_ulong val) | ||
945 | { | ||
946 | target_ulong newval = (env->mie & ~VS_MODE_INTERRUPTS) | (val & VS_MODE_INTERRUPTS); | ||
947 | return write_mie(env, CSR_MIE, newval); | ||
948 | } | ||
949 | |||
950 | -static int read_hcounteren(CPURISCVState *env, int csrno, target_ulong *val) | ||
951 | +static RISCVException read_hcounteren(CPURISCVState *env, int csrno, | ||
952 | + target_ulong *val) | ||
953 | { | ||
954 | *val = env->hcounteren; | ||
955 | - return 0; | ||
956 | + return RISCV_EXCP_NONE; | ||
957 | } | ||
958 | |||
959 | -static int write_hcounteren(CPURISCVState *env, int csrno, target_ulong val) | ||
960 | +static RISCVException write_hcounteren(CPURISCVState *env, int csrno, | ||
961 | + target_ulong val) | ||
962 | { | ||
963 | env->hcounteren = val; | ||
964 | - return 0; | ||
965 | + return RISCV_EXCP_NONE; | ||
966 | } | ||
967 | |||
968 | -static int read_hgeie(CPURISCVState *env, int csrno, target_ulong *val) | ||
969 | +static RISCVException read_hgeie(CPURISCVState *env, int csrno, | ||
970 | + target_ulong *val) | ||
971 | { | ||
972 | qemu_log_mask(LOG_UNIMP, "No support for a non-zero GEILEN."); | ||
973 | - return 0; | ||
974 | + return RISCV_EXCP_NONE; | ||
975 | } | ||
976 | |||
977 | -static int write_hgeie(CPURISCVState *env, int csrno, target_ulong val) | ||
978 | +static RISCVException write_hgeie(CPURISCVState *env, int csrno, | ||
979 | + target_ulong val) | ||
980 | { | ||
981 | qemu_log_mask(LOG_UNIMP, "No support for a non-zero GEILEN."); | ||
982 | - return 0; | ||
983 | + return RISCV_EXCP_NONE; | ||
984 | } | ||
985 | |||
986 | -static int read_htval(CPURISCVState *env, int csrno, target_ulong *val) | ||
987 | +static RISCVException read_htval(CPURISCVState *env, int csrno, | ||
988 | + target_ulong *val) | ||
989 | { | ||
990 | *val = env->htval; | ||
991 | - return 0; | ||
992 | + return RISCV_EXCP_NONE; | ||
993 | } | ||
994 | |||
995 | -static int write_htval(CPURISCVState *env, int csrno, target_ulong val) | ||
996 | +static RISCVException write_htval(CPURISCVState *env, int csrno, | ||
997 | + target_ulong val) | ||
998 | { | ||
999 | env->htval = val; | ||
1000 | - return 0; | ||
1001 | + return RISCV_EXCP_NONE; | ||
1002 | } | ||
1003 | |||
1004 | -static int read_htinst(CPURISCVState *env, int csrno, target_ulong *val) | ||
1005 | +static RISCVException read_htinst(CPURISCVState *env, int csrno, | ||
1006 | + target_ulong *val) | ||
1007 | { | ||
1008 | *val = env->htinst; | ||
1009 | - return 0; | ||
1010 | + return RISCV_EXCP_NONE; | ||
1011 | } | ||
1012 | |||
1013 | -static int write_htinst(CPURISCVState *env, int csrno, target_ulong val) | ||
1014 | +static RISCVException write_htinst(CPURISCVState *env, int csrno, | ||
1015 | + target_ulong val) | ||
1016 | { | ||
1017 | - return 0; | ||
1018 | + return RISCV_EXCP_NONE; | ||
1019 | } | ||
1020 | |||
1021 | -static int read_hgeip(CPURISCVState *env, int csrno, target_ulong *val) | ||
1022 | +static RISCVException read_hgeip(CPURISCVState *env, int csrno, | ||
1023 | + target_ulong *val) | ||
1024 | { | ||
1025 | qemu_log_mask(LOG_UNIMP, "No support for a non-zero GEILEN."); | ||
1026 | - return 0; | ||
1027 | + return RISCV_EXCP_NONE; | ||
1028 | } | ||
1029 | |||
1030 | -static int write_hgeip(CPURISCVState *env, int csrno, target_ulong val) | ||
1031 | +static RISCVException write_hgeip(CPURISCVState *env, int csrno, | ||
1032 | + target_ulong val) | ||
1033 | { | ||
1034 | qemu_log_mask(LOG_UNIMP, "No support for a non-zero GEILEN."); | ||
1035 | - return 0; | ||
1036 | + return RISCV_EXCP_NONE; | ||
1037 | } | ||
1038 | |||
1039 | -static int read_hgatp(CPURISCVState *env, int csrno, target_ulong *val) | ||
1040 | +static RISCVException read_hgatp(CPURISCVState *env, int csrno, | ||
1041 | + target_ulong *val) | ||
1042 | { | ||
1043 | *val = env->hgatp; | ||
1044 | - return 0; | ||
1045 | + return RISCV_EXCP_NONE; | ||
1046 | } | ||
1047 | |||
1048 | -static int write_hgatp(CPURISCVState *env, int csrno, target_ulong val) | ||
1049 | +static RISCVException write_hgatp(CPURISCVState *env, int csrno, | ||
1050 | + target_ulong val) | ||
1051 | { | ||
1052 | env->hgatp = val; | ||
1053 | - return 0; | ||
1054 | + return RISCV_EXCP_NONE; | ||
1055 | } | ||
1056 | |||
1057 | -static int read_htimedelta(CPURISCVState *env, int csrno, target_ulong *val) | ||
1058 | +static RISCVException read_htimedelta(CPURISCVState *env, int csrno, | ||
1059 | + target_ulong *val) | ||
1060 | { | ||
1061 | if (!env->rdtime_fn) { | ||
1062 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
1063 | + return RISCV_EXCP_ILLEGAL_INST; | ||
1064 | } | ||
1065 | |||
1066 | *val = env->htimedelta; | ||
1067 | - return 0; | ||
1068 | + return RISCV_EXCP_NONE; | ||
1069 | } | ||
1070 | |||
1071 | -static int write_htimedelta(CPURISCVState *env, int csrno, target_ulong val) | ||
1072 | +static RISCVException write_htimedelta(CPURISCVState *env, int csrno, | ||
1073 | + target_ulong val) | ||
1074 | { | ||
1075 | if (!env->rdtime_fn) { | ||
1076 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
1077 | + return RISCV_EXCP_ILLEGAL_INST; | ||
1078 | } | ||
1079 | |||
1080 | if (riscv_cpu_is_32bit(env)) { | ||
1081 | @@ -XXX,XX +XXX,XX @@ static int write_htimedelta(CPURISCVState *env, int csrno, target_ulong val) | ||
1082 | } else { | ||
1083 | env->htimedelta = val; | ||
1084 | } | ||
1085 | - return 0; | ||
1086 | + return RISCV_EXCP_NONE; | ||
1087 | } | ||
1088 | |||
1089 | -static int read_htimedeltah(CPURISCVState *env, int csrno, target_ulong *val) | ||
1090 | +static RISCVException read_htimedeltah(CPURISCVState *env, int csrno, | ||
1091 | + target_ulong *val) | ||
1092 | { | ||
1093 | if (!env->rdtime_fn) { | ||
1094 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
1095 | + return RISCV_EXCP_ILLEGAL_INST; | ||
1096 | } | ||
1097 | |||
1098 | *val = env->htimedelta >> 32; | ||
1099 | - return 0; | ||
1100 | + return RISCV_EXCP_NONE; | ||
1101 | } | ||
1102 | |||
1103 | -static int write_htimedeltah(CPURISCVState *env, int csrno, target_ulong val) | ||
1104 | +static RISCVException write_htimedeltah(CPURISCVState *env, int csrno, | ||
1105 | + target_ulong val) | ||
1106 | { | ||
1107 | if (!env->rdtime_fn) { | ||
1108 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
1109 | + return RISCV_EXCP_ILLEGAL_INST; | ||
1110 | } | ||
1111 | |||
1112 | env->htimedelta = deposit64(env->htimedelta, 32, 32, (uint64_t)val); | ||
1113 | - return 0; | ||
1114 | + return RISCV_EXCP_NONE; | ||
1115 | } | ||
1116 | |||
1117 | /* Virtual CSR Registers */ | ||
1118 | -static int read_vsstatus(CPURISCVState *env, int csrno, target_ulong *val) | ||
1119 | +static RISCVException read_vsstatus(CPURISCVState *env, int csrno, | ||
1120 | + target_ulong *val) | ||
1121 | { | ||
1122 | *val = env->vsstatus; | ||
1123 | - return 0; | ||
1124 | + return RISCV_EXCP_NONE; | ||
1125 | } | ||
1126 | |||
1127 | -static int write_vsstatus(CPURISCVState *env, int csrno, target_ulong val) | ||
1128 | +static RISCVException write_vsstatus(CPURISCVState *env, int csrno, | ||
1129 | + target_ulong val) | ||
1130 | { | ||
1131 | uint64_t mask = (target_ulong)-1; | ||
1132 | env->vsstatus = (env->vsstatus & ~mask) | (uint64_t)val; | ||
1133 | - return 0; | ||
1134 | + return RISCV_EXCP_NONE; | ||
1135 | } | ||
1136 | |||
1137 | static int read_vstvec(CPURISCVState *env, int csrno, target_ulong *val) | ||
1138 | { | ||
1139 | *val = env->vstvec; | ||
1140 | - return 0; | ||
1141 | + return RISCV_EXCP_NONE; | ||
1142 | } | ||
1143 | |||
1144 | -static int write_vstvec(CPURISCVState *env, int csrno, target_ulong val) | ||
1145 | +static RISCVException write_vstvec(CPURISCVState *env, int csrno, | ||
1146 | + target_ulong val) | ||
1147 | { | ||
1148 | env->vstvec = val; | ||
1149 | - return 0; | ||
1150 | + return RISCV_EXCP_NONE; | ||
1151 | } | ||
1152 | |||
1153 | -static int read_vsscratch(CPURISCVState *env, int csrno, target_ulong *val) | ||
1154 | +static RISCVException read_vsscratch(CPURISCVState *env, int csrno, | ||
1155 | + target_ulong *val) | ||
1156 | { | ||
1157 | *val = env->vsscratch; | ||
1158 | - return 0; | ||
1159 | + return RISCV_EXCP_NONE; | ||
1160 | } | ||
1161 | |||
1162 | -static int write_vsscratch(CPURISCVState *env, int csrno, target_ulong val) | ||
1163 | +static RISCVException write_vsscratch(CPURISCVState *env, int csrno, | ||
1164 | + target_ulong val) | ||
1165 | { | ||
1166 | env->vsscratch = val; | ||
1167 | - return 0; | ||
1168 | + return RISCV_EXCP_NONE; | ||
1169 | } | ||
1170 | |||
1171 | -static int read_vsepc(CPURISCVState *env, int csrno, target_ulong *val) | ||
1172 | +static RISCVException read_vsepc(CPURISCVState *env, int csrno, | ||
1173 | + target_ulong *val) | ||
1174 | { | ||
1175 | *val = env->vsepc; | ||
1176 | - return 0; | ||
1177 | + return RISCV_EXCP_NONE; | ||
1178 | } | ||
1179 | |||
1180 | -static int write_vsepc(CPURISCVState *env, int csrno, target_ulong val) | ||
1181 | +static RISCVException write_vsepc(CPURISCVState *env, int csrno, | ||
1182 | + target_ulong val) | ||
1183 | { | ||
1184 | env->vsepc = val; | ||
1185 | - return 0; | ||
1186 | + return RISCV_EXCP_NONE; | ||
1187 | } | ||
1188 | |||
1189 | -static int read_vscause(CPURISCVState *env, int csrno, target_ulong *val) | ||
1190 | +static RISCVException read_vscause(CPURISCVState *env, int csrno, | ||
1191 | + target_ulong *val) | ||
1192 | { | ||
1193 | *val = env->vscause; | ||
1194 | - return 0; | ||
1195 | + return RISCV_EXCP_NONE; | ||
1196 | } | ||
1197 | |||
1198 | -static int write_vscause(CPURISCVState *env, int csrno, target_ulong val) | ||
1199 | +static RISCVException write_vscause(CPURISCVState *env, int csrno, | ||
1200 | + target_ulong val) | ||
1201 | { | ||
1202 | env->vscause = val; | ||
1203 | - return 0; | ||
1204 | + return RISCV_EXCP_NONE; | ||
1205 | } | ||
1206 | |||
1207 | -static int read_vstval(CPURISCVState *env, int csrno, target_ulong *val) | ||
1208 | +static RISCVException read_vstval(CPURISCVState *env, int csrno, | ||
1209 | + target_ulong *val) | ||
1210 | { | ||
1211 | *val = env->vstval; | ||
1212 | - return 0; | ||
1213 | + return RISCV_EXCP_NONE; | ||
1214 | } | ||
1215 | |||
1216 | -static int write_vstval(CPURISCVState *env, int csrno, target_ulong val) | ||
1217 | +static RISCVException write_vstval(CPURISCVState *env, int csrno, | ||
1218 | + target_ulong val) | ||
1219 | { | ||
1220 | env->vstval = val; | ||
1221 | - return 0; | ||
1222 | + return RISCV_EXCP_NONE; | ||
1223 | } | ||
1224 | |||
1225 | -static int read_vsatp(CPURISCVState *env, int csrno, target_ulong *val) | ||
1226 | +static RISCVException read_vsatp(CPURISCVState *env, int csrno, | ||
1227 | + target_ulong *val) | ||
1228 | { | ||
1229 | *val = env->vsatp; | ||
1230 | - return 0; | ||
1231 | + return RISCV_EXCP_NONE; | ||
1232 | } | ||
1233 | |||
1234 | -static int write_vsatp(CPURISCVState *env, int csrno, target_ulong val) | ||
1235 | +static RISCVException write_vsatp(CPURISCVState *env, int csrno, | ||
1236 | + target_ulong val) | ||
1237 | { | ||
1238 | env->vsatp = val; | ||
1239 | - return 0; | ||
1240 | + return RISCV_EXCP_NONE; | ||
1241 | } | ||
1242 | |||
1243 | -static int read_mtval2(CPURISCVState *env, int csrno, target_ulong *val) | ||
1244 | +static RISCVException read_mtval2(CPURISCVState *env, int csrno, | ||
1245 | + target_ulong *val) | ||
1246 | { | ||
1247 | *val = env->mtval2; | ||
1248 | - return 0; | ||
1249 | + return RISCV_EXCP_NONE; | ||
1250 | } | ||
1251 | |||
1252 | -static int write_mtval2(CPURISCVState *env, int csrno, target_ulong val) | ||
1253 | +static RISCVException write_mtval2(CPURISCVState *env, int csrno, | ||
1254 | + target_ulong val) | ||
1255 | { | ||
1256 | env->mtval2 = val; | ||
1257 | - return 0; | ||
1258 | + return RISCV_EXCP_NONE; | ||
1259 | } | ||
1260 | |||
1261 | -static int read_mtinst(CPURISCVState *env, int csrno, target_ulong *val) | ||
1262 | +static RISCVException read_mtinst(CPURISCVState *env, int csrno, | ||
1263 | + target_ulong *val) | ||
1264 | { | ||
1265 | *val = env->mtinst; | ||
1266 | - return 0; | ||
1267 | + return RISCV_EXCP_NONE; | ||
1268 | } | ||
1269 | |||
1270 | -static int write_mtinst(CPURISCVState *env, int csrno, target_ulong val) | ||
1271 | +static RISCVException write_mtinst(CPURISCVState *env, int csrno, | ||
1272 | + target_ulong val) | ||
1273 | { | ||
1274 | env->mtinst = val; | ||
1275 | - return 0; | ||
1276 | + return RISCV_EXCP_NONE; | ||
1277 | } | ||
1278 | |||
1279 | /* Physical Memory Protection */ | ||
1280 | -static int read_pmpcfg(CPURISCVState *env, int csrno, target_ulong *val) | ||
1281 | +static RISCVException read_pmpcfg(CPURISCVState *env, int csrno, | ||
1282 | + target_ulong *val) | ||
1283 | { | ||
1284 | *val = pmpcfg_csr_read(env, csrno - CSR_PMPCFG0); | ||
1285 | - return 0; | ||
1286 | + return RISCV_EXCP_NONE; | ||
1287 | } | ||
1288 | |||
1289 | -static int write_pmpcfg(CPURISCVState *env, int csrno, target_ulong val) | ||
1290 | +static RISCVException write_pmpcfg(CPURISCVState *env, int csrno, | ||
1291 | + target_ulong val) | ||
1292 | { | ||
1293 | pmpcfg_csr_write(env, csrno - CSR_PMPCFG0, val); | ||
1294 | - return 0; | ||
1295 | + return RISCV_EXCP_NONE; | ||
1296 | } | ||
1297 | |||
1298 | -static int read_pmpaddr(CPURISCVState *env, int csrno, target_ulong *val) | ||
1299 | +static RISCVException read_pmpaddr(CPURISCVState *env, int csrno, | ||
1300 | + target_ulong *val) | ||
1301 | { | ||
1302 | *val = pmpaddr_csr_read(env, csrno - CSR_PMPADDR0); | ||
1303 | - return 0; | ||
1304 | + return RISCV_EXCP_NONE; | ||
1305 | } | ||
1306 | |||
1307 | -static int write_pmpaddr(CPURISCVState *env, int csrno, target_ulong val) | ||
1308 | +static RISCVException write_pmpaddr(CPURISCVState *env, int csrno, | ||
1309 | + target_ulong val) | ||
1310 | { | ||
1311 | pmpaddr_csr_write(env, csrno - CSR_PMPADDR0, val); | ||
1312 | - return 0; | ||
1313 | + return RISCV_EXCP_NONE; | ||
1314 | } | ||
1315 | |||
1316 | #endif | ||
1317 | @@ -XXX,XX +XXX,XX @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
1318 | |||
1319 | /* execute combined read/write operation if it exists */ | ||
1320 | if (csr_ops[csrno].op) { | ||
1321 | - return csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask); | ||
1322 | + ret = csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask); | ||
1323 | + if (ret != RISCV_EXCP_NONE) { | ||
1324 | + return -ret; | ||
1325 | + } | ||
1326 | + return 0; | ||
1327 | } | ||
1328 | |||
1329 | /* if no accessor exists then return failure */ | ||
1330 | if (!csr_ops[csrno].read) { | ||
1331 | return -RISCV_EXCP_ILLEGAL_INST; | ||
1332 | } | ||
1333 | - | ||
1334 | /* read old value */ | ||
1335 | ret = csr_ops[csrno].read(env, csrno, &old_value); | ||
1336 | - if (ret < 0) { | ||
1337 | - return ret; | ||
1338 | + if (ret != RISCV_EXCP_NONE) { | ||
1339 | + return -ret; | ||
1340 | } | ||
1341 | |||
1342 | /* write value if writable and write mask set, otherwise drop writes */ | ||
1343 | @@ -XXX,XX +XXX,XX @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
1344 | new_value = (old_value & ~write_mask) | (new_value & write_mask); | ||
1345 | if (csr_ops[csrno].write) { | ||
1346 | ret = csr_ops[csrno].write(env, csrno, new_value); | ||
1347 | - if (ret < 0) { | ||
1348 | - return ret; | ||
1349 | + if (ret != RISCV_EXCP_NONE) { | ||
1350 | + return -ret; | ||
1351 | } | ||
1352 | } | ||
1353 | } | ||
1354 | -- | ||
1355 | 2.31.1 | ||
1356 | |||
1357 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
4 | Message-id: 302b208f40373557fa11b351b5c9f43039ca8ea3.1617290165.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/cpu.h | 11 +++++++---- | ||
7 | target/riscv/csr.c | 37 ++++++++++++++++++------------------- | ||
8 | target/riscv/gdbstub.c | 8 ++++---- | ||
9 | target/riscv/op_helper.c | 18 +++++++++--------- | ||
10 | 4 files changed, 38 insertions(+), 36 deletions(-) | ||
1 | 11 | ||
12 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/riscv/cpu.h | ||
15 | +++ b/target/riscv/cpu.h | ||
16 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, | ||
17 | *pflags = flags; | ||
18 | } | ||
19 | |||
20 | -int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
21 | - target_ulong new_value, target_ulong write_mask); | ||
22 | -int riscv_csrrw_debug(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
23 | - target_ulong new_value, target_ulong write_mask); | ||
24 | +RISCVException riscv_csrrw(CPURISCVState *env, int csrno, | ||
25 | + target_ulong *ret_value, | ||
26 | + target_ulong new_value, target_ulong write_mask); | ||
27 | +RISCVException riscv_csrrw_debug(CPURISCVState *env, int csrno, | ||
28 | + target_ulong *ret_value, | ||
29 | + target_ulong new_value, | ||
30 | + target_ulong write_mask); | ||
31 | |||
32 | static inline void riscv_csr_write(CPURISCVState *env, int csrno, | ||
33 | target_ulong val) | ||
34 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/riscv/csr.c | ||
37 | +++ b/target/riscv/csr.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static RISCVException write_pmpaddr(CPURISCVState *env, int csrno, | ||
39 | * csrrc <-> riscv_csrrw(env, csrno, ret_value, 0, value); | ||
40 | */ | ||
41 | |||
42 | -int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
43 | - target_ulong new_value, target_ulong write_mask) | ||
44 | +RISCVException riscv_csrrw(CPURISCVState *env, int csrno, | ||
45 | + target_ulong *ret_value, | ||
46 | + target_ulong new_value, target_ulong write_mask) | ||
47 | { | ||
48 | - int ret; | ||
49 | + RISCVException ret; | ||
50 | target_ulong old_value; | ||
51 | RISCVCPU *cpu = env_archcpu(env); | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
54 | |||
55 | if ((write_mask && read_only) || | ||
56 | (!env->debugger && (effective_priv < get_field(csrno, 0x300)))) { | ||
57 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
58 | + return RISCV_EXCP_ILLEGAL_INST; | ||
59 | } | ||
60 | #endif | ||
61 | |||
62 | /* ensure the CSR extension is enabled. */ | ||
63 | if (!cpu->cfg.ext_icsr) { | ||
64 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
65 | + return RISCV_EXCP_ILLEGAL_INST; | ||
66 | } | ||
67 | |||
68 | /* check predicate */ | ||
69 | if (!csr_ops[csrno].predicate) { | ||
70 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
71 | + return RISCV_EXCP_ILLEGAL_INST; | ||
72 | } | ||
73 | ret = csr_ops[csrno].predicate(env, csrno); | ||
74 | if (ret != RISCV_EXCP_NONE) { | ||
75 | - return -ret; | ||
76 | + return ret; | ||
77 | } | ||
78 | |||
79 | /* execute combined read/write operation if it exists */ | ||
80 | if (csr_ops[csrno].op) { | ||
81 | - ret = csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask); | ||
82 | - if (ret != RISCV_EXCP_NONE) { | ||
83 | - return -ret; | ||
84 | - } | ||
85 | - return 0; | ||
86 | + return csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask); | ||
87 | } | ||
88 | |||
89 | /* if no accessor exists then return failure */ | ||
90 | if (!csr_ops[csrno].read) { | ||
91 | - return -RISCV_EXCP_ILLEGAL_INST; | ||
92 | + return RISCV_EXCP_ILLEGAL_INST; | ||
93 | } | ||
94 | /* read old value */ | ||
95 | ret = csr_ops[csrno].read(env, csrno, &old_value); | ||
96 | if (ret != RISCV_EXCP_NONE) { | ||
97 | - return -ret; | ||
98 | + return ret; | ||
99 | } | ||
100 | |||
101 | /* write value if writable and write mask set, otherwise drop writes */ | ||
102 | @@ -XXX,XX +XXX,XX @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
103 | if (csr_ops[csrno].write) { | ||
104 | ret = csr_ops[csrno].write(env, csrno, new_value); | ||
105 | if (ret != RISCV_EXCP_NONE) { | ||
106 | - return -ret; | ||
107 | + return ret; | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | @@ -XXX,XX +XXX,XX @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
112 | *ret_value = old_value; | ||
113 | } | ||
114 | |||
115 | - return 0; | ||
116 | + return RISCV_EXCP_NONE; | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * Debugger support. If not in user mode, set env->debugger before the | ||
121 | * riscv_csrrw call and clear it after the call. | ||
122 | */ | ||
123 | -int riscv_csrrw_debug(CPURISCVState *env, int csrno, target_ulong *ret_value, | ||
124 | - target_ulong new_value, target_ulong write_mask) | ||
125 | +RISCVException riscv_csrrw_debug(CPURISCVState *env, int csrno, | ||
126 | + target_ulong *ret_value, | ||
127 | + target_ulong new_value, | ||
128 | + target_ulong write_mask) | ||
129 | { | ||
130 | - int ret; | ||
131 | + RISCVException ret; | ||
132 | #if !defined(CONFIG_USER_ONLY) | ||
133 | env->debugger = true; | ||
134 | #endif | ||
135 | diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/target/riscv/gdbstub.c | ||
138 | +++ b/target/riscv/gdbstub.c | ||
139 | @@ -XXX,XX +XXX,XX @@ static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) | ||
140 | */ | ||
141 | result = riscv_csrrw_debug(env, n - 32, &val, | ||
142 | 0, 0); | ||
143 | - if (result == 0) { | ||
144 | + if (result == RISCV_EXCP_NONE) { | ||
145 | return gdb_get_regl(buf, val); | ||
146 | } | ||
147 | } | ||
148 | @@ -XXX,XX +XXX,XX @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) | ||
149 | */ | ||
150 | result = riscv_csrrw_debug(env, n - 32, NULL, | ||
151 | val, -1); | ||
152 | - if (result == 0) { | ||
153 | + if (result == RISCV_EXCP_NONE) { | ||
154 | return sizeof(target_ulong); | ||
155 | } | ||
156 | } | ||
157 | @@ -XXX,XX +XXX,XX @@ static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n) | ||
158 | int result; | ||
159 | |||
160 | result = riscv_csrrw_debug(env, n, &val, 0, 0); | ||
161 | - if (result == 0) { | ||
162 | + if (result == RISCV_EXCP_NONE) { | ||
163 | return gdb_get_regl(buf, val); | ||
164 | } | ||
165 | } | ||
166 | @@ -XXX,XX +XXX,XX @@ static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n) | ||
167 | int result; | ||
168 | |||
169 | result = riscv_csrrw_debug(env, n, NULL, val, -1); | ||
170 | - if (result == 0) { | ||
171 | + if (result == RISCV_EXCP_NONE) { | ||
172 | return sizeof(target_ulong); | ||
173 | } | ||
174 | } | ||
175 | diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c | ||
176 | index XXXXXXX..XXXXXXX 100644 | ||
177 | --- a/target/riscv/op_helper.c | ||
178 | +++ b/target/riscv/op_helper.c | ||
179 | @@ -XXX,XX +XXX,XX @@ target_ulong helper_csrrw(CPURISCVState *env, target_ulong src, | ||
180 | target_ulong csr) | ||
181 | { | ||
182 | target_ulong val = 0; | ||
183 | - int ret = riscv_csrrw(env, csr, &val, src, -1); | ||
184 | + RISCVException ret = riscv_csrrw(env, csr, &val, src, -1); | ||
185 | |||
186 | - if (ret < 0) { | ||
187 | - riscv_raise_exception(env, -ret, GETPC()); | ||
188 | + if (ret != RISCV_EXCP_NONE) { | ||
189 | + riscv_raise_exception(env, ret, GETPC()); | ||
190 | } | ||
191 | return val; | ||
192 | } | ||
193 | @@ -XXX,XX +XXX,XX @@ target_ulong helper_csrrs(CPURISCVState *env, target_ulong src, | ||
194 | target_ulong csr, target_ulong rs1_pass) | ||
195 | { | ||
196 | target_ulong val = 0; | ||
197 | - int ret = riscv_csrrw(env, csr, &val, -1, rs1_pass ? src : 0); | ||
198 | + RISCVException ret = riscv_csrrw(env, csr, &val, -1, rs1_pass ? src : 0); | ||
199 | |||
200 | - if (ret < 0) { | ||
201 | - riscv_raise_exception(env, -ret, GETPC()); | ||
202 | + if (ret != RISCV_EXCP_NONE) { | ||
203 | + riscv_raise_exception(env, ret, GETPC()); | ||
204 | } | ||
205 | return val; | ||
206 | } | ||
207 | @@ -XXX,XX +XXX,XX @@ target_ulong helper_csrrc(CPURISCVState *env, target_ulong src, | ||
208 | target_ulong csr, target_ulong rs1_pass) | ||
209 | { | ||
210 | target_ulong val = 0; | ||
211 | - int ret = riscv_csrrw(env, csr, &val, 0, rs1_pass ? src : 0); | ||
212 | + RISCVException ret = riscv_csrrw(env, csr, &val, 0, rs1_pass ? src : 0); | ||
213 | |||
214 | - if (ret < 0) { | ||
215 | - riscv_raise_exception(env, -ret, GETPC()); | ||
216 | + if (ret != RISCV_EXCP_NONE) { | ||
217 | + riscv_raise_exception(env, ret, GETPC()); | ||
218 | } | ||
219 | return val; | ||
220 | } | ||
221 | -- | ||
222 | 2.31.1 | ||
223 | |||
224 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Update the RISC-V maintainers by removing Sagar and Bastian who haven't | ||
2 | been involved recently. | ||
1 | 3 | ||
4 | Also add Bin who has been helping with reviews. | ||
5 | |||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Acked-by: Bin Meng <bin.meng@windriver.com> | ||
8 | Acked-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 6564ba829c40ad9aa7d28f43be69d8eb5cf4b56b.1617749142.git.alistair.francis@wdc.com | ||
11 | --- | ||
12 | MAINTAINERS | 5 ++--- | ||
13 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/MAINTAINERS | ||
18 | +++ b/MAINTAINERS | ||
19 | @@ -XXX,XX +XXX,XX @@ F: tests/acceptance/machine_ppc.py | ||
20 | |||
21 | RISC-V TCG CPUs | ||
22 | M: Palmer Dabbelt <palmer@dabbelt.com> | ||
23 | -M: Alistair Francis <Alistair.Francis@wdc.com> | ||
24 | -M: Sagar Karandikar <sagark@eecs.berkeley.edu> | ||
25 | -M: Bastian Koppelmann <kbastian@mail.uni-paderborn.de> | ||
26 | +M: Alistair Francis <alistair.francis@wdc.com> | ||
27 | +M: Bin Meng <bin.meng@windriver.com> | ||
28 | L: qemu-riscv@nongnu.org | ||
29 | S: Supported | ||
30 | F: target/riscv/ | ||
31 | -- | ||
32 | 2.31.1 | ||
33 | |||
34 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Update the OpenTitan interrupt layout to match the latest OpenTitan | ||
2 | bitstreams. This involves changing the Ibex PLIC memory layout and the | ||
3 | UART interrupts. | ||
1 | 4 | ||
5 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
7 | Message-id: e92b696f1809c9fa4410da2e9f23c414db5a6960.1617202791.git.alistair.francis@wdc.com | ||
8 | --- | ||
9 | include/hw/riscv/opentitan.h | 16 ++++++++-------- | ||
10 | hw/intc/ibex_plic.c | 20 ++++++++++---------- | ||
11 | hw/riscv/opentitan.c | 8 ++++---- | ||
12 | 3 files changed, 22 insertions(+), 22 deletions(-) | ||
13 | |||
14 | diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/riscv/opentitan.h | ||
17 | +++ b/include/hw/riscv/opentitan.h | ||
18 | @@ -XXX,XX +XXX,XX @@ enum { | ||
19 | }; | ||
20 | |||
21 | enum { | ||
22 | - IBEX_UART_RX_PARITY_ERR_IRQ = 0x28, | ||
23 | - IBEX_UART_RX_TIMEOUT_IRQ = 0x27, | ||
24 | - IBEX_UART_RX_BREAK_ERR_IRQ = 0x26, | ||
25 | - IBEX_UART_RX_FRAME_ERR_IRQ = 0x25, | ||
26 | - IBEX_UART_RX_OVERFLOW_IRQ = 0x24, | ||
27 | - IBEX_UART_TX_EMPTY_IRQ = 0x23, | ||
28 | - IBEX_UART_RX_WATERMARK_IRQ = 0x22, | ||
29 | - IBEX_UART_TX_WATERMARK_IRQ = 0x21, | ||
30 | + IBEX_UART0_RX_PARITY_ERR_IRQ = 8, | ||
31 | + IBEX_UART0_RX_TIMEOUT_IRQ = 7, | ||
32 | + IBEX_UART0_RX_BREAK_ERR_IRQ = 6, | ||
33 | + IBEX_UART0_RX_FRAME_ERR_IRQ = 5, | ||
34 | + IBEX_UART0_RX_OVERFLOW_IRQ = 4, | ||
35 | + IBEX_UART0_TX_EMPTY_IRQ = 3, | ||
36 | + IBEX_UART0_RX_WATERMARK_IRQ = 2, | ||
37 | + IBEX_UART0_TX_WATERMARK_IRQ = 1, | ||
38 | }; | ||
39 | |||
40 | #endif | ||
41 | diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/intc/ibex_plic.c | ||
44 | +++ b/hw/intc/ibex_plic.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void ibex_plic_irq_request(void *opaque, int irq, int level) | ||
46 | |||
47 | static Property ibex_plic_properties[] = { | ||
48 | DEFINE_PROP_UINT32("num-cpus", IbexPlicState, num_cpus, 1), | ||
49 | - DEFINE_PROP_UINT32("num-sources", IbexPlicState, num_sources, 80), | ||
50 | + DEFINE_PROP_UINT32("num-sources", IbexPlicState, num_sources, 176), | ||
51 | |||
52 | DEFINE_PROP_UINT32("pending-base", IbexPlicState, pending_base, 0), | ||
53 | - DEFINE_PROP_UINT32("pending-num", IbexPlicState, pending_num, 3), | ||
54 | + DEFINE_PROP_UINT32("pending-num", IbexPlicState, pending_num, 6), | ||
55 | |||
56 | - DEFINE_PROP_UINT32("source-base", IbexPlicState, source_base, 0x0c), | ||
57 | - DEFINE_PROP_UINT32("source-num", IbexPlicState, source_num, 3), | ||
58 | + DEFINE_PROP_UINT32("source-base", IbexPlicState, source_base, 0x18), | ||
59 | + DEFINE_PROP_UINT32("source-num", IbexPlicState, source_num, 6), | ||
60 | |||
61 | - DEFINE_PROP_UINT32("priority-base", IbexPlicState, priority_base, 0x18), | ||
62 | - DEFINE_PROP_UINT32("priority-num", IbexPlicState, priority_num, 80), | ||
63 | + DEFINE_PROP_UINT32("priority-base", IbexPlicState, priority_base, 0x30), | ||
64 | + DEFINE_PROP_UINT32("priority-num", IbexPlicState, priority_num, 177), | ||
65 | |||
66 | - DEFINE_PROP_UINT32("enable-base", IbexPlicState, enable_base, 0x200), | ||
67 | - DEFINE_PROP_UINT32("enable-num", IbexPlicState, enable_num, 3), | ||
68 | + DEFINE_PROP_UINT32("enable-base", IbexPlicState, enable_base, 0x300), | ||
69 | + DEFINE_PROP_UINT32("enable-num", IbexPlicState, enable_num, 6), | ||
70 | |||
71 | - DEFINE_PROP_UINT32("threshold-base", IbexPlicState, threshold_base, 0x20c), | ||
72 | + DEFINE_PROP_UINT32("threshold-base", IbexPlicState, threshold_base, 0x318), | ||
73 | |||
74 | - DEFINE_PROP_UINT32("claim-base", IbexPlicState, claim_base, 0x210), | ||
75 | + DEFINE_PROP_UINT32("claim-base", IbexPlicState, claim_base, 0x31c), | ||
76 | DEFINE_PROP_END_OF_LIST(), | ||
77 | }; | ||
78 | |||
79 | diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/riscv/opentitan.c | ||
82 | +++ b/hw/riscv/opentitan.c | ||
83 | @@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) | ||
84 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart), 0, memmap[IBEX_DEV_UART].base); | ||
85 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), | ||
86 | 0, qdev_get_gpio_in(DEVICE(&s->plic), | ||
87 | - IBEX_UART_TX_WATERMARK_IRQ)); | ||
88 | + IBEX_UART0_TX_WATERMARK_IRQ)); | ||
89 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), | ||
90 | 1, qdev_get_gpio_in(DEVICE(&s->plic), | ||
91 | - IBEX_UART_RX_WATERMARK_IRQ)); | ||
92 | + IBEX_UART0_RX_WATERMARK_IRQ)); | ||
93 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), | ||
94 | 2, qdev_get_gpio_in(DEVICE(&s->plic), | ||
95 | - IBEX_UART_TX_EMPTY_IRQ)); | ||
96 | + IBEX_UART0_TX_EMPTY_IRQ)); | ||
97 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), | ||
98 | 3, qdev_get_gpio_in(DEVICE(&s->plic), | ||
99 | - IBEX_UART_RX_OVERFLOW_IRQ)); | ||
100 | + IBEX_UART0_RX_OVERFLOW_IRQ)); | ||
101 | |||
102 | create_unimplemented_device("riscv.lowrisc.ibex.gpio", | ||
103 | memmap[IBEX_DEV_GPIO].base, memmap[IBEX_DEV_GPIO].size); | ||
104 | -- | ||
105 | 2.31.1 | ||
106 | |||
107 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | imply VIRTIO_VGA for the virt machine, this fixes the following error | ||
2 | when specifying `-vga virtio` as a command line argument: | ||
1 | 3 | ||
4 | qemu-system-riscv64: Virtio VGA not available | ||
5 | |||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
8 | Message-id: 7ac26fafee8bd59d2a0640f3233f8ad1ab270e1e.1617367317.git.alistair.francis@wdc.com | ||
9 | --- | ||
10 | hw/riscv/Kconfig | 1 + | ||
11 | 1 file changed, 1 insertion(+) | ||
12 | |||
13 | diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/riscv/Kconfig | ||
16 | +++ b/hw/riscv/Kconfig | ||
17 | @@ -XXX,XX +XXX,XX @@ config SHAKTI_C | ||
18 | config RISCV_VIRT | ||
19 | bool | ||
20 | imply PCI_DEVICES | ||
21 | + imply VIRTIO_VGA | ||
22 | imply TEST_DEVICES | ||
23 | select GOLDFISH_RTC | ||
24 | select MSI_NONBROKEN | ||
25 | -- | ||
26 | 2.31.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Jade Fink <qemu@jade.fyi> |
---|---|---|---|
2 | 2 | ||
3 | Once a "One Time Programmable" is programmed, it shouldn't be reset. | 3 | Previously the qemu monitor and gdbstub looked at SUM and refused to |
4 | perform accesses to user memory if it is off, which was an impediment to | ||
5 | debugging. | ||
4 | 6 | ||
5 | Do not re-initialize the OTP content in the DeviceReset handler, | 7 | Signed-off-by: Jade Fink <qemu@jade.fyi> |
6 | initialize it once in the DeviceRealize one. | ||
7 | |||
8 | Fixes: 9fb45c62ae8 ("riscv: sifive: Implement a model for SiFive FU540 OTP") | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
11 | Message-Id: <20211119104757.331579-1-f4bug@amsat.org> | 9 | Message-id: 20210406113109.1031033-1-qemu@jade.fyi |
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
13 | --- | 11 | --- |
14 | hw/misc/sifive_u_otp.c | 13 +++++-------- | 12 | target/riscv/cpu_helper.c | 20 ++++++++++++-------- |
15 | 1 file changed, 5 insertions(+), 8 deletions(-) | 13 | 1 file changed, 12 insertions(+), 8 deletions(-) |
16 | 14 | ||
17 | diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c | 15 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/misc/sifive_u_otp.c | 17 | --- a/target/riscv/cpu_helper.c |
20 | +++ b/hw/misc/sifive_u_otp.c | 18 | +++ b/target/riscv/cpu_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp) | 19 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address_pmp(CPURISCVState *env, int *prot, |
22 | 20 | * @first_stage: Are we in first stage translation? | |
23 | if (blk_pread(s->blk, 0, s->fuse, filesize) != filesize) { | 21 | * Second stage is used for hypervisor guest translation |
24 | error_setg(errp, "failed to read the initial flash content"); | 22 | * @two_stage: Are we going to perform two stage translation |
25 | + return; | 23 | + * @is_debug: Is this access from a debugger or the monitor? |
26 | } | 24 | */ |
25 | static int get_physical_address(CPURISCVState *env, hwaddr *physical, | ||
26 | int *prot, target_ulong addr, | ||
27 | target_ulong *fault_pte_addr, | ||
28 | int access_type, int mmu_idx, | ||
29 | - bool first_stage, bool two_stage) | ||
30 | + bool first_stage, bool two_stage, | ||
31 | + bool is_debug) | ||
32 | { | ||
33 | /* NOTE: the env->pc value visible here will not be | ||
34 | * correct, but the value visible to the exception handler | ||
35 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, | ||
36 | widened = 2; | ||
37 | } | ||
38 | /* status.SUM will be ignored if execute on background */ | ||
39 | - sum = get_field(env->mstatus, MSTATUS_SUM) || use_background; | ||
40 | + sum = get_field(env->mstatus, MSTATUS_SUM) || use_background || is_debug; | ||
41 | switch (vm) { | ||
42 | case VM_1_10_SV32: | ||
43 | levels = 2; ptidxbits = 10; ptesize = 4; break; | ||
44 | @@ -XXX,XX +XXX,XX @@ restart: | ||
45 | /* Do the second stage translation on the base PTE address. */ | ||
46 | int vbase_ret = get_physical_address(env, &vbase, &vbase_prot, | ||
47 | base, NULL, MMU_DATA_LOAD, | ||
48 | - mmu_idx, false, true); | ||
49 | + mmu_idx, false, true, | ||
50 | + is_debug); | ||
51 | |||
52 | if (vbase_ret != TRANSLATE_SUCCESS) { | ||
53 | if (fault_pte_addr) { | ||
54 | @@ -XXX,XX +XXX,XX @@ hwaddr riscv_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) | ||
55 | int mmu_idx = cpu_mmu_index(&cpu->env, false); | ||
56 | |||
57 | if (get_physical_address(env, &phys_addr, &prot, addr, NULL, 0, mmu_idx, | ||
58 | - true, riscv_cpu_virt_enabled(env))) { | ||
59 | + true, riscv_cpu_virt_enabled(env), true)) { | ||
60 | return -1; | ||
61 | } | ||
62 | |||
63 | if (riscv_cpu_virt_enabled(env)) { | ||
64 | if (get_physical_address(env, &phys_addr, &prot, phys_addr, NULL, | ||
65 | - 0, mmu_idx, false, true)) { | ||
66 | + 0, mmu_idx, false, true, true)) { | ||
67 | return -1; | ||
27 | } | 68 | } |
28 | } | 69 | } |
29 | -} | 70 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
30 | - | 71 | /* Two stage lookup */ |
31 | -static void sifive_u_otp_reset(DeviceState *dev) | 72 | ret = get_physical_address(env, &pa, &prot, address, |
32 | -{ | 73 | &env->guest_phys_fault_addr, access_type, |
33 | - SiFiveUOTPState *s = SIFIVE_U_OTP(dev); | 74 | - mmu_idx, true, true); |
34 | 75 | + mmu_idx, true, true, false); | |
35 | /* Initialize all fuses' initial value to 0xFFs */ | 76 | |
36 | memset(s->fuse, 0xff, sizeof(s->fuse)); | 77 | /* |
37 | @@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_reset(DeviceState *dev) | 78 | * A G-stage exception may be triggered during two state lookup. |
38 | serial_data = s->serial; | 79 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
39 | if (blk_pwrite(s->blk, index * SIFIVE_U_OTP_FUSE_WORD, | 80 | im_address = pa; |
40 | &serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) { | 81 | |
41 | - error_report("write error index<%d>", index); | 82 | ret = get_physical_address(env, &pa, &prot2, im_address, NULL, |
42 | + error_setg(errp, "failed to write index<%d>", index); | 83 | - access_type, mmu_idx, false, true); |
43 | + return; | 84 | + access_type, mmu_idx, false, true, |
44 | } | 85 | + false); |
45 | 86 | ||
46 | serial_data = ~(s->serial); | 87 | qemu_log_mask(CPU_LOG_MMU, |
47 | if (blk_pwrite(s->blk, (index + 1) * SIFIVE_U_OTP_FUSE_WORD, | 88 | "%s 2nd-stage address=%" VADDR_PRIx " ret %d physical " |
48 | &serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) { | 89 | @@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
49 | - error_report("write error index<%d>", index + 1); | 90 | } else { |
50 | + error_setg(errp, "failed to write index<%d>", index + 1); | 91 | /* Single stage lookup */ |
51 | + return; | 92 | ret = get_physical_address(env, &pa, &prot, address, NULL, |
52 | } | 93 | - access_type, mmu_idx, true, false); |
53 | } | 94 | + access_type, mmu_idx, true, false, false); |
54 | 95 | ||
55 | @@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_class_init(ObjectClass *klass, void *data) | 96 | qemu_log_mask(CPU_LOG_MMU, |
56 | 97 | "%s address=%" VADDR_PRIx " ret %d physical " | |
57 | device_class_set_props(dc, sifive_u_otp_properties); | ||
58 | dc->realize = sifive_u_otp_realize; | ||
59 | - dc->reset = sifive_u_otp_reset; | ||
60 | } | ||
61 | |||
62 | static const TypeInfo sifive_u_otp_info = { | ||
63 | -- | 98 | -- |
64 | 2.31.1 | 99 | 2.31.1 |
65 | 100 | ||
66 | 101 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
1 | 2 | ||
3 | The overflow predication ((a - b) ^ a) & (a ^ b) & INT64_MIN is right. | ||
4 | However, when the predication is ture and a is 0, it should return maximum. | ||
5 | |||
6 | Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Message-id: 20210212150256.885-4-zhiwei_liu@c-sky.com | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | --- | ||
12 | target/riscv/vector_helper.c | 8 ++++---- | ||
13 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/vector_helper.c | ||
18 | +++ b/target/riscv/vector_helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline int8_t ssub8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) | ||
20 | { | ||
21 | int8_t res = a - b; | ||
22 | if ((res ^ a) & (a ^ b) & INT8_MIN) { | ||
23 | - res = a > 0 ? INT8_MAX : INT8_MIN; | ||
24 | + res = a >= 0 ? INT8_MAX : INT8_MIN; | ||
25 | env->vxsat = 0x1; | ||
26 | } | ||
27 | return res; | ||
28 | @@ -XXX,XX +XXX,XX @@ static inline int16_t ssub16(CPURISCVState *env, int vxrm, int16_t a, int16_t b) | ||
29 | { | ||
30 | int16_t res = a - b; | ||
31 | if ((res ^ a) & (a ^ b) & INT16_MIN) { | ||
32 | - res = a > 0 ? INT16_MAX : INT16_MIN; | ||
33 | + res = a >= 0 ? INT16_MAX : INT16_MIN; | ||
34 | env->vxsat = 0x1; | ||
35 | } | ||
36 | return res; | ||
37 | @@ -XXX,XX +XXX,XX @@ static inline int32_t ssub32(CPURISCVState *env, int vxrm, int32_t a, int32_t b) | ||
38 | { | ||
39 | int32_t res = a - b; | ||
40 | if ((res ^ a) & (a ^ b) & INT32_MIN) { | ||
41 | - res = a > 0 ? INT32_MAX : INT32_MIN; | ||
42 | + res = a >= 0 ? INT32_MAX : INT32_MIN; | ||
43 | env->vxsat = 0x1; | ||
44 | } | ||
45 | return res; | ||
46 | @@ -XXX,XX +XXX,XX @@ static inline int64_t ssub64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) | ||
47 | { | ||
48 | int64_t res = a - b; | ||
49 | if ((res ^ a) & (a ^ b) & INT64_MIN) { | ||
50 | - res = a > 0 ? INT64_MAX : INT64_MIN; | ||
51 | + res = a >= 0 ? INT64_MAX : INT64_MIN; | ||
52 | env->vxsat = 0x1; | ||
53 | } | ||
54 | return res; | ||
55 | -- | ||
56 | 2.31.1 | ||
57 | |||
58 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Vijai Kumar K <vijai@behindbytes.com> | ||
1 | 2 | ||
3 | Add documentation for Shakti C reference platform. | ||
4 | |||
5 | Signed-off-by: Vijai Kumar K <vijai@behindbytes.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Message-id: 20210412174248.8668-1-vijai@behindbytes.com | ||
8 | Signed-off-by: Bin Meng <bmeng.cn@gmail.com> | ||
9 | [ Changes from Bin Meng: | ||
10 | - Add missing TOC | ||
11 | Message-id: 20210430070534.1487242-1-bmeng.cn@gmail.com | ||
12 | ] | ||
13 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | --- | ||
15 | docs/system/riscv/shakti-c.rst | 82 ++++++++++++++++++++++++++++++++++ | ||
16 | docs/system/target-riscv.rst | 1 + | ||
17 | 2 files changed, 83 insertions(+) | ||
18 | create mode 100644 docs/system/riscv/shakti-c.rst | ||
19 | |||
20 | diff --git a/docs/system/riscv/shakti-c.rst b/docs/system/riscv/shakti-c.rst | ||
21 | new file mode 100644 | ||
22 | index XXXXXXX..XXXXXXX | ||
23 | --- /dev/null | ||
24 | +++ b/docs/system/riscv/shakti-c.rst | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | +Shakti C Reference Platform (``shakti_c``) | ||
27 | +========================================== | ||
28 | + | ||
29 | +Shakti C Reference Platform is a reference platform based on arty a7 100t | ||
30 | +for the Shakti SoC. | ||
31 | + | ||
32 | +Shakti SoC is a SoC based on the Shakti C-class processor core. Shakti C | ||
33 | +is a 64bit RV64GCSUN processor core. | ||
34 | + | ||
35 | +For more details on Shakti SoC, please see: | ||
36 | +https://gitlab.com/shaktiproject/cores/shakti-soc/-/blob/master/fpga/boards/artya7-100t/c-class/README.rst | ||
37 | + | ||
38 | +For more info on the Shakti C-class core, please see: | ||
39 | +https://c-class.readthedocs.io/en/latest/ | ||
40 | + | ||
41 | +Supported devices | ||
42 | +----------------- | ||
43 | + | ||
44 | +The ``shakti_c`` machine supports the following devices: | ||
45 | + | ||
46 | + * 1 C-class core | ||
47 | + * Core Level Interruptor (CLINT) | ||
48 | + * Platform-Level Interrupt Controller (PLIC) | ||
49 | + * 1 UART | ||
50 | + | ||
51 | +Boot options | ||
52 | +------------ | ||
53 | + | ||
54 | +The ``shakti_c`` machine can start using the standard -bios | ||
55 | +functionality for loading the baremetal application or opensbi. | ||
56 | + | ||
57 | +Boot the machine | ||
58 | +---------------- | ||
59 | + | ||
60 | +Shakti SDK | ||
61 | +~~~~~~~~~~ | ||
62 | +Shakti SDK can be used to generate the baremetal example UART applications. | ||
63 | + | ||
64 | +.. code-block:: bash | ||
65 | + | ||
66 | + $ git clone https://gitlab.com/behindbytes/shakti-sdk.git | ||
67 | + $ cd shakti-sdk | ||
68 | + $ make software PROGRAM=loopback TARGET=artix7_100t | ||
69 | + | ||
70 | +Binary would be generated in: | ||
71 | + software/examples/uart_applns/loopback/output/loopback.shakti | ||
72 | + | ||
73 | +You could also download the precompiled example applicatons using below | ||
74 | +commands. | ||
75 | + | ||
76 | +.. code-block:: bash | ||
77 | + | ||
78 | + $ wget -c https://gitlab.com/behindbytes/shakti-binaries/-/raw/master/sdk/shakti_sdk_qemu.zip | ||
79 | + $ unzip shakti_sdk_qemu.zip | ||
80 | + | ||
81 | +Then we can run the UART example using: | ||
82 | + | ||
83 | +.. code-block:: bash | ||
84 | + | ||
85 | + $ qemu-system-riscv64 -M shakti_c -nographic \ | ||
86 | + -bios path/to/shakti_sdk_qemu/loopback.shakti | ||
87 | + | ||
88 | +OpenSBI | ||
89 | +~~~~~~~ | ||
90 | +We can also run OpenSBI with Test Payload. | ||
91 | + | ||
92 | +.. code-block:: bash | ||
93 | + | ||
94 | + $ git clone https://github.com/riscv/opensbi.git -b v0.9 | ||
95 | + $ cd opensbi | ||
96 | + $ wget -c https://gitlab.com/behindbytes/shakti-binaries/-/raw/master/dts/shakti.dtb | ||
97 | + $ export CROSS_COMPILE=riscv64-unknown-elf- | ||
98 | + $ export FW_FDT_PATH=./shakti.dtb | ||
99 | + $ make PLATFORM=generic | ||
100 | + | ||
101 | +fw_payload.elf would be generated in build/platform/generic/firmware/fw_payload.elf. | ||
102 | +Boot it using the below qemu command. | ||
103 | + | ||
104 | +.. code-block:: bash | ||
105 | + | ||
106 | + $ qemu-system-riscv64 -M shakti_c -nographic \ | ||
107 | + -bios path/to/fw_payload.elf | ||
108 | diff --git a/docs/system/target-riscv.rst b/docs/system/target-riscv.rst | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/docs/system/target-riscv.rst | ||
111 | +++ b/docs/system/target-riscv.rst | ||
112 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | ||
113 | :maxdepth: 1 | ||
114 | |||
115 | riscv/microchip-icicle-kit | ||
116 | + riscv/shakti-c | ||
117 | riscv/sifive_u | ||
118 | |||
119 | RISC-V CPU features | ||
120 | -- | ||
121 | 2.31.1 | ||
122 | |||
123 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The RISC-V spec says: | ||
2 | if PMP entry i is locked and pmpicfg.A is set to TOR, writes to | ||
3 | pmpaddri-1 are ignored. | ||
1 | 4 | ||
5 | The current QEMU code ignores accesses to pmpaddri-1 and pmpcfgi-1 which | ||
6 | is incorrect. | ||
7 | |||
8 | Update the pmp_is_locked() function to not check the supporting fields | ||
9 | and instead enforce the lock functionality in the pmpaddr write operation. | ||
10 | |||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
13 | Message-id: 2831241458163f445a89bd59c59990247265b0c6.1618812899.git.alistair.francis@wdc.com | ||
14 | --- | ||
15 | target/riscv/pmp.c | 26 ++++++++++++++++---------- | ||
16 | 1 file changed, 16 insertions(+), 10 deletions(-) | ||
17 | |||
18 | diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/riscv/pmp.c | ||
21 | +++ b/target/riscv/pmp.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index) | ||
23 | return 0; | ||
24 | } | ||
25 | |||
26 | - /* In TOR mode, need to check the lock bit of the next pmp | ||
27 | - * (if there is a next) | ||
28 | - */ | ||
29 | - const uint8_t a_field = | ||
30 | - pmp_get_a_field(env->pmp_state.pmp[pmp_index + 1].cfg_reg); | ||
31 | - if ((env->pmp_state.pmp[pmp_index + 1u].cfg_reg & PMP_LOCK) && | ||
32 | - (PMP_AMATCH_TOR == a_field)) { | ||
33 | - return 1; | ||
34 | - } | ||
35 | - | ||
36 | return 0; | ||
37 | } | ||
38 | |||
39 | @@ -XXX,XX +XXX,XX @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index, | ||
40 | target_ulong val) | ||
41 | { | ||
42 | trace_pmpaddr_csr_write(env->mhartid, addr_index, val); | ||
43 | + | ||
44 | if (addr_index < MAX_RISCV_PMPS) { | ||
45 | + /* | ||
46 | + * In TOR mode, need to check the lock bit of the next pmp | ||
47 | + * (if there is a next). | ||
48 | + */ | ||
49 | + if (addr_index + 1 < MAX_RISCV_PMPS) { | ||
50 | + uint8_t pmp_cfg = env->pmp_state.pmp[addr_index + 1].cfg_reg; | ||
51 | + | ||
52 | + if (pmp_cfg & PMP_LOCK && | ||
53 | + PMP_AMATCH_TOR == pmp_get_a_field(pmp_cfg)) { | ||
54 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
55 | + "ignoring pmpaddr write - pmpcfg + 1 locked\n"); | ||
56 | + return; | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | if (!pmp_is_locked(env, addr_index)) { | ||
61 | env->pmp_state.pmp[addr_index].addr_reg = val; | ||
62 | pmp_update_rule(env, addr_index); | ||
63 | -- | ||
64 | 2.31.1 | ||
65 | |||
66 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Hou Weiying <weiying_hou@outlook.com> | ||
1 | 2 | ||
3 | Use address 0x390 and 0x391 for the ePMP CSRs. | ||
4 | |||
5 | Signed-off-by: Hongzheng-Li <Ethan.Lee.QNL@gmail.com> | ||
6 | Signed-off-by: Hou Weiying <weiying_hou@outlook.com> | ||
7 | Signed-off-by: Myriad-Dreamin <camiyoru@gmail.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
11 | Message-id: 63245b559f477a9ce6d4f930136d2d7fd7f99c78.1618812899.git.alistair.francis@wdc.com | ||
12 | [ Changes by AF: | ||
13 | - Tidy up commit message | ||
14 | ] | ||
15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
17 | --- | ||
18 | target/riscv/cpu_bits.h | 3 +++ | ||
19 | 1 file changed, 3 insertions(+) | ||
20 | |||
21 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/riscv/cpu_bits.h | ||
24 | +++ b/target/riscv/cpu_bits.h | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | #define CSR_MTINST 0x34a | ||
27 | #define CSR_MTVAL2 0x34b | ||
28 | |||
29 | +/* Enhanced Physical Memory Protection (ePMP) */ | ||
30 | +#define CSR_MSECCFG 0x390 | ||
31 | +#define CSR_MSECCFGH 0x391 | ||
32 | /* Physical Memory Protection */ | ||
33 | #define CSR_PMPCFG0 0x3a0 | ||
34 | #define CSR_PMPCFG1 0x3a1 | ||
35 | -- | ||
36 | 2.31.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The spec is avaliable at: | ||
2 | https://docs.google.com/document/d/1Mh_aiHYxemL0umN3GTTw8vsbmzHZ_nxZXgjgOUzbvc8 | ||
1 | 3 | ||
4 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
6 | Message-id: 28c8855c80b0388a08c3ae009f5467e2b3960ce0.1618812899.git.alistair.francis@wdc.com | ||
7 | --- | ||
8 | target/riscv/cpu.h | 1 + | ||
9 | 1 file changed, 1 insertion(+) | ||
10 | |||
11 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/riscv/cpu.h | ||
14 | +++ b/target/riscv/cpu.h | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | enum { | ||
17 | RISCV_FEATURE_MMU, | ||
18 | RISCV_FEATURE_PMP, | ||
19 | + RISCV_FEATURE_EPMP, | ||
20 | RISCV_FEATURE_MISA | ||
21 | }; | ||
22 | |||
23 | -- | ||
24 | 2.31.1 | ||
25 | |||
26 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Hou Weiying <weiying_hou@outlook.com> | ||
1 | 2 | ||
3 | Signed-off-by: Hongzheng-Li <Ethan.Lee.QNL@gmail.com> | ||
4 | Signed-off-by: Hou Weiying <weiying_hou@outlook.com> | ||
5 | Signed-off-by: Myriad-Dreamin <camiyoru@gmail.com> | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
8 | Message-id: 270762cb2507fba6a9eeb99a774cf49f7da9cc32.1618812899.git.alistair.francis@wdc.com | ||
9 | [ Changes by AF: | ||
10 | - Rebase on master | ||
11 | - Fix build errors | ||
12 | - Fix some style issues | ||
13 | ] | ||
14 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
15 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
16 | --- | ||
17 | target/riscv/cpu.h | 1 + | ||
18 | target/riscv/pmp.h | 14 ++++++++++++++ | ||
19 | target/riscv/csr.c | 24 ++++++++++++++++++++++++ | ||
20 | target/riscv/pmp.c | 34 ++++++++++++++++++++++++++++++++++ | ||
21 | target/riscv/trace-events | 3 +++ | ||
22 | 5 files changed, 76 insertions(+) | ||
23 | |||
24 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/riscv/cpu.h | ||
27 | +++ b/target/riscv/cpu.h | ||
28 | @@ -XXX,XX +XXX,XX @@ struct CPURISCVState { | ||
29 | |||
30 | /* physical memory protection */ | ||
31 | pmp_table_t pmp_state; | ||
32 | + target_ulong mseccfg; | ||
33 | |||
34 | /* machine specific rdtime callback */ | ||
35 | uint64_t (*rdtime_fn)(uint32_t); | ||
36 | diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/riscv/pmp.h | ||
39 | +++ b/target/riscv/pmp.h | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
41 | PMP_AMATCH_NAPOT /* Naturally aligned power-of-two region */ | ||
42 | } pmp_am_t; | ||
43 | |||
44 | +typedef enum { | ||
45 | + MSECCFG_MML = 1 << 0, | ||
46 | + MSECCFG_MMWP = 1 << 1, | ||
47 | + MSECCFG_RLB = 1 << 2 | ||
48 | +} mseccfg_field_t; | ||
49 | + | ||
50 | typedef struct { | ||
51 | target_ulong addr_reg; | ||
52 | uint8_t cfg_reg; | ||
53 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
54 | void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index, | ||
55 | target_ulong val); | ||
56 | target_ulong pmpcfg_csr_read(CPURISCVState *env, uint32_t reg_index); | ||
57 | + | ||
58 | +void mseccfg_csr_write(CPURISCVState *env, target_ulong val); | ||
59 | +target_ulong mseccfg_csr_read(CPURISCVState *env); | ||
60 | + | ||
61 | void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index, | ||
62 | target_ulong val); | ||
63 | target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t addr_index); | ||
64 | @@ -XXX,XX +XXX,XX @@ void pmp_update_rule_nums(CPURISCVState *env); | ||
65 | uint32_t pmp_get_num_rules(CPURISCVState *env); | ||
66 | int pmp_priv_to_page_prot(pmp_priv_t pmp_priv); | ||
67 | |||
68 | +#define MSECCFG_MML_ISSET(env) get_field(env->mseccfg, MSECCFG_MML) | ||
69 | +#define MSECCFG_MMWP_ISSET(env) get_field(env->mseccfg, MSECCFG_MMWP) | ||
70 | +#define MSECCFG_RLB_ISSET(env) get_field(env->mseccfg, MSECCFG_RLB) | ||
71 | + | ||
72 | #endif | ||
73 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/riscv/csr.c | ||
76 | +++ b/target/riscv/csr.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static RISCVException pmp(CPURISCVState *env, int csrno) | ||
78 | |||
79 | return RISCV_EXCP_ILLEGAL_INST; | ||
80 | } | ||
81 | + | ||
82 | +static RISCVException epmp(CPURISCVState *env, int csrno) | ||
83 | +{ | ||
84 | + if (env->priv == PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) { | ||
85 | + return RISCV_EXCP_NONE; | ||
86 | + } | ||
87 | + | ||
88 | + return RISCV_EXCP_ILLEGAL_INST; | ||
89 | +} | ||
90 | #endif | ||
91 | |||
92 | /* User Floating-Point CSRs */ | ||
93 | @@ -XXX,XX +XXX,XX @@ static RISCVException write_mtinst(CPURISCVState *env, int csrno, | ||
94 | } | ||
95 | |||
96 | /* Physical Memory Protection */ | ||
97 | +static RISCVException read_mseccfg(CPURISCVState *env, int csrno, | ||
98 | + target_ulong *val) | ||
99 | +{ | ||
100 | + *val = mseccfg_csr_read(env); | ||
101 | + return RISCV_EXCP_NONE; | ||
102 | +} | ||
103 | + | ||
104 | +static RISCVException write_mseccfg(CPURISCVState *env, int csrno, | ||
105 | + target_ulong val) | ||
106 | +{ | ||
107 | + mseccfg_csr_write(env, val); | ||
108 | + return RISCV_EXCP_NONE; | ||
109 | +} | ||
110 | + | ||
111 | static RISCVException read_pmpcfg(CPURISCVState *env, int csrno, | ||
112 | target_ulong *val) | ||
113 | { | ||
114 | @@ -XXX,XX +XXX,XX @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { | ||
115 | [CSR_MTINST] = { "mtinst", hmode, read_mtinst, write_mtinst }, | ||
116 | |||
117 | /* Physical Memory Protection */ | ||
118 | + [CSR_MSECCFG] = { "mseccfg", epmp, read_mseccfg, write_mseccfg }, | ||
119 | [CSR_PMPCFG0] = { "pmpcfg0", pmp, read_pmpcfg, write_pmpcfg }, | ||
120 | [CSR_PMPCFG1] = { "pmpcfg1", pmp, read_pmpcfg, write_pmpcfg }, | ||
121 | [CSR_PMPCFG2] = { "pmpcfg2", pmp, read_pmpcfg, write_pmpcfg }, | ||
122 | diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/target/riscv/pmp.c | ||
125 | +++ b/target/riscv/pmp.c | ||
126 | @@ -XXX,XX +XXX,XX @@ target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t addr_index) | ||
127 | return val; | ||
128 | } | ||
129 | |||
130 | +/* | ||
131 | + * Handle a write to a mseccfg CSR | ||
132 | + */ | ||
133 | +void mseccfg_csr_write(CPURISCVState *env, target_ulong val) | ||
134 | +{ | ||
135 | + int i; | ||
136 | + | ||
137 | + trace_mseccfg_csr_write(env->mhartid, val); | ||
138 | + | ||
139 | + /* RLB cannot be enabled if it's already 0 and if any regions are locked */ | ||
140 | + if (!MSECCFG_RLB_ISSET(env)) { | ||
141 | + for (i = 0; i < MAX_RISCV_PMPS; i++) { | ||
142 | + if (pmp_is_locked(env, i)) { | ||
143 | + val &= ~MSECCFG_RLB; | ||
144 | + break; | ||
145 | + } | ||
146 | + } | ||
147 | + } | ||
148 | + | ||
149 | + /* Sticky bits */ | ||
150 | + val |= (env->mseccfg & (MSECCFG_MMWP | MSECCFG_MML)); | ||
151 | + | ||
152 | + env->mseccfg = val; | ||
153 | +} | ||
154 | + | ||
155 | +/* | ||
156 | + * Handle a read from a mseccfg CSR | ||
157 | + */ | ||
158 | +target_ulong mseccfg_csr_read(CPURISCVState *env) | ||
159 | +{ | ||
160 | + trace_mseccfg_csr_read(env->mhartid, env->mseccfg); | ||
161 | + return env->mseccfg; | ||
162 | +} | ||
163 | + | ||
164 | /* | ||
165 | * Calculate the TLB size if the start address or the end address of | ||
166 | * PMP entry is presented in thie TLB page. | ||
167 | diff --git a/target/riscv/trace-events b/target/riscv/trace-events | ||
168 | index XXXXXXX..XXXXXXX 100644 | ||
169 | --- a/target/riscv/trace-events | ||
170 | +++ b/target/riscv/trace-events | ||
171 | @@ -XXX,XX +XXX,XX @@ pmpcfg_csr_read(uint64_t mhartid, uint32_t reg_index, uint64_t val) "hart %" PRI | ||
172 | pmpcfg_csr_write(uint64_t mhartid, uint32_t reg_index, uint64_t val) "hart %" PRIu64 ": write reg%" PRIu32", val: 0x%" PRIx64 | ||
173 | pmpaddr_csr_read(uint64_t mhartid, uint32_t addr_index, uint64_t val) "hart %" PRIu64 ": read addr%" PRIu32", val: 0x%" PRIx64 | ||
174 | pmpaddr_csr_write(uint64_t mhartid, uint32_t addr_index, uint64_t val) "hart %" PRIu64 ": write addr%" PRIu32", val: 0x%" PRIx64 | ||
175 | + | ||
176 | +mseccfg_csr_read(uint64_t mhartid, uint64_t val) "hart %" PRIu64 ": read mseccfg, val: 0x%" PRIx64 | ||
177 | +mseccfg_csr_write(uint64_t mhartid, uint64_t val) "hart %" PRIu64 ": write mseccfg, val: 0x%" PRIx64 | ||
178 | -- | ||
179 | 2.31.1 | ||
180 | |||
181 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Hou Weiying <weiying_hou@outlook.com> |
---|---|---|---|
2 | 2 | ||
3 | Configuring a drive with "if=none" is meant for creation of a backend | 3 | This commit adds support for ePMP v0.9.1. |
4 | only, it should not get automatically assigned to a device frontend. | 4 | |
5 | Use "if=pflash" for the One-Time-Programmable device instead (like | 5 | The ePMP spec can be found in: |
6 | it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c). | 6 | https://docs.google.com/document/d/1Mh_aiHYxemL0umN3GTTw8vsbmzHZ_nxZXgjgOUzbvc8 |
7 | 7 | ||
8 | Since the old way of configuring the device has already been published | 8 | Signed-off-by: Hongzheng-Li <Ethan.Lee.QNL@gmail.com> |
9 | with the previous QEMU versions, we cannot remove this immediately, but | 9 | Signed-off-by: Hou Weiying <weiying_hou@outlook.com> |
10 | have to deprecate it and support it for at least two more releases. | 10 | Signed-off-by: Myriad-Dreamin <camiyoru@gmail.com> |
11 | 11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | |
12 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 12 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> |
13 | Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 13 | Message-id: fef23b885f9649a4d54e7c98b168bdec5d297bb1.1618812899.git.alistair.francis@wdc.com |
14 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 14 | [ Changes by AF: |
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 15 | - Rebase on master |
16 | Message-id: 20211119102549.217755-1-thuth@redhat.com | 16 | - Update to latest spec |
17 | - Use a switch case to handle ePMP MML permissions | ||
18 | - Fix a few bugs | ||
19 | ] | ||
17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 20 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
18 | --- | 21 | --- |
19 | docs/about/deprecated.rst | 6 ++++++ | 22 | target/riscv/pmp.c | 154 ++++++++++++++++++++++++++++++++++++++++++--- |
20 | hw/misc/sifive_u_otp.c | 9 ++++++++- | 23 | 1 file changed, 146 insertions(+), 8 deletions(-) |
21 | 2 files changed, 14 insertions(+), 1 deletion(-) | 24 | |
22 | 25 | diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c | |
23 | diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst | ||
24 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/docs/about/deprecated.rst | 27 | --- a/target/riscv/pmp.c |
26 | +++ b/docs/about/deprecated.rst | 28 | +++ b/target/riscv/pmp.c |
27 | @@ -XXX,XX +XXX,XX @@ as short-form boolean values, and passed to plugins as ``arg_name=on``. | 29 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t pmp_read_cfg(CPURISCVState *env, uint32_t pmp_index) |
28 | However, short-form booleans are deprecated and full explicit ``arg_name=on`` | 30 | static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val) |
29 | form is preferred. | 31 | { |
30 | 32 | if (pmp_index < MAX_RISCV_PMPS) { | |
31 | +``-drive if=none`` for the sifive_u OTP device (since 6.2) | 33 | - if (!pmp_is_locked(env, pmp_index)) { |
32 | +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | 34 | - env->pmp_state.pmp[pmp_index].cfg_reg = val; |
33 | + | 35 | - pmp_update_rule(env, pmp_index); |
34 | +Using ``-drive if=none`` to configure the OTP device of the sifive_u | 36 | + bool locked = true; |
35 | +RISC-V machine is deprecated. Use ``-drive if=pflash`` instead. | 37 | + |
36 | + | 38 | + if (riscv_feature(env, RISCV_FEATURE_EPMP)) { |
37 | 39 | + /* mseccfg.RLB is set */ | |
38 | QEMU Machine Protocol (QMP) commands | 40 | + if (MSECCFG_RLB_ISSET(env)) { |
39 | ------------------------------------ | 41 | + locked = false; |
40 | diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c | 42 | + } |
41 | index XXXXXXX..XXXXXXX 100644 | 43 | + |
42 | --- a/hw/misc/sifive_u_otp.c | 44 | + /* mseccfg.MML is not set */ |
43 | +++ b/hw/misc/sifive_u_otp.c | 45 | + if (!MSECCFG_MML_ISSET(env) && !pmp_is_locked(env, pmp_index)) { |
44 | @@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp) | 46 | + locked = false; |
45 | TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE); | 47 | + } |
46 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio); | 48 | + |
47 | 49 | + /* mseccfg.MML is set */ | |
48 | - dinfo = drive_get_next(IF_NONE); | 50 | + if (MSECCFG_MML_ISSET(env)) { |
49 | + dinfo = drive_get_next(IF_PFLASH); | 51 | + /* not adding execute bit */ |
50 | + if (!dinfo) { | 52 | + if ((val & PMP_LOCK) != 0 && (val & PMP_EXEC) != PMP_EXEC) { |
51 | + dinfo = drive_get_next(IF_NONE); | 53 | + locked = false; |
52 | + if (dinfo) { | 54 | + } |
53 | + warn_report("using \"-drive if=none\" for the OTP is deprecated, " | 55 | + /* shared region and not adding X bit */ |
54 | + "use \"-drive if=pflash\" instead."); | 56 | + if ((val & PMP_LOCK) != PMP_LOCK && |
57 | + (val & 0x7) != (PMP_WRITE | PMP_EXEC)) { | ||
58 | + locked = false; | ||
59 | + } | ||
60 | + } | ||
61 | } else { | ||
62 | + if (!pmp_is_locked(env, pmp_index)) { | ||
63 | + locked = false; | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | + if (locked) { | ||
68 | qemu_log_mask(LOG_GUEST_ERROR, "ignoring pmpcfg write - locked\n"); | ||
69 | + } else { | ||
70 | + env->pmp_state.pmp[pmp_index].cfg_reg = val; | ||
71 | + pmp_update_rule(env, pmp_index); | ||
72 | } | ||
73 | } else { | ||
74 | qemu_log_mask(LOG_GUEST_ERROR, | ||
75 | @@ -XXX,XX +XXX,XX @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, | ||
76 | { | ||
77 | bool ret; | ||
78 | |||
79 | + if (riscv_feature(env, RISCV_FEATURE_EPMP)) { | ||
80 | + if (MSECCFG_MMWP_ISSET(env)) { | ||
81 | + /* | ||
82 | + * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set | ||
83 | + * so we default to deny all, even for M-mode. | ||
84 | + */ | ||
85 | + *allowed_privs = 0; | ||
86 | + return false; | ||
87 | + } else if (MSECCFG_MML_ISSET(env)) { | ||
88 | + /* | ||
89 | + * The Machine Mode Lockdown (mseccfg.MML) bit is set | ||
90 | + * so we can only execute code in M-mode with an applicable | ||
91 | + * rule. Other modes are disabled. | ||
92 | + */ | ||
93 | + if (mode == PRV_M && !(privs & PMP_EXEC)) { | ||
94 | + ret = true; | ||
95 | + *allowed_privs = PMP_READ | PMP_WRITE; | ||
96 | + } else { | ||
97 | + ret = false; | ||
98 | + *allowed_privs = 0; | ||
99 | + } | ||
100 | + | ||
101 | + return ret; | ||
55 | + } | 102 | + } |
56 | + } | 103 | + } |
57 | if (dinfo) { | 104 | + |
58 | int ret; | 105 | if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode == PRV_M)) { |
59 | uint64_t perm; | 106 | /* |
107 | * Privileged spec v1.10 states if HW doesn't implement any PMP entry | ||
108 | @@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, | ||
109 | pmp_get_a_field(env->pmp_state.pmp[i].cfg_reg); | ||
110 | |||
111 | /* | ||
112 | - * If the PMP entry is not off and the address is in range, do the priv | ||
113 | - * check | ||
114 | + * Convert the PMP permissions to match the truth table in the | ||
115 | + * ePMP spec. | ||
116 | */ | ||
117 | + const uint8_t epmp_operation = | ||
118 | + ((env->pmp_state.pmp[i].cfg_reg & PMP_LOCK) >> 4) | | ||
119 | + ((env->pmp_state.pmp[i].cfg_reg & PMP_READ) << 2) | | ||
120 | + (env->pmp_state.pmp[i].cfg_reg & PMP_WRITE) | | ||
121 | + ((env->pmp_state.pmp[i].cfg_reg & PMP_EXEC) >> 2); | ||
122 | + | ||
123 | if (((s + e) == 2) && (PMP_AMATCH_OFF != a_field)) { | ||
124 | - *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; | ||
125 | - if ((mode != PRV_M) || pmp_is_locked(env, i)) { | ||
126 | - *allowed_privs &= env->pmp_state.pmp[i].cfg_reg; | ||
127 | + /* | ||
128 | + * If the PMP entry is not off and the address is in range, | ||
129 | + * do the priv check | ||
130 | + */ | ||
131 | + if (!MSECCFG_MML_ISSET(env)) { | ||
132 | + /* | ||
133 | + * If mseccfg.MML Bit is not set, do pmp priv check | ||
134 | + * This will always apply to regular PMP. | ||
135 | + */ | ||
136 | + *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; | ||
137 | + if ((mode != PRV_M) || pmp_is_locked(env, i)) { | ||
138 | + *allowed_privs &= env->pmp_state.pmp[i].cfg_reg; | ||
139 | + } | ||
140 | + } else { | ||
141 | + /* | ||
142 | + * If mseccfg.MML Bit set, do the enhanced pmp priv check | ||
143 | + */ | ||
144 | + if (mode == PRV_M) { | ||
145 | + switch (epmp_operation) { | ||
146 | + case 0: | ||
147 | + case 1: | ||
148 | + case 4: | ||
149 | + case 5: | ||
150 | + case 6: | ||
151 | + case 7: | ||
152 | + case 8: | ||
153 | + *allowed_privs = 0; | ||
154 | + break; | ||
155 | + case 2: | ||
156 | + case 3: | ||
157 | + case 14: | ||
158 | + *allowed_privs = PMP_READ | PMP_WRITE; | ||
159 | + break; | ||
160 | + case 9: | ||
161 | + case 10: | ||
162 | + *allowed_privs = PMP_EXEC; | ||
163 | + break; | ||
164 | + case 11: | ||
165 | + case 13: | ||
166 | + *allowed_privs = PMP_READ | PMP_EXEC; | ||
167 | + break; | ||
168 | + case 12: | ||
169 | + case 15: | ||
170 | + *allowed_privs = PMP_READ; | ||
171 | + break; | ||
172 | + } | ||
173 | + } else { | ||
174 | + switch (epmp_operation) { | ||
175 | + case 0: | ||
176 | + case 8: | ||
177 | + case 9: | ||
178 | + case 12: | ||
179 | + case 13: | ||
180 | + case 14: | ||
181 | + *allowed_privs = 0; | ||
182 | + break; | ||
183 | + case 1: | ||
184 | + case 10: | ||
185 | + case 11: | ||
186 | + *allowed_privs = PMP_EXEC; | ||
187 | + break; | ||
188 | + case 2: | ||
189 | + case 4: | ||
190 | + case 15: | ||
191 | + *allowed_privs = PMP_READ; | ||
192 | + break; | ||
193 | + case 3: | ||
194 | + case 6: | ||
195 | + *allowed_privs = PMP_READ | PMP_WRITE; | ||
196 | + break; | ||
197 | + case 5: | ||
198 | + *allowed_privs = PMP_READ | PMP_EXEC; | ||
199 | + break; | ||
200 | + case 7: | ||
201 | + *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; | ||
202 | + break; | ||
203 | + } | ||
204 | + } | ||
205 | } | ||
206 | |||
207 | ret = ((privs & *allowed_privs) == privs); | ||
60 | -- | 208 | -- |
61 | 2.31.1 | 209 | 2.31.1 |
62 | 210 | ||
63 | 211 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Hou Weiying <weiying_hou@outlook.com> | ||
1 | 2 | ||
3 | Add a config option to enable experimental support for ePMP. This | ||
4 | is disabled by default and can be enabled with 'x-epmp=true'. | ||
5 | |||
6 | Signed-off-by: Hongzheng-Li <Ethan.Lee.QNL@gmail.com> | ||
7 | Signed-off-by: Hou Weiying <weiying_hou@outlook.com> | ||
8 | Signed-off-by: Myriad-Dreamin <camiyoru@gmail.com> | ||
9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
11 | Message-id: a22ccdaf9314078bc735d3b323f966623f8af020.1618812899.git.alistair.francis@wdc.com | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
14 | --- | ||
15 | target/riscv/cpu.h | 1 + | ||
16 | target/riscv/cpu.c | 10 ++++++++++ | ||
17 | 2 files changed, 11 insertions(+) | ||
18 | |||
19 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/riscv/cpu.h | ||
22 | +++ b/target/riscv/cpu.h | ||
23 | @@ -XXX,XX +XXX,XX @@ struct RISCVCPU { | ||
24 | uint16_t elen; | ||
25 | bool mmu; | ||
26 | bool pmp; | ||
27 | + bool epmp; | ||
28 | uint64_t resetvec; | ||
29 | } cfg; | ||
30 | }; | ||
31 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/riscv/cpu.c | ||
34 | +++ b/target/riscv/cpu.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) | ||
36 | |||
37 | if (cpu->cfg.pmp) { | ||
38 | set_feature(env, RISCV_FEATURE_PMP); | ||
39 | + | ||
40 | + /* | ||
41 | + * Enhanced PMP should only be available | ||
42 | + * on harts with PMP support | ||
43 | + */ | ||
44 | + if (cpu->cfg.epmp) { | ||
45 | + set_feature(env, RISCV_FEATURE_EPMP); | ||
46 | + } | ||
47 | } | ||
48 | |||
49 | set_resetvec(env, cpu->cfg.resetvec); | ||
50 | @@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = { | ||
51 | DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), | ||
52 | DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), | ||
53 | DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), | ||
54 | + DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), | ||
55 | + | ||
56 | DEFINE_PROP_UINT64("resetvec", RISCVCPU, cfg.resetvec, DEFAULT_RSTVEC), | ||
57 | DEFINE_PROP_END_OF_LIST(), | ||
58 | }; | ||
59 | -- | ||
60 | 2.31.1 | ||
61 | |||
62 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
3 | Message-id: 10387eec21d2f17c499a78fdba85280cab4dd27f.1618812899.git.alistair.francis@wdc.com | ||
4 | --- | ||
5 | target/riscv/pmp.c | 4 ---- | ||
6 | 1 file changed, 4 deletions(-) | ||
1 | 7 | ||
8 | diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/target/riscv/pmp.c | ||
11 | +++ b/target/riscv/pmp.c | ||
12 | @@ -XXX,XX +XXX,XX @@ | ||
13 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
14 | */ | ||
15 | |||
16 | -/* | ||
17 | - * PMP (Physical Memory Protection) is as-of-yet unused and needs testing. | ||
18 | - */ | ||
19 | - | ||
20 | #include "qemu/osdep.h" | ||
21 | #include "qemu/log.h" | ||
22 | #include "qapi/error.h" | ||
23 | -- | ||
24 | 2.31.1 | ||
25 | |||
26 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The physical Ibex CPU has ePMP support and it's enabled for the | ||
2 | OpenTitan machine so let's enable ePMP support for the Ibex CPU in QEMU. | ||
1 | 3 | ||
4 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
6 | Message-id: d426baabab0c9361ed2e989dbe416e417a551fd1.1618812899.git.alistair.francis@wdc.com | ||
7 | --- | ||
8 | target/riscv/cpu.c | 1 + | ||
9 | 1 file changed, 1 insertion(+) | ||
10 | |||
11 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/riscv/cpu.c | ||
14 | +++ b/target/riscv/cpu.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void rv32_ibex_cpu_init(Object *obj) | ||
16 | set_misa(env, RV32 | RVI | RVM | RVC | RVU); | ||
17 | set_priv_version(env, PRIV_VERSION_1_10_0); | ||
18 | qdev_prop_set_bit(DEVICE(obj), "mmu", false); | ||
19 | + qdev_prop_set_bit(DEVICE(obj), "x-epmp", true); | ||
20 | } | ||
21 | |||
22 | static void rv32_imafcu_nommu_cpu_init(Object *obj) | ||
23 | -- | ||
24 | 2.31.1 | ||
25 | |||
26 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Frank Chang <frank.chang@sifive.com> | ||
1 | 2 | ||
3 | ETYPE may be type of uint64_t, thus index variable has to be declared as | ||
4 | type of uint64_t, too. Otherwise the value read from vs1 register may be | ||
5 | truncated to type of uint32_t. | ||
6 | |||
7 | Signed-off-by: Frank Chang <frank.chang@sifive.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210419060302.14075-1-frank.chang@sifive.com | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | --- | ||
12 | target/riscv/vector_helper.c | 6 ++++-- | ||
13 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/vector_helper.c | ||
18 | +++ b/target/riscv/vector_helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ | ||
20 | uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
21 | uint32_t vm = vext_vm(desc); \ | ||
22 | uint32_t vl = env->vl; \ | ||
23 | - uint32_t index, i; \ | ||
24 | + uint64_t index; \ | ||
25 | + uint32_t i; \ | ||
26 | \ | ||
27 | for (i = 0; i < vl; i++) { \ | ||
28 | if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
29 | @@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ | ||
30 | uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ | ||
31 | uint32_t vm = vext_vm(desc); \ | ||
32 | uint32_t vl = env->vl; \ | ||
33 | - uint32_t index = s1, i; \ | ||
34 | + uint64_t index = s1; \ | ||
35 | + uint32_t i; \ | ||
36 | \ | ||
37 | for (i = 0; i < vl; i++) { \ | ||
38 | if (!vm && !vext_elem_mask(v0, mlen, i)) { \ | ||
39 | -- | ||
40 | 2.31.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Emmanuel Blot <emmanuel.blot@sifive.com> | ||
1 | 2 | ||
3 | When no MMU is used and the guest code attempts to fetch an instruction | ||
4 | from an invalid memory location, the exception index defaults to a data | ||
5 | load access fault, rather an instruction access fault. | ||
6 | |||
7 | Signed-off-by: Emmanuel Blot <emmanuel.blot@sifive.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Message-id: FB9EA197-B018-4879-AB0F-922C2047A08B@sifive.com | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | --- | ||
12 | target/riscv/cpu_helper.c | 4 +++- | ||
13 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/riscv/cpu_helper.c | ||
18 | +++ b/target/riscv/cpu_helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, | ||
20 | |||
21 | if (access_type == MMU_DATA_STORE) { | ||
22 | cs->exception_index = RISCV_EXCP_STORE_AMO_ACCESS_FAULT; | ||
23 | - } else { | ||
24 | + } else if (access_type == MMU_DATA_LOAD) { | ||
25 | cs->exception_index = RISCV_EXCP_LOAD_ACCESS_FAULT; | ||
26 | + } else { | ||
27 | + cs->exception_index = RISCV_EXCP_INST_ACCESS_FAULT; | ||
28 | } | ||
29 | |||
30 | env->badaddr = addr; | ||
31 | -- | ||
32 | 2.31.1 | ||
33 | |||
34 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alexander Wagner <alexander.wagner@ulal.de> | ||
1 | 2 | ||
3 | The IBEX documentation [1] specifies the reset vector to be "the most | ||
4 | significant 3 bytes of the boot address and the reset value (0x80) as | ||
5 | the least significant byte". | ||
6 | |||
7 | [1] https://github.com/lowRISC/ibex/blob/master/doc/03_reference/exception_interrupts.rst | ||
8 | |||
9 | Signed-off-by: Alexander Wagner <alexander.wagner@ulal.de> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Message-id: 20210420080008.119798-1-alexander.wagner@ulal.de | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | --- | ||
14 | hw/riscv/opentitan.c | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/riscv/opentitan.c | ||
20 | +++ b/hw/riscv/opentitan.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) | ||
22 | &error_abort); | ||
23 | object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus, | ||
24 | &error_abort); | ||
25 | - object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x8090, &error_abort); | ||
26 | + object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x8080, &error_abort); | ||
27 | sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_abort); | ||
28 | |||
29 | /* Boot ROM */ | ||
30 | -- | ||
31 | 2.31.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Frank Chang <frank.chang@sifive.com> | ||
1 | 2 | ||
3 | In IEEE 754-2008 spec: | ||
4 | Invalid operation exception is signaled when doing: | ||
5 | fusedMultiplyAdd(0, Inf, c) or fusedMultiplyAdd(Inf, 0, c) | ||
6 | unless c is a quiet NaN; if c is a quiet NaN then it is | ||
7 | implementation defined whether the invalid operation exception | ||
8 | is signaled. | ||
9 | |||
10 | In RISC-V Unprivileged ISA spec: | ||
11 | The fused multiply-add instructions must set the invalid | ||
12 | operation exception flag when the multiplicands are Inf and | ||
13 | zero, even when the addend is a quiet NaN. | ||
14 | |||
15 | This commit set invalid operation execption flag for RISC-V when | ||
16 | multiplicands of muladd instructions are Inf and zero. | ||
17 | |||
18 | Signed-off-by: Frank Chang <frank.chang@sifive.com> | ||
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Message-id: 20210420013150.21992-1-frank.chang@sifive.com | ||
21 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
22 | --- | ||
23 | fpu/softfloat-specialize.c.inc | 6 ++++++ | ||
24 | 1 file changed, 6 insertions(+) | ||
25 | |||
26 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/fpu/softfloat-specialize.c.inc | ||
29 | +++ b/fpu/softfloat-specialize.c.inc | ||
30 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
31 | } else { | ||
32 | return 1; | ||
33 | } | ||
34 | +#elif defined(TARGET_RISCV) | ||
35 | + /* For RISC-V, InvalidOp is set when multiplicands are Inf and zero */ | ||
36 | + if (infzero) { | ||
37 | + float_raise(float_flag_invalid, status); | ||
38 | + } | ||
39 | + return 3; /* default NaN */ | ||
40 | #elif defined(TARGET_XTENSA) | ||
41 | /* | ||
42 | * For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns | ||
43 | -- | ||
44 | 2.31.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Emmanuel Blot <emmanuel.blot@sifive.com> | ||
1 | 2 | ||
3 | Interrupt names have been swapped in 205377f8 and do not follow | ||
4 | IRQ_*_EXT definition order. | ||
5 | |||
6 | Signed-off-by: Emmanuel Blot <emmanuel.blot@sifive.com> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20210421133236.11323-1-emmanuel.blot@sifive.com | ||
9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | --- | ||
11 | target/riscv/cpu.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/riscv/cpu.c | ||
17 | +++ b/target/riscv/cpu.c | ||
18 | @@ -XXX,XX +XXX,XX @@ const char * const riscv_intr_names[] = { | ||
19 | "vs_timer", | ||
20 | "m_timer", | ||
21 | "u_external", | ||
22 | + "s_external", | ||
23 | "vs_external", | ||
24 | - "h_external", | ||
25 | "m_external", | ||
26 | "reserved", | ||
27 | "reserved", | ||
28 | -- | ||
29 | 2.31.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
4 | Message-id: a07bc0c6dc4958681b4f93cbc5d0acc31ed3344a.1619234854.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/cpu.h | 6 ------ | ||
7 | target/riscv/cpu.c | 6 +++++- | ||
8 | 2 files changed, 5 insertions(+), 7 deletions(-) | ||
1 | 9 | ||
10 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/riscv/cpu.h | ||
13 | +++ b/target/riscv/cpu.h | ||
14 | @@ -XXX,XX +XXX,XX @@ | ||
15 | #define RV32 ((target_ulong)1 << (TARGET_LONG_BITS - 2)) | ||
16 | #define RV64 ((target_ulong)2 << (TARGET_LONG_BITS - 2)) | ||
17 | |||
18 | -#if defined(TARGET_RISCV32) | ||
19 | -#define RVXLEN RV32 | ||
20 | -#elif defined(TARGET_RISCV64) | ||
21 | -#define RVXLEN RV64 | ||
22 | -#endif | ||
23 | - | ||
24 | #define RV(x) ((target_ulong)1 << (x - 'A')) | ||
25 | |||
26 | #define RVI RV('I') | ||
27 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/riscv/cpu.c | ||
30 | +++ b/target/riscv/cpu.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static void set_resetvec(CPURISCVState *env, target_ulong resetvec) | ||
32 | static void riscv_any_cpu_init(Object *obj) | ||
33 | { | ||
34 | CPURISCVState *env = &RISCV_CPU(obj)->env; | ||
35 | - set_misa(env, RVXLEN | RVI | RVM | RVA | RVF | RVD | RVC | RVU); | ||
36 | +#if defined(TARGET_RISCV32) | ||
37 | + set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVD | RVC | RVU); | ||
38 | +#elif defined(TARGET_RISCV64) | ||
39 | + set_misa(env, RV64 | RVI | RVM | RVA | RVF | RVD | RVC | RVU); | ||
40 | +#endif | ||
41 | set_priv_version(env, PRIV_VERSION_1_11_0); | ||
42 | } | ||
43 | |||
44 | -- | ||
45 | 2.31.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This also ensures that the SD bit is not writable. | ||
1 | 2 | ||
3 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
6 | Message-id: 9ea842309f0fd7adff172790f5b5fc058b40f2f1.1619234854.git.alistair.francis@wdc.com | ||
7 | --- | ||
8 | target/riscv/cpu_bits.h | 6 ------ | ||
9 | target/riscv/csr.c | 9 ++++++++- | ||
10 | 2 files changed, 8 insertions(+), 7 deletions(-) | ||
11 | |||
12 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/riscv/cpu_bits.h | ||
15 | +++ b/target/riscv/cpu_bits.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | #define SSTATUS32_SD 0x80000000 | ||
18 | #define SSTATUS64_SD 0x8000000000000000ULL | ||
19 | |||
20 | -#if defined(TARGET_RISCV32) | ||
21 | -#define SSTATUS_SD SSTATUS32_SD | ||
22 | -#elif defined(TARGET_RISCV64) | ||
23 | -#define SSTATUS_SD SSTATUS64_SD | ||
24 | -#endif | ||
25 | - | ||
26 | /* hstatus CSR bits */ | ||
27 | #define HSTATUS_VSBE 0x00000020 | ||
28 | #define HSTATUS_GVA 0x00000040 | ||
29 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/riscv/csr.c | ||
32 | +++ b/target/riscv/csr.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static const target_ulong delegable_excps = | ||
34 | (1ULL << (RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT)); | ||
35 | static const target_ulong sstatus_v1_10_mask = SSTATUS_SIE | SSTATUS_SPIE | | ||
36 | SSTATUS_UIE | SSTATUS_UPIE | SSTATUS_SPP | SSTATUS_FS | SSTATUS_XS | | ||
37 | - SSTATUS_SUM | SSTATUS_MXR | SSTATUS_SD; | ||
38 | + SSTATUS_SUM | SSTATUS_MXR; | ||
39 | static const target_ulong sip_writable_mask = SIP_SSIP | MIP_USIP | MIP_UEIP; | ||
40 | static const target_ulong hip_writable_mask = MIP_VSSIP; | ||
41 | static const target_ulong hvip_writable_mask = MIP_VSSIP | MIP_VSTIP | MIP_VSEIP; | ||
42 | @@ -XXX,XX +XXX,XX @@ static RISCVException read_sstatus(CPURISCVState *env, int csrno, | ||
43 | target_ulong *val) | ||
44 | { | ||
45 | target_ulong mask = (sstatus_v1_10_mask); | ||
46 | + | ||
47 | + if (riscv_cpu_is_32bit(env)) { | ||
48 | + mask |= SSTATUS32_SD; | ||
49 | + } else { | ||
50 | + mask |= SSTATUS64_SD; | ||
51 | + } | ||
52 | + | ||
53 | *val = env->mstatus & mask; | ||
54 | return RISCV_EXCP_NONE; | ||
55 | } | ||
56 | -- | ||
57 | 2.31.1 | ||
58 | |||
59 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
4 | Message-id: 665f624bfdc2e3ca64265004b07de7489c77a766.1619234854.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/cpu_bits.h | 11 ----------- | ||
7 | target/riscv/cpu_helper.c | 24 +++++++++++++++--------- | ||
8 | 2 files changed, 15 insertions(+), 20 deletions(-) | ||
1 | 9 | ||
10 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/riscv/cpu_bits.h | ||
13 | +++ b/target/riscv/cpu_bits.h | ||
14 | @@ -XXX,XX +XXX,XX @@ | ||
15 | #define CSR_HTIMEDELTA 0x605 | ||
16 | #define CSR_HTIMEDELTAH 0x615 | ||
17 | |||
18 | -#if defined(TARGET_RISCV32) | ||
19 | -#define HGATP_MODE SATP32_MODE | ||
20 | -#define HGATP_VMID SATP32_ASID | ||
21 | -#define HGATP_PPN SATP32_PPN | ||
22 | -#endif | ||
23 | -#if defined(TARGET_RISCV64) | ||
24 | -#define HGATP_MODE SATP64_MODE | ||
25 | -#define HGATP_VMID SATP64_ASID | ||
26 | -#define HGATP_PPN SATP64_PPN | ||
27 | -#endif | ||
28 | - | ||
29 | /* Virtual CSRs */ | ||
30 | #define CSR_VSSTATUS 0x200 | ||
31 | #define CSR_VSIE 0x204 | ||
32 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/riscv/cpu_helper.c | ||
35 | +++ b/target/riscv/cpu_helper.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, | ||
37 | } | ||
38 | widened = 0; | ||
39 | } else { | ||
40 | - base = (hwaddr)get_field(env->hgatp, HGATP_PPN) << PGSHIFT; | ||
41 | - vm = get_field(env->hgatp, HGATP_MODE); | ||
42 | + if (riscv_cpu_is_32bit(env)) { | ||
43 | + base = (hwaddr)get_field(env->hgatp, SATP32_PPN) << PGSHIFT; | ||
44 | + vm = get_field(env->hgatp, SATP32_MODE); | ||
45 | + } else { | ||
46 | + base = (hwaddr)get_field(env->hgatp, SATP64_PPN) << PGSHIFT; | ||
47 | + vm = get_field(env->hgatp, SATP64_MODE); | ||
48 | + } | ||
49 | widened = 2; | ||
50 | } | ||
51 | /* status.SUM will be ignored if execute on background */ | ||
52 | @@ -XXX,XX +XXX,XX @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, | ||
53 | bool first_stage, bool two_stage) | ||
54 | { | ||
55 | CPUState *cs = env_cpu(env); | ||
56 | - int page_fault_exceptions; | ||
57 | + int page_fault_exceptions, vm; | ||
58 | + | ||
59 | if (first_stage) { | ||
60 | - page_fault_exceptions = | ||
61 | - get_field(env->satp, SATP_MODE) != VM_1_10_MBARE && | ||
62 | - !pmp_violation; | ||
63 | + vm = get_field(env->satp, SATP_MODE); | ||
64 | + } else if (riscv_cpu_is_32bit(env)) { | ||
65 | + vm = get_field(env->hgatp, SATP32_MODE); | ||
66 | } else { | ||
67 | - page_fault_exceptions = | ||
68 | - get_field(env->hgatp, HGATP_MODE) != VM_1_10_MBARE && | ||
69 | - !pmp_violation; | ||
70 | + vm = get_field(env->hgatp, SATP64_MODE); | ||
71 | } | ||
72 | + page_fault_exceptions = vm != VM_1_10_MBARE && !pmp_violation; | ||
73 | + | ||
74 | switch (access_type) { | ||
75 | case MMU_INST_FETCH: | ||
76 | if (riscv_cpu_virt_enabled(env) && !first_stage) { | ||
77 | -- | ||
78 | 2.31.1 | ||
79 | |||
80 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Message-id: fcc125d96da941b56c817c9dd6068dc36478fc53.1619234854.git.alistair.francis@wdc.com | ||
4 | --- | ||
5 | target/riscv/cpu_bits.h | 10 ---------- | ||
6 | target/riscv/csr.c | 12 ++++++++++-- | ||
7 | target/riscv/translate.c | 19 +++++++++++++++++-- | ||
8 | 3 files changed, 27 insertions(+), 14 deletions(-) | ||
1 | 9 | ||
10 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/riscv/cpu_bits.h | ||
13 | +++ b/target/riscv/cpu_bits.h | ||
14 | @@ -XXX,XX +XXX,XX @@ | ||
15 | #define MXL_RV64 2 | ||
16 | #define MXL_RV128 3 | ||
17 | |||
18 | -#if defined(TARGET_RISCV32) | ||
19 | -#define MSTATUS_SD MSTATUS32_SD | ||
20 | -#define MISA_MXL MISA32_MXL | ||
21 | -#define MXL_VAL MXL_RV32 | ||
22 | -#elif defined(TARGET_RISCV64) | ||
23 | -#define MSTATUS_SD MSTATUS64_SD | ||
24 | -#define MISA_MXL MISA64_MXL | ||
25 | -#define MXL_VAL MXL_RV64 | ||
26 | -#endif | ||
27 | - | ||
28 | /* sstatus CSR bits */ | ||
29 | #define SSTATUS_UIE 0x00000001 | ||
30 | #define SSTATUS_SIE 0x00000002 | ||
31 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/riscv/csr.c | ||
34 | +++ b/target/riscv/csr.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, | ||
36 | |||
37 | dirty = ((mstatus & MSTATUS_FS) == MSTATUS_FS) | | ||
38 | ((mstatus & MSTATUS_XS) == MSTATUS_XS); | ||
39 | - mstatus = set_field(mstatus, MSTATUS_SD, dirty); | ||
40 | + if (riscv_cpu_is_32bit(env)) { | ||
41 | + mstatus = set_field(mstatus, MSTATUS32_SD, dirty); | ||
42 | + } else { | ||
43 | + mstatus = set_field(mstatus, MSTATUS64_SD, dirty); | ||
44 | + } | ||
45 | env->mstatus = mstatus; | ||
46 | |||
47 | return RISCV_EXCP_NONE; | ||
48 | @@ -XXX,XX +XXX,XX @@ static RISCVException write_misa(CPURISCVState *env, int csrno, | ||
49 | } | ||
50 | |||
51 | /* misa.MXL writes are not supported by QEMU */ | ||
52 | - val = (env->misa & MISA_MXL) | (val & ~MISA_MXL); | ||
53 | + if (riscv_cpu_is_32bit(env)) { | ||
54 | + val = (env->misa & MISA32_MXL) | (val & ~MISA32_MXL); | ||
55 | + } else { | ||
56 | + val = (env->misa & MISA64_MXL) | (val & ~MISA64_MXL); | ||
57 | + } | ||
58 | |||
59 | /* flush translation cache */ | ||
60 | if (val != env->misa) { | ||
61 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/riscv/translate.c | ||
64 | +++ b/target/riscv/translate.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext) | ||
66 | return ctx->misa & ext; | ||
67 | } | ||
68 | |||
69 | +#ifdef TARGET_RISCV32 | ||
70 | +# define is_32bit(ctx) true | ||
71 | +#elif defined(CONFIG_USER_ONLY) | ||
72 | +# define is_32bit(ctx) false | ||
73 | +#else | ||
74 | +static inline bool is_32bit(DisasContext *ctx) | ||
75 | +{ | ||
76 | + return (ctx->misa & RV32) == RV32; | ||
77 | +} | ||
78 | +#endif | ||
79 | + | ||
80 | /* | ||
81 | * RISC-V requires NaN-boxing of narrower width floating point values. | ||
82 | * This applies when a 32-bit value is assigned to a 64-bit FP register. | ||
83 | @@ -XXX,XX +XXX,XX @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) | ||
84 | static void mark_fs_dirty(DisasContext *ctx) | ||
85 | { | ||
86 | TCGv tmp; | ||
87 | + target_ulong sd; | ||
88 | + | ||
89 | if (ctx->mstatus_fs == MSTATUS_FS) { | ||
90 | return; | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ static void mark_fs_dirty(DisasContext *ctx) | ||
93 | ctx->mstatus_fs = MSTATUS_FS; | ||
94 | |||
95 | tmp = tcg_temp_new(); | ||
96 | + sd = is_32bit(ctx) ? MSTATUS32_SD : MSTATUS64_SD; | ||
97 | + | ||
98 | tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus)); | ||
99 | - tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | MSTATUS_SD); | ||
100 | + tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd); | ||
101 | tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus)); | ||
102 | |||
103 | if (ctx->virt_enabled) { | ||
104 | tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs)); | ||
105 | - tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | MSTATUS_SD); | ||
106 | + tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd); | ||
107 | tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs)); | ||
108 | } | ||
109 | tcg_temp_free(tmp); | ||
110 | -- | ||
111 | 2.31.1 | ||
112 | |||
113 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Message-id: 6b701769d6621f45ba1739334198e36a64fe04df.1619234854.git.alistair.francis@wdc.com | ||
4 | --- | ||
5 | target/riscv/cpu_bits.h | 11 ----------- | ||
6 | target/riscv/cpu_helper.c | 32 ++++++++++++++++++++++++-------- | ||
7 | target/riscv/csr.c | 19 +++++++++++++++---- | ||
8 | target/riscv/monitor.c | 22 +++++++++++++++++----- | ||
9 | 4 files changed, 56 insertions(+), 28 deletions(-) | ||
1 | 10 | ||
11 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/riscv/cpu_bits.h | ||
14 | +++ b/target/riscv/cpu_bits.h | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | #define SATP64_ASID 0x0FFFF00000000000ULL | ||
17 | #define SATP64_PPN 0x00000FFFFFFFFFFFULL | ||
18 | |||
19 | -#if defined(TARGET_RISCV32) | ||
20 | -#define SATP_MODE SATP32_MODE | ||
21 | -#define SATP_ASID SATP32_ASID | ||
22 | -#define SATP_PPN SATP32_PPN | ||
23 | -#endif | ||
24 | -#if defined(TARGET_RISCV64) | ||
25 | -#define SATP_MODE SATP64_MODE | ||
26 | -#define SATP_ASID SATP64_ASID | ||
27 | -#define SATP_PPN SATP64_PPN | ||
28 | -#endif | ||
29 | - | ||
30 | /* VM modes (mstatus.vm) privileged ISA 1.9.1 */ | ||
31 | #define VM_1_09_MBARE 0 | ||
32 | #define VM_1_09_MBB 1 | ||
33 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/riscv/cpu_helper.c | ||
36 | +++ b/target/riscv/cpu_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, | ||
38 | |||
39 | if (first_stage == true) { | ||
40 | if (use_background) { | ||
41 | - base = (hwaddr)get_field(env->vsatp, SATP_PPN) << PGSHIFT; | ||
42 | - vm = get_field(env->vsatp, SATP_MODE); | ||
43 | + if (riscv_cpu_is_32bit(env)) { | ||
44 | + base = (hwaddr)get_field(env->vsatp, SATP32_PPN) << PGSHIFT; | ||
45 | + vm = get_field(env->vsatp, SATP32_MODE); | ||
46 | + } else { | ||
47 | + base = (hwaddr)get_field(env->vsatp, SATP64_PPN) << PGSHIFT; | ||
48 | + vm = get_field(env->vsatp, SATP64_MODE); | ||
49 | + } | ||
50 | } else { | ||
51 | - base = (hwaddr)get_field(env->satp, SATP_PPN) << PGSHIFT; | ||
52 | - vm = get_field(env->satp, SATP_MODE); | ||
53 | + if (riscv_cpu_is_32bit(env)) { | ||
54 | + base = (hwaddr)get_field(env->satp, SATP32_PPN) << PGSHIFT; | ||
55 | + vm = get_field(env->satp, SATP32_MODE); | ||
56 | + } else { | ||
57 | + base = (hwaddr)get_field(env->satp, SATP64_PPN) << PGSHIFT; | ||
58 | + vm = get_field(env->satp, SATP64_MODE); | ||
59 | + } | ||
60 | } | ||
61 | widened = 0; | ||
62 | } else { | ||
63 | @@ -XXX,XX +XXX,XX @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, | ||
64 | { | ||
65 | CPUState *cs = env_cpu(env); | ||
66 | int page_fault_exceptions, vm; | ||
67 | + uint64_t stap_mode; | ||
68 | + | ||
69 | + if (riscv_cpu_is_32bit(env)) { | ||
70 | + stap_mode = SATP32_MODE; | ||
71 | + } else { | ||
72 | + stap_mode = SATP64_MODE; | ||
73 | + } | ||
74 | |||
75 | if (first_stage) { | ||
76 | - vm = get_field(env->satp, SATP_MODE); | ||
77 | - } else if (riscv_cpu_is_32bit(env)) { | ||
78 | - vm = get_field(env->hgatp, SATP32_MODE); | ||
79 | + vm = get_field(env->satp, stap_mode); | ||
80 | } else { | ||
81 | - vm = get_field(env->hgatp, SATP64_MODE); | ||
82 | + vm = get_field(env->hgatp, stap_mode); | ||
83 | } | ||
84 | + | ||
85 | page_fault_exceptions = vm != VM_1_10_MBARE && !pmp_violation; | ||
86 | |||
87 | switch (access_type) { | ||
88 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/riscv/csr.c | ||
91 | +++ b/target/riscv/csr.c | ||
92 | @@ -XXX,XX +XXX,XX @@ static RISCVException read_satp(CPURISCVState *env, int csrno, | ||
93 | static RISCVException write_satp(CPURISCVState *env, int csrno, | ||
94 | target_ulong val) | ||
95 | { | ||
96 | + int vm, mask, asid; | ||
97 | + | ||
98 | if (!riscv_feature(env, RISCV_FEATURE_MMU)) { | ||
99 | return RISCV_EXCP_NONE; | ||
100 | } | ||
101 | - if (validate_vm(env, get_field(val, SATP_MODE)) && | ||
102 | - ((val ^ env->satp) & (SATP_MODE | SATP_ASID | SATP_PPN))) | ||
103 | - { | ||
104 | + | ||
105 | + if (riscv_cpu_is_32bit(env)) { | ||
106 | + vm = validate_vm(env, get_field(val, SATP32_MODE)); | ||
107 | + mask = (val ^ env->satp) & (SATP32_MODE | SATP32_ASID | SATP32_PPN); | ||
108 | + asid = (val ^ env->satp) & SATP32_ASID; | ||
109 | + } else { | ||
110 | + vm = validate_vm(env, get_field(val, SATP64_MODE)); | ||
111 | + mask = (val ^ env->satp) & (SATP64_MODE | SATP64_ASID | SATP64_PPN); | ||
112 | + asid = (val ^ env->satp) & SATP64_ASID; | ||
113 | + } | ||
114 | + | ||
115 | + if (vm && mask) { | ||
116 | if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { | ||
117 | return RISCV_EXCP_ILLEGAL_INST; | ||
118 | } else { | ||
119 | - if ((val ^ env->satp) & SATP_ASID) { | ||
120 | + if (asid) { | ||
121 | tlb_flush(env_cpu(env)); | ||
122 | } | ||
123 | env->satp = val; | ||
124 | diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/target/riscv/monitor.c | ||
127 | +++ b/target/riscv/monitor.c | ||
128 | @@ -XXX,XX +XXX,XX @@ static void mem_info_svxx(Monitor *mon, CPUArchState *env) | ||
129 | target_ulong last_size; | ||
130 | int last_attr; | ||
131 | |||
132 | - base = (hwaddr)get_field(env->satp, SATP_PPN) << PGSHIFT; | ||
133 | + if (riscv_cpu_is_32bit(env)) { | ||
134 | + base = (hwaddr)get_field(env->satp, SATP32_PPN) << PGSHIFT; | ||
135 | + vm = get_field(env->satp, SATP32_MODE); | ||
136 | + } else { | ||
137 | + base = (hwaddr)get_field(env->satp, SATP64_PPN) << PGSHIFT; | ||
138 | + vm = get_field(env->satp, SATP64_MODE); | ||
139 | + } | ||
140 | |||
141 | - vm = get_field(env->satp, SATP_MODE); | ||
142 | switch (vm) { | ||
143 | case VM_1_10_SV32: | ||
144 | levels = 2; | ||
145 | @@ -XXX,XX +XXX,XX @@ void hmp_info_mem(Monitor *mon, const QDict *qdict) | ||
146 | return; | ||
147 | } | ||
148 | |||
149 | - if (!(env->satp & SATP_MODE)) { | ||
150 | - monitor_printf(mon, "No translation or protection\n"); | ||
151 | - return; | ||
152 | + if (riscv_cpu_is_32bit(env)) { | ||
153 | + if (!(env->satp & SATP32_MODE)) { | ||
154 | + monitor_printf(mon, "No translation or protection\n"); | ||
155 | + return; | ||
156 | + } | ||
157 | + } else { | ||
158 | + if (!(env->satp & SATP64_MODE)) { | ||
159 | + monitor_printf(mon, "No translation or protection\n"); | ||
160 | + return; | ||
161 | + } | ||
162 | } | ||
163 | |||
164 | mem_info_svxx(mon, env); | ||
165 | -- | ||
166 | 2.31.1 | ||
167 | |||
168 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
4 | Message-id: e095b57af0d419c8ed822958f04dfc732d7beb7e.1619234854.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/cpu_bits.h | 6 ------ | ||
7 | 1 file changed, 6 deletions(-) | ||
1 | 8 | ||
9 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/target/riscv/cpu_bits.h | ||
12 | +++ b/target/riscv/cpu_bits.h | ||
13 | @@ -XXX,XX +XXX,XX @@ | ||
14 | #define HSTATUS32_WPRI 0xFF8FF87E | ||
15 | #define HSTATUS64_WPRI 0xFFFFFFFFFF8FF87EULL | ||
16 | |||
17 | -#if defined(TARGET_RISCV32) | ||
18 | -#define HSTATUS_WPRI HSTATUS32_WPRI | ||
19 | -#elif defined(TARGET_RISCV64) | ||
20 | -#define HSTATUS_WPRI HSTATUS64_WPRI | ||
21 | -#endif | ||
22 | - | ||
23 | #define HCOUNTEREN_CY (1 << 0) | ||
24 | #define HCOUNTEREN_TM (1 << 1) | ||
25 | #define HCOUNTEREN_IR (1 << 2) | ||
26 | -- | ||
27 | 2.31.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
2 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
4 | Message-id: 4853459564af35a6690120c74ad892f60cec35ff.1619234854.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/translate.c | 6 ------ | ||
7 | 1 file changed, 6 deletions(-) | ||
1 | 8 | ||
9 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/target/riscv/translate.c | ||
12 | +++ b/target/riscv/translate.c | ||
13 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
14 | CPUState *cs; | ||
15 | } DisasContext; | ||
16 | |||
17 | -#ifdef TARGET_RISCV64 | ||
18 | -#define CASE_OP_32_64(X) case X: case glue(X, W) | ||
19 | -#else | ||
20 | -#define CASE_OP_32_64(X) case X | ||
21 | -#endif | ||
22 | - | ||
23 | static inline bool has_ext(DisasContext *ctx, uint32_t ext) | ||
24 | { | ||
25 | return ctx->misa & ext; | ||
26 | -- | ||
27 | 2.31.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This patch removes the insn32-64.decode decode file and consolidates the | ||
2 | instructions into the general RISC-V insn32.decode decode tree. | ||
1 | 3 | ||
4 | This means that all of the instructions are avaliable in both the 32-bit | ||
5 | and 64-bit builds. This also means that we run a check to ensure we are | ||
6 | running a 64-bit softmmu before we execute the 64-bit only instructions. | ||
7 | This allows us to include the 32-bit instructions in the 64-bit build, | ||
8 | while also ensuring that 32-bit only software can not execute the | ||
9 | instructions. | ||
10 | |||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: db709360e2be47d2f9c6483ab973fe4791aefa77.1619234854.git.alistair.francis@wdc.com | ||
14 | --- | ||
15 | target/riscv/helper.h | 18 +++-- | ||
16 | target/riscv/insn32-64.decode | 88 ------------------------- | ||
17 | target/riscv/insn32.decode | 67 ++++++++++++++++++- | ||
18 | target/riscv/fpu_helper.c | 16 ++--- | ||
19 | target/riscv/translate.c | 9 ++- | ||
20 | target/riscv/vector_helper.c | 4 -- | ||
21 | target/riscv/insn_trans/trans_rva.c.inc | 14 +++- | ||
22 | target/riscv/insn_trans/trans_rvd.c.inc | 17 ++++- | ||
23 | target/riscv/insn_trans/trans_rvf.c.inc | 6 +- | ||
24 | target/riscv/insn_trans/trans_rvh.c.inc | 8 ++- | ||
25 | target/riscv/insn_trans/trans_rvi.c.inc | 16 +++-- | ||
26 | target/riscv/insn_trans/trans_rvm.c.inc | 12 +++- | ||
27 | target/riscv/insn_trans/trans_rvv.c.inc | 39 +++++------ | ||
28 | target/riscv/meson.build | 2 +- | ||
29 | 14 files changed, 166 insertions(+), 150 deletions(-) | ||
30 | delete mode 100644 target/riscv/insn32-64.decode | ||
31 | |||
32 | diff --git a/target/riscv/helper.h b/target/riscv/helper.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/riscv/helper.h | ||
35 | +++ b/target/riscv/helper.h | ||
36 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(flt_s, TCG_CALL_NO_RWG, tl, env, i64, i64) | ||
37 | DEF_HELPER_FLAGS_3(feq_s, TCG_CALL_NO_RWG, tl, env, i64, i64) | ||
38 | DEF_HELPER_FLAGS_2(fcvt_w_s, TCG_CALL_NO_RWG, tl, env, i64) | ||
39 | DEF_HELPER_FLAGS_2(fcvt_wu_s, TCG_CALL_NO_RWG, tl, env, i64) | ||
40 | -DEF_HELPER_FLAGS_2(fcvt_l_s, TCG_CALL_NO_RWG, i64, env, i64) | ||
41 | -DEF_HELPER_FLAGS_2(fcvt_lu_s, TCG_CALL_NO_RWG, i64, env, i64) | ||
42 | +DEF_HELPER_FLAGS_2(fcvt_l_s, TCG_CALL_NO_RWG, tl, env, i64) | ||
43 | +DEF_HELPER_FLAGS_2(fcvt_lu_s, TCG_CALL_NO_RWG, tl, env, i64) | ||
44 | DEF_HELPER_FLAGS_2(fcvt_s_w, TCG_CALL_NO_RWG, i64, env, tl) | ||
45 | DEF_HELPER_FLAGS_2(fcvt_s_wu, TCG_CALL_NO_RWG, i64, env, tl) | ||
46 | -DEF_HELPER_FLAGS_2(fcvt_s_l, TCG_CALL_NO_RWG, i64, env, i64) | ||
47 | -DEF_HELPER_FLAGS_2(fcvt_s_lu, TCG_CALL_NO_RWG, i64, env, i64) | ||
48 | +DEF_HELPER_FLAGS_2(fcvt_s_l, TCG_CALL_NO_RWG, i64, env, tl) | ||
49 | +DEF_HELPER_FLAGS_2(fcvt_s_lu, TCG_CALL_NO_RWG, i64, env, tl) | ||
50 | DEF_HELPER_FLAGS_1(fclass_s, TCG_CALL_NO_RWG_SE, tl, i64) | ||
51 | |||
52 | /* Floating Point - Double Precision */ | ||
53 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(flt_d, TCG_CALL_NO_RWG, tl, env, i64, i64) | ||
54 | DEF_HELPER_FLAGS_3(feq_d, TCG_CALL_NO_RWG, tl, env, i64, i64) | ||
55 | DEF_HELPER_FLAGS_2(fcvt_w_d, TCG_CALL_NO_RWG, tl, env, i64) | ||
56 | DEF_HELPER_FLAGS_2(fcvt_wu_d, TCG_CALL_NO_RWG, tl, env, i64) | ||
57 | -DEF_HELPER_FLAGS_2(fcvt_l_d, TCG_CALL_NO_RWG, i64, env, i64) | ||
58 | -DEF_HELPER_FLAGS_2(fcvt_lu_d, TCG_CALL_NO_RWG, i64, env, i64) | ||
59 | +DEF_HELPER_FLAGS_2(fcvt_l_d, TCG_CALL_NO_RWG, tl, env, i64) | ||
60 | +DEF_HELPER_FLAGS_2(fcvt_lu_d, TCG_CALL_NO_RWG, tl, env, i64) | ||
61 | DEF_HELPER_FLAGS_2(fcvt_d_w, TCG_CALL_NO_RWG, i64, env, tl) | ||
62 | DEF_HELPER_FLAGS_2(fcvt_d_wu, TCG_CALL_NO_RWG, i64, env, tl) | ||
63 | -DEF_HELPER_FLAGS_2(fcvt_d_l, TCG_CALL_NO_RWG, i64, env, i64) | ||
64 | -DEF_HELPER_FLAGS_2(fcvt_d_lu, TCG_CALL_NO_RWG, i64, env, i64) | ||
65 | +DEF_HELPER_FLAGS_2(fcvt_d_l, TCG_CALL_NO_RWG, i64, env, tl) | ||
66 | +DEF_HELPER_FLAGS_2(fcvt_d_lu, TCG_CALL_NO_RWG, i64, env, tl) | ||
67 | DEF_HELPER_FLAGS_1(fclass_d, TCG_CALL_NO_RWG_SE, tl, i64) | ||
68 | |||
69 | /* Special functions */ | ||
70 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vlhuff_v_w, void, ptr, ptr, tl, env, i32) | ||
71 | DEF_HELPER_5(vlhuff_v_d, void, ptr, ptr, tl, env, i32) | ||
72 | DEF_HELPER_5(vlwuff_v_w, void, ptr, ptr, tl, env, i32) | ||
73 | DEF_HELPER_5(vlwuff_v_d, void, ptr, ptr, tl, env, i32) | ||
74 | -#ifdef TARGET_RISCV64 | ||
75 | DEF_HELPER_6(vamoswapw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
76 | DEF_HELPER_6(vamoswapd_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
77 | DEF_HELPER_6(vamoaddw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
78 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vamominuw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
79 | DEF_HELPER_6(vamominud_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
80 | DEF_HELPER_6(vamomaxuw_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
81 | DEF_HELPER_6(vamomaxud_v_d, void, ptr, ptr, tl, ptr, env, i32) | ||
82 | -#endif | ||
83 | DEF_HELPER_6(vamoswapw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
84 | DEF_HELPER_6(vamoaddw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
85 | DEF_HELPER_6(vamoxorw_v_w, void, ptr, ptr, tl, ptr, env, i32) | ||
86 | diff --git a/target/riscv/insn32-64.decode b/target/riscv/insn32-64.decode | ||
87 | deleted file mode 100644 | ||
88 | index XXXXXXX..XXXXXXX | ||
89 | --- a/target/riscv/insn32-64.decode | ||
90 | +++ /dev/null | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | -# | ||
93 | -# RISC-V translation routines for the RV Instruction Set. | ||
94 | -# | ||
95 | -# Copyright (c) 2018 Peer Adelt, peer.adelt@hni.uni-paderborn.de | ||
96 | -# Bastian Koppelmann, kbastian@mail.uni-paderborn.de | ||
97 | -# | ||
98 | -# This program is free software; you can redistribute it and/or modify it | ||
99 | -# under the terms and conditions of the GNU General Public License, | ||
100 | -# version 2 or later, as published by the Free Software Foundation. | ||
101 | -# | ||
102 | -# This program is distributed in the hope it will be useful, but WITHOUT | ||
103 | -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
104 | -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
105 | -# more details. | ||
106 | -# | ||
107 | -# You should have received a copy of the GNU General Public License along with | ||
108 | -# this program. If not, see <http://www.gnu.org/licenses/>. | ||
109 | - | ||
110 | -# This is concatenated with insn32.decode for risc64 targets. | ||
111 | -# Most of the fields and formats are there. | ||
112 | - | ||
113 | -%sh5 20:5 | ||
114 | - | ||
115 | -@sh5 ....... ..... ..... ... ..... ....... &shift shamt=%sh5 %rs1 %rd | ||
116 | - | ||
117 | -# *** RV64I Base Instruction Set (in addition to RV32I) *** | ||
118 | -lwu ............ ..... 110 ..... 0000011 @i | ||
119 | -ld ............ ..... 011 ..... 0000011 @i | ||
120 | -sd ....... ..... ..... 011 ..... 0100011 @s | ||
121 | -addiw ............ ..... 000 ..... 0011011 @i | ||
122 | -slliw 0000000 ..... ..... 001 ..... 0011011 @sh5 | ||
123 | -srliw 0000000 ..... ..... 101 ..... 0011011 @sh5 | ||
124 | -sraiw 0100000 ..... ..... 101 ..... 0011011 @sh5 | ||
125 | -addw 0000000 ..... ..... 000 ..... 0111011 @r | ||
126 | -subw 0100000 ..... ..... 000 ..... 0111011 @r | ||
127 | -sllw 0000000 ..... ..... 001 ..... 0111011 @r | ||
128 | -srlw 0000000 ..... ..... 101 ..... 0111011 @r | ||
129 | -sraw 0100000 ..... ..... 101 ..... 0111011 @r | ||
130 | - | ||
131 | -# *** RV64M Standard Extension (in addition to RV32M) *** | ||
132 | -mulw 0000001 ..... ..... 000 ..... 0111011 @r | ||
133 | -divw 0000001 ..... ..... 100 ..... 0111011 @r | ||
134 | -divuw 0000001 ..... ..... 101 ..... 0111011 @r | ||
135 | -remw 0000001 ..... ..... 110 ..... 0111011 @r | ||
136 | -remuw 0000001 ..... ..... 111 ..... 0111011 @r | ||
137 | - | ||
138 | -# *** RV64A Standard Extension (in addition to RV32A) *** | ||
139 | -lr_d 00010 . . 00000 ..... 011 ..... 0101111 @atom_ld | ||
140 | -sc_d 00011 . . ..... ..... 011 ..... 0101111 @atom_st | ||
141 | -amoswap_d 00001 . . ..... ..... 011 ..... 0101111 @atom_st | ||
142 | -amoadd_d 00000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
143 | -amoxor_d 00100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
144 | -amoand_d 01100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
145 | -amoor_d 01000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
146 | -amomin_d 10000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
147 | -amomax_d 10100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
148 | -amominu_d 11000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
149 | -amomaxu_d 11100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
150 | - | ||
151 | -#*** Vector AMO operations (in addition to Zvamo) *** | ||
152 | -vamoswapd_v 00001 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
153 | -vamoaddd_v 00000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
154 | -vamoxord_v 00100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
155 | -vamoandd_v 01100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
156 | -vamoord_v 01000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
157 | -vamomind_v 10000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
158 | -vamomaxd_v 10100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
159 | -vamominud_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
160 | -vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
161 | - | ||
162 | -# *** RV64F Standard Extension (in addition to RV32F) *** | ||
163 | -fcvt_l_s 1100000 00010 ..... ... ..... 1010011 @r2_rm | ||
164 | -fcvt_lu_s 1100000 00011 ..... ... ..... 1010011 @r2_rm | ||
165 | -fcvt_s_l 1101000 00010 ..... ... ..... 1010011 @r2_rm | ||
166 | -fcvt_s_lu 1101000 00011 ..... ... ..... 1010011 @r2_rm | ||
167 | - | ||
168 | -# *** RV64D Standard Extension (in addition to RV32D) *** | ||
169 | -fcvt_l_d 1100001 00010 ..... ... ..... 1010011 @r2_rm | ||
170 | -fcvt_lu_d 1100001 00011 ..... ... ..... 1010011 @r2_rm | ||
171 | -fmv_x_d 1110001 00000 ..... 000 ..... 1010011 @r2 | ||
172 | -fcvt_d_l 1101001 00010 ..... ... ..... 1010011 @r2_rm | ||
173 | -fcvt_d_lu 1101001 00011 ..... ... ..... 1010011 @r2_rm | ||
174 | -fmv_d_x 1111001 00000 ..... 000 ..... 1010011 @r2 | ||
175 | - | ||
176 | -# *** RV32H Base Instruction Set *** | ||
177 | -hlv_wu 0110100 00001 ..... 100 ..... 1110011 @r2 | ||
178 | -hlv_d 0110110 00000 ..... 100 ..... 1110011 @r2 | ||
179 | -hsv_d 0110111 ..... ..... 100 00000 1110011 @r2_s | ||
180 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
181 | index XXXXXXX..XXXXXXX 100644 | ||
182 | --- a/target/riscv/insn32.decode | ||
183 | +++ b/target/riscv/insn32.decode | ||
184 | @@ -XXX,XX +XXX,XX @@ | ||
185 | %rs2 20:5 | ||
186 | %rs1 15:5 | ||
187 | %rd 7:5 | ||
188 | +%sh5 20:5 | ||
189 | |||
190 | %sh10 20:10 | ||
191 | %csr 20:12 | ||
192 | @@ -XXX,XX +XXX,XX @@ | ||
193 | @sfence_vma ....... ..... ..... ... ..... ....... %rs2 %rs1 | ||
194 | @sfence_vm ....... ..... ..... ... ..... ....... %rs1 | ||
195 | |||
196 | +# Formats 64: | ||
197 | +@sh5 ....... ..... ..... ... ..... ....... &shift shamt=%sh5 %rs1 %rd | ||
198 | |||
199 | # *** Privileged Instructions *** | ||
200 | ecall 000000000000 00000 000 00000 1110011 | ||
201 | @@ -XXX,XX +XXX,XX @@ csrrwi ............ ..... 101 ..... 1110011 @csr | ||
202 | csrrsi ............ ..... 110 ..... 1110011 @csr | ||
203 | csrrci ............ ..... 111 ..... 1110011 @csr | ||
204 | |||
205 | +# *** RV64I Base Instruction Set (in addition to RV32I) *** | ||
206 | +lwu ............ ..... 110 ..... 0000011 @i | ||
207 | +ld ............ ..... 011 ..... 0000011 @i | ||
208 | +sd ....... ..... ..... 011 ..... 0100011 @s | ||
209 | +addiw ............ ..... 000 ..... 0011011 @i | ||
210 | +slliw 0000000 ..... ..... 001 ..... 0011011 @sh5 | ||
211 | +srliw 0000000 ..... ..... 101 ..... 0011011 @sh5 | ||
212 | +sraiw 0100000 ..... ..... 101 ..... 0011011 @sh5 | ||
213 | +addw 0000000 ..... ..... 000 ..... 0111011 @r | ||
214 | +subw 0100000 ..... ..... 000 ..... 0111011 @r | ||
215 | +sllw 0000000 ..... ..... 001 ..... 0111011 @r | ||
216 | +srlw 0000000 ..... ..... 101 ..... 0111011 @r | ||
217 | +sraw 0100000 ..... ..... 101 ..... 0111011 @r | ||
218 | + | ||
219 | # *** RV32M Standard Extension *** | ||
220 | mul 0000001 ..... ..... 000 ..... 0110011 @r | ||
221 | mulh 0000001 ..... ..... 001 ..... 0110011 @r | ||
222 | @@ -XXX,XX +XXX,XX @@ divu 0000001 ..... ..... 101 ..... 0110011 @r | ||
223 | rem 0000001 ..... ..... 110 ..... 0110011 @r | ||
224 | remu 0000001 ..... ..... 111 ..... 0110011 @r | ||
225 | |||
226 | +# *** RV64M Standard Extension (in addition to RV32M) *** | ||
227 | +mulw 0000001 ..... ..... 000 ..... 0111011 @r | ||
228 | +divw 0000001 ..... ..... 100 ..... 0111011 @r | ||
229 | +divuw 0000001 ..... ..... 101 ..... 0111011 @r | ||
230 | +remw 0000001 ..... ..... 110 ..... 0111011 @r | ||
231 | +remuw 0000001 ..... ..... 111 ..... 0111011 @r | ||
232 | + | ||
233 | # *** RV32A Standard Extension *** | ||
234 | lr_w 00010 . . 00000 ..... 010 ..... 0101111 @atom_ld | ||
235 | sc_w 00011 . . ..... ..... 010 ..... 0101111 @atom_st | ||
236 | @@ -XXX,XX +XXX,XX @@ amomax_w 10100 . . ..... ..... 010 ..... 0101111 @atom_st | ||
237 | amominu_w 11000 . . ..... ..... 010 ..... 0101111 @atom_st | ||
238 | amomaxu_w 11100 . . ..... ..... 010 ..... 0101111 @atom_st | ||
239 | |||
240 | +# *** RV64A Standard Extension (in addition to RV32A) *** | ||
241 | +lr_d 00010 . . 00000 ..... 011 ..... 0101111 @atom_ld | ||
242 | +sc_d 00011 . . ..... ..... 011 ..... 0101111 @atom_st | ||
243 | +amoswap_d 00001 . . ..... ..... 011 ..... 0101111 @atom_st | ||
244 | +amoadd_d 00000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
245 | +amoxor_d 00100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
246 | +amoand_d 01100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
247 | +amoor_d 01000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
248 | +amomin_d 10000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
249 | +amomax_d 10100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
250 | +amominu_d 11000 . . ..... ..... 011 ..... 0101111 @atom_st | ||
251 | +amomaxu_d 11100 . . ..... ..... 011 ..... 0101111 @atom_st | ||
252 | + | ||
253 | # *** RV32F Standard Extension *** | ||
254 | flw ............ ..... 010 ..... 0000111 @i | ||
255 | fsw ....... ..... ..... 010 ..... 0100111 @s | ||
256 | @@ -XXX,XX +XXX,XX @@ fcvt_s_w 1101000 00000 ..... ... ..... 1010011 @r2_rm | ||
257 | fcvt_s_wu 1101000 00001 ..... ... ..... 1010011 @r2_rm | ||
258 | fmv_w_x 1111000 00000 ..... 000 ..... 1010011 @r2 | ||
259 | |||
260 | +# *** RV64F Standard Extension (in addition to RV32F) *** | ||
261 | +fcvt_l_s 1100000 00010 ..... ... ..... 1010011 @r2_rm | ||
262 | +fcvt_lu_s 1100000 00011 ..... ... ..... 1010011 @r2_rm | ||
263 | +fcvt_s_l 1101000 00010 ..... ... ..... 1010011 @r2_rm | ||
264 | +fcvt_s_lu 1101000 00011 ..... ... ..... 1010011 @r2_rm | ||
265 | + | ||
266 | # *** RV32D Standard Extension *** | ||
267 | fld ............ ..... 011 ..... 0000111 @i | ||
268 | fsd ....... ..... ..... 011 ..... 0100111 @s | ||
269 | @@ -XXX,XX +XXX,XX @@ fcvt_wu_d 1100001 00001 ..... ... ..... 1010011 @r2_rm | ||
270 | fcvt_d_w 1101001 00000 ..... ... ..... 1010011 @r2_rm | ||
271 | fcvt_d_wu 1101001 00001 ..... ... ..... 1010011 @r2_rm | ||
272 | |||
273 | +# *** RV64D Standard Extension (in addition to RV32D) *** | ||
274 | +fcvt_l_d 1100001 00010 ..... ... ..... 1010011 @r2_rm | ||
275 | +fcvt_lu_d 1100001 00011 ..... ... ..... 1010011 @r2_rm | ||
276 | +fmv_x_d 1110001 00000 ..... 000 ..... 1010011 @r2 | ||
277 | +fcvt_d_l 1101001 00010 ..... ... ..... 1010011 @r2_rm | ||
278 | +fcvt_d_lu 1101001 00011 ..... ... ..... 1010011 @r2_rm | ||
279 | +fmv_d_x 1111001 00000 ..... 000 ..... 1010011 @r2 | ||
280 | + | ||
281 | # *** RV32H Base Instruction Set *** | ||
282 | hlv_b 0110000 00000 ..... 100 ..... 1110011 @r2 | ||
283 | hlv_bu 0110000 00001 ..... 100 ..... 1110011 @r2 | ||
284 | @@ -XXX,XX +XXX,XX @@ hsv_w 0110101 ..... ..... 100 00000 1110011 @r2_s | ||
285 | hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma | ||
286 | hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma | ||
287 | |||
288 | -# *** RV32V Extension *** | ||
289 | +# *** RV32H Base Instruction Set *** | ||
290 | +hlv_wu 0110100 00001 ..... 100 ..... 1110011 @r2 | ||
291 | +hlv_d 0110110 00000 ..... 100 ..... 1110011 @r2 | ||
292 | +hsv_d 0110111 ..... ..... 100 00000 1110011 @r2_s | ||
293 | |||
294 | # *** Vector loads and stores are encoded within LOADFP/STORE-FP *** | ||
295 | vlb_v ... 100 . 00000 ..... 000 ..... 0000111 @r2_nfvm | ||
296 | @@ -XXX,XX +XXX,XX @@ vcompress_vm 010111 - ..... ..... 010 ..... 1010111 @r | ||
297 | |||
298 | vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm | ||
299 | vsetvl 1000000 ..... ..... 111 ..... 1010111 @r | ||
300 | + | ||
301 | +#*** Vector AMO operations (in addition to Zvamo) *** | ||
302 | +vamoswapd_v 00001 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
303 | +vamoaddd_v 00000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
304 | +vamoxord_v 00100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
305 | +vamoandd_v 01100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
306 | +vamoord_v 01000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
307 | +vamomind_v 10000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
308 | +vamomaxd_v 10100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
309 | +vamominud_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
310 | +vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm | ||
311 | diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c | ||
312 | index XXXXXXX..XXXXXXX 100644 | ||
313 | --- a/target/riscv/fpu_helper.c | ||
314 | +++ b/target/riscv/fpu_helper.c | ||
315 | @@ -XXX,XX +XXX,XX @@ target_ulong helper_fcvt_wu_s(CPURISCVState *env, uint64_t rs1) | ||
316 | return (int32_t)float32_to_uint32(frs1, &env->fp_status); | ||
317 | } | ||
318 | |||
319 | -uint64_t helper_fcvt_l_s(CPURISCVState *env, uint64_t rs1) | ||
320 | +target_ulong helper_fcvt_l_s(CPURISCVState *env, uint64_t rs1) | ||
321 | { | ||
322 | float32 frs1 = check_nanbox_s(rs1); | ||
323 | return float32_to_int64(frs1, &env->fp_status); | ||
324 | } | ||
325 | |||
326 | -uint64_t helper_fcvt_lu_s(CPURISCVState *env, uint64_t rs1) | ||
327 | +target_ulong helper_fcvt_lu_s(CPURISCVState *env, uint64_t rs1) | ||
328 | { | ||
329 | float32 frs1 = check_nanbox_s(rs1); | ||
330 | return float32_to_uint64(frs1, &env->fp_status); | ||
331 | @@ -XXX,XX +XXX,XX @@ uint64_t helper_fcvt_s_wu(CPURISCVState *env, target_ulong rs1) | ||
332 | return nanbox_s(uint32_to_float32((uint32_t)rs1, &env->fp_status)); | ||
333 | } | ||
334 | |||
335 | -uint64_t helper_fcvt_s_l(CPURISCVState *env, uint64_t rs1) | ||
336 | +uint64_t helper_fcvt_s_l(CPURISCVState *env, target_ulong rs1) | ||
337 | { | ||
338 | return nanbox_s(int64_to_float32(rs1, &env->fp_status)); | ||
339 | } | ||
340 | |||
341 | -uint64_t helper_fcvt_s_lu(CPURISCVState *env, uint64_t rs1) | ||
342 | +uint64_t helper_fcvt_s_lu(CPURISCVState *env, target_ulong rs1) | ||
343 | { | ||
344 | return nanbox_s(uint64_to_float32(rs1, &env->fp_status)); | ||
345 | } | ||
346 | @@ -XXX,XX +XXX,XX @@ target_ulong helper_fcvt_wu_d(CPURISCVState *env, uint64_t frs1) | ||
347 | return (int32_t)float64_to_uint32(frs1, &env->fp_status); | ||
348 | } | ||
349 | |||
350 | -uint64_t helper_fcvt_l_d(CPURISCVState *env, uint64_t frs1) | ||
351 | +target_ulong helper_fcvt_l_d(CPURISCVState *env, uint64_t frs1) | ||
352 | { | ||
353 | return float64_to_int64(frs1, &env->fp_status); | ||
354 | } | ||
355 | |||
356 | -uint64_t helper_fcvt_lu_d(CPURISCVState *env, uint64_t frs1) | ||
357 | +target_ulong helper_fcvt_lu_d(CPURISCVState *env, uint64_t frs1) | ||
358 | { | ||
359 | return float64_to_uint64(frs1, &env->fp_status); | ||
360 | } | ||
361 | @@ -XXX,XX +XXX,XX @@ uint64_t helper_fcvt_d_wu(CPURISCVState *env, target_ulong rs1) | ||
362 | return uint32_to_float64((uint32_t)rs1, &env->fp_status); | ||
363 | } | ||
364 | |||
365 | -uint64_t helper_fcvt_d_l(CPURISCVState *env, uint64_t rs1) | ||
366 | +uint64_t helper_fcvt_d_l(CPURISCVState *env, target_ulong rs1) | ||
367 | { | ||
368 | return int64_to_float64(rs1, &env->fp_status); | ||
369 | } | ||
370 | |||
371 | -uint64_t helper_fcvt_d_lu(CPURISCVState *env, uint64_t rs1) | ||
372 | +uint64_t helper_fcvt_d_lu(CPURISCVState *env, target_ulong rs1) | ||
373 | { | ||
374 | return uint64_to_float64(rs1, &env->fp_status); | ||
375 | } | ||
376 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | ||
377 | index XXXXXXX..XXXXXXX 100644 | ||
378 | --- a/target/riscv/translate.c | ||
379 | +++ b/target/riscv/translate.c | ||
380 | @@ -XXX,XX +XXX,XX @@ EX_SH(12) | ||
381 | } \ | ||
382 | } while (0) | ||
383 | |||
384 | +#define REQUIRE_64BIT(ctx) do { \ | ||
385 | + if (is_32bit(ctx)) { \ | ||
386 | + return false; \ | ||
387 | + } \ | ||
388 | +} while (0) | ||
389 | + | ||
390 | static int ex_rvc_register(DisasContext *ctx, int reg) | ||
391 | { | ||
392 | return 8 + reg; | ||
393 | @@ -XXX,XX +XXX,XX @@ static bool gen_arith_imm_tl(DisasContext *ctx, arg_i *a, | ||
394 | return true; | ||
395 | } | ||
396 | |||
397 | -#ifdef TARGET_RISCV64 | ||
398 | static void gen_addw(TCGv ret, TCGv arg1, TCGv arg2) | ||
399 | { | ||
400 | tcg_gen_add_tl(ret, arg1, arg2); | ||
401 | @@ -XXX,XX +XXX,XX @@ static bool gen_arith_div_uw(DisasContext *ctx, arg_r *a, | ||
402 | return true; | ||
403 | } | ||
404 | |||
405 | -#endif | ||
406 | - | ||
407 | static bool gen_arith(DisasContext *ctx, arg_r *a, | ||
408 | void(*func)(TCGv, TCGv, TCGv)) | ||
409 | { | ||
410 | diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c | ||
411 | index XXXXXXX..XXXXXXX 100644 | ||
412 | --- a/target/riscv/vector_helper.c | ||
413 | +++ b/target/riscv/vector_helper.c | ||
414 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_AMO_NOATOMIC_OP(vamominw_v_w, 32, 32, H4, DO_MIN, l) | ||
415 | GEN_VEXT_AMO_NOATOMIC_OP(vamomaxw_v_w, 32, 32, H4, DO_MAX, l) | ||
416 | GEN_VEXT_AMO_NOATOMIC_OP(vamominuw_v_w, 32, 32, H4, DO_MINU, l) | ||
417 | GEN_VEXT_AMO_NOATOMIC_OP(vamomaxuw_v_w, 32, 32, H4, DO_MAXU, l) | ||
418 | -#ifdef TARGET_RISCV64 | ||
419 | GEN_VEXT_AMO_NOATOMIC_OP(vamoswapw_v_d, 64, 32, H8, DO_SWAP, l) | ||
420 | GEN_VEXT_AMO_NOATOMIC_OP(vamoswapd_v_d, 64, 64, H8, DO_SWAP, q) | ||
421 | GEN_VEXT_AMO_NOATOMIC_OP(vamoaddw_v_d, 64, 32, H8, DO_ADD, l) | ||
422 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_AMO_NOATOMIC_OP(vamominuw_v_d, 64, 32, H8, DO_MINU, l) | ||
423 | GEN_VEXT_AMO_NOATOMIC_OP(vamominud_v_d, 64, 64, H8, DO_MINU, q) | ||
424 | GEN_VEXT_AMO_NOATOMIC_OP(vamomaxuw_v_d, 64, 32, H8, DO_MAXU, l) | ||
425 | GEN_VEXT_AMO_NOATOMIC_OP(vamomaxud_v_d, 64, 64, H8, DO_MAXU, q) | ||
426 | -#endif | ||
427 | |||
428 | static inline void | ||
429 | vext_amo_noatomic(void *vs3, void *v0, target_ulong base, | ||
430 | @@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vs3, void *v0, target_ulong base, \ | ||
431 | GETPC()); \ | ||
432 | } | ||
433 | |||
434 | -#ifdef TARGET_RISCV64 | ||
435 | GEN_VEXT_AMO(vamoswapw_v_d, int32_t, int64_t, idx_d, clearq) | ||
436 | GEN_VEXT_AMO(vamoswapd_v_d, int64_t, int64_t, idx_d, clearq) | ||
437 | GEN_VEXT_AMO(vamoaddw_v_d, int32_t, int64_t, idx_d, clearq) | ||
438 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_AMO(vamominuw_v_d, uint32_t, uint64_t, idx_d, clearq) | ||
439 | GEN_VEXT_AMO(vamominud_v_d, uint64_t, uint64_t, idx_d, clearq) | ||
440 | GEN_VEXT_AMO(vamomaxuw_v_d, uint32_t, uint64_t, idx_d, clearq) | ||
441 | GEN_VEXT_AMO(vamomaxud_v_d, uint64_t, uint64_t, idx_d, clearq) | ||
442 | -#endif | ||
443 | GEN_VEXT_AMO(vamoswapw_v_w, int32_t, int32_t, idx_w, clearl) | ||
444 | GEN_VEXT_AMO(vamoaddw_v_w, int32_t, int32_t, idx_w, clearl) | ||
445 | GEN_VEXT_AMO(vamoxorw_v_w, int32_t, int32_t, idx_w, clearl) | ||
446 | diff --git a/target/riscv/insn_trans/trans_rva.c.inc b/target/riscv/insn_trans/trans_rva.c.inc | ||
447 | index XXXXXXX..XXXXXXX 100644 | ||
448 | --- a/target/riscv/insn_trans/trans_rva.c.inc | ||
449 | +++ b/target/riscv/insn_trans/trans_rva.c.inc | ||
450 | @@ -XXX,XX +XXX,XX @@ static bool trans_amomaxu_w(DisasContext *ctx, arg_amomaxu_w *a) | ||
451 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umax_tl, (MO_ALIGN | MO_TESL)); | ||
452 | } | ||
453 | |||
454 | -#ifdef TARGET_RISCV64 | ||
455 | - | ||
456 | static bool trans_lr_d(DisasContext *ctx, arg_lr_d *a) | ||
457 | { | ||
458 | + REQUIRE_64BIT(ctx); | ||
459 | return gen_lr(ctx, a, MO_ALIGN | MO_TEQ); | ||
460 | } | ||
461 | |||
462 | static bool trans_sc_d(DisasContext *ctx, arg_sc_d *a) | ||
463 | { | ||
464 | + REQUIRE_64BIT(ctx); | ||
465 | return gen_sc(ctx, a, (MO_ALIGN | MO_TEQ)); | ||
466 | } | ||
467 | |||
468 | static bool trans_amoswap_d(DisasContext *ctx, arg_amoswap_d *a) | ||
469 | { | ||
470 | + REQUIRE_64BIT(ctx); | ||
471 | return gen_amo(ctx, a, &tcg_gen_atomic_xchg_tl, (MO_ALIGN | MO_TEQ)); | ||
472 | } | ||
473 | |||
474 | static bool trans_amoadd_d(DisasContext *ctx, arg_amoadd_d *a) | ||
475 | { | ||
476 | + REQUIRE_64BIT(ctx); | ||
477 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_add_tl, (MO_ALIGN | MO_TEQ)); | ||
478 | } | ||
479 | |||
480 | static bool trans_amoxor_d(DisasContext *ctx, arg_amoxor_d *a) | ||
481 | { | ||
482 | + REQUIRE_64BIT(ctx); | ||
483 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_xor_tl, (MO_ALIGN | MO_TEQ)); | ||
484 | } | ||
485 | |||
486 | static bool trans_amoand_d(DisasContext *ctx, arg_amoand_d *a) | ||
487 | { | ||
488 | + REQUIRE_64BIT(ctx); | ||
489 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_and_tl, (MO_ALIGN | MO_TEQ)); | ||
490 | } | ||
491 | |||
492 | static bool trans_amoor_d(DisasContext *ctx, arg_amoor_d *a) | ||
493 | { | ||
494 | + REQUIRE_64BIT(ctx); | ||
495 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_or_tl, (MO_ALIGN | MO_TEQ)); | ||
496 | } | ||
497 | |||
498 | static bool trans_amomin_d(DisasContext *ctx, arg_amomin_d *a) | ||
499 | { | ||
500 | + REQUIRE_64BIT(ctx); | ||
501 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_smin_tl, (MO_ALIGN | MO_TEQ)); | ||
502 | } | ||
503 | |||
504 | static bool trans_amomax_d(DisasContext *ctx, arg_amomax_d *a) | ||
505 | { | ||
506 | + REQUIRE_64BIT(ctx); | ||
507 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_smax_tl, (MO_ALIGN | MO_TEQ)); | ||
508 | } | ||
509 | |||
510 | static bool trans_amominu_d(DisasContext *ctx, arg_amominu_d *a) | ||
511 | { | ||
512 | + REQUIRE_64BIT(ctx); | ||
513 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umin_tl, (MO_ALIGN | MO_TEQ)); | ||
514 | } | ||
515 | |||
516 | static bool trans_amomaxu_d(DisasContext *ctx, arg_amomaxu_d *a) | ||
517 | { | ||
518 | + REQUIRE_64BIT(ctx); | ||
519 | return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umax_tl, (MO_ALIGN | MO_TEQ)); | ||
520 | } | ||
521 | -#endif | ||
522 | diff --git a/target/riscv/insn_trans/trans_rvd.c.inc b/target/riscv/insn_trans/trans_rvd.c.inc | ||
523 | index XXXXXXX..XXXXXXX 100644 | ||
524 | --- a/target/riscv/insn_trans/trans_rvd.c.inc | ||
525 | +++ b/target/riscv/insn_trans/trans_rvd.c.inc | ||
526 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_d_wu(DisasContext *ctx, arg_fcvt_d_wu *a) | ||
527 | return true; | ||
528 | } | ||
529 | |||
530 | -#ifdef TARGET_RISCV64 | ||
531 | - | ||
532 | static bool trans_fcvt_l_d(DisasContext *ctx, arg_fcvt_l_d *a) | ||
533 | { | ||
534 | + REQUIRE_64BIT(ctx); | ||
535 | REQUIRE_FPU; | ||
536 | REQUIRE_EXT(ctx, RVD); | ||
537 | |||
538 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_l_d(DisasContext *ctx, arg_fcvt_l_d *a) | ||
539 | |||
540 | static bool trans_fcvt_lu_d(DisasContext *ctx, arg_fcvt_lu_d *a) | ||
541 | { | ||
542 | + REQUIRE_64BIT(ctx); | ||
543 | REQUIRE_FPU; | ||
544 | REQUIRE_EXT(ctx, RVD); | ||
545 | |||
546 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_lu_d(DisasContext *ctx, arg_fcvt_lu_d *a) | ||
547 | |||
548 | static bool trans_fmv_x_d(DisasContext *ctx, arg_fmv_x_d *a) | ||
549 | { | ||
550 | + REQUIRE_64BIT(ctx); | ||
551 | REQUIRE_FPU; | ||
552 | REQUIRE_EXT(ctx, RVD); | ||
553 | |||
554 | +#ifdef TARGET_RISCV64 | ||
555 | gen_set_gpr(a->rd, cpu_fpr[a->rs1]); | ||
556 | return true; | ||
557 | +#else | ||
558 | + qemu_build_not_reached(); | ||
559 | +#endif | ||
560 | } | ||
561 | |||
562 | static bool trans_fcvt_d_l(DisasContext *ctx, arg_fcvt_d_l *a) | ||
563 | { | ||
564 | + REQUIRE_64BIT(ctx); | ||
565 | REQUIRE_FPU; | ||
566 | REQUIRE_EXT(ctx, RVD); | ||
567 | |||
568 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_d_l(DisasContext *ctx, arg_fcvt_d_l *a) | ||
569 | |||
570 | static bool trans_fcvt_d_lu(DisasContext *ctx, arg_fcvt_d_lu *a) | ||
571 | { | ||
572 | + REQUIRE_64BIT(ctx); | ||
573 | REQUIRE_FPU; | ||
574 | REQUIRE_EXT(ctx, RVD); | ||
575 | |||
576 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_d_lu(DisasContext *ctx, arg_fcvt_d_lu *a) | ||
577 | |||
578 | static bool trans_fmv_d_x(DisasContext *ctx, arg_fmv_d_x *a) | ||
579 | { | ||
580 | + REQUIRE_64BIT(ctx); | ||
581 | REQUIRE_FPU; | ||
582 | REQUIRE_EXT(ctx, RVD); | ||
583 | |||
584 | +#ifdef TARGET_RISCV64 | ||
585 | TCGv t0 = tcg_temp_new(); | ||
586 | gen_get_gpr(t0, a->rs1); | ||
587 | |||
588 | @@ -XXX,XX +XXX,XX @@ static bool trans_fmv_d_x(DisasContext *ctx, arg_fmv_d_x *a) | ||
589 | tcg_temp_free(t0); | ||
590 | mark_fs_dirty(ctx); | ||
591 | return true; | ||
592 | -} | ||
593 | +#else | ||
594 | + qemu_build_not_reached(); | ||
595 | #endif | ||
596 | +} | ||
597 | diff --git a/target/riscv/insn_trans/trans_rvf.c.inc b/target/riscv/insn_trans/trans_rvf.c.inc | ||
598 | index XXXXXXX..XXXXXXX 100644 | ||
599 | --- a/target/riscv/insn_trans/trans_rvf.c.inc | ||
600 | +++ b/target/riscv/insn_trans/trans_rvf.c.inc | ||
601 | @@ -XXX,XX +XXX,XX @@ static bool trans_fmv_w_x(DisasContext *ctx, arg_fmv_w_x *a) | ||
602 | return true; | ||
603 | } | ||
604 | |||
605 | -#ifdef TARGET_RISCV64 | ||
606 | static bool trans_fcvt_l_s(DisasContext *ctx, arg_fcvt_l_s *a) | ||
607 | { | ||
608 | + REQUIRE_64BIT(ctx); | ||
609 | REQUIRE_FPU; | ||
610 | REQUIRE_EXT(ctx, RVF); | ||
611 | |||
612 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_l_s(DisasContext *ctx, arg_fcvt_l_s *a) | ||
613 | |||
614 | static bool trans_fcvt_lu_s(DisasContext *ctx, arg_fcvt_lu_s *a) | ||
615 | { | ||
616 | + REQUIRE_64BIT(ctx); | ||
617 | REQUIRE_FPU; | ||
618 | REQUIRE_EXT(ctx, RVF); | ||
619 | |||
620 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_lu_s(DisasContext *ctx, arg_fcvt_lu_s *a) | ||
621 | |||
622 | static bool trans_fcvt_s_l(DisasContext *ctx, arg_fcvt_s_l *a) | ||
623 | { | ||
624 | + REQUIRE_64BIT(ctx); | ||
625 | REQUIRE_FPU; | ||
626 | REQUIRE_EXT(ctx, RVF); | ||
627 | |||
628 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_s_l(DisasContext *ctx, arg_fcvt_s_l *a) | ||
629 | |||
630 | static bool trans_fcvt_s_lu(DisasContext *ctx, arg_fcvt_s_lu *a) | ||
631 | { | ||
632 | + REQUIRE_64BIT(ctx); | ||
633 | REQUIRE_FPU; | ||
634 | REQUIRE_EXT(ctx, RVF); | ||
635 | |||
636 | @@ -XXX,XX +XXX,XX @@ static bool trans_fcvt_s_lu(DisasContext *ctx, arg_fcvt_s_lu *a) | ||
637 | tcg_temp_free(t0); | ||
638 | return true; | ||
639 | } | ||
640 | -#endif | ||
641 | diff --git a/target/riscv/insn_trans/trans_rvh.c.inc b/target/riscv/insn_trans/trans_rvh.c.inc | ||
642 | index XXXXXXX..XXXXXXX 100644 | ||
643 | --- a/target/riscv/insn_trans/trans_rvh.c.inc | ||
644 | +++ b/target/riscv/insn_trans/trans_rvh.c.inc | ||
645 | @@ -XXX,XX +XXX,XX @@ static bool trans_hsv_w(DisasContext *ctx, arg_hsv_w *a) | ||
646 | #endif | ||
647 | } | ||
648 | |||
649 | -#ifdef TARGET_RISCV64 | ||
650 | static bool trans_hlv_wu(DisasContext *ctx, arg_hlv_wu *a) | ||
651 | { | ||
652 | + REQUIRE_64BIT(ctx); | ||
653 | REQUIRE_EXT(ctx, RVH); | ||
654 | + | ||
655 | #ifndef CONFIG_USER_ONLY | ||
656 | TCGv t0 = tcg_temp_new(); | ||
657 | TCGv t1 = tcg_temp_new(); | ||
658 | @@ -XXX,XX +XXX,XX @@ static bool trans_hlv_wu(DisasContext *ctx, arg_hlv_wu *a) | ||
659 | |||
660 | static bool trans_hlv_d(DisasContext *ctx, arg_hlv_d *a) | ||
661 | { | ||
662 | + REQUIRE_64BIT(ctx); | ||
663 | REQUIRE_EXT(ctx, RVH); | ||
664 | + | ||
665 | #ifndef CONFIG_USER_ONLY | ||
666 | TCGv t0 = tcg_temp_new(); | ||
667 | TCGv t1 = tcg_temp_new(); | ||
668 | @@ -XXX,XX +XXX,XX @@ static bool trans_hlv_d(DisasContext *ctx, arg_hlv_d *a) | ||
669 | |||
670 | static bool trans_hsv_d(DisasContext *ctx, arg_hsv_d *a) | ||
671 | { | ||
672 | + REQUIRE_64BIT(ctx); | ||
673 | REQUIRE_EXT(ctx, RVH); | ||
674 | + | ||
675 | #ifndef CONFIG_USER_ONLY | ||
676 | TCGv t0 = tcg_temp_new(); | ||
677 | TCGv dat = tcg_temp_new(); | ||
678 | @@ -XXX,XX +XXX,XX @@ static bool trans_hsv_d(DisasContext *ctx, arg_hsv_d *a) | ||
679 | return false; | ||
680 | #endif | ||
681 | } | ||
682 | -#endif | ||
683 | |||
684 | static bool trans_hlvx_hu(DisasContext *ctx, arg_hlvx_hu *a) | ||
685 | { | ||
686 | diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc | ||
687 | index XXXXXXX..XXXXXXX 100644 | ||
688 | --- a/target/riscv/insn_trans/trans_rvi.c.inc | ||
689 | +++ b/target/riscv/insn_trans/trans_rvi.c.inc | ||
690 | @@ -XXX,XX +XXX,XX @@ static bool trans_sw(DisasContext *ctx, arg_sw *a) | ||
691 | return gen_store(ctx, a, MO_TESL); | ||
692 | } | ||
693 | |||
694 | -#ifdef TARGET_RISCV64 | ||
695 | static bool trans_lwu(DisasContext *ctx, arg_lwu *a) | ||
696 | { | ||
697 | + REQUIRE_64BIT(ctx); | ||
698 | return gen_load(ctx, a, MO_TEUL); | ||
699 | } | ||
700 | |||
701 | static bool trans_ld(DisasContext *ctx, arg_ld *a) | ||
702 | { | ||
703 | + REQUIRE_64BIT(ctx); | ||
704 | return gen_load(ctx, a, MO_TEQ); | ||
705 | } | ||
706 | |||
707 | static bool trans_sd(DisasContext *ctx, arg_sd *a) | ||
708 | { | ||
709 | + REQUIRE_64BIT(ctx); | ||
710 | return gen_store(ctx, a, MO_TEQ); | ||
711 | } | ||
712 | -#endif | ||
713 | |||
714 | static bool trans_addi(DisasContext *ctx, arg_addi *a) | ||
715 | { | ||
716 | @@ -XXX,XX +XXX,XX @@ static bool trans_and(DisasContext *ctx, arg_and *a) | ||
717 | return gen_arith(ctx, a, &tcg_gen_and_tl); | ||
718 | } | ||
719 | |||
720 | -#ifdef TARGET_RISCV64 | ||
721 | static bool trans_addiw(DisasContext *ctx, arg_addiw *a) | ||
722 | { | ||
723 | + REQUIRE_64BIT(ctx); | ||
724 | return gen_arith_imm_tl(ctx, a, &gen_addw); | ||
725 | } | ||
726 | |||
727 | static bool trans_slliw(DisasContext *ctx, arg_slliw *a) | ||
728 | { | ||
729 | + REQUIRE_64BIT(ctx); | ||
730 | TCGv source1; | ||
731 | source1 = tcg_temp_new(); | ||
732 | gen_get_gpr(source1, a->rs1); | ||
733 | @@ -XXX,XX +XXX,XX @@ static bool trans_slliw(DisasContext *ctx, arg_slliw *a) | ||
734 | |||
735 | static bool trans_srliw(DisasContext *ctx, arg_srliw *a) | ||
736 | { | ||
737 | + REQUIRE_64BIT(ctx); | ||
738 | TCGv t = tcg_temp_new(); | ||
739 | gen_get_gpr(t, a->rs1); | ||
740 | tcg_gen_extract_tl(t, t, a->shamt, 32 - a->shamt); | ||
741 | @@ -XXX,XX +XXX,XX @@ static bool trans_srliw(DisasContext *ctx, arg_srliw *a) | ||
742 | |||
743 | static bool trans_sraiw(DisasContext *ctx, arg_sraiw *a) | ||
744 | { | ||
745 | + REQUIRE_64BIT(ctx); | ||
746 | TCGv t = tcg_temp_new(); | ||
747 | gen_get_gpr(t, a->rs1); | ||
748 | tcg_gen_sextract_tl(t, t, a->shamt, 32 - a->shamt); | ||
749 | @@ -XXX,XX +XXX,XX @@ static bool trans_sraiw(DisasContext *ctx, arg_sraiw *a) | ||
750 | |||
751 | static bool trans_addw(DisasContext *ctx, arg_addw *a) | ||
752 | { | ||
753 | + REQUIRE_64BIT(ctx); | ||
754 | return gen_arith(ctx, a, &gen_addw); | ||
755 | } | ||
756 | |||
757 | static bool trans_subw(DisasContext *ctx, arg_subw *a) | ||
758 | { | ||
759 | + REQUIRE_64BIT(ctx); | ||
760 | return gen_arith(ctx, a, &gen_subw); | ||
761 | } | ||
762 | |||
763 | static bool trans_sllw(DisasContext *ctx, arg_sllw *a) | ||
764 | { | ||
765 | + REQUIRE_64BIT(ctx); | ||
766 | TCGv source1 = tcg_temp_new(); | ||
767 | TCGv source2 = tcg_temp_new(); | ||
768 | |||
769 | @@ -XXX,XX +XXX,XX @@ static bool trans_sllw(DisasContext *ctx, arg_sllw *a) | ||
770 | |||
771 | static bool trans_srlw(DisasContext *ctx, arg_srlw *a) | ||
772 | { | ||
773 | + REQUIRE_64BIT(ctx); | ||
774 | TCGv source1 = tcg_temp_new(); | ||
775 | TCGv source2 = tcg_temp_new(); | ||
776 | |||
777 | @@ -XXX,XX +XXX,XX @@ static bool trans_srlw(DisasContext *ctx, arg_srlw *a) | ||
778 | |||
779 | static bool trans_sraw(DisasContext *ctx, arg_sraw *a) | ||
780 | { | ||
781 | + REQUIRE_64BIT(ctx); | ||
782 | TCGv source1 = tcg_temp_new(); | ||
783 | TCGv source2 = tcg_temp_new(); | ||
784 | |||
785 | @@ -XXX,XX +XXX,XX @@ static bool trans_sraw(DisasContext *ctx, arg_sraw *a) | ||
786 | |||
787 | return true; | ||
788 | } | ||
789 | -#endif | ||
790 | |||
791 | static bool trans_fence(DisasContext *ctx, arg_fence *a) | ||
792 | { | ||
793 | diff --git a/target/riscv/insn_trans/trans_rvm.c.inc b/target/riscv/insn_trans/trans_rvm.c.inc | ||
794 | index XXXXXXX..XXXXXXX 100644 | ||
795 | --- a/target/riscv/insn_trans/trans_rvm.c.inc | ||
796 | +++ b/target/riscv/insn_trans/trans_rvm.c.inc | ||
797 | @@ -XXX,XX +XXX,XX @@ static bool trans_remu(DisasContext *ctx, arg_remu *a) | ||
798 | return gen_arith(ctx, a, &gen_remu); | ||
799 | } | ||
800 | |||
801 | -#ifdef TARGET_RISCV64 | ||
802 | static bool trans_mulw(DisasContext *ctx, arg_mulw *a) | ||
803 | { | ||
804 | + REQUIRE_64BIT(ctx); | ||
805 | REQUIRE_EXT(ctx, RVM); | ||
806 | + | ||
807 | return gen_arith(ctx, a, &gen_mulw); | ||
808 | } | ||
809 | |||
810 | static bool trans_divw(DisasContext *ctx, arg_divw *a) | ||
811 | { | ||
812 | + REQUIRE_64BIT(ctx); | ||
813 | REQUIRE_EXT(ctx, RVM); | ||
814 | + | ||
815 | return gen_arith_div_w(ctx, a, &gen_div); | ||
816 | } | ||
817 | |||
818 | static bool trans_divuw(DisasContext *ctx, arg_divuw *a) | ||
819 | { | ||
820 | + REQUIRE_64BIT(ctx); | ||
821 | REQUIRE_EXT(ctx, RVM); | ||
822 | + | ||
823 | return gen_arith_div_uw(ctx, a, &gen_divu); | ||
824 | } | ||
825 | |||
826 | static bool trans_remw(DisasContext *ctx, arg_remw *a) | ||
827 | { | ||
828 | + REQUIRE_64BIT(ctx); | ||
829 | REQUIRE_EXT(ctx, RVM); | ||
830 | + | ||
831 | return gen_arith_div_w(ctx, a, &gen_rem); | ||
832 | } | ||
833 | |||
834 | static bool trans_remuw(DisasContext *ctx, arg_remuw *a) | ||
835 | { | ||
836 | + REQUIRE_64BIT(ctx); | ||
837 | REQUIRE_EXT(ctx, RVM); | ||
838 | + | ||
839 | return gen_arith_div_uw(ctx, a, &gen_remu); | ||
840 | } | ||
841 | -#endif | ||
842 | diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc | ||
843 | index XXXXXXX..XXXXXXX 100644 | ||
844 | --- a/target/riscv/insn_trans/trans_rvv.c.inc | ||
845 | +++ b/target/riscv/insn_trans/trans_rvv.c.inc | ||
846 | @@ -XXX,XX +XXX,XX @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) | ||
847 | gen_helper_vamominuw_v_w, | ||
848 | gen_helper_vamomaxuw_v_w | ||
849 | }; | ||
850 | -#ifdef TARGET_RISCV64 | ||
851 | static gen_helper_amo *const fnsd[18] = { | ||
852 | gen_helper_vamoswapw_v_d, | ||
853 | gen_helper_vamoaddw_v_d, | ||
854 | @@ -XXX,XX +XXX,XX @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) | ||
855 | gen_helper_vamominud_v_d, | ||
856 | gen_helper_vamomaxud_v_d | ||
857 | }; | ||
858 | -#endif | ||
859 | |||
860 | if (tb_cflags(s->base.tb) & CF_PARALLEL) { | ||
861 | gen_helper_exit_atomic(cpu_env); | ||
862 | @@ -XXX,XX +XXX,XX @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) | ||
863 | return true; | ||
864 | } else { | ||
865 | if (s->sew == 3) { | ||
866 | -#ifdef TARGET_RISCV64 | ||
867 | - fn = fnsd[seq]; | ||
868 | -#else | ||
869 | - /* Check done in amo_check(). */ | ||
870 | - g_assert_not_reached(); | ||
871 | -#endif | ||
872 | + if (!is_32bit(s)) { | ||
873 | + fn = fnsd[seq]; | ||
874 | + } else { | ||
875 | + /* Check done in amo_check(). */ | ||
876 | + g_assert_not_reached(); | ||
877 | + } | ||
878 | } else { | ||
879 | assert(seq < ARRAY_SIZE(fnsw)); | ||
880 | fn = fnsw[seq]; | ||
881 | @@ -XXX,XX +XXX,XX @@ static bool amo_check(DisasContext *s, arg_rwdvm* a) | ||
882 | ((1 << s->sew) >= 4)); | ||
883 | } | ||
884 | |||
885 | +static bool amo_check64(DisasContext *s, arg_rwdvm* a) | ||
886 | +{ | ||
887 | + return !is_32bit(s) && amo_check(s, a); | ||
888 | +} | ||
889 | + | ||
890 | GEN_VEXT_TRANS(vamoswapw_v, 0, rwdvm, amo_op, amo_check) | ||
891 | GEN_VEXT_TRANS(vamoaddw_v, 1, rwdvm, amo_op, amo_check) | ||
892 | GEN_VEXT_TRANS(vamoxorw_v, 2, rwdvm, amo_op, amo_check) | ||
893 | @@ -XXX,XX +XXX,XX @@ GEN_VEXT_TRANS(vamominw_v, 5, rwdvm, amo_op, amo_check) | ||
894 | GEN_VEXT_TRANS(vamomaxw_v, 6, rwdvm, amo_op, amo_check) | ||
895 | GEN_VEXT_TRANS(vamominuw_v, 7, rwdvm, amo_op, amo_check) | ||
896 | GEN_VEXT_TRANS(vamomaxuw_v, 8, rwdvm, amo_op, amo_check) | ||
897 | -#ifdef TARGET_RISCV64 | ||
898 | -GEN_VEXT_TRANS(vamoswapd_v, 9, rwdvm, amo_op, amo_check) | ||
899 | -GEN_VEXT_TRANS(vamoaddd_v, 10, rwdvm, amo_op, amo_check) | ||
900 | -GEN_VEXT_TRANS(vamoxord_v, 11, rwdvm, amo_op, amo_check) | ||
901 | -GEN_VEXT_TRANS(vamoandd_v, 12, rwdvm, amo_op, amo_check) | ||
902 | -GEN_VEXT_TRANS(vamoord_v, 13, rwdvm, amo_op, amo_check) | ||
903 | -GEN_VEXT_TRANS(vamomind_v, 14, rwdvm, amo_op, amo_check) | ||
904 | -GEN_VEXT_TRANS(vamomaxd_v, 15, rwdvm, amo_op, amo_check) | ||
905 | -GEN_VEXT_TRANS(vamominud_v, 16, rwdvm, amo_op, amo_check) | ||
906 | -GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check) | ||
907 | -#endif | ||
908 | +GEN_VEXT_TRANS(vamoswapd_v, 9, rwdvm, amo_op, amo_check64) | ||
909 | +GEN_VEXT_TRANS(vamoaddd_v, 10, rwdvm, amo_op, amo_check64) | ||
910 | +GEN_VEXT_TRANS(vamoxord_v, 11, rwdvm, amo_op, amo_check64) | ||
911 | +GEN_VEXT_TRANS(vamoandd_v, 12, rwdvm, amo_op, amo_check64) | ||
912 | +GEN_VEXT_TRANS(vamoord_v, 13, rwdvm, amo_op, amo_check64) | ||
913 | +GEN_VEXT_TRANS(vamomind_v, 14, rwdvm, amo_op, amo_check64) | ||
914 | +GEN_VEXT_TRANS(vamomaxd_v, 15, rwdvm, amo_op, amo_check64) | ||
915 | +GEN_VEXT_TRANS(vamominud_v, 16, rwdvm, amo_op, amo_check64) | ||
916 | +GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check64) | ||
917 | |||
918 | /* | ||
919 | *** Vector Integer Arithmetic Instructions | ||
920 | diff --git a/target/riscv/meson.build b/target/riscv/meson.build | ||
921 | index XXXXXXX..XXXXXXX 100644 | ||
922 | --- a/target/riscv/meson.build | ||
923 | +++ b/target/riscv/meson.build | ||
924 | @@ -XXX,XX +XXX,XX @@ gen32 = [ | ||
925 | |||
926 | gen64 = [ | ||
927 | decodetree.process('insn16.decode', extra_args: [dir / 'insn16-64.decode', '--static-decode=decode_insn16', '--insnwidth=16']), | ||
928 | - decodetree.process('insn32.decode', extra_args: [dir / 'insn32-64.decode', '--static-decode=decode_insn32']), | ||
929 | + decodetree.process('insn32.decode', extra_args: '--static-decode=decode_insn32'), | ||
930 | ] | ||
931 | |||
932 | riscv_ss = ss.source_set() | ||
933 | -- | ||
934 | 2.31.1 | ||
935 | |||
936 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This patch removes the insn16-32.decode and insn16-64.decode decode | ||
2 | files and consolidates the instructions into the general RISC-V | ||
3 | insn16.decode decode tree. | ||
1 | 4 | ||
5 | This means that all of the instructions are avaliable in both the 32-bit | ||
6 | and 64-bit builds. This also means that we run a check to ensure we are | ||
7 | running a 64-bit softmmu before we execute the 64-bit only instructions. | ||
8 | This allows us to include the 32-bit instructions in the 64-bit build, | ||
9 | while also ensuring that 32-bit only software can not execute the | ||
10 | instructions. | ||
11 | |||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 01e2b0efeae311adc7ebf133c2cde6a7a37224d7.1619234854.git.alistair.francis@wdc.com | ||
15 | --- | ||
16 | target/riscv/insn16-32.decode | 28 ------------------- | ||
17 | target/riscv/insn16-64.decode | 36 ------------------------- | ||
18 | target/riscv/insn16.decode | 30 +++++++++++++++++++++ | ||
19 | target/riscv/insn_trans/trans_rvi.c.inc | 6 +++++ | ||
20 | target/riscv/meson.build | 11 +++----- | ||
21 | 5 files changed, 39 insertions(+), 72 deletions(-) | ||
22 | delete mode 100644 target/riscv/insn16-32.decode | ||
23 | delete mode 100644 target/riscv/insn16-64.decode | ||
24 | |||
25 | diff --git a/target/riscv/insn16-32.decode b/target/riscv/insn16-32.decode | ||
26 | deleted file mode 100644 | ||
27 | index XXXXXXX..XXXXXXX | ||
28 | --- a/target/riscv/insn16-32.decode | ||
29 | +++ /dev/null | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | -# | ||
32 | -# RISC-V translation routines for the RVXI Base Integer Instruction Set. | ||
33 | -# | ||
34 | -# Copyright (c) 2018 Peer Adelt, peer.adelt@hni.uni-paderborn.de | ||
35 | -# Bastian Koppelmann, kbastian@mail.uni-paderborn.de | ||
36 | -# | ||
37 | -# This program is free software; you can redistribute it and/or modify it | ||
38 | -# under the terms and conditions of the GNU General Public License, | ||
39 | -# version 2 or later, as published by the Free Software Foundation. | ||
40 | -# | ||
41 | -# This program is distributed in the hope it will be useful, but WITHOUT | ||
42 | -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
43 | -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
44 | -# more details. | ||
45 | -# | ||
46 | -# You should have received a copy of the GNU General Public License along with | ||
47 | -# this program. If not, see <http://www.gnu.org/licenses/>. | ||
48 | - | ||
49 | -# *** RV32C Standard Extension (Quadrant 0) *** | ||
50 | -flw 011 ... ... .. ... 00 @cl_w | ||
51 | -fsw 111 ... ... .. ... 00 @cs_w | ||
52 | - | ||
53 | -# *** RV32C Standard Extension (Quadrant 1) *** | ||
54 | -jal 001 ........... 01 @cj rd=1 # C.JAL | ||
55 | - | ||
56 | -# *** RV32C Standard Extension (Quadrant 2) *** | ||
57 | -flw 011 . ..... ..... 10 @c_lwsp | ||
58 | -fsw 111 . ..... ..... 10 @c_swsp | ||
59 | diff --git a/target/riscv/insn16-64.decode b/target/riscv/insn16-64.decode | ||
60 | deleted file mode 100644 | ||
61 | index XXXXXXX..XXXXXXX | ||
62 | --- a/target/riscv/insn16-64.decode | ||
63 | +++ /dev/null | ||
64 | @@ -XXX,XX +XXX,XX @@ | ||
65 | -# | ||
66 | -# RISC-V translation routines for the RVXI Base Integer Instruction Set. | ||
67 | -# | ||
68 | -# Copyright (c) 2018 Peer Adelt, peer.adelt@hni.uni-paderborn.de | ||
69 | -# Bastian Koppelmann, kbastian@mail.uni-paderborn.de | ||
70 | -# | ||
71 | -# This program is free software; you can redistribute it and/or modify it | ||
72 | -# under the terms and conditions of the GNU General Public License, | ||
73 | -# version 2 or later, as published by the Free Software Foundation. | ||
74 | -# | ||
75 | -# This program is distributed in the hope it will be useful, but WITHOUT | ||
76 | -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
77 | -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
78 | -# more details. | ||
79 | -# | ||
80 | -# You should have received a copy of the GNU General Public License along with | ||
81 | -# this program. If not, see <http://www.gnu.org/licenses/>. | ||
82 | - | ||
83 | -# *** RV64C Standard Extension (Quadrant 0) *** | ||
84 | -ld 011 ... ... .. ... 00 @cl_d | ||
85 | -sd 111 ... ... .. ... 00 @cs_d | ||
86 | - | ||
87 | -# *** RV64C Standard Extension (Quadrant 1) *** | ||
88 | -{ | ||
89 | - illegal 001 - 00000 ----- 01 # c.addiw, RES rd=0 | ||
90 | - addiw 001 . ..... ..... 01 @ci | ||
91 | -} | ||
92 | -subw 100 1 11 ... 00 ... 01 @cs_2 | ||
93 | -addw 100 1 11 ... 01 ... 01 @cs_2 | ||
94 | - | ||
95 | -# *** RV64C Standard Extension (Quadrant 2) *** | ||
96 | -{ | ||
97 | - illegal 011 - 00000 ----- 10 # c.ldsp, RES rd=0 | ||
98 | - ld 011 . ..... ..... 10 @c_ldsp | ||
99 | -} | ||
100 | -sd 111 . ..... ..... 10 @c_sdsp | ||
101 | diff --git a/target/riscv/insn16.decode b/target/riscv/insn16.decode | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/riscv/insn16.decode | ||
104 | +++ b/target/riscv/insn16.decode | ||
105 | @@ -XXX,XX +XXX,XX @@ lw 010 ... ... .. ... 00 @cl_w | ||
106 | fsd 101 ... ... .. ... 00 @cs_d | ||
107 | sw 110 ... ... .. ... 00 @cs_w | ||
108 | |||
109 | +# *** RV32C and RV64C specific Standard Extension (Quadrant 0) *** | ||
110 | +{ | ||
111 | + ld 011 ... ... .. ... 00 @cl_d | ||
112 | + flw 011 ... ... .. ... 00 @cl_w | ||
113 | +} | ||
114 | +{ | ||
115 | + sd 111 ... ... .. ... 00 @cs_d | ||
116 | + fsw 111 ... ... .. ... 00 @cs_w | ||
117 | +} | ||
118 | + | ||
119 | # *** RV32/64C Standard Extension (Quadrant 1) *** | ||
120 | addi 000 . ..... ..... 01 @ci | ||
121 | addi 010 . ..... ..... 01 @c_li | ||
122 | @@ -XXX,XX +XXX,XX @@ jal 101 ........... 01 @cj rd=0 # C.J | ||
123 | beq 110 ... ... ..... 01 @cb_z | ||
124 | bne 111 ... ... ..... 01 @cb_z | ||
125 | |||
126 | +# *** RV64C and RV32C specific Standard Extension (Quadrant 1) *** | ||
127 | +{ | ||
128 | + c64_illegal 001 - 00000 ----- 01 # c.addiw, RES rd=0 | ||
129 | + addiw 001 . ..... ..... 01 @ci | ||
130 | + jal 001 ........... 01 @cj rd=1 # C.JAL | ||
131 | +} | ||
132 | +subw 100 1 11 ... 00 ... 01 @cs_2 | ||
133 | +addw 100 1 11 ... 01 ... 01 @cs_2 | ||
134 | + | ||
135 | # *** RV32/64C Standard Extension (Quadrant 2) *** | ||
136 | slli 000 . ..... ..... 10 @c_shift2 | ||
137 | fld 001 . ..... ..... 10 @c_ldsp | ||
138 | @@ -XXX,XX +XXX,XX @@ fld 001 . ..... ..... 10 @c_ldsp | ||
139 | } | ||
140 | fsd 101 ...... ..... 10 @c_sdsp | ||
141 | sw 110 . ..... ..... 10 @c_swsp | ||
142 | + | ||
143 | +# *** RV32C and RV64C specific Standard Extension (Quadrant 2) *** | ||
144 | +{ | ||
145 | + c64_illegal 011 - 00000 ----- 10 # c.ldsp, RES rd=0 | ||
146 | + ld 011 . ..... ..... 10 @c_ldsp | ||
147 | + flw 011 . ..... ..... 10 @c_lwsp | ||
148 | +} | ||
149 | +{ | ||
150 | + sd 111 . ..... ..... 10 @c_sdsp | ||
151 | + fsw 111 . ..... ..... 10 @c_swsp | ||
152 | +} | ||
153 | diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc | ||
154 | index XXXXXXX..XXXXXXX 100644 | ||
155 | --- a/target/riscv/insn_trans/trans_rvi.c.inc | ||
156 | +++ b/target/riscv/insn_trans/trans_rvi.c.inc | ||
157 | @@ -XXX,XX +XXX,XX @@ static bool trans_illegal(DisasContext *ctx, arg_empty *a) | ||
158 | return true; | ||
159 | } | ||
160 | |||
161 | +static bool trans_c64_illegal(DisasContext *ctx, arg_empty *a) | ||
162 | +{ | ||
163 | + REQUIRE_64BIT(ctx); | ||
164 | + return trans_illegal(ctx, a); | ||
165 | +} | ||
166 | + | ||
167 | static bool trans_lui(DisasContext *ctx, arg_lui *a) | ||
168 | { | ||
169 | if (a->rd != 0) { | ||
170 | diff --git a/target/riscv/meson.build b/target/riscv/meson.build | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/target/riscv/meson.build | ||
173 | +++ b/target/riscv/meson.build | ||
174 | @@ -XXX,XX +XXX,XX @@ | ||
175 | # FIXME extra_args should accept files() | ||
176 | dir = meson.current_source_dir() | ||
177 | -gen32 = [ | ||
178 | - decodetree.process('insn16.decode', extra_args: [dir / 'insn16-32.decode', '--static-decode=decode_insn16', '--insnwidth=16']), | ||
179 | - decodetree.process('insn32.decode', extra_args: '--static-decode=decode_insn32'), | ||
180 | -] | ||
181 | |||
182 | -gen64 = [ | ||
183 | - decodetree.process('insn16.decode', extra_args: [dir / 'insn16-64.decode', '--static-decode=decode_insn16', '--insnwidth=16']), | ||
184 | +gen = [ | ||
185 | + decodetree.process('insn16.decode', extra_args: ['--static-decode=decode_insn16', '--insnwidth=16']), | ||
186 | decodetree.process('insn32.decode', extra_args: '--static-decode=decode_insn32'), | ||
187 | ] | ||
188 | |||
189 | riscv_ss = ss.source_set() | ||
190 | -riscv_ss.add(when: 'TARGET_RISCV32', if_true: gen32) | ||
191 | -riscv_ss.add(when: 'TARGET_RISCV64', if_true: gen64) | ||
192 | +riscv_ss.add(gen) | ||
193 | riscv_ss.add(files( | ||
194 | 'cpu.c', | ||
195 | 'cpu_helper.c', | ||
196 | -- | ||
197 | 2.31.1 | ||
198 | |||
199 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | BugLink: https://gitlab.com/qemu-project/qemu/-/issues/47 | ||
2 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 024ce841221c1d15c74b253512428c4baca7e4ba.1619234854.git.alistair.francis@wdc.com | ||
5 | --- | ||
6 | target/riscv/insn32.decode | 2 +- | ||
7 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
1 | 8 | ||
9 | diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/target/riscv/insn32.decode | ||
12 | +++ b/target/riscv/insn32.decode | ||
13 | @@ -XXX,XX +XXX,XX @@ hsv_w 0110101 ..... ..... 100 00000 1110011 @r2_s | ||
14 | hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma | ||
15 | hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma | ||
16 | |||
17 | -# *** RV32H Base Instruction Set *** | ||
18 | +# *** RV64H Base Instruction Set *** | ||
19 | hlv_wu 0110100 00001 ..... 100 ..... 1110011 @r2 | ||
20 | hlv_d 0110110 00000 ..... 100 ..... 1110011 @r2 | ||
21 | hsv_d 0110111 ..... ..... 100 00000 1110011 @r2_s | ||
22 | -- | ||
23 | 2.31.1 | ||
24 | |||
25 | diff view generated by jsdifflib |