1
The following changes since commit fdd0df5340a8ebc8de88078387ebc85c5af7b40f:
1
The following changes since commit c5ea91da443b458352c1b629b490ee6631775cb4:
2
2
3
Merge tag 'pull-ppc-20230610' of https://gitlab.com/danielhb/qemu into staging (2023-06-10 07:25:00 -0700)
3
Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging (2023-09-08 10:06:25 -0400)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/alistair23/qemu.git tags/pull-riscv-to-apply-20230614
7
https://github.com/alistair23/qemu.git tags/pull-riscv-to-apply-20230911
8
8
9
for you to fetch changes up to 860029321d9ebdff47e89561de61e9441fead70a:
9
for you to fetch changes up to e7a03409f29e2da59297d55afbaec98c96e43e3a:
10
10
11
hw/intc: If mmsiaddrcfgh.L == 1, smsiaddrcfg and smsiaddrcfgh are read-only. (2023-06-14 10:04:30 +1000)
11
target/riscv: don't read CSR in riscv_csrrw_do64 (2023-09-11 11:45:55 +1000)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Second RISC-V PR for 8.1
14
First RISC-V PR for 8.2
15
15
16
* Skip Vector set tail when vta is zero
16
* Remove 'host' CPU from TCG
17
* Move zc* out of the experimental properties
17
* riscv_htif Fixup printing on big endian hosts
18
* Mask the implicitly enabled extensions in isa_string based on priv version
18
* Add zmmul isa string
19
* Rework CPU extension validation and validate MISA changes
19
* Add smepmp isa string
20
* Fixup PMP TLB cacheing errors
20
* Fix page_check_range use in fault-only-first
21
* Writing to pmpaddr and MML/MMWP correctly triggers TLB flushes
21
* Use existing lookup tables for MixColumns
22
* Fixup PMP bypass checks
22
* Add RISC-V vector cryptographic instruction set support
23
* Deny access if access is partially inside a PMP entry
23
* Implement WARL behaviour for mcountinhibit/mcounteren
24
* Correct OpenTitanState parent type/size
24
* Add Zihintntl extension ISA string to DTS
25
* Fix QEMU crash when NUMA nodes exceed available CPUs
25
* Fix zfa fleq.d and fltq.d
26
* Fix pointer mask transformation for vector address
26
* Fix upper/lower mtime write calculation
27
* Updates and improvements for Smstateen
27
* Make rtc variable names consistent
28
* Support disas for Zcm* extensions
28
* Use abi type for linux-user target_ucontext
29
* Support disas for Z*inx extensions
29
* Add RISC-V KVM AIA Support
30
* Remove unused decomp_rv32/64 value for vector instructions
30
* Fix riscv,pmu DT node path in the virt machine
31
* Enable PC-relative translation
31
* Update CSR bits name for svadu extension
32
* Assume M-mode FW in pflash0 only when "-bios none"
32
* Mark zicond non-experimental
33
* Support using pflash via -blockdev option
33
* Fix satp_mode_finalize() when satp_mode.supported = 0
34
* Add vector registers to log
34
* Fix non-KVM --enable-debug build
35
* Clean up reference of Vector MTYPE
35
* Add new extensions to hwprobe
36
* Remove the check for extra Vector tail elements
36
* Use accelerated helper for AES64KS1I
37
* Smepmp: Return error when access permission not allowed in PMP
37
* Allocate itrigger timers only once
38
* Fixes for smsiaddrcfg and smsiaddrcfgh in AIA
38
* Respect mseccfg.RLB for pmpaddrX changes
39
* Align the AIA model to v1.0 ratified spec
40
* Don't read the CSR in riscv_csrrw_do64
39
41
40
----------------------------------------------------------------
42
----------------------------------------------------------------
41
Daniel Henrique Barboza (10):
43
Akihiko Odaki (1):
42
target/riscv/vector_helper.c: skip set tail when vta is zero
44
target/riscv: Allocate itrigger timers only once
43
target/riscv/cpu.c: add riscv_cpu_validate_v()
44
target/riscv/cpu.c: remove set_vext_version()
45
target/riscv/cpu.c: remove set_priv_version()
46
target/riscv: add PRIV_VERSION_LATEST
47
target/riscv/cpu.c: add priv_spec validate/disable_exts helpers
48
target/riscv/cpu.c: add riscv_cpu_validate_misa_mxl()
49
target/riscv/cpu.c: validate extensions before riscv_timer_init()
50
target/riscv/cpu.c: remove cfg setup from riscv_cpu_init()
51
target/riscv: rework write_misa()
52
45
53
Himanshu Chauhan (1):
46
Ard Biesheuvel (2):
54
target/riscv: Smepmp: Return error when access permission not allowed in PMP
47
target/riscv: Use existing lookup tables for MixColumns
48
target/riscv: Use accelerated helper for AES64KS1I
55
49
56
Ivan Klokov (1):
50
Conor Dooley (1):
57
util/log: Add vector registers to log
51
hw/riscv: virt: Fix riscv,pmu DT node path
58
52
59
Mayuresh Chitale (3):
53
Daniel Henrique Barboza (6):
60
target/riscv: smstateen check for fcsr
54
target/riscv/cpu.c: do not run 'host' CPU with TCG
61
target/riscv: Reuse tb->flags.FS
55
target/riscv/cpu.c: add zmmul isa string
62
target/riscv: smstateen knobs
56
target/riscv/cpu.c: add smepmp isa string
57
target/riscv: fix satp_mode_finalize() when satp_mode.supported = 0
58
hw/riscv/virt.c: fix non-KVM --enable-debug build
59
hw/intc/riscv_aplic.c fix non-KVM --enable-debug build
63
60
64
Philippe Mathieu-Daudé (5):
61
Dickon Hood (2):
65
hw/riscv/opentitan: Rename machine_[class]_init() functions
62
target/riscv: Refactor translation of vector-widening instruction
66
hw/riscv/opentitan: Declare QOM types using DEFINE_TYPES() macro
63
target/riscv: Add Zvbb ISA extension support
67
hw/riscv/opentitan: Add TYPE_OPENTITAN_MACHINE definition
68
hw/riscv/opentitan: Explicit machine type definition
69
hw/riscv/opentitan: Correct OpenTitanState parent type/size
70
64
71
Sunil V L (3):
65
Jason Chien (3):
72
hw/riscv: virt: Assume M-mode FW in pflash0 only when "-bios none"
66
target/riscv: Add Zihintntl extension ISA string to DTS
73
riscv/virt: Support using pflash via -blockdev option
67
hw/intc: Fix upper/lower mtime write calculation
74
docs/system: riscv: Add pflash usage details
68
hw/intc: Make rtc variable names consistent
69
70
Kiran Ostrolenk (4):
71
target/riscv: Refactor some of the generic vector functionality
72
target/riscv: Refactor vector-vector translation macro
73
target/riscv: Refactor some of the generic vector functionality
74
target/riscv: Add Zvknh ISA extension support
75
76
LIU Zhiwei (3):
77
target/riscv: Fix page_check_range use in fault-only-first
78
target/riscv: Fix zfa fleq.d and fltq.d
79
linux-user/riscv: Use abi type for target_ucontext
80
81
Lawrence Hunter (2):
82
target/riscv: Add Zvbc ISA extension support
83
target/riscv: Add Zvksh ISA extension support
84
85
Leon Schuermann (1):
86
target/riscv/pmp.c: respect mseccfg.RLB for pmpaddrX changes
87
88
Max Chou (3):
89
crypto: Create sm4_subword
90
crypto: Add SM4 constant parameter CK
91
target/riscv: Add Zvksed ISA extension support
92
93
Nazar Kazakov (4):
94
target/riscv: Remove redundant "cpu_vl == 0" checks
95
target/riscv: Move vector translation checks
96
target/riscv: Add Zvkned ISA extension support
97
target/riscv: Add Zvkg ISA extension support
98
99
Nikita Shubin (1):
100
target/riscv: don't read CSR in riscv_csrrw_do64
101
102
Rob Bradford (1):
103
target/riscv: Implement WARL behaviour for mcountinhibit/mcounteren
104
105
Robbin Ehn (1):
106
linux-user/riscv: Add new extensions to hwprobe
107
108
Thomas Huth (2):
109
hw/char/riscv_htif: Fix printing of console characters on big endian hosts
110
hw/char/riscv_htif: Fix the console syscall on big endian hosts
75
111
76
Tommy Wu (1):
112
Tommy Wu (1):
77
hw/intc: If mmsiaddrcfgh.L == 1, smsiaddrcfg and smsiaddrcfgh are read-only.
113
target/riscv: Align the AIA model to v1.0 ratified spec
78
114
79
Weiwei Li (33):
115
Vineet Gupta (1):
80
target/riscv: Move zc* out of the experimental properties
116
riscv: zicond: make non-experimental
81
target/riscv: Mask the implicitly enabled extensions in isa_string based on priv version
82
target/riscv: Update check for Zca/Zcf/Zcd
83
target/riscv: Update pmp_get_tlb_size()
84
target/riscv: Move pmp_get_tlb_size apart from get_physical_address_pmp
85
target/riscv: Make the short cut really work in pmp_hart_has_privs
86
target/riscv: Change the return type of pmp_hart_has_privs() to bool
87
target/riscv: Make RLB/MML/MMWP bits writable only when Smepmp is enabled
88
target/riscv: Remove unused paramters in pmp_hart_has_privs_default()
89
target/riscv: Flush TLB when MMWP or MML bits are changed
90
target/riscv: Update the next rule addr in pmpaddr_csr_write()
91
target/riscv: Flush TLB when pmpaddr is updated
92
target/riscv: Flush TLB only when pmpcfg/pmpaddr really changes
93
target/riscv: Separate pmp_update_rule() in pmpcfg_csr_write
94
target/riscv: Deny access if access is partially inside the PMP entry
95
target/riscv: Fix pointer mask transformation for vector address
96
target/riscv: Update cur_pmmask/base when xl changes
97
disas: Change type of disassemble_info.target_info to pointer
98
target/riscv: Split RISCVCPUConfig declarations from cpu.h into cpu_cfg.h
99
target/riscv: Pass RISCVCPUConfig as target_info to disassemble_info
100
disas/riscv.c: Support disas for Zcm* extensions
101
disas/riscv.c: Support disas for Z*inx extensions
102
disas/riscv.c: Remove unused decomp_rv32/64 value for vector instructions
103
disas/riscv.c: Fix lines with over 80 characters
104
disas/riscv.c: Remove redundant parentheses
105
target/riscv: Fix target address to update badaddr
106
target/riscv: Introduce cur_insn_len into DisasContext
107
target/riscv: Change gen_goto_tb to work on displacements
108
target/riscv: Change gen_set_pc_imm to gen_update_pc
109
target/riscv: Use true diff for gen_pc_plus_diff
110
target/riscv: Enable PC-relative translation
111
target/riscv: Remove pc_succ_insn from DisasContext
112
target/riscv: Fix initialized value for cur_pmmask
113
117
114
Xiao Wang (2):
118
Weiwei Li (1):
115
target/riscv/vector_helper.c: clean up reference of MTYPE
119
target/riscv: Update CSR bits name for svadu extension
116
target/riscv/vector_helper.c: Remove the check for extra tail elements
117
120
118
Yin Wang (1):
121
Yong-Xuan Wang (5):
119
hw/riscv: qemu crash when NUMA nodes exceed available CPUs
122
target/riscv: support the AIA device emulation with KVM enabled
123
target/riscv: check the in-kernel irqchip support
124
target/riscv: Create an KVM AIA irqchip
125
target/riscv: update APLIC and IMSIC to support KVM AIA
126
target/riscv: select KVM AIA in riscv virt machine
120
127
121
docs/system/riscv/virt.rst | 31 +
128
include/crypto/aes.h | 7 +
122
include/disas/dis-asm.h | 2 +-
129
include/crypto/sm4.h | 9 +
123
include/hw/core/cpu.h | 2 +
130
target/riscv/cpu_bits.h | 8 +-
124
include/hw/riscv/opentitan.h | 6 +-
131
target/riscv/cpu_cfg.h | 9 +
125
include/qemu/log.h | 1 +
132
target/riscv/debug.h | 3 +-
126
target/riscv/cpu.h | 117 +--
133
target/riscv/helper.h | 98 +++
127
target/riscv/cpu_cfg.h | 136 +++
134
target/riscv/kvm_riscv.h | 5 +
128
target/riscv/pmp.h | 11 +-
135
target/riscv/vector_internals.h | 228 +++++++
129
accel/tcg/cpu-exec.c | 3 +
136
target/riscv/insn32.decode | 58 ++
130
disas/riscv.c | 1194 +++++++++++++-----------
137
crypto/aes.c | 4 +-
131
hw/intc/riscv_aplic.c | 4 +-
138
crypto/sm4.c | 10 +
132
hw/riscv/numa.c | 6 +
139
hw/char/riscv_htif.c | 12 +-
133
hw/riscv/opentitan.c | 38 +-
140
hw/intc/riscv_aclint.c | 11 +-
134
hw/riscv/virt.c | 59 +-
141
hw/intc/riscv_aplic.c | 52 +-
135
target/riscv/cpu.c | 384 +++++---
142
hw/intc/riscv_imsic.c | 25 +-
136
target/riscv/cpu_helper.c | 37 +-
143
hw/riscv/virt.c | 374 ++++++------
137
target/riscv/csr.c | 75 +-
144
linux-user/riscv/signal.c | 4 +-
138
target/riscv/pmp.c | 205 ++--
145
linux-user/syscall.c | 14 +-
139
target/riscv/translate.c | 99 +-
146
target/arm/tcg/crypto_helper.c | 10 +-
140
target/riscv/vector_helper.c | 33 +-
147
target/riscv/cpu.c | 83 ++-
141
util/log.c | 2 +
148
target/riscv/cpu_helper.c | 6 +-
142
target/riscv/insn_trans/trans_privileged.c.inc | 2 +-
149
target/riscv/crypto_helper.c | 51 +-
143
target/riscv/insn_trans/trans_rvd.c.inc | 12 +-
150
target/riscv/csr.c | 54 +-
144
target/riscv/insn_trans/trans_rvf.c.inc | 21 +-
151
target/riscv/debug.c | 15 +-
145
target/riscv/insn_trans/trans_rvi.c.inc | 46 +-
152
target/riscv/kvm.c | 201 ++++++-
146
target/riscv/insn_trans/trans_rvv.c.inc | 4 +-
153
target/riscv/pmp.c | 4 +
147
target/riscv/insn_trans/trans_rvzawrs.c.inc | 2 +-
154
target/riscv/translate.c | 1 +
148
target/riscv/insn_trans/trans_rvzce.c.inc | 10 +-
155
target/riscv/vcrypto_helper.c | 970 ++++++++++++++++++++++++++++++
149
target/riscv/insn_trans/trans_xthead.c.inc | 2 +-
156
target/riscv/vector_helper.c | 245 +-------
150
29 files changed, 1442 insertions(+), 1102 deletions(-)
157
target/riscv/vector_internals.c | 81 +++
151
create mode 100644 target/riscv/cpu_cfg.h
158
target/riscv/insn_trans/trans_rvv.c.inc | 171 +++---
152
159
target/riscv/insn_trans/trans_rvvk.c.inc | 606 +++++++++++++++++++
160
target/riscv/insn_trans/trans_rvzfa.c.inc | 4 +-
161
target/riscv/meson.build | 4 +-
162
34 files changed, 2785 insertions(+), 652 deletions(-)
163
create mode 100644 target/riscv/vector_internals.h
164
create mode 100644 target/riscv/vcrypto_helper.c
165
create mode 100644 target/riscv/vector_internals.c
166
create mode 100644 target/riscv/insn_trans/trans_rvvk.c.inc
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2
2
3
Let's remove more code that is open coded in riscv_cpu_realize() and put
3
The 'host' CPU is available in a CONFIG_KVM build and it's currently
4
it into a helper. Let's also add an error message instead of just
4
available for all accels, but is a KVM only CPU. This means that in a
5
asserting out if env->misa_mxl_max != env->misa_mlx.
5
RISC-V KVM capable host we can do things like this:
6
7
$ ./build/qemu-system-riscv64 -M virt,accel=tcg -cpu host --nographic
8
qemu-system-riscv64: H extension requires priv spec 1.12.0
9
10
This CPU does not have a priv spec because we don't filter its extensions
11
via priv spec. We shouldn't be reaching riscv_cpu_realize_tcg() at all
12
with the 'host' CPU.
13
14
We don't have a way to filter the 'host' CPU out of the available CPU
15
options (-cpu help) if the build includes both KVM and TCG. What we can
16
do is to error out during riscv_cpu_realize_tcg() if the user chooses
17
the 'host' CPU with accel=tcg:
18
19
$ ./build/qemu-system-riscv64 -M virt,accel=tcg -cpu host --nographic
20
qemu-system-riscv64: 'host' CPU is not compatible with TCG acceleration
6
21
7
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
22
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
9
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
23
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Message-Id: <20230517135714.211809-9-dbarboza@ventanamicro.com>
24
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
25
Message-Id: <20230721133411.474105-1-dbarboza@ventanamicro.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
26
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
27
---
14
target/riscv/cpu.c | 50 ++++++++++++++++++++++++++++++----------------
28
target/riscv/cpu.c | 5 +++++
15
1 file changed, 33 insertions(+), 17 deletions(-)
29
1 file changed, 5 insertions(+)
16
30
17
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
31
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
18
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/cpu.c
33
--- a/target/riscv/cpu.c
20
+++ b/target/riscv/cpu.c
34
+++ b/target/riscv/cpu.c
21
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu)
35
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize_tcg(DeviceState *dev, Error **errp)
22
}
23
}
24
25
+static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu, Error **errp)
26
+{
27
+ RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu);
28
+ CPUClass *cc = CPU_CLASS(mcc);
29
+ CPURISCVState *env = &cpu->env;
30
+
31
+ /* Validate that MISA_MXL is set properly. */
32
+ switch (env->misa_mxl_max) {
33
+#ifdef TARGET_RISCV64
34
+ case MXL_RV64:
35
+ case MXL_RV128:
36
+ cc->gdb_core_xml_file = "riscv-64bit-cpu.xml";
37
+ break;
38
+#endif
39
+ case MXL_RV32:
40
+ cc->gdb_core_xml_file = "riscv-32bit-cpu.xml";
41
+ break;
42
+ default:
43
+ g_assert_not_reached();
44
+ }
45
+
46
+ if (env->misa_mxl_max != env->misa_mxl) {
47
+ error_setg(errp, "misa_mxl_max must be equal to misa_mxl");
48
+ return;
49
+ }
50
+}
51
+
52
/*
53
* Check consistency between chosen extensions while setting
54
* cpu->cfg accordingly.
55
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
56
RISCVCPU *cpu = RISCV_CPU(dev);
57
CPURISCVState *env = &cpu->env;
36
CPURISCVState *env = &cpu->env;
58
RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev);
59
- CPUClass *cc = CPU_CLASS(mcc);
60
Error *local_err = NULL;
37
Error *local_err = NULL;
61
38
62
cpu_exec_realizefn(cs, &local_err);
39
+ if (object_dynamic_cast(OBJECT(dev), TYPE_RISCV_CPU_HOST)) {
63
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
40
+ error_setg(errp, "'host' CPU is not compatible with TCG acceleration");
64
return;
65
}
66
67
+ riscv_cpu_validate_misa_mxl(cpu, &local_err);
68
+ if (local_err != NULL) {
69
+ error_propagate(errp, local_err);
70
+ return;
41
+ return;
71
+ }
42
+ }
72
+
43
+
73
riscv_cpu_validate_priv_spec(cpu, &local_err);
44
riscv_cpu_validate_misa_mxl(cpu, &local_err);
74
if (local_err != NULL) {
75
error_propagate(errp, local_err);
76
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
77
}
78
#endif /* CONFIG_USER_ONLY */
79
80
- /* Validate that MISA_MXL is set properly. */
81
- switch (env->misa_mxl_max) {
82
-#ifdef TARGET_RISCV64
83
- case MXL_RV64:
84
- case MXL_RV128:
85
- cc->gdb_core_xml_file = "riscv-64bit-cpu.xml";
86
- break;
87
-#endif
88
- case MXL_RV32:
89
- cc->gdb_core_xml_file = "riscv-32bit-cpu.xml";
90
- break;
91
- default:
92
- g_assert_not_reached();
93
- }
94
- assert(env->misa_mxl_max == env->misa_mxl);
95
-
96
riscv_cpu_validate_set_extensions(cpu, &local_err);
97
if (local_err != NULL) {
45
if (local_err != NULL) {
98
error_propagate(errp, local_err);
46
error_propagate(errp, local_err);
99
--
47
--
100
2.40.1
48
2.41.0
49
50
diff view generated by jsdifflib
1
From: Sunil V L <sunilvl@ventanamicro.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
pflash devices can be used in virt machine for different
3
The character that should be printed is stored in the 64 bit "payload"
4
purposes like for ROM code or S-mode FW payload. Add a
4
variable. The code currently tries to print it by taking the address
5
section in the documentation on how to use pflash devices
5
of the variable and passing this pointer to qemu_chr_fe_write(). However,
6
for different purposes.
6
this only works on little endian hosts where the least significant bits
7
are stored on the lowest address. To do this in a portable way, we have
8
to store the value in an uint8_t variable instead.
7
9
8
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
10
Fixes: 5033606780 ("RISC-V HTIF Console")
11
Signed-off-by: Thomas Huth <thuth@redhat.com>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Reviewed-by: Bin Meng <bmeng@tinylab.org>
14
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
16
Message-Id: <20230721094720.902454-2-thuth@redhat.com>
11
Message-Id: <20230601045910.18646-4-sunilvl@ventanamicro.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
18
---
14
docs/system/riscv/virt.rst | 31 +++++++++++++++++++++++++++++++
19
hw/char/riscv_htif.c | 3 ++-
15
1 file changed, 31 insertions(+)
20
1 file changed, 2 insertions(+), 1 deletion(-)
16
21
17
diff --git a/docs/system/riscv/virt.rst b/docs/system/riscv/virt.rst
22
diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
18
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
19
--- a/docs/system/riscv/virt.rst
24
--- a/hw/char/riscv_htif.c
20
+++ b/docs/system/riscv/virt.rst
25
+++ b/hw/char/riscv_htif.c
21
@@ -XXX,XX +XXX,XX @@ with the default OpenSBI firmware image as the -bios. It also supports
26
@@ -XXX,XX +XXX,XX @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
22
the recommended RISC-V bootflow: U-Boot SPL (M-mode) loads OpenSBI fw_dynamic
27
s->tohost = 0; /* clear to indicate we read */
23
firmware and U-Boot proper (S-mode), using the standard -bios functionality.
28
return;
24
29
} else if (cmd == HTIF_CONSOLE_CMD_PUTC) {
25
+Using flash devices
30
- qemu_chr_fe_write(&s->chr, (uint8_t *)&payload, 1);
26
+-------------------
31
+ uint8_t ch = (uint8_t)payload;
27
+
32
+ qemu_chr_fe_write(&s->chr, &ch, 1);
28
+By default, the first flash device (pflash0) is expected to contain
33
resp = 0x100 | (uint8_t)payload;
29
+S-mode firmware code. It can be configured as read-only, with the
34
} else {
30
+second flash device (pflash1) available to store configuration data.
35
qemu_log("HTIF device %d: unknown command\n", device);
31
+
32
+For example, booting edk2 looks like
33
+
34
+.. code-block:: bash
35
+
36
+ $ qemu-system-riscv64 \
37
+ -blockdev node-name=pflash0,driver=file,read-only=on,filename=<edk2_code> \
38
+ -blockdev node-name=pflash1,driver=file,filename=<edk2_vars> \
39
+ -M virt,pflash0=pflash0,pflash1=pflash1 \
40
+ ... other args ....
41
+
42
+For TCG guests only, it is also possible to boot M-mode firmware from
43
+the first flash device (pflash0) by additionally passing ``-bios
44
+none``, as in
45
+
46
+.. code-block:: bash
47
+
48
+ $ qemu-system-riscv64 \
49
+ -bios none \
50
+ -blockdev node-name=pflash0,driver=file,read-only=on,filename=<m_mode_code> \
51
+ -M virt,pflash0=pflash0 \
52
+ ... other args ....
53
+
54
+Firmware images used for pflash must be exactly 32 MiB in size.
55
+
56
Machine-specific options
57
------------------------
58
59
--
36
--
60
2.40.1
37
2.41.0
61
38
62
39
diff view generated by jsdifflib
1
From: Xiao Wang <xiao.w.wang@intel.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
Commit 752614cab8e6 ("target/riscv: rvv: Add tail agnostic for vector
3
Values that have been read via cpu_physical_memory_read() from the
4
load / store instructions") added an extra check for LMUL fragmentation,
4
guest's memory have to be swapped in case the host endianess differs
5
intended for setting the "rest tail elements" in the last register for a
5
from the guest.
6
segment load insn.
7
6
8
Actually, the max_elements derived in vext_ld*() won't be a fraction of
7
Fixes: a6e13e31d5 ("riscv_htif: Support console output via proxy syscall")
9
vector register size, since the lmul encoded in desc is emul, which has
8
Signed-off-by: Thomas Huth <thuth@redhat.com>
10
already been adjusted to 1 for LMUL fragmentation case by vext_get_emul()
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
in trans_rvv.c.inc, for ld_stride(), ld_us(), ld_index() and ldff().
10
Reviewed-by: Bin Meng <bmeng@tinylab.org>
12
13
Besides, vext_get_emul() has also taken EEW/SEW into consideration, so no
14
need to call vext_get_total_elems() which would base on the emul to derive
15
another emul, the second emul would be incorrect when esz differs from sew.
16
17
Thus this patch removes the check for extra tail elements.
18
19
Fixes: 752614cab8e6 ("target/riscv: rvv: Add tail agnostic for vector load / store instructions")
20
21
Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
22
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
11
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
23
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
12
Message-Id: <20230721094720.902454-3-thuth@redhat.com>
24
Message-Id: <20230607091646.4049428-1-xiao.w.wang@intel.com>
25
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
26
---
14
---
27
target/riscv/vector_helper.c | 22 ++++++----------------
15
hw/char/riscv_htif.c | 9 +++++----
28
1 file changed, 6 insertions(+), 16 deletions(-)
16
1 file changed, 5 insertions(+), 4 deletions(-)
29
17
30
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
18
diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
31
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
32
--- a/target/riscv/vector_helper.c
20
--- a/hw/char/riscv_htif.c
33
+++ b/target/riscv/vector_helper.c
21
+++ b/hw/char/riscv_htif.c
34
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_ST_ELEM(ste_h, int16_t, H2, stw)
22
@@ -XXX,XX +XXX,XX @@
35
GEN_VEXT_ST_ELEM(ste_w, int32_t, H4, stl)
23
#include "qemu/timer.h"
36
GEN_VEXT_ST_ELEM(ste_d, int64_t, H8, stq)
24
#include "qemu/error-report.h"
37
25
#include "exec/address-spaces.h"
38
-static void vext_set_tail_elems_1s(CPURISCVState *env, target_ulong vl,
26
+#include "exec/tswap.h"
39
- void *vd, uint32_t desc, uint32_t nf,
27
#include "sysemu/dma.h"
40
+static void vext_set_tail_elems_1s(target_ulong vl, void *vd,
28
41
+ uint32_t desc, uint32_t nf,
29
#define RISCV_DEBUG_HTIF 0
42
uint32_t esz, uint32_t max_elems)
30
@@ -XXX,XX +XXX,XX @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
43
{
31
} else {
44
- uint32_t total_elems, vlenb, registers_used;
32
uint64_t syscall[8];
45
uint32_t vta = vext_vta(desc);
33
cpu_physical_memory_read(payload, syscall, sizeof(syscall));
46
int k;
34
- if (syscall[0] == PK_SYS_WRITE &&
47
35
- syscall[1] == HTIF_DEV_CONSOLE &&
48
@@ -XXX,XX +XXX,XX @@ static void vext_set_tail_elems_1s(CPURISCVState *env, target_ulong vl,
36
- syscall[3] == HTIF_CONSOLE_CMD_PUTC) {
49
return;
37
+ if (tswap64(syscall[0]) == PK_SYS_WRITE &&
50
}
38
+ tswap64(syscall[1]) == HTIF_DEV_CONSOLE &&
51
39
+ tswap64(syscall[3]) == HTIF_CONSOLE_CMD_PUTC) {
52
- total_elems = vext_get_total_elems(env, desc, esz);
40
uint8_t ch;
53
- vlenb = riscv_cpu_cfg(env)->vlen >> 3;
41
- cpu_physical_memory_read(syscall[2], &ch, 1);
54
-
42
+ cpu_physical_memory_read(tswap64(syscall[2]), &ch, 1);
55
for (k = 0; k < nf; ++k) {
43
qemu_chr_fe_write(&s->chr, &ch, 1);
56
vext_set_elems_1s(vd, vta, (k * max_elems + vl) * esz,
44
resp = 0x100 | (uint8_t)payload;
57
(k * max_elems + max_elems) * esz);
45
} else {
58
}
59
-
60
- if (nf * max_elems % total_elems != 0) {
61
- registers_used = ((nf * max_elems) * esz + (vlenb - 1)) / vlenb;
62
- vext_set_elems_1s(vd, vta, (nf * max_elems) * esz,
63
- registers_used * vlenb);
64
- }
65
}
66
67
/*
68
@@ -XXX,XX +XXX,XX @@ vext_ldst_stride(void *vd, void *v0, target_ulong base,
69
}
70
env->vstart = 0;
71
72
- vext_set_tail_elems_1s(env, env->vl, vd, desc, nf, esz, max_elems);
73
+ vext_set_tail_elems_1s(env->vl, vd, desc, nf, esz, max_elems);
74
}
75
76
#define GEN_VEXT_LD_STRIDE(NAME, ETYPE, LOAD_FN) \
77
@@ -XXX,XX +XXX,XX @@ vext_ldst_us(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc,
78
}
79
env->vstart = 0;
80
81
- vext_set_tail_elems_1s(env, evl, vd, desc, nf, esz, max_elems);
82
+ vext_set_tail_elems_1s(evl, vd, desc, nf, esz, max_elems);
83
}
84
85
/*
86
@@ -XXX,XX +XXX,XX @@ vext_ldst_index(void *vd, void *v0, target_ulong base,
87
}
88
env->vstart = 0;
89
90
- vext_set_tail_elems_1s(env, env->vl, vd, desc, nf, esz, max_elems);
91
+ vext_set_tail_elems_1s(env->vl, vd, desc, nf, esz, max_elems);
92
}
93
94
#define GEN_VEXT_LD_INDEX(NAME, ETYPE, INDEX_FN, LOAD_FN) \
95
@@ -XXX,XX +XXX,XX @@ ProbeSuccess:
96
}
97
env->vstart = 0;
98
99
- vext_set_tail_elems_1s(env, env->vl, vd, desc, nf, esz, max_elems);
100
+ vext_set_tail_elems_1s(env->vl, vd, desc, nf, esz, max_elems);
101
}
102
103
#define GEN_VEXT_LDFF(NAME, ETYPE, LOAD_FN) \
104
--
46
--
105
2.40.1
47
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2
2
3
We have 4 config settings being done in riscv_cpu_init(): ext_ifencei,
3
zmmul was promoted from experimental to ratified in commit 6d00ffad4e95.
4
ext_icsr, mmu and pmp. This is also the constructor of the "riscv-cpu"
4
Add a riscv,isa string for it.
5
device, which happens to be the parent device of every RISC-V cpu.
6
5
7
The result is that these 4 configs are being set every time, and every
6
Fixes: 6d00ffad4e95 ("target/riscv: move zmmul out of the experimental properties")
8
other CPU should always account for them. CPUs such as sifive_e need to
9
disable settings that aren't enabled simply because the parent class
10
happens to be enabling it.
11
12
Moving all configurations from the parent class to each CPU will
13
centralize the config of each CPU into its own init(), which is clearer
14
than having to account to whatever happens to be set in the parent
15
device. These settings are also being set in register_cpu_props() when
16
no 'misa_ext' is set, so for these CPUs we don't need changes. Named
17
CPUs will receive all cfgs that the parent were setting into their
18
init().
19
20
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
7
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
21
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
22
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
23
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
24
Message-Id: <20230517135714.211809-11-dbarboza@ventanamicro.com>
10
Message-Id: <20230720132424.371132-2-dbarboza@ventanamicro.com>
25
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
26
---
12
---
27
target/riscv/cpu.c | 59 ++++++++++++++++++++++++++++++++++++----------
13
target/riscv/cpu.c | 1 +
28
1 file changed, 47 insertions(+), 12 deletions(-)
14
1 file changed, 1 insertion(+)
29
15
30
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
16
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
31
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
32
--- a/target/riscv/cpu.c
18
--- a/target/riscv/cpu.c
33
+++ b/target/riscv/cpu.c
19
+++ b/target/riscv/cpu.c
34
@@ -XXX,XX +XXX,XX @@ static void set_satp_mode_default_map(RISCVCPU *cpu)
20
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
35
21
ISA_EXT_DATA_ENTRY(zicsr, PRIV_VERSION_1_10_0, ext_icsr),
36
static void riscv_any_cpu_init(Object *obj)
22
ISA_EXT_DATA_ENTRY(zifencei, PRIV_VERSION_1_10_0, ext_ifencei),
37
{
23
ISA_EXT_DATA_ENTRY(zihintpause, PRIV_VERSION_1_10_0, ext_zihintpause),
38
- CPURISCVState *env = &RISCV_CPU(obj)->env;
24
+ ISA_EXT_DATA_ENTRY(zmmul, PRIV_VERSION_1_12_0, ext_zmmul),
39
+ RISCVCPU *cpu = RISCV_CPU(obj);
25
ISA_EXT_DATA_ENTRY(zawrs, PRIV_VERSION_1_12_0, ext_zawrs),
40
+ CPURISCVState *env = &cpu->env;
26
ISA_EXT_DATA_ENTRY(zfa, PRIV_VERSION_1_12_0, ext_zfa),
41
#if defined(TARGET_RISCV32)
27
ISA_EXT_DATA_ENTRY(zfbfmin, PRIV_VERSION_1_12_0, ext_zfbfmin),
42
set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVD | RVC | RVU);
43
#elif defined(TARGET_RISCV64)
44
@@ -XXX,XX +XXX,XX @@ static void riscv_any_cpu_init(Object *obj)
45
#endif
46
47
env->priv_ver = PRIV_VERSION_LATEST;
48
+
49
+ /* inherited from parent obj via riscv_cpu_init() */
50
+ cpu->cfg.ext_ifencei = true;
51
+ cpu->cfg.ext_icsr = true;
52
+ cpu->cfg.mmu = true;
53
+ cpu->cfg.pmp = true;
54
}
55
56
#if defined(TARGET_RISCV64)
57
@@ -XXX,XX +XXX,XX @@ static void rv64_base_cpu_init(Object *obj)
58
59
static void rv64_sifive_u_cpu_init(Object *obj)
60
{
61
- CPURISCVState *env = &RISCV_CPU(obj)->env;
62
+ RISCVCPU *cpu = RISCV_CPU(obj);
63
+ CPURISCVState *env = &cpu->env;
64
set_misa(env, MXL_RV64, RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
65
env->priv_ver = PRIV_VERSION_1_10_0;
66
#ifndef CONFIG_USER_ONLY
67
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV39);
68
#endif
69
+
70
+ /* inherited from parent obj via riscv_cpu_init() */
71
+ cpu->cfg.ext_ifencei = true;
72
+ cpu->cfg.ext_icsr = true;
73
+ cpu->cfg.mmu = true;
74
+ cpu->cfg.pmp = true;
75
}
76
77
static void rv64_sifive_e_cpu_init(Object *obj)
78
@@ -XXX,XX +XXX,XX @@ static void rv64_sifive_e_cpu_init(Object *obj)
79
80
set_misa(env, MXL_RV64, RVI | RVM | RVA | RVC | RVU);
81
env->priv_ver = PRIV_VERSION_1_10_0;
82
- cpu->cfg.mmu = false;
83
#ifndef CONFIG_USER_ONLY
84
set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
85
#endif
86
+
87
+ /* inherited from parent obj via riscv_cpu_init() */
88
+ cpu->cfg.ext_ifencei = true;
89
+ cpu->cfg.ext_icsr = true;
90
+ cpu->cfg.pmp = true;
91
}
92
93
static void rv64_thead_c906_cpu_init(Object *obj)
94
@@ -XXX,XX +XXX,XX @@ static void rv64_thead_c906_cpu_init(Object *obj)
95
#ifndef CONFIG_USER_ONLY
96
set_satp_mode_max_supported(cpu, VM_1_10_SV39);
97
#endif
98
+
99
+ /* inherited from parent obj via riscv_cpu_init() */
100
+ cpu->cfg.pmp = true;
101
}
102
103
static void rv64_veyron_v1_cpu_init(Object *obj)
104
@@ -XXX,XX +XXX,XX @@ static void rv32_base_cpu_init(Object *obj)
105
106
static void rv32_sifive_u_cpu_init(Object *obj)
107
{
108
- CPURISCVState *env = &RISCV_CPU(obj)->env;
109
+ RISCVCPU *cpu = RISCV_CPU(obj);
110
+ CPURISCVState *env = &cpu->env;
111
set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
112
env->priv_ver = PRIV_VERSION_1_10_0;
113
#ifndef CONFIG_USER_ONLY
114
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV32);
115
#endif
116
+
117
+ /* inherited from parent obj via riscv_cpu_init() */
118
+ cpu->cfg.ext_ifencei = true;
119
+ cpu->cfg.ext_icsr = true;
120
+ cpu->cfg.mmu = true;
121
+ cpu->cfg.pmp = true;
122
}
123
124
static void rv32_sifive_e_cpu_init(Object *obj)
125
@@ -XXX,XX +XXX,XX @@ static void rv32_sifive_e_cpu_init(Object *obj)
126
127
set_misa(env, MXL_RV32, RVI | RVM | RVA | RVC | RVU);
128
env->priv_ver = PRIV_VERSION_1_10_0;
129
- cpu->cfg.mmu = false;
130
#ifndef CONFIG_USER_ONLY
131
set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
132
#endif
133
+
134
+ /* inherited from parent obj via riscv_cpu_init() */
135
+ cpu->cfg.ext_ifencei = true;
136
+ cpu->cfg.ext_icsr = true;
137
+ cpu->cfg.pmp = true;
138
}
139
140
static void rv32_ibex_cpu_init(Object *obj)
141
@@ -XXX,XX +XXX,XX @@ static void rv32_ibex_cpu_init(Object *obj)
142
143
set_misa(env, MXL_RV32, RVI | RVM | RVC | RVU);
144
env->priv_ver = PRIV_VERSION_1_11_0;
145
- cpu->cfg.mmu = false;
146
#ifndef CONFIG_USER_ONLY
147
set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
148
#endif
149
cpu->cfg.epmp = true;
150
+
151
+ /* inherited from parent obj via riscv_cpu_init() */
152
+ cpu->cfg.ext_ifencei = true;
153
+ cpu->cfg.ext_icsr = true;
154
+ cpu->cfg.pmp = true;
155
}
156
157
static void rv32_imafcu_nommu_cpu_init(Object *obj)
158
@@ -XXX,XX +XXX,XX @@ static void rv32_imafcu_nommu_cpu_init(Object *obj)
159
160
set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVC | RVU);
161
env->priv_ver = PRIV_VERSION_1_10_0;
162
- cpu->cfg.mmu = false;
163
#ifndef CONFIG_USER_ONLY
164
set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
165
#endif
166
+
167
+ /* inherited from parent obj via riscv_cpu_init() */
168
+ cpu->cfg.ext_ifencei = true;
169
+ cpu->cfg.ext_icsr = true;
170
+ cpu->cfg.pmp = true;
171
}
172
#endif
173
174
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_init(Object *obj)
175
{
176
RISCVCPU *cpu = RISCV_CPU(obj);
177
178
- cpu->cfg.ext_ifencei = true;
179
- cpu->cfg.ext_icsr = true;
180
- cpu->cfg.mmu = true;
181
- cpu->cfg.pmp = true;
182
-
183
cpu_set_cpustate_pointers(cpu);
184
185
#ifndef CONFIG_USER_ONLY
186
--
28
--
187
2.40.1
29
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2
2
3
This setter is doing nothing else but setting env->vext_ver. Assign the
3
The cpu->cfg.epmp extension is still experimental, but it already has a
4
value directly.
4
'smepmp' riscv,isa string. Add it.
5
5
6
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
6
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
7
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
8
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-Id: <20230517135714.211809-3-dbarboza@ventanamicro.com>
9
Message-Id: <20230720132424.371132-3-dbarboza@ventanamicro.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
11
---
13
target/riscv/cpu.c | 7 +------
12
target/riscv/cpu.c | 1 +
14
1 file changed, 1 insertion(+), 6 deletions(-)
13
1 file changed, 1 insertion(+)
15
14
16
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
15
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/cpu.c
17
--- a/target/riscv/cpu.c
19
+++ b/target/riscv/cpu.c
18
+++ b/target/riscv/cpu.c
20
@@ -XXX,XX +XXX,XX @@ static void set_priv_version(CPURISCVState *env, int priv_ver)
19
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
21
env->priv_ver = priv_ver;
20
ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx),
22
}
21
ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin),
23
22
ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia),
24
-static void set_vext_version(CPURISCVState *env, int vext_ver)
23
+ ISA_EXT_DATA_ENTRY(smepmp, PRIV_VERSION_1_12_0, epmp),
25
-{
24
ISA_EXT_DATA_ENTRY(smstateen, PRIV_VERSION_1_12_0, ext_smstateen),
26
- env->vext_ver = vext_ver;
25
ISA_EXT_DATA_ENTRY(ssaia, PRIV_VERSION_1_12_0, ext_ssaia),
27
-}
26
ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf),
28
-
29
#ifndef CONFIG_USER_ONLY
30
static uint8_t satp_mode_from_str(const char *satp_mode_str)
31
{
32
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg,
33
qemu_log("vector version is not specified, "
34
"use the default value v1.0\n");
35
}
36
- set_vext_version(env, vext_version);
37
+ env->vext_ver = vext_version;
38
}
39
40
/*
41
--
27
--
42
2.40.1
28
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
2
2
3
actual_address = (requested_address & ~mpmmask) | mpmbase.
3
Commit bef6f008b98(accel/tcg: Return bool from page_check_range) converts
4
integer return value to bool type. However, it wrongly converted the use
5
of the API in riscv fault-only-first, where page_check_range < = 0, should
6
be converted to !page_check_range.
4
7
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
Signed-off-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
10
Message-ID: <20230729031618.821-1-zhiwei_liu@linux.alibaba.com>
8
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
9
Message-Id: <20230524015933.17349-2-liweiwei@iscas.ac.cn>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
---
12
target/riscv/vector_helper.c | 2 +-
13
target/riscv/vector_helper.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
15
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
16
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/vector_helper.c
18
--- a/target/riscv/vector_helper.c
18
+++ b/target/riscv/vector_helper.c
19
+++ b/target/riscv/vector_helper.c
19
@@ -XXX,XX +XXX,XX @@ static inline uint32_t vext_get_total_elems(CPURISCVState *env, uint32_t desc,
20
@@ -XXX,XX +XXX,XX @@ vext_ldff(void *vd, void *v0, target_ulong base,
20
21
cpu_mmu_index(env, false));
21
static inline target_ulong adjust_addr(CPURISCVState *env, target_ulong addr)
22
if (host) {
22
{
23
#ifdef CONFIG_USER_ONLY
23
- return (addr & env->cur_pmmask) | env->cur_pmbase;
24
- if (page_check_range(addr, offset, PAGE_READ)) {
24
+ return (addr & ~env->cur_pmmask) | env->cur_pmbase;
25
+ if (!page_check_range(addr, offset, PAGE_READ)) {
25
}
26
vl = i;
26
27
goto ProbeSuccess;
27
/*
28
}
28
--
29
--
29
2.40.1
30
2.41.0
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Ard Biesheuvel <ardb@kernel.org>
2
2
3
OpenTitanState is the 'machine' (or 'board') state: it isn't
3
The AES MixColumns and InvMixColumns operations are relatively
4
a SysBus device, but inherits from the MachineState type.
4
expensive 4x4 matrix multiplications in GF(2^8), which is why C
5
Correct the instance size.
5
implementations usually rely on precomputed lookup tables rather than
6
Doing so we avoid leaking an OpenTitanState pointer in
6
performing the calculations on demand.
7
opentitan_machine_init().
8
7
9
Fixes: fe0fe4735e ("riscv: Initial commit of OpenTitan machine")
8
Given that we already carry those tables in QEMU, we can just grab the
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
right value in the implementation of the RISC-V AES32 instructions. Note
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
that the tables in question are permuted according to the respective
12
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
11
Sbox, so we can omit the Sbox lookup as well in this case.
13
Message-Id: <20230520054510.68822-6-philmd@linaro.org>
12
13
Cc: Richard Henderson <richard.henderson@linaro.org>
14
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Cc: Zewen Ye <lustrew@foxmail.com>
16
Cc: Weiwei Li <liweiwei@iscas.ac.cn>
17
Cc: Junqiang Wang <wangjunqiang@iscas.ac.cn>
18
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-ID: <20230731084043.1791984-1-ardb@kernel.org>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
21
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
---
22
---
16
include/hw/riscv/opentitan.h | 3 ++-
23
include/crypto/aes.h | 7 +++++++
17
hw/riscv/opentitan.c | 3 ++-
24
crypto/aes.c | 4 ++--
18
2 files changed, 4 insertions(+), 2 deletions(-)
25
target/riscv/crypto_helper.c | 34 ++++------------------------------
26
3 files changed, 13 insertions(+), 32 deletions(-)
19
27
20
diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h
28
diff --git a/include/crypto/aes.h b/include/crypto/aes.h
21
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/riscv/opentitan.h
30
--- a/include/crypto/aes.h
23
+++ b/include/hw/riscv/opentitan.h
31
+++ b/include/crypto/aes.h
24
@@ -XXX,XX +XXX,XX @@ struct LowRISCIbexSoCState {
32
@@ -XXX,XX +XXX,XX @@ void AES_decrypt(const unsigned char *in, unsigned char *out,
33
extern const uint8_t AES_sbox[256];
34
extern const uint8_t AES_isbox[256];
35
36
+/*
37
+AES_Te0[x] = S [x].[02, 01, 01, 03];
38
+AES_Td0[x] = Si[x].[0e, 09, 0d, 0b];
39
+*/
40
+
41
+extern const uint32_t AES_Te0[256], AES_Td0[256];
42
+
43
#endif
44
diff --git a/crypto/aes.c b/crypto/aes.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/crypto/aes.c
47
+++ b/crypto/aes.c
48
@@ -XXX,XX +XXX,XX @@ AES_Td3[x] = Si[x].[09, 0d, 0b, 0e];
49
AES_Td4[x] = Si[x].[01, 01, 01, 01];
50
*/
51
52
-static const uint32_t AES_Te0[256] = {
53
+const uint32_t AES_Te0[256] = {
54
0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
55
0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
56
0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
57
@@ -XXX,XX +XXX,XX @@ static const uint32_t AES_Te4[256] = {
58
0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
25
};
59
};
26
60
27
#define TYPE_OPENTITAN_MACHINE MACHINE_TYPE_NAME("opentitan")
61
-static const uint32_t AES_Td0[256] = {
28
+OBJECT_DECLARE_SIMPLE_TYPE(OpenTitanState, OPENTITAN_MACHINE)
62
+const uint32_t AES_Td0[256] = {
29
63
0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
30
typedef struct OpenTitanState {
64
0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
31
/*< private >*/
65
0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
32
- SysBusDevice parent_obj;
66
diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c
33
+ MachineState parent_obj;
34
35
/*< public >*/
36
LowRISCIbexSoCState soc;
37
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
38
index XXXXXXX..XXXXXXX 100644
67
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/riscv/opentitan.c
68
--- a/target/riscv/crypto_helper.c
40
+++ b/hw/riscv/opentitan.c
69
+++ b/target/riscv/crypto_helper.c
41
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry ibex_memmap[] = {
70
@@ -XXX,XX +XXX,XX @@
42
static void opentitan_machine_init(MachineState *machine)
71
#include "crypto/aes-round.h"
72
#include "crypto/sm4.h"
73
74
-#define AES_XTIME(a) \
75
- ((a << 1) ^ ((a & 0x80) ? 0x1b : 0))
76
-
77
-#define AES_GFMUL(a, b) (( \
78
- (((b) & 0x1) ? (a) : 0) ^ \
79
- (((b) & 0x2) ? AES_XTIME(a) : 0) ^ \
80
- (((b) & 0x4) ? AES_XTIME(AES_XTIME(a)) : 0) ^ \
81
- (((b) & 0x8) ? AES_XTIME(AES_XTIME(AES_XTIME(a))) : 0)) & 0xFF)
82
-
83
-static inline uint32_t aes_mixcolumn_byte(uint8_t x, bool fwd)
84
-{
85
- uint32_t u;
86
-
87
- if (fwd) {
88
- u = (AES_GFMUL(x, 3) << 24) | (x << 16) | (x << 8) |
89
- (AES_GFMUL(x, 2) << 0);
90
- } else {
91
- u = (AES_GFMUL(x, 0xb) << 24) | (AES_GFMUL(x, 0xd) << 16) |
92
- (AES_GFMUL(x, 0x9) << 8) | (AES_GFMUL(x, 0xe) << 0);
93
- }
94
- return u;
95
-}
96
-
97
#define sext32_xlen(x) (target_ulong)(int32_t)(x)
98
99
static inline target_ulong aes32_operation(target_ulong shamt,
100
@@ -XXX,XX +XXX,XX @@ static inline target_ulong aes32_operation(target_ulong shamt,
101
bool enc, bool mix)
43
{
102
{
44
MachineClass *mc = MACHINE_GET_CLASS(machine);
103
uint8_t si = rs2 >> shamt;
45
+ OpenTitanState *s = OPENTITAN_MACHINE(machine);
104
- uint8_t so;
46
const MemMapEntry *memmap = ibex_memmap;
105
uint32_t mixed;
47
- OpenTitanState *s = g_new0(OpenTitanState, 1);
106
target_ulong res;
48
MemoryRegion *sys_mem = get_system_memory();
107
49
108
if (enc) {
50
if (machine->ram_size != mc->default_ram_size) {
109
- so = AES_sbox[si];
51
@@ -XXX,XX +XXX,XX @@ static const TypeInfo open_titan_types[] = {
110
if (mix) {
52
}, {
111
- mixed = aes_mixcolumn_byte(so, true);
53
.name = TYPE_OPENTITAN_MACHINE,
112
+ mixed = be32_to_cpu(AES_Te0[si]);
54
.parent = TYPE_MACHINE,
113
} else {
55
+ .instance_size = sizeof(OpenTitanState),
114
- mixed = so;
56
.class_init = opentitan_machine_class_init,
115
+ mixed = AES_sbox[si];
116
}
117
} else {
118
- so = AES_isbox[si];
119
if (mix) {
120
- mixed = aes_mixcolumn_byte(so, false);
121
+ mixed = be32_to_cpu(AES_Td0[si]);
122
} else {
123
- mixed = so;
124
+ mixed = AES_isbox[si];
125
}
57
}
126
}
58
};
127
mixed = rol32(mixed, shamt);
59
--
128
--
60
2.40.1
129
2.41.0
61
130
62
131
diff view generated by jsdifflib
1
From: Xiao Wang <xiao.w.wang@intel.com>
1
From: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
2
2
3
There's no code using MTYPE, which was a concept used in older vector
3
Take some functions/macros out of `vector_helper` and put them in a new
4
implementation.
4
module called `vector_internals`. This ensures they can be used by both
5
vector and vector-crypto helpers (latter implemented in proceeding
6
commits).
5
7
6
Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
8
Signed-off-by: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
7
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
9
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
10
Signed-off-by: Max Chou <max.chou@sifive.com>
9
Message-Id: <20230608053517.4102648-1-xiao.w.wang@intel.com>
11
Acked-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-ID: <20230711165917.2629866-2-max.chou@sifive.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
14
---
12
target/riscv/vector_helper.c | 6 +-----
15
target/riscv/vector_internals.h | 182 +++++++++++++++++++++++++++++
13
1 file changed, 1 insertion(+), 5 deletions(-)
16
target/riscv/vector_helper.c | 201 +-------------------------------
17
target/riscv/vector_internals.c | 81 +++++++++++++
18
target/riscv/meson.build | 1 +
19
4 files changed, 265 insertions(+), 200 deletions(-)
20
create mode 100644 target/riscv/vector_internals.h
21
create mode 100644 target/riscv/vector_internals.c
14
22
23
diff --git a/target/riscv/vector_internals.h b/target/riscv/vector_internals.h
24
new file mode 100644
25
index XXXXXXX..XXXXXXX
26
--- /dev/null
27
+++ b/target/riscv/vector_internals.h
28
@@ -XXX,XX +XXX,XX @@
29
+/*
30
+ * RISC-V Vector Extension Internals
31
+ *
32
+ * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved.
33
+ *
34
+ * This program is free software; you can redistribute it and/or modify it
35
+ * under the terms and conditions of the GNU General Public License,
36
+ * version 2 or later, as published by the Free Software Foundation.
37
+ *
38
+ * This program is distributed in the hope it will be useful, but WITHOUT
39
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
40
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
41
+ * more details.
42
+ *
43
+ * You should have received a copy of the GNU General Public License along with
44
+ * this program. If not, see <http://www.gnu.org/licenses/>.
45
+ */
46
+
47
+#ifndef TARGET_RISCV_VECTOR_INTERNALS_H
48
+#define TARGET_RISCV_VECTOR_INTERNALS_H
49
+
50
+#include "qemu/osdep.h"
51
+#include "qemu/bitops.h"
52
+#include "cpu.h"
53
+#include "tcg/tcg-gvec-desc.h"
54
+#include "internals.h"
55
+
56
+static inline uint32_t vext_nf(uint32_t desc)
57
+{
58
+ return FIELD_EX32(simd_data(desc), VDATA, NF);
59
+}
60
+
61
+/*
62
+ * Note that vector data is stored in host-endian 64-bit chunks,
63
+ * so addressing units smaller than that needs a host-endian fixup.
64
+ */
65
+#if HOST_BIG_ENDIAN
66
+#define H1(x) ((x) ^ 7)
67
+#define H1_2(x) ((x) ^ 6)
68
+#define H1_4(x) ((x) ^ 4)
69
+#define H2(x) ((x) ^ 3)
70
+#define H4(x) ((x) ^ 1)
71
+#define H8(x) ((x))
72
+#else
73
+#define H1(x) (x)
74
+#define H1_2(x) (x)
75
+#define H1_4(x) (x)
76
+#define H2(x) (x)
77
+#define H4(x) (x)
78
+#define H8(x) (x)
79
+#endif
80
+
81
+/*
82
+ * Encode LMUL to lmul as following:
83
+ * LMUL vlmul lmul
84
+ * 1 000 0
85
+ * 2 001 1
86
+ * 4 010 2
87
+ * 8 011 3
88
+ * - 100 -
89
+ * 1/8 101 -3
90
+ * 1/4 110 -2
91
+ * 1/2 111 -1
92
+ */
93
+static inline int32_t vext_lmul(uint32_t desc)
94
+{
95
+ return sextract32(FIELD_EX32(simd_data(desc), VDATA, LMUL), 0, 3);
96
+}
97
+
98
+static inline uint32_t vext_vm(uint32_t desc)
99
+{
100
+ return FIELD_EX32(simd_data(desc), VDATA, VM);
101
+}
102
+
103
+static inline uint32_t vext_vma(uint32_t desc)
104
+{
105
+ return FIELD_EX32(simd_data(desc), VDATA, VMA);
106
+}
107
+
108
+static inline uint32_t vext_vta(uint32_t desc)
109
+{
110
+ return FIELD_EX32(simd_data(desc), VDATA, VTA);
111
+}
112
+
113
+static inline uint32_t vext_vta_all_1s(uint32_t desc)
114
+{
115
+ return FIELD_EX32(simd_data(desc), VDATA, VTA_ALL_1S);
116
+}
117
+
118
+/*
119
+ * Earlier designs (pre-0.9) had a varying number of bits
120
+ * per mask value (MLEN). In the 0.9 design, MLEN=1.
121
+ * (Section 4.5)
122
+ */
123
+static inline int vext_elem_mask(void *v0, int index)
124
+{
125
+ int idx = index / 64;
126
+ int pos = index % 64;
127
+ return (((uint64_t *)v0)[idx] >> pos) & 1;
128
+}
129
+
130
+/*
131
+ * Get number of total elements, including prestart, body and tail elements.
132
+ * Note that when LMUL < 1, the tail includes the elements past VLMAX that
133
+ * are held in the same vector register.
134
+ */
135
+static inline uint32_t vext_get_total_elems(CPURISCVState *env, uint32_t desc,
136
+ uint32_t esz)
137
+{
138
+ uint32_t vlenb = simd_maxsz(desc);
139
+ uint32_t sew = 1 << FIELD_EX64(env->vtype, VTYPE, VSEW);
140
+ int8_t emul = ctzl(esz) - ctzl(sew) + vext_lmul(desc) < 0 ? 0 :
141
+ ctzl(esz) - ctzl(sew) + vext_lmul(desc);
142
+ return (vlenb << emul) / esz;
143
+}
144
+
145
+/* set agnostic elements to 1s */
146
+void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt,
147
+ uint32_t tot);
148
+
149
+/* expand macro args before macro */
150
+#define RVVCALL(macro, ...) macro(__VA_ARGS__)
151
+
152
+/* (TD, T1, T2, TX1, TX2) */
153
+#define OP_UUU_B uint8_t, uint8_t, uint8_t, uint8_t, uint8_t
154
+#define OP_UUU_H uint16_t, uint16_t, uint16_t, uint16_t, uint16_t
155
+#define OP_UUU_W uint32_t, uint32_t, uint32_t, uint32_t, uint32_t
156
+#define OP_UUU_D uint64_t, uint64_t, uint64_t, uint64_t, uint64_t
157
+
158
+/* operation of two vector elements */
159
+typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i);
160
+
161
+#define OPIVV2(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \
162
+static void do_##NAME(void *vd, void *vs1, void *vs2, int i) \
163
+{ \
164
+ TX1 s1 = *((T1 *)vs1 + HS1(i)); \
165
+ TX2 s2 = *((T2 *)vs2 + HS2(i)); \
166
+ *((TD *)vd + HD(i)) = OP(s2, s1); \
167
+}
168
+
169
+void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2,
170
+ CPURISCVState *env, uint32_t desc,
171
+ opivv2_fn *fn, uint32_t esz);
172
+
173
+/* generate the helpers for OPIVV */
174
+#define GEN_VEXT_VV(NAME, ESZ) \
175
+void HELPER(NAME)(void *vd, void *v0, void *vs1, \
176
+ void *vs2, CPURISCVState *env, \
177
+ uint32_t desc) \
178
+{ \
179
+ do_vext_vv(vd, v0, vs1, vs2, env, desc, \
180
+ do_##NAME, ESZ); \
181
+}
182
+
183
+typedef void opivx2_fn(void *vd, target_long s1, void *vs2, int i);
184
+
185
+/*
186
+ * (T1)s1 gives the real operator type.
187
+ * (TX1)(T1)s1 expands the operator type of widen or narrow operations.
188
+ */
189
+#define OPIVX2(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \
190
+static void do_##NAME(void *vd, target_long s1, void *vs2, int i) \
191
+{ \
192
+ TX2 s2 = *((T2 *)vs2 + HS2(i)); \
193
+ *((TD *)vd + HD(i)) = OP(s2, (TX1)(T1)s1); \
194
+}
195
+
196
+void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2,
197
+ CPURISCVState *env, uint32_t desc,
198
+ opivx2_fn fn, uint32_t esz);
199
+
200
+/* generate the helpers for OPIVX */
201
+#define GEN_VEXT_VX(NAME, ESZ) \
202
+void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \
203
+ void *vs2, CPURISCVState *env, \
204
+ uint32_t desc) \
205
+{ \
206
+ do_vext_vx(vd, v0, s1, vs2, env, desc, \
207
+ do_##NAME, ESZ); \
208
+}
209
+
210
+#endif /* TARGET_RISCV_VECTOR_INTERNALS_H */
15
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
211
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
16
index XXXXXXX..XXXXXXX 100644
212
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/vector_helper.c
213
--- a/target/riscv/vector_helper.c
18
+++ b/target/riscv/vector_helper.c
214
+++ b/target/riscv/vector_helper.c
19
@@ -XXX,XX +XXX,XX @@ vext_ldst_us(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc,
215
@@ -XXX,XX +XXX,XX @@
20
216
#include "fpu/softfloat.h"
217
#include "tcg/tcg-gvec-desc.h"
218
#include "internals.h"
219
+#include "vector_internals.h"
220
#include <math.h>
221
222
target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
223
@@ -XXX,XX +XXX,XX @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
224
return vl;
225
}
226
227
-/*
228
- * Note that vector data is stored in host-endian 64-bit chunks,
229
- * so addressing units smaller than that needs a host-endian fixup.
230
- */
231
-#if HOST_BIG_ENDIAN
232
-#define H1(x) ((x) ^ 7)
233
-#define H1_2(x) ((x) ^ 6)
234
-#define H1_4(x) ((x) ^ 4)
235
-#define H2(x) ((x) ^ 3)
236
-#define H4(x) ((x) ^ 1)
237
-#define H8(x) ((x))
238
-#else
239
-#define H1(x) (x)
240
-#define H1_2(x) (x)
241
-#define H1_4(x) (x)
242
-#define H2(x) (x)
243
-#define H4(x) (x)
244
-#define H8(x) (x)
245
-#endif
246
-
247
-static inline uint32_t vext_nf(uint32_t desc)
248
-{
249
- return FIELD_EX32(simd_data(desc), VDATA, NF);
250
-}
251
-
252
-static inline uint32_t vext_vm(uint32_t desc)
253
-{
254
- return FIELD_EX32(simd_data(desc), VDATA, VM);
255
-}
256
-
257
-/*
258
- * Encode LMUL to lmul as following:
259
- * LMUL vlmul lmul
260
- * 1 000 0
261
- * 2 001 1
262
- * 4 010 2
263
- * 8 011 3
264
- * - 100 -
265
- * 1/8 101 -3
266
- * 1/4 110 -2
267
- * 1/2 111 -1
268
- */
269
-static inline int32_t vext_lmul(uint32_t desc)
270
-{
271
- return sextract32(FIELD_EX32(simd_data(desc), VDATA, LMUL), 0, 3);
272
-}
273
-
274
-static inline uint32_t vext_vta(uint32_t desc)
275
-{
276
- return FIELD_EX32(simd_data(desc), VDATA, VTA);
277
-}
278
-
279
-static inline uint32_t vext_vma(uint32_t desc)
280
-{
281
- return FIELD_EX32(simd_data(desc), VDATA, VMA);
282
-}
283
-
284
-static inline uint32_t vext_vta_all_1s(uint32_t desc)
285
-{
286
- return FIELD_EX32(simd_data(desc), VDATA, VTA_ALL_1S);
287
-}
288
-
21
/*
289
/*
22
* masked unit-stride load and store operation will be a special case of
290
* Get the maximum number of elements can be operated.
23
- * stride, stride = NF * sizeof (MTYPE)
291
*
24
+ * stride, stride = NF * sizeof (ETYPE)
292
@@ -XXX,XX +XXX,XX @@ static inline uint32_t vext_max_elems(uint32_t desc, uint32_t log2_esz)
293
return scale < 0 ? vlenb >> -scale : vlenb << scale;
294
}
295
296
-/*
297
- * Get number of total elements, including prestart, body and tail elements.
298
- * Note that when LMUL < 1, the tail includes the elements past VLMAX that
299
- * are held in the same vector register.
300
- */
301
-static inline uint32_t vext_get_total_elems(CPURISCVState *env, uint32_t desc,
302
- uint32_t esz)
303
-{
304
- uint32_t vlenb = simd_maxsz(desc);
305
- uint32_t sew = 1 << FIELD_EX64(env->vtype, VTYPE, VSEW);
306
- int8_t emul = ctzl(esz) - ctzl(sew) + vext_lmul(desc) < 0 ? 0 :
307
- ctzl(esz) - ctzl(sew) + vext_lmul(desc);
308
- return (vlenb << emul) / esz;
309
-}
310
-
311
static inline target_ulong adjust_addr(CPURISCVState *env, target_ulong addr)
312
{
313
return (addr & ~env->cur_pmmask) | env->cur_pmbase;
314
@@ -XXX,XX +XXX,XX @@ static void probe_pages(CPURISCVState *env, target_ulong addr,
315
}
316
}
317
318
-/* set agnostic elements to 1s */
319
-static void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt,
320
- uint32_t tot)
321
-{
322
- if (is_agnostic == 0) {
323
- /* policy undisturbed */
324
- return;
325
- }
326
- if (tot - cnt == 0) {
327
- return;
328
- }
329
- memset(base + cnt, -1, tot - cnt);
330
-}
331
-
332
static inline void vext_set_elem_mask(void *v0, int index,
333
uint8_t value)
334
{
335
@@ -XXX,XX +XXX,XX @@ static inline void vext_set_elem_mask(void *v0, int index,
336
((uint64_t *)v0)[idx] = deposit64(old, pos, 1, value);
337
}
338
339
-/*
340
- * Earlier designs (pre-0.9) had a varying number of bits
341
- * per mask value (MLEN). In the 0.9 design, MLEN=1.
342
- * (Section 4.5)
343
- */
344
-static inline int vext_elem_mask(void *v0, int index)
345
-{
346
- int idx = index / 64;
347
- int pos = index % 64;
348
- return (((uint64_t *)v0)[idx] >> pos) & 1;
349
-}
350
-
351
/* elements operations for load and store */
352
typedef void vext_ldst_elem_fn(CPURISCVState *env, abi_ptr addr,
353
uint32_t idx, void *vd, uintptr_t retaddr);
354
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_ST_WHOLE(vs8r_v, int8_t, ste_b)
355
* Vector Integer Arithmetic Instructions
25
*/
356
*/
26
357
27
#define GEN_VEXT_LD_US(NAME, ETYPE, LOAD_FN) \
358
-/* expand macro args before macro */
28
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_LDFF(vle64ff_v, int64_t, lde_d)
359
-#define RVVCALL(macro, ...) macro(__VA_ARGS__)
29
#define DO_MAX(N, M) ((N) >= (M) ? (N) : (M))
360
-
30
#define DO_MIN(N, M) ((N) >= (M) ? (M) : (N))
361
/* (TD, T1, T2, TX1, TX2) */
31
362
#define OP_SSS_B int8_t, int8_t, int8_t, int8_t, int8_t
32
-/* Unsigned min/max */
363
#define OP_SSS_H int16_t, int16_t, int16_t, int16_t, int16_t
33
-#define DO_MAXU(N, M) DO_MAX((UMTYPE)N, (UMTYPE)M)
364
#define OP_SSS_W int32_t, int32_t, int32_t, int32_t, int32_t
34
-#define DO_MINU(N, M) DO_MIN((UMTYPE)N, (UMTYPE)M)
365
#define OP_SSS_D int64_t, int64_t, int64_t, int64_t, int64_t
35
-
366
-#define OP_UUU_B uint8_t, uint8_t, uint8_t, uint8_t, uint8_t
36
/*
367
-#define OP_UUU_H uint16_t, uint16_t, uint16_t, uint16_t, uint16_t
37
* load and store whole register instructions
368
-#define OP_UUU_W uint32_t, uint32_t, uint32_t, uint32_t, uint32_t
38
*/
369
-#define OP_UUU_D uint64_t, uint64_t, uint64_t, uint64_t, uint64_t
370
#define OP_SUS_B int8_t, uint8_t, int8_t, uint8_t, int8_t
371
#define OP_SUS_H int16_t, uint16_t, int16_t, uint16_t, int16_t
372
#define OP_SUS_W int32_t, uint32_t, int32_t, uint32_t, int32_t
373
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_ST_WHOLE(vs8r_v, int8_t, ste_b)
374
#define NOP_UUU_H uint16_t, uint16_t, uint32_t, uint16_t, uint32_t
375
#define NOP_UUU_W uint32_t, uint32_t, uint64_t, uint32_t, uint64_t
376
377
-/* operation of two vector elements */
378
-typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i);
379
-
380
-#define OPIVV2(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \
381
-static void do_##NAME(void *vd, void *vs1, void *vs2, int i) \
382
-{ \
383
- TX1 s1 = *((T1 *)vs1 + HS1(i)); \
384
- TX2 s2 = *((T2 *)vs2 + HS2(i)); \
385
- *((TD *)vd + HD(i)) = OP(s2, s1); \
386
-}
387
#define DO_SUB(N, M) (N - M)
388
#define DO_RSUB(N, M) (M - N)
389
390
@@ -XXX,XX +XXX,XX @@ RVVCALL(OPIVV2, vsub_vv_h, OP_SSS_H, H2, H2, H2, DO_SUB)
391
RVVCALL(OPIVV2, vsub_vv_w, OP_SSS_W, H4, H4, H4, DO_SUB)
392
RVVCALL(OPIVV2, vsub_vv_d, OP_SSS_D, H8, H8, H8, DO_SUB)
393
394
-static void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2,
395
- CPURISCVState *env, uint32_t desc,
396
- opivv2_fn *fn, uint32_t esz)
397
-{
398
- uint32_t vm = vext_vm(desc);
399
- uint32_t vl = env->vl;
400
- uint32_t total_elems = vext_get_total_elems(env, desc, esz);
401
- uint32_t vta = vext_vta(desc);
402
- uint32_t vma = vext_vma(desc);
403
- uint32_t i;
404
-
405
- for (i = env->vstart; i < vl; i++) {
406
- if (!vm && !vext_elem_mask(v0, i)) {
407
- /* set masked-off elements to 1s */
408
- vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz);
409
- continue;
410
- }
411
- fn(vd, vs1, vs2, i);
412
- }
413
- env->vstart = 0;
414
- /* set tail elements to 1s */
415
- vext_set_elems_1s(vd, vta, vl * esz, total_elems * esz);
416
-}
417
-
418
-/* generate the helpers for OPIVV */
419
-#define GEN_VEXT_VV(NAME, ESZ) \
420
-void HELPER(NAME)(void *vd, void *v0, void *vs1, \
421
- void *vs2, CPURISCVState *env, \
422
- uint32_t desc) \
423
-{ \
424
- do_vext_vv(vd, v0, vs1, vs2, env, desc, \
425
- do_##NAME, ESZ); \
426
-}
427
-
428
GEN_VEXT_VV(vadd_vv_b, 1)
429
GEN_VEXT_VV(vadd_vv_h, 2)
430
GEN_VEXT_VV(vadd_vv_w, 4)
431
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_VV(vsub_vv_h, 2)
432
GEN_VEXT_VV(vsub_vv_w, 4)
433
GEN_VEXT_VV(vsub_vv_d, 8)
434
435
-typedef void opivx2_fn(void *vd, target_long s1, void *vs2, int i);
436
-
437
-/*
438
- * (T1)s1 gives the real operator type.
439
- * (TX1)(T1)s1 expands the operator type of widen or narrow operations.
440
- */
441
-#define OPIVX2(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \
442
-static void do_##NAME(void *vd, target_long s1, void *vs2, int i) \
443
-{ \
444
- TX2 s2 = *((T2 *)vs2 + HS2(i)); \
445
- *((TD *)vd + HD(i)) = OP(s2, (TX1)(T1)s1); \
446
-}
447
448
RVVCALL(OPIVX2, vadd_vx_b, OP_SSS_B, H1, H1, DO_ADD)
449
RVVCALL(OPIVX2, vadd_vx_h, OP_SSS_H, H2, H2, DO_ADD)
450
@@ -XXX,XX +XXX,XX @@ RVVCALL(OPIVX2, vrsub_vx_h, OP_SSS_H, H2, H2, DO_RSUB)
451
RVVCALL(OPIVX2, vrsub_vx_w, OP_SSS_W, H4, H4, DO_RSUB)
452
RVVCALL(OPIVX2, vrsub_vx_d, OP_SSS_D, H8, H8, DO_RSUB)
453
454
-static void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2,
455
- CPURISCVState *env, uint32_t desc,
456
- opivx2_fn fn, uint32_t esz)
457
-{
458
- uint32_t vm = vext_vm(desc);
459
- uint32_t vl = env->vl;
460
- uint32_t total_elems = vext_get_total_elems(env, desc, esz);
461
- uint32_t vta = vext_vta(desc);
462
- uint32_t vma = vext_vma(desc);
463
- uint32_t i;
464
-
465
- for (i = env->vstart; i < vl; i++) {
466
- if (!vm && !vext_elem_mask(v0, i)) {
467
- /* set masked-off elements to 1s */
468
- vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz);
469
- continue;
470
- }
471
- fn(vd, s1, vs2, i);
472
- }
473
- env->vstart = 0;
474
- /* set tail elements to 1s */
475
- vext_set_elems_1s(vd, vta, vl * esz, total_elems * esz);
476
-}
477
-
478
-/* generate the helpers for OPIVX */
479
-#define GEN_VEXT_VX(NAME, ESZ) \
480
-void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \
481
- void *vs2, CPURISCVState *env, \
482
- uint32_t desc) \
483
-{ \
484
- do_vext_vx(vd, v0, s1, vs2, env, desc, \
485
- do_##NAME, ESZ); \
486
-}
487
-
488
GEN_VEXT_VX(vadd_vx_b, 1)
489
GEN_VEXT_VX(vadd_vx_h, 2)
490
GEN_VEXT_VX(vadd_vx_w, 4)
491
diff --git a/target/riscv/vector_internals.c b/target/riscv/vector_internals.c
492
new file mode 100644
493
index XXXXXXX..XXXXXXX
494
--- /dev/null
495
+++ b/target/riscv/vector_internals.c
496
@@ -XXX,XX +XXX,XX @@
497
+/*
498
+ * RISC-V Vector Extension Internals
499
+ *
500
+ * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved.
501
+ *
502
+ * This program is free software; you can redistribute it and/or modify it
503
+ * under the terms and conditions of the GNU General Public License,
504
+ * version 2 or later, as published by the Free Software Foundation.
505
+ *
506
+ * This program is distributed in the hope it will be useful, but WITHOUT
507
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
508
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
509
+ * more details.
510
+ *
511
+ * You should have received a copy of the GNU General Public License along with
512
+ * this program. If not, see <http://www.gnu.org/licenses/>.
513
+ */
514
+
515
+#include "vector_internals.h"
516
+
517
+/* set agnostic elements to 1s */
518
+void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt,
519
+ uint32_t tot)
520
+{
521
+ if (is_agnostic == 0) {
522
+ /* policy undisturbed */
523
+ return;
524
+ }
525
+ if (tot - cnt == 0) {
526
+ return ;
527
+ }
528
+ memset(base + cnt, -1, tot - cnt);
529
+}
530
+
531
+void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2,
532
+ CPURISCVState *env, uint32_t desc,
533
+ opivv2_fn *fn, uint32_t esz)
534
+{
535
+ uint32_t vm = vext_vm(desc);
536
+ uint32_t vl = env->vl;
537
+ uint32_t total_elems = vext_get_total_elems(env, desc, esz);
538
+ uint32_t vta = vext_vta(desc);
539
+ uint32_t vma = vext_vma(desc);
540
+ uint32_t i;
541
+
542
+ for (i = env->vstart; i < vl; i++) {
543
+ if (!vm && !vext_elem_mask(v0, i)) {
544
+ /* set masked-off elements to 1s */
545
+ vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz);
546
+ continue;
547
+ }
548
+ fn(vd, vs1, vs2, i);
549
+ }
550
+ env->vstart = 0;
551
+ /* set tail elements to 1s */
552
+ vext_set_elems_1s(vd, vta, vl * esz, total_elems * esz);
553
+}
554
+
555
+void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2,
556
+ CPURISCVState *env, uint32_t desc,
557
+ opivx2_fn fn, uint32_t esz)
558
+{
559
+ uint32_t vm = vext_vm(desc);
560
+ uint32_t vl = env->vl;
561
+ uint32_t total_elems = vext_get_total_elems(env, desc, esz);
562
+ uint32_t vta = vext_vta(desc);
563
+ uint32_t vma = vext_vma(desc);
564
+ uint32_t i;
565
+
566
+ for (i = env->vstart; i < vl; i++) {
567
+ if (!vm && !vext_elem_mask(v0, i)) {
568
+ /* set masked-off elements to 1s */
569
+ vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz);
570
+ continue;
571
+ }
572
+ fn(vd, s1, vs2, i);
573
+ }
574
+ env->vstart = 0;
575
+ /* set tail elements to 1s */
576
+ vext_set_elems_1s(vd, vta, vl * esz, total_elems * esz);
577
+}
578
diff --git a/target/riscv/meson.build b/target/riscv/meson.build
579
index XXXXXXX..XXXXXXX 100644
580
--- a/target/riscv/meson.build
581
+++ b/target/riscv/meson.build
582
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(files(
583
'gdbstub.c',
584
'op_helper.c',
585
'vector_helper.c',
586
+ 'vector_internals.c',
587
'bitmanip_helper.c',
588
'translate.c',
589
'm128_helper.c',
39
--
590
--
40
2.40.1
591
2.41.0
diff view generated by jsdifflib
1
From: Himanshu Chauhan <hchauhan@ventanamicro.com>
1
From: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
2
2
3
On an address match, skip checking for default permissions and return error
3
Refactor the non SEW-specific stuff out of `GEN_OPIVV_TRANS` into
4
based on access defined in PMP configuration.
4
function `opivv_trans` (similar to `opivi_trans`). `opivv_trans` will be
5
used in proceeding vector-crypto commits.
5
6
6
v3 Changes:
7
Signed-off-by: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
7
o Removed explicit return of boolean value from comparision
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
of priv/allowed_priv
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
10
v2 Changes:
11
o Removed goto to return in place when address matches
12
o Call pmp_hart_has_privs_default at the end of the loop
13
14
Fixes: 90b1fafce06 ("target/riscv: Smepmp: Skip applying default rules when address matches")
15
Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
16
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
17
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
10
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
18
Message-Id: <20230605164548.715336-1-hchauhan@ventanamicro.com>
11
Signed-off-by: Max Chou <max.chou@sifive.com>
12
Message-ID: <20230711165917.2629866-3-max.chou@sifive.com>
19
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
20
---
14
---
21
target/riscv/pmp.c | 10 ++--------
15
target/riscv/insn_trans/trans_rvv.c.inc | 62 +++++++++++++------------
22
1 file changed, 2 insertions(+), 8 deletions(-)
16
1 file changed, 32 insertions(+), 30 deletions(-)
23
17
24
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
18
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
25
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
26
--- a/target/riscv/pmp.c
20
--- a/target/riscv/insn_trans/trans_rvv.c.inc
27
+++ b/target/riscv/pmp.c
21
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
28
@@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
22
@@ -XXX,XX +XXX,XX @@ GEN_OPIWX_WIDEN_TRANS(vwadd_wx)
29
pmp_priv_t *allowed_privs, target_ulong mode)
23
GEN_OPIWX_WIDEN_TRANS(vwsubu_wx)
30
{
24
GEN_OPIWX_WIDEN_TRANS(vwsub_wx)
31
int i = 0;
25
32
- bool ret = false;
26
+static bool opivv_trans(uint32_t vd, uint32_t vs1, uint32_t vs2, uint32_t vm,
33
int pmp_size = 0;
27
+ gen_helper_gvec_4_ptr *fn, DisasContext *s)
34
target_ulong s = 0;
28
+{
35
target_ulong e = 0;
29
+ uint32_t data = 0;
36
@@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
30
+ TCGLabel *over = gen_new_label();
37
* defined with PMP must be used. We shouldn't fallback on
31
+ tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
38
* finding default privileges.
32
+ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
39
*/
33
+
40
- ret = true;
34
+ data = FIELD_DP32(data, VDATA, VM, vm);
41
- break;
35
+ data = FIELD_DP32(data, VDATA, LMUL, s->lmul);
42
+ return (privs & *allowed_privs) == privs;
36
+ data = FIELD_DP32(data, VDATA, VTA, s->vta);
43
}
37
+ data = FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s);
44
}
38
+ data = FIELD_DP32(data, VDATA, VMA, s->vma);
45
39
+ tcg_gen_gvec_4_ptr(vreg_ofs(s, vd), vreg_ofs(s, 0), vreg_ofs(s, vs1),
46
/* No rule matched */
40
+ vreg_ofs(s, vs2), cpu_env, s->cfg_ptr->vlen / 8,
47
- if (!ret) {
41
+ s->cfg_ptr->vlen / 8, data, fn);
48
- ret = pmp_hart_has_privs_default(env, privs, allowed_privs, mode);
42
+ mark_vs_dirty(s);
49
- }
43
+ gen_set_label(over);
50
-
44
+ return true;
51
- return ret;
45
+}
52
+ return pmp_hart_has_privs_default(env, privs, allowed_privs, mode);
46
+
47
/* Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions */
48
/* OPIVV without GVEC IR */
49
-#define GEN_OPIVV_TRANS(NAME, CHECK) \
50
-static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
51
-{ \
52
- if (CHECK(s, a)) { \
53
- uint32_t data = 0; \
54
- static gen_helper_gvec_4_ptr * const fns[4] = { \
55
- gen_helper_##NAME##_b, gen_helper_##NAME##_h, \
56
- gen_helper_##NAME##_w, gen_helper_##NAME##_d, \
57
- }; \
58
- TCGLabel *over = gen_new_label(); \
59
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
60
- tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
61
- \
62
- data = FIELD_DP32(data, VDATA, VM, a->vm); \
63
- data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
64
- data = FIELD_DP32(data, VDATA, VTA, s->vta); \
65
- data = \
66
- FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s);\
67
- data = FIELD_DP32(data, VDATA, VMA, s->vma); \
68
- tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
69
- vreg_ofs(s, a->rs1), \
70
- vreg_ofs(s, a->rs2), cpu_env, \
71
- s->cfg_ptr->vlen / 8, \
72
- s->cfg_ptr->vlen / 8, data, \
73
- fns[s->sew]); \
74
- mark_vs_dirty(s); \
75
- gen_set_label(over); \
76
- return true; \
77
- } \
78
- return false; \
79
+#define GEN_OPIVV_TRANS(NAME, CHECK) \
80
+static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
81
+{ \
82
+ if (CHECK(s, a)) { \
83
+ static gen_helper_gvec_4_ptr * const fns[4] = { \
84
+ gen_helper_##NAME##_b, gen_helper_##NAME##_h, \
85
+ gen_helper_##NAME##_w, gen_helper_##NAME##_d, \
86
+ }; \
87
+ return opivv_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s);\
88
+ } \
89
+ return false; \
53
}
90
}
54
91
55
/*
92
/*
56
--
93
--
57
2.40.1
94
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
2
2
3
Reduce reliance on absolute values(by passing pc difference) to
3
Remove the redundant "vl == 0" check which is already included within the vstart >= vl check, when vl == 0.
4
prepare for PC-relative translation.
5
4
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
5
Signed-off-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
6
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Max Chou <max.chou@sifive.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Acked-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-Id: <20230526072124.298466-5-liweiwei@iscas.ac.cn>
9
Message-ID: <20230711165917.2629866-4-max.chou@sifive.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
11
---
13
target/riscv/translate.c | 10 +++++-----
12
target/riscv/insn_trans/trans_rvv.c.inc | 31 +------------------------
14
target/riscv/insn_trans/trans_privileged.c.inc | 2 +-
13
1 file changed, 1 insertion(+), 30 deletions(-)
15
target/riscv/insn_trans/trans_rvi.c.inc | 6 +++---
16
target/riscv/insn_trans/trans_rvv.c.inc | 4 ++--
17
target/riscv/insn_trans/trans_rvzawrs.c.inc | 2 +-
18
target/riscv/insn_trans/trans_xthead.c.inc | 2 +-
19
6 files changed, 13 insertions(+), 13 deletions(-)
20
14
21
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/riscv/translate.c
24
+++ b/target/riscv/translate.c
25
@@ -XXX,XX +XXX,XX @@ static void gen_pc_plus_diff(TCGv target, DisasContext *ctx,
26
tcg_gen_movi_tl(target, dest);
27
}
28
29
-static void gen_set_pc_imm(DisasContext *ctx, target_ulong dest)
30
+static void gen_update_pc(DisasContext *ctx, target_long diff)
31
{
32
- gen_pc_plus_diff(cpu_pc, ctx, dest);
33
+ gen_pc_plus_diff(cpu_pc, ctx, ctx->base.pc_next + diff);
34
}
35
36
static void generate_exception(DisasContext *ctx, int excp)
37
{
38
- gen_set_pc_imm(ctx, ctx->base.pc_next);
39
+ gen_update_pc(ctx, 0);
40
gen_helper_raise_exception(cpu_env, tcg_constant_i32(excp));
41
ctx->base.is_jmp = DISAS_NORETURN;
42
}
43
@@ -XXX,XX +XXX,XX @@ static void gen_goto_tb(DisasContext *ctx, int n, target_long diff)
44
*/
45
if (translator_use_goto_tb(&ctx->base, dest) && !ctx->itrigger) {
46
tcg_gen_goto_tb(n);
47
- gen_set_pc_imm(ctx, dest);
48
+ gen_update_pc(ctx, diff);
49
tcg_gen_exit_tb(ctx->base.tb, n);
50
} else {
51
- gen_set_pc_imm(ctx, dest);
52
+ gen_update_pc(ctx, diff);
53
lookup_and_goto_ptr(ctx);
54
}
55
}
56
diff --git a/target/riscv/insn_trans/trans_privileged.c.inc b/target/riscv/insn_trans/trans_privileged.c.inc
57
index XXXXXXX..XXXXXXX 100644
58
--- a/target/riscv/insn_trans/trans_privileged.c.inc
59
+++ b/target/riscv/insn_trans/trans_privileged.c.inc
60
@@ -XXX,XX +XXX,XX @@ static bool trans_wfi(DisasContext *ctx, arg_wfi *a)
61
{
62
#ifndef CONFIG_USER_ONLY
63
decode_save_opc(ctx);
64
- gen_set_pc_imm(ctx, ctx->pc_succ_insn);
65
+ gen_update_pc(ctx, ctx->cur_insn_len);
66
gen_helper_wfi(cpu_env);
67
return true;
68
#else
69
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
70
index XXXXXXX..XXXXXXX 100644
71
--- a/target/riscv/insn_trans/trans_rvi.c.inc
72
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
73
@@ -XXX,XX +XXX,XX @@ static bool trans_pause(DisasContext *ctx, arg_pause *a)
74
* PAUSE is a no-op in QEMU,
75
* end the TB and return to main loop
76
*/
77
- gen_set_pc_imm(ctx, ctx->pc_succ_insn);
78
+ gen_update_pc(ctx, ctx->cur_insn_len);
79
exit_tb(ctx);
80
ctx->base.is_jmp = DISAS_NORETURN;
81
82
@@ -XXX,XX +XXX,XX @@ static bool trans_fence_i(DisasContext *ctx, arg_fence_i *a)
83
* FENCE_I is a no-op in QEMU,
84
* however we need to end the translation block
85
*/
86
- gen_set_pc_imm(ctx, ctx->pc_succ_insn);
87
+ gen_update_pc(ctx, ctx->cur_insn_len);
88
exit_tb(ctx);
89
ctx->base.is_jmp = DISAS_NORETURN;
90
return true;
91
@@ -XXX,XX +XXX,XX @@ static bool do_csr_post(DisasContext *ctx)
92
/* The helper may raise ILLEGAL_INSN -- record binv for unwind. */
93
decode_save_opc(ctx);
94
/* We may have changed important cpu state -- exit to main loop. */
95
- gen_set_pc_imm(ctx, ctx->pc_succ_insn);
96
+ gen_update_pc(ctx, ctx->cur_insn_len);
97
exit_tb(ctx);
98
ctx->base.is_jmp = DISAS_NORETURN;
99
return true;
100
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
15
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
101
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
102
--- a/target/riscv/insn_trans/trans_rvv.c.inc
17
--- a/target/riscv/insn_trans/trans_rvv.c.inc
103
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
18
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
104
@@ -XXX,XX +XXX,XX @@ static bool do_vsetvl(DisasContext *s, int rd, int rs1, TCGv s2)
19
@@ -XXX,XX +XXX,XX @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data,
105
gen_set_gpr(s, rd, dst);
20
TCGv_i32 desc;
106
mark_vs_dirty(s);
21
107
22
TCGLabel *over = gen_new_label();
108
- gen_set_pc_imm(s, s->pc_succ_insn);
23
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
109
+ gen_update_pc(s, s->cur_insn_len);
24
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
110
lookup_and_goto_ptr(s);
25
111
s->base.is_jmp = DISAS_NORETURN;
26
dest = tcg_temp_new_ptr();
112
return true;
27
@@ -XXX,XX +XXX,XX @@ static bool ldst_stride_trans(uint32_t vd, uint32_t rs1, uint32_t rs2,
113
@@ -XXX,XX +XXX,XX @@ static bool do_vsetivli(DisasContext *s, int rd, TCGv s1, TCGv s2)
28
TCGv_i32 desc;
114
gen_helper_vsetvl(dst, cpu_env, s1, s2);
29
115
gen_set_gpr(s, rd, dst);
30
TCGLabel *over = gen_new_label();
116
mark_vs_dirty(s);
31
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
117
- gen_set_pc_imm(s, s->pc_succ_insn);
32
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
118
+ gen_update_pc(s, s->cur_insn_len);
33
119
lookup_and_goto_ptr(s);
34
dest = tcg_temp_new_ptr();
120
s->base.is_jmp = DISAS_NORETURN;
35
@@ -XXX,XX +XXX,XX @@ static bool ldst_index_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,
121
36
TCGv_i32 desc;
122
diff --git a/target/riscv/insn_trans/trans_rvzawrs.c.inc b/target/riscv/insn_trans/trans_rvzawrs.c.inc
37
123
index XXXXXXX..XXXXXXX 100644
38
TCGLabel *over = gen_new_label();
124
--- a/target/riscv/insn_trans/trans_rvzawrs.c.inc
39
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
125
+++ b/target/riscv/insn_trans/trans_rvzawrs.c.inc
40
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
126
@@ -XXX,XX +XXX,XX @@ static bool trans_wrs(DisasContext *ctx)
41
127
/* Clear the load reservation (if any). */
42
dest = tcg_temp_new_ptr();
128
tcg_gen_movi_tl(load_res, -1);
43
@@ -XXX,XX +XXX,XX @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data,
129
44
TCGv_i32 desc;
130
- gen_set_pc_imm(ctx, ctx->pc_succ_insn);
45
131
+ gen_update_pc(ctx, ctx->cur_insn_len);
46
TCGLabel *over = gen_new_label();
132
tcg_gen_exit_tb(NULL, 0);
47
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
133
ctx->base.is_jmp = DISAS_NORETURN;
48
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
134
49
135
diff --git a/target/riscv/insn_trans/trans_xthead.c.inc b/target/riscv/insn_trans/trans_xthead.c.inc
50
dest = tcg_temp_new_ptr();
136
index XXXXXXX..XXXXXXX 100644
51
@@ -XXX,XX +XXX,XX @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3Fn *gvec_fn,
137
--- a/target/riscv/insn_trans/trans_xthead.c.inc
52
return false;
138
+++ b/target/riscv/insn_trans/trans_xthead.c.inc
53
}
139
@@ -XXX,XX +XXX,XX @@ static void gen_th_sync_local(DisasContext *ctx)
54
140
* Emulate out-of-order barriers with pipeline flush
55
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
141
* by exiting the translation block.
56
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
142
*/
57
143
- gen_set_pc_imm(ctx, ctx->pc_succ_insn);
58
if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) {
144
+ gen_update_pc(ctx, ctx->cur_insn_len);
59
@@ -XXX,XX +XXX,XX @@ static bool opivx_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, uint32_t vm,
145
tcg_gen_exit_tb(NULL, 0);
60
uint32_t data = 0;
146
ctx->base.is_jmp = DISAS_NORETURN;
61
147
}
62
TCGLabel *over = gen_new_label();
63
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
64
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
65
66
dest = tcg_temp_new_ptr();
67
@@ -XXX,XX +XXX,XX @@ static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm,
68
uint32_t data = 0;
69
70
TCGLabel *over = gen_new_label();
71
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
72
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
73
74
dest = tcg_temp_new_ptr();
75
@@ -XXX,XX +XXX,XX @@ static bool do_opivv_widen(DisasContext *s, arg_rmrr *a,
76
if (checkfn(s, a)) {
77
uint32_t data = 0;
78
TCGLabel *over = gen_new_label();
79
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
80
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
81
82
data = FIELD_DP32(data, VDATA, VM, a->vm);
83
@@ -XXX,XX +XXX,XX @@ static bool do_opiwv_widen(DisasContext *s, arg_rmrr *a,
84
if (opiwv_widen_check(s, a)) {
85
uint32_t data = 0;
86
TCGLabel *over = gen_new_label();
87
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
88
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
89
90
data = FIELD_DP32(data, VDATA, VM, a->vm);
91
@@ -XXX,XX +XXX,XX @@ static bool opivv_trans(uint32_t vd, uint32_t vs1, uint32_t vs2, uint32_t vm,
92
{
93
uint32_t data = 0;
94
TCGLabel *over = gen_new_label();
95
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
96
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
97
98
data = FIELD_DP32(data, VDATA, VM, vm);
99
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
100
gen_helper_##NAME##_w, \
101
}; \
102
TCGLabel *over = gen_new_label(); \
103
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
104
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
105
\
106
data = FIELD_DP32(data, VDATA, VM, a->vm); \
107
@@ -XXX,XX +XXX,XX @@ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a)
108
gen_helper_vmv_v_v_w, gen_helper_vmv_v_v_d,
109
};
110
TCGLabel *over = gen_new_label();
111
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
112
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
113
114
tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1),
115
@@ -XXX,XX +XXX,XX @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a)
116
vext_check_ss(s, a->rd, 0, 1)) {
117
TCGv s1;
118
TCGLabel *over = gen_new_label();
119
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
120
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
121
122
s1 = get_gpr(s, a->rs1, EXT_SIGN);
123
@@ -XXX,XX +XXX,XX @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_i *a)
124
gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d,
125
};
126
TCGLabel *over = gen_new_label();
127
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
128
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
129
130
s1 = tcg_constant_i64(simm);
131
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
132
}; \
133
TCGLabel *over = gen_new_label(); \
134
gen_set_rm(s, RISCV_FRM_DYN); \
135
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
136
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
137
\
138
data = FIELD_DP32(data, VDATA, VM, a->vm); \
139
@@ -XXX,XX +XXX,XX @@ static bool opfvf_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,
140
TCGv_i64 t1;
141
142
TCGLabel *over = gen_new_label();
143
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
144
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
145
146
dest = tcg_temp_new_ptr();
147
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
148
}; \
149
TCGLabel *over = gen_new_label(); \
150
gen_set_rm(s, RISCV_FRM_DYN); \
151
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
152
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);\
153
\
154
data = FIELD_DP32(data, VDATA, VM, a->vm); \
155
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
156
}; \
157
TCGLabel *over = gen_new_label(); \
158
gen_set_rm(s, RISCV_FRM_DYN); \
159
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
160
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
161
\
162
data = FIELD_DP32(data, VDATA, VM, a->vm); \
163
@@ -XXX,XX +XXX,XX @@ static bool do_opfv(DisasContext *s, arg_rmr *a,
164
uint32_t data = 0;
165
TCGLabel *over = gen_new_label();
166
gen_set_rm_chkfrm(s, rm);
167
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
168
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
169
170
data = FIELD_DP32(data, VDATA, VM, a->vm);
171
@@ -XXX,XX +XXX,XX @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a)
172
gen_helper_vmv_v_x_d,
173
};
174
TCGLabel *over = gen_new_label();
175
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
176
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
177
178
t1 = tcg_temp_new_i64();
179
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
180
}; \
181
TCGLabel *over = gen_new_label(); \
182
gen_set_rm_chkfrm(s, FRM); \
183
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
184
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
185
\
186
data = FIELD_DP32(data, VDATA, VM, a->vm); \
187
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
188
}; \
189
TCGLabel *over = gen_new_label(); \
190
gen_set_rm(s, RISCV_FRM_DYN); \
191
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
192
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
193
\
194
data = FIELD_DP32(data, VDATA, VM, a->vm); \
195
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
196
}; \
197
TCGLabel *over = gen_new_label(); \
198
gen_set_rm_chkfrm(s, FRM); \
199
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
200
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
201
\
202
data = FIELD_DP32(data, VDATA, VM, a->vm); \
203
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
204
}; \
205
TCGLabel *over = gen_new_label(); \
206
gen_set_rm_chkfrm(s, FRM); \
207
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
208
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
209
\
210
data = FIELD_DP32(data, VDATA, VM, a->vm); \
211
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_r *a) \
212
uint32_t data = 0; \
213
gen_helper_gvec_4_ptr *fn = gen_helper_##NAME; \
214
TCGLabel *over = gen_new_label(); \
215
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
216
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
217
\
218
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
219
@@ -XXX,XX +XXX,XX @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a)
220
require_vm(a->vm, a->rd)) {
221
uint32_t data = 0;
222
TCGLabel *over = gen_new_label();
223
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
224
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
225
226
data = FIELD_DP32(data, VDATA, VM, a->vm);
227
@@ -XXX,XX +XXX,XX @@ static bool trans_vmv_s_x(DisasContext *s, arg_vmv_s_x *a)
228
TCGv s1;
229
TCGLabel *over = gen_new_label();
230
231
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
232
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
233
234
t1 = tcg_temp_new_i64();
235
@@ -XXX,XX +XXX,XX @@ static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_s_f *a)
236
TCGv_i64 t1;
237
TCGLabel *over = gen_new_label();
238
239
- /* if vl == 0 or vstart >= vl, skip vector register write back */
240
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
241
+ /* if vstart >= vl, skip vector register write back */
242
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
243
244
/* NaN-box f[rs1] */
245
@@ -XXX,XX +XXX,XX @@ static bool int_ext_op(DisasContext *s, arg_rmr *a, uint8_t seq)
246
uint32_t data = 0;
247
gen_helper_gvec_3_ptr *fn;
248
TCGLabel *over = gen_new_label();
249
- tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
250
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
251
252
static gen_helper_gvec_3_ptr * const fns[6][4] = {
148
--
253
--
149
2.40.1
254
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
2
2
3
Split RISCVCPUConfig declarations to prepare for passing it to disas.
3
This commit adds support for the Zvbc vector-crypto extension, which
4
4
consists of the following instructions:
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
5
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
6
* vclmulh.[vx,vv]
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
* vclmul.[vx,vv]
8
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
9
Message-Id: <20230523093539.203909-3-liweiwei@iscas.ac.cn>
9
Translation functions are defined in
10
`target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in
11
`target/riscv/vcrypto_helper.c`.
12
13
Co-authored-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
14
Co-authored-by: Max Chou <max.chou@sifive.com>
15
Signed-off-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
16
Signed-off-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
17
Signed-off-by: Max Chou <max.chou@sifive.com>
18
[max.chou@sifive.com: Exposed x-zvbc property]
19
Message-ID: <20230711165917.2629866-5-max.chou@sifive.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
20
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
21
---
12
target/riscv/cpu.h | 114 +---------------------------------
22
target/riscv/cpu_cfg.h | 1 +
13
target/riscv/cpu_cfg.h | 136 +++++++++++++++++++++++++++++++++++++++++
23
target/riscv/helper.h | 6 +++
14
2 files changed, 137 insertions(+), 113 deletions(-)
24
target/riscv/insn32.decode | 6 +++
15
create mode 100644 target/riscv/cpu_cfg.h
25
target/riscv/cpu.c | 9 ++++
16
26
target/riscv/translate.c | 1 +
17
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
27
target/riscv/vcrypto_helper.c | 59 ++++++++++++++++++++++
18
index XXXXXXX..XXXXXXX 100644
28
target/riscv/insn_trans/trans_rvvk.c.inc | 62 ++++++++++++++++++++++++
19
--- a/target/riscv/cpu.h
29
target/riscv/meson.build | 3 +-
20
+++ b/target/riscv/cpu.h
30
8 files changed, 146 insertions(+), 1 deletion(-)
21
@@ -XXX,XX +XXX,XX @@
31
create mode 100644 target/riscv/vcrypto_helper.c
22
#include "qom/object.h"
32
create mode 100644 target/riscv/insn_trans/trans_rvvk.c.inc
23
#include "qemu/int128.h"
33
24
#include "cpu_bits.h"
34
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
25
+#include "cpu_cfg.h"
35
index XXXXXXX..XXXXXXX 100644
26
#include "qapi/qapi-types-common.h"
36
--- a/target/riscv/cpu_cfg.h
27
#include "cpu-qom.h"
37
+++ b/target/riscv/cpu_cfg.h
28
38
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
29
@@ -XXX,XX +XXX,XX @@ struct CPUArchState {
39
bool ext_zve32f;
30
uint64_t kvm_timer_frequency;
40
bool ext_zve64f;
41
bool ext_zve64d;
42
+ bool ext_zvbc;
43
bool ext_zmmul;
44
bool ext_zvfbfmin;
45
bool ext_zvfbfwma;
46
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/riscv/helper.h
49
+++ b/target/riscv/helper.h
50
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vfwcvtbf16_f_f_v, void, ptr, ptr, ptr, env, i32)
51
52
DEF_HELPER_6(vfwmaccbf16_vv, void, ptr, ptr, ptr, ptr, env, i32)
53
DEF_HELPER_6(vfwmaccbf16_vf, void, ptr, ptr, i64, ptr, env, i32)
54
+
55
+/* Vector crypto functions */
56
+DEF_HELPER_6(vclmul_vv, void, ptr, ptr, ptr, ptr, env, i32)
57
+DEF_HELPER_6(vclmul_vx, void, ptr, ptr, tl, ptr, env, i32)
58
+DEF_HELPER_6(vclmulh_vv, void, ptr, ptr, ptr, ptr, env, i32)
59
+DEF_HELPER_6(vclmulh_vx, void, ptr, ptr, tl, ptr, env, i32)
60
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
61
index XXXXXXX..XXXXXXX 100644
62
--- a/target/riscv/insn32.decode
63
+++ b/target/riscv/insn32.decode
64
@@ -XXX,XX +XXX,XX @@ vfwcvtbf16_f_f_v 010010 . ..... 01101 001 ..... 1010111 @r2_vm
65
# *** Zvfbfwma Standard Extension ***
66
vfwmaccbf16_vv 111011 . ..... ..... 001 ..... 1010111 @r_vm
67
vfwmaccbf16_vf 111011 . ..... ..... 101 ..... 1010111 @r_vm
68
+
69
+# *** Zvbc vector crypto extension ***
70
+vclmul_vv 001100 . ..... ..... 010 ..... 1010111 @r_vm
71
+vclmul_vx 001100 . ..... ..... 110 ..... 1010111 @r_vm
72
+vclmulh_vv 001101 . ..... ..... 010 ..... 1010111 @r_vm
73
+vclmulh_vx 001101 . ..... ..... 110 ..... 1010111 @r_vm
74
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
75
index XXXXXXX..XXXXXXX 100644
76
--- a/target/riscv/cpu.c
77
+++ b/target/riscv/cpu.c
78
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
79
ISA_EXT_DATA_ENTRY(zksed, PRIV_VERSION_1_12_0, ext_zksed),
80
ISA_EXT_DATA_ENTRY(zksh, PRIV_VERSION_1_12_0, ext_zksh),
81
ISA_EXT_DATA_ENTRY(zkt, PRIV_VERSION_1_12_0, ext_zkt),
82
+ ISA_EXT_DATA_ENTRY(zvbc, PRIV_VERSION_1_12_0, ext_zvbc),
83
ISA_EXT_DATA_ENTRY(zve32f, PRIV_VERSION_1_10_0, ext_zve32f),
84
ISA_EXT_DATA_ENTRY(zve64f, PRIV_VERSION_1_10_0, ext_zve64f),
85
ISA_EXT_DATA_ENTRY(zve64d, PRIV_VERSION_1_10_0, ext_zve64d),
86
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
87
return;
88
}
89
90
+ if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) {
91
+ error_setg(errp, "Zvbc extension requires V or Zve64{f,d} extensions");
92
+ return;
93
+ }
94
+
95
if (cpu->cfg.ext_zk) {
96
cpu->cfg.ext_zkn = true;
97
cpu->cfg.ext_zkr = true;
98
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
99
DEFINE_PROP_BOOL("x-zvfbfmin", RISCVCPU, cfg.ext_zvfbfmin, false),
100
DEFINE_PROP_BOOL("x-zvfbfwma", RISCVCPU, cfg.ext_zvfbfwma, false),
101
102
+ /* Vector cryptography extensions */
103
+ DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false),
104
+
105
DEFINE_PROP_END_OF_LIST(),
31
};
106
};
32
107
33
-/*
108
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
34
- * map is a 16-bit bitmap: the most significant set bit in map is the maximum
109
index XXXXXXX..XXXXXXX 100644
35
- * satp mode that is supported. It may be chosen by the user and must respect
110
--- a/target/riscv/translate.c
36
- * what qemu implements (valid_1_10_32/64) and what the hw is capable of
111
+++ b/target/riscv/translate.c
37
- * (supported bitmap below).
112
@@ -XXX,XX +XXX,XX @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)
38
- *
113
#include "insn_trans/trans_rvzfa.c.inc"
39
- * init is a 16-bit bitmap used to make sure the user selected a correct
114
#include "insn_trans/trans_rvzfh.c.inc"
40
- * configuration as per the specification.
115
#include "insn_trans/trans_rvk.c.inc"
41
- *
116
+#include "insn_trans/trans_rvvk.c.inc"
42
- * supported is a 16-bit bitmap used to reflect the hw capabilities.
117
#include "insn_trans/trans_privileged.c.inc"
43
- */
118
#include "insn_trans/trans_svinval.c.inc"
44
-typedef struct {
119
#include "insn_trans/trans_rvbf16.c.inc"
45
- uint16_t map, init, supported;
120
diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c
46
-} RISCVSATPMap;
47
-
48
-struct RISCVCPUConfig {
49
- bool ext_zba;
50
- bool ext_zbb;
51
- bool ext_zbc;
52
- bool ext_zbkb;
53
- bool ext_zbkc;
54
- bool ext_zbkx;
55
- bool ext_zbs;
56
- bool ext_zca;
57
- bool ext_zcb;
58
- bool ext_zcd;
59
- bool ext_zce;
60
- bool ext_zcf;
61
- bool ext_zcmp;
62
- bool ext_zcmt;
63
- bool ext_zk;
64
- bool ext_zkn;
65
- bool ext_zknd;
66
- bool ext_zkne;
67
- bool ext_zknh;
68
- bool ext_zkr;
69
- bool ext_zks;
70
- bool ext_zksed;
71
- bool ext_zksh;
72
- bool ext_zkt;
73
- bool ext_ifencei;
74
- bool ext_icsr;
75
- bool ext_icbom;
76
- bool ext_icboz;
77
- bool ext_zicond;
78
- bool ext_zihintpause;
79
- bool ext_smstateen;
80
- bool ext_sstc;
81
- bool ext_svadu;
82
- bool ext_svinval;
83
- bool ext_svnapot;
84
- bool ext_svpbmt;
85
- bool ext_zdinx;
86
- bool ext_zawrs;
87
- bool ext_zfh;
88
- bool ext_zfhmin;
89
- bool ext_zfinx;
90
- bool ext_zhinx;
91
- bool ext_zhinxmin;
92
- bool ext_zve32f;
93
- bool ext_zve64f;
94
- bool ext_zve64d;
95
- bool ext_zmmul;
96
- bool ext_zvfh;
97
- bool ext_zvfhmin;
98
- bool ext_smaia;
99
- bool ext_ssaia;
100
- bool ext_sscofpmf;
101
- bool rvv_ta_all_1s;
102
- bool rvv_ma_all_1s;
103
-
104
- uint32_t mvendorid;
105
- uint64_t marchid;
106
- uint64_t mimpid;
107
-
108
- /* Vendor-specific custom extensions */
109
- bool ext_xtheadba;
110
- bool ext_xtheadbb;
111
- bool ext_xtheadbs;
112
- bool ext_xtheadcmo;
113
- bool ext_xtheadcondmov;
114
- bool ext_xtheadfmemidx;
115
- bool ext_xtheadfmv;
116
- bool ext_xtheadmac;
117
- bool ext_xtheadmemidx;
118
- bool ext_xtheadmempair;
119
- bool ext_xtheadsync;
120
- bool ext_XVentanaCondOps;
121
-
122
- uint8_t pmu_num;
123
- char *priv_spec;
124
- char *user_spec;
125
- char *bext_spec;
126
- char *vext_spec;
127
- uint16_t vlen;
128
- uint16_t elen;
129
- uint16_t cbom_blocksize;
130
- uint16_t cboz_blocksize;
131
- bool mmu;
132
- bool pmp;
133
- bool epmp;
134
- bool debug;
135
- bool misa_w;
136
-
137
- bool short_isa_string;
138
-
139
-#ifndef CONFIG_USER_ONLY
140
- RISCVSATPMap satp_mode;
141
-#endif
142
-};
143
-
144
-typedef struct RISCVCPUConfig RISCVCPUConfig;
145
-
146
/*
147
* RISCVCPU:
148
* @env: #CPURISCVState
149
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
150
new file mode 100644
121
new file mode 100644
151
index XXXXXXX..XXXXXXX
122
index XXXXXXX..XXXXXXX
152
--- /dev/null
123
--- /dev/null
153
+++ b/target/riscv/cpu_cfg.h
124
+++ b/target/riscv/vcrypto_helper.c
154
@@ -XXX,XX +XXX,XX @@
125
@@ -XXX,XX +XXX,XX @@
155
+/*
126
+/*
156
+ * QEMU RISC-V CPU CFG
127
+ * RISC-V Vector Crypto Extension Helpers for QEMU.
157
+ *
128
+ *
158
+ * Copyright (c) 2016-2017 Sagar Karandikar, sagark@eecs.berkeley.edu
129
+ * Copyright (C) 2023 SiFive, Inc.
159
+ * Copyright (c) 2017-2018 SiFive, Inc.
130
+ * Written by Codethink Ltd and SiFive.
160
+ * Copyright (c) 2021-2023 PLCT Lab
161
+ *
131
+ *
162
+ * This program is free software; you can redistribute it and/or modify it
132
+ * This program is free software; you can redistribute it and/or modify it
163
+ * under the terms and conditions of the GNU General Public License,
133
+ * under the terms and conditions of the GNU General Public License,
164
+ * version 2 or later, as published by the Free Software Foundation.
134
+ * version 2 or later, as published by the Free Software Foundation.
165
+ *
135
+ *
...
...
170
+ *
140
+ *
171
+ * You should have received a copy of the GNU General Public License along with
141
+ * You should have received a copy of the GNU General Public License along with
172
+ * this program. If not, see <http://www.gnu.org/licenses/>.
142
+ * this program. If not, see <http://www.gnu.org/licenses/>.
173
+ */
143
+ */
174
+
144
+
175
+#ifndef RISCV_CPU_CFG_H
145
+#include "qemu/osdep.h"
176
+#define RISCV_CPU_CFG_H
146
+#include "qemu/host-utils.h"
177
+
147
+#include "qemu/bitops.h"
148
+#include "cpu.h"
149
+#include "exec/memop.h"
150
+#include "exec/exec-all.h"
151
+#include "exec/helper-proto.h"
152
+#include "internals.h"
153
+#include "vector_internals.h"
154
+
155
+static uint64_t clmul64(uint64_t y, uint64_t x)
156
+{
157
+ uint64_t result = 0;
158
+ for (int j = 63; j >= 0; j--) {
159
+ if ((y >> j) & 1) {
160
+ result ^= (x << j);
161
+ }
162
+ }
163
+ return result;
164
+}
165
+
166
+static uint64_t clmulh64(uint64_t y, uint64_t x)
167
+{
168
+ uint64_t result = 0;
169
+ for (int j = 63; j >= 1; j--) {
170
+ if ((y >> j) & 1) {
171
+ result ^= (x >> (64 - j));
172
+ }
173
+ }
174
+ return result;
175
+}
176
+
177
+RVVCALL(OPIVV2, vclmul_vv, OP_UUU_D, H8, H8, H8, clmul64)
178
+GEN_VEXT_VV(vclmul_vv, 8)
179
+RVVCALL(OPIVX2, vclmul_vx, OP_UUU_D, H8, H8, clmul64)
180
+GEN_VEXT_VX(vclmul_vx, 8)
181
+RVVCALL(OPIVV2, vclmulh_vv, OP_UUU_D, H8, H8, H8, clmulh64)
182
+GEN_VEXT_VV(vclmulh_vv, 8)
183
+RVVCALL(OPIVX2, vclmulh_vx, OP_UUU_D, H8, H8, clmulh64)
184
+GEN_VEXT_VX(vclmulh_vx, 8)
185
diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_trans/trans_rvvk.c.inc
186
new file mode 100644
187
index XXXXXXX..XXXXXXX
188
--- /dev/null
189
+++ b/target/riscv/insn_trans/trans_rvvk.c.inc
190
@@ -XXX,XX +XXX,XX @@
178
+/*
191
+/*
179
+ * map is a 16-bit bitmap: the most significant set bit in map is the maximum
192
+ * RISC-V translation routines for the vector crypto extension.
180
+ * satp mode that is supported. It may be chosen by the user and must respect
193
+ *
181
+ * what qemu implements (valid_1_10_32/64) and what the hw is capable of
194
+ * Copyright (C) 2023 SiFive, Inc.
182
+ * (supported bitmap below).
195
+ * Written by Codethink Ltd and SiFive.
183
+ *
196
+ *
184
+ * init is a 16-bit bitmap used to make sure the user selected a correct
197
+ * This program is free software; you can redistribute it and/or modify it
185
+ * configuration as per the specification.
198
+ * under the terms and conditions of the GNU General Public License,
186
+ *
199
+ * version 2 or later, as published by the Free Software Foundation.
187
+ * supported is a 16-bit bitmap used to reflect the hw capabilities.
200
+ *
201
+ * This program is distributed in the hope it will be useful, but WITHOUT
202
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
203
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
204
+ * more details.
205
+ *
206
+ * You should have received a copy of the GNU General Public License along with
207
+ * this program. If not, see <http://www.gnu.org/licenses/>.
188
+ */
208
+ */
189
+typedef struct {
209
+
190
+ uint16_t map, init, supported;
210
+/*
191
+} RISCVSATPMap;
211
+ * Zvbc
192
+
212
+ */
193
+struct RISCVCPUConfig {
213
+
194
+ bool ext_zba;
214
+#define GEN_VV_MASKED_TRANS(NAME, CHECK) \
195
+ bool ext_zbb;
215
+ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
196
+ bool ext_zbc;
216
+ { \
197
+ bool ext_zbkb;
217
+ if (CHECK(s, a)) { \
198
+ bool ext_zbkc;
218
+ return opivv_trans(a->rd, a->rs1, a->rs2, a->vm, \
199
+ bool ext_zbkx;
219
+ gen_helper_##NAME, s); \
200
+ bool ext_zbs;
220
+ } \
201
+ bool ext_zca;
221
+ return false; \
202
+ bool ext_zcb;
222
+ }
203
+ bool ext_zcd;
223
+
204
+ bool ext_zce;
224
+static bool vclmul_vv_check(DisasContext *s, arg_rmrr *a)
205
+ bool ext_zcf;
225
+{
206
+ bool ext_zcmp;
226
+ return opivv_check(s, a) &&
207
+ bool ext_zcmt;
227
+ s->cfg_ptr->ext_zvbc == true &&
208
+ bool ext_zk;
228
+ s->sew == MO_64;
209
+ bool ext_zkn;
229
+}
210
+ bool ext_zknd;
230
+
211
+ bool ext_zkne;
231
+GEN_VV_MASKED_TRANS(vclmul_vv, vclmul_vv_check)
212
+ bool ext_zknh;
232
+GEN_VV_MASKED_TRANS(vclmulh_vv, vclmul_vv_check)
213
+ bool ext_zkr;
233
+
214
+ bool ext_zks;
234
+#define GEN_VX_MASKED_TRANS(NAME, CHECK) \
215
+ bool ext_zksed;
235
+ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
216
+ bool ext_zksh;
236
+ { \
217
+ bool ext_zkt;
237
+ if (CHECK(s, a)) { \
218
+ bool ext_ifencei;
238
+ return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, \
219
+ bool ext_icsr;
239
+ gen_helper_##NAME, s); \
220
+ bool ext_icbom;
240
+ } \
221
+ bool ext_icboz;
241
+ return false; \
222
+ bool ext_zicond;
242
+ }
223
+ bool ext_zihintpause;
243
+
224
+ bool ext_smstateen;
244
+static bool vclmul_vx_check(DisasContext *s, arg_rmrr *a)
225
+ bool ext_sstc;
245
+{
226
+ bool ext_svadu;
246
+ return opivx_check(s, a) &&
227
+ bool ext_svinval;
247
+ s->cfg_ptr->ext_zvbc == true &&
228
+ bool ext_svnapot;
248
+ s->sew == MO_64;
229
+ bool ext_svpbmt;
249
+}
230
+ bool ext_zdinx;
250
+
231
+ bool ext_zawrs;
251
+GEN_VX_MASKED_TRANS(vclmul_vx, vclmul_vx_check)
232
+ bool ext_zfh;
252
+GEN_VX_MASKED_TRANS(vclmulh_vx, vclmul_vx_check)
233
+ bool ext_zfhmin;
253
diff --git a/target/riscv/meson.build b/target/riscv/meson.build
234
+ bool ext_zfinx;
254
index XXXXXXX..XXXXXXX 100644
235
+ bool ext_zhinx;
255
--- a/target/riscv/meson.build
236
+ bool ext_zhinxmin;
256
+++ b/target/riscv/meson.build
237
+ bool ext_zve32f;
257
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(files(
238
+ bool ext_zve64f;
258
'translate.c',
239
+ bool ext_zve64d;
259
'm128_helper.c',
240
+ bool ext_zmmul;
260
'crypto_helper.c',
241
+ bool ext_zvfh;
261
- 'zce_helper.c'
242
+ bool ext_zvfhmin;
262
+ 'zce_helper.c',
243
+ bool ext_smaia;
263
+ 'vcrypto_helper.c'
244
+ bool ext_ssaia;
264
))
245
+ bool ext_sscofpmf;
265
riscv_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c'))
246
+ bool rvv_ta_all_1s;
266
247
+ bool rvv_ma_all_1s;
248
+
249
+ uint32_t mvendorid;
250
+ uint64_t marchid;
251
+ uint64_t mimpid;
252
+
253
+ /* Vendor-specific custom extensions */
254
+ bool ext_xtheadba;
255
+ bool ext_xtheadbb;
256
+ bool ext_xtheadbs;
257
+ bool ext_xtheadcmo;
258
+ bool ext_xtheadcondmov;
259
+ bool ext_xtheadfmemidx;
260
+ bool ext_xtheadfmv;
261
+ bool ext_xtheadmac;
262
+ bool ext_xtheadmemidx;
263
+ bool ext_xtheadmempair;
264
+ bool ext_xtheadsync;
265
+ bool ext_XVentanaCondOps;
266
+
267
+ uint8_t pmu_num;
268
+ char *priv_spec;
269
+ char *user_spec;
270
+ char *bext_spec;
271
+ char *vext_spec;
272
+ uint16_t vlen;
273
+ uint16_t elen;
274
+ uint16_t cbom_blocksize;
275
+ uint16_t cboz_blocksize;
276
+ bool mmu;
277
+ bool pmp;
278
+ bool epmp;
279
+ bool debug;
280
+ bool misa_w;
281
+
282
+ bool short_isa_string;
283
+
284
+#ifndef CONFIG_USER_ONLY
285
+ RISCVSATPMap satp_mode;
286
+#endif
287
+};
288
+
289
+typedef struct RISCVCPUConfig RISCVCPUConfig;
290
+#endif
291
--
267
--
292
2.40.1
268
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
2
2
3
Even though Zca/Zcf/Zcd can be included by C/F/D, however, their priv
3
Move the checks out of `do_opiv{v,x,i}_gvec{,_shift}` functions
4
version is higher than the priv version of C/F/D. So if we use check
4
and into the corresponding macros. This enables the functions to be
5
for them instead of check for C/F/D totally, it will trigger new
5
reused in proceeding commits without check duplication.
6
problem when we try to disable the extensions based on the configured
7
priv version.
8
6
9
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
10
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
12
Message-Id: <20230517135714.211809-7-dbarboza@ventanamicro.com>
10
Signed-off-by: Max Chou <max.chou@sifive.com>
11
Message-ID: <20230711165917.2629866-6-max.chou@sifive.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
13
---
15
target/riscv/translate.c | 5 +++--
14
target/riscv/insn_trans/trans_rvv.c.inc | 28 +++++++++++--------------
16
target/riscv/insn_trans/trans_rvd.c.inc | 12 +++++++-----
15
1 file changed, 12 insertions(+), 16 deletions(-)
17
target/riscv/insn_trans/trans_rvf.c.inc | 14 ++++++++------
18
target/riscv/insn_trans/trans_rvi.c.inc | 5 +++--
19
4 files changed, 21 insertions(+), 15 deletions(-)
20
16
21
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
17
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
22
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
23
--- a/target/riscv/translate.c
19
--- a/target/riscv/insn_trans/trans_rvv.c.inc
24
+++ b/target/riscv/translate.c
20
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
25
@@ -XXX,XX +XXX,XX @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
21
@@ -XXX,XX +XXX,XX @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3Fn *gvec_fn,
26
22
gen_helper_gvec_4_ptr *fn)
27
/* check misaligned: */
28
next_pc = ctx->base.pc_next + imm;
29
- if (!ctx->cfg_ptr->ext_zca) {
30
+ if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca) {
31
if ((next_pc & 0x3) != 0) {
32
gen_exception_inst_addr_mis(ctx);
33
return;
34
@@ -XXX,XX +XXX,XX @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
35
* The Zca extension is added as way to refer to instructions in the C
36
* extension that do not include the floating-point loads and stores
37
*/
38
- if (ctx->cfg_ptr->ext_zca && decode_insn16(ctx, opcode)) {
39
+ if ((has_ext(ctx, RVC) || ctx->cfg_ptr->ext_zca) &&
40
+ decode_insn16(ctx, opcode)) {
41
return;
42
}
43
} else {
44
diff --git a/target/riscv/insn_trans/trans_rvd.c.inc b/target/riscv/insn_trans/trans_rvd.c.inc
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/riscv/insn_trans/trans_rvd.c.inc
47
+++ b/target/riscv/insn_trans/trans_rvd.c.inc
48
@@ -XXX,XX +XXX,XX @@
49
} \
50
} while (0)
51
52
-#define REQUIRE_ZCD(ctx) do { \
53
- if (!ctx->cfg_ptr->ext_zcd) { \
54
- return false; \
55
+#define REQUIRE_ZCD_OR_DC(ctx) do { \
56
+ if (!ctx->cfg_ptr->ext_zcd) { \
57
+ if (!has_ext(ctx, RVD) || !has_ext(ctx, RVC)) { \
58
+ return false; \
59
+ } \
60
} \
61
} while (0)
62
63
@@ -XXX,XX +XXX,XX @@ static bool trans_fsd(DisasContext *ctx, arg_fsd *a)
64
65
static bool trans_c_fld(DisasContext *ctx, arg_fld *a)
66
{
23
{
67
- REQUIRE_ZCD(ctx);
24
TCGLabel *over = gen_new_label();
68
+ REQUIRE_ZCD_OR_DC(ctx);
25
- if (!opivv_check(s, a)) {
69
return trans_fld(ctx, a);
26
- return false;
27
- }
28
29
tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
30
31
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
32
gen_helper_##NAME##_b, gen_helper_##NAME##_h, \
33
gen_helper_##NAME##_w, gen_helper_##NAME##_d, \
34
}; \
35
+ if (!opivv_check(s, a)) { \
36
+ return false; \
37
+ } \
38
return do_opivv_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \
70
}
39
}
71
40
72
static bool trans_c_fsd(DisasContext *ctx, arg_fsd *a)
41
@@ -XXX,XX +XXX,XX @@ static inline bool
42
do_opivx_gvec(DisasContext *s, arg_rmrr *a, GVecGen2sFn *gvec_fn,
43
gen_helper_opivx *fn)
73
{
44
{
74
- REQUIRE_ZCD(ctx);
45
- if (!opivx_check(s, a)) {
75
+ REQUIRE_ZCD_OR_DC(ctx);
46
- return false;
76
return trans_fsd(ctx, a);
47
- }
48
-
49
if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) {
50
TCGv_i64 src1 = tcg_temp_new_i64();
51
52
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
53
gen_helper_##NAME##_b, gen_helper_##NAME##_h, \
54
gen_helper_##NAME##_w, gen_helper_##NAME##_d, \
55
}; \
56
+ if (!opivx_check(s, a)) { \
57
+ return false; \
58
+ } \
59
return do_opivx_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \
77
}
60
}
78
61
79
diff --git a/target/riscv/insn_trans/trans_rvf.c.inc b/target/riscv/insn_trans/trans_rvf.c.inc
62
@@ -XXX,XX +XXX,XX @@ static inline bool
80
index XXXXXXX..XXXXXXX 100644
63
do_opivi_gvec(DisasContext *s, arg_rmrr *a, GVecGen2iFn *gvec_fn,
81
--- a/target/riscv/insn_trans/trans_rvf.c.inc
64
gen_helper_opivx *fn, imm_mode_t imm_mode)
82
+++ b/target/riscv/insn_trans/trans_rvf.c.inc
83
@@ -XXX,XX +XXX,XX @@
84
} \
85
} while (0)
86
87
-#define REQUIRE_ZCF(ctx) do { \
88
- if (!ctx->cfg_ptr->ext_zcf) { \
89
- return false; \
90
- } \
91
+#define REQUIRE_ZCF_OR_FC(ctx) do { \
92
+ if (!ctx->cfg_ptr->ext_zcf) { \
93
+ if (!has_ext(ctx, RVF) || !has_ext(ctx, RVC)) { \
94
+ return false; \
95
+ } \
96
+ } \
97
} while (0)
98
99
static bool trans_flw(DisasContext *ctx, arg_flw *a)
100
@@ -XXX,XX +XXX,XX @@ static bool trans_fsw(DisasContext *ctx, arg_fsw *a)
101
102
static bool trans_c_flw(DisasContext *ctx, arg_flw *a)
103
{
65
{
104
- REQUIRE_ZCF(ctx);
66
- if (!opivx_check(s, a)) {
105
+ REQUIRE_ZCF_OR_FC(ctx);
67
- return false;
106
return trans_flw(ctx, a);
68
- }
69
-
70
if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) {
71
gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2),
72
extract_imm(s, a->rs1, imm_mode), MAXSZ(s), MAXSZ(s));
73
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
74
gen_helper_##OPIVX##_b, gen_helper_##OPIVX##_h, \
75
gen_helper_##OPIVX##_w, gen_helper_##OPIVX##_d, \
76
}; \
77
+ if (!opivx_check(s, a)) { \
78
+ return false; \
79
+ } \
80
return do_opivi_gvec(s, a, tcg_gen_gvec_##SUF, \
81
fns[s->sew], IMM_MODE); \
107
}
82
}
108
83
@@ -XXX,XX +XXX,XX @@ static inline bool
109
static bool trans_c_fsw(DisasContext *ctx, arg_fsw *a)
84
do_opivx_gvec_shift(DisasContext *s, arg_rmrr *a, GVecGen2sFn32 *gvec_fn,
85
gen_helper_opivx *fn)
110
{
86
{
111
- REQUIRE_ZCF(ctx);
87
- if (!opivx_check(s, a)) {
112
+ REQUIRE_ZCF_OR_FC(ctx);
88
- return false;
113
return trans_fsw(ctx, a);
89
- }
90
-
91
if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) {
92
TCGv_i32 src1 = tcg_temp_new_i32();
93
94
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
95
gen_helper_##NAME##_b, gen_helper_##NAME##_h, \
96
gen_helper_##NAME##_w, gen_helper_##NAME##_d, \
97
}; \
98
- \
99
+ if (!opivx_check(s, a)) { \
100
+ return false; \
101
+ } \
102
return do_opivx_gvec_shift(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \
114
}
103
}
115
104
116
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
117
index XXXXXXX..XXXXXXX 100644
118
--- a/target/riscv/insn_trans/trans_rvi.c.inc
119
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
120
@@ -XXX,XX +XXX,XX @@ static bool trans_jalr(DisasContext *ctx, arg_jalr *a)
121
tcg_gen_andi_tl(cpu_pc, cpu_pc, (target_ulong)-2);
122
123
gen_set_pc(ctx, cpu_pc);
124
- if (!ctx->cfg_ptr->ext_zca) {
125
+ if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca) {
126
TCGv t0 = tcg_temp_new();
127
128
misaligned = gen_new_label();
129
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
130
131
gen_set_label(l); /* branch taken */
132
133
- if (!ctx->cfg_ptr->ext_zca && ((ctx->base.pc_next + a->imm) & 0x3)) {
134
+ if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca &&
135
+ ((ctx->base.pc_next + a->imm) & 0x3)) {
136
/* misaligned */
137
gen_exception_inst_addr_mis(ctx);
138
} else {
139
--
105
--
140
2.40.1
106
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Dickon Hood <dickon.hood@codethink.co.uk>
2
2
3
Reduce reliance on absolute values by using true pc difference for
3
Zvbb (implemented in later commit) has a widening instruction, which
4
gen_pc_plus_diff() to prepare for PC-relative translation.
4
requires an extra check on the enabled extensions. Refactor
5
GEN_OPIVX_WIDEN_TRANS() to take a check function to avoid reimplementing
6
it.
5
7
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
Signed-off-by: Dickon Hood <dickon.hood@codethink.co.uk>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
10
Message-Id: <20230526072124.298466-6-liweiwei@iscas.ac.cn>
11
Signed-off-by: Max Chou <max.chou@sifive.com>
12
Message-ID: <20230711165917.2629866-7-max.chou@sifive.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
14
---
13
target/riscv/translate.c | 13 ++++++-------
15
target/riscv/insn_trans/trans_rvv.c.inc | 52 +++++++++++--------------
14
target/riscv/insn_trans/trans_rvi.c.inc | 6 ++----
16
1 file changed, 23 insertions(+), 29 deletions(-)
15
target/riscv/insn_trans/trans_rvzce.c.inc | 2 +-
16
3 files changed, 9 insertions(+), 12 deletions(-)
17
17
18
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
18
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
19
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/riscv/translate.c
20
--- a/target/riscv/insn_trans/trans_rvv.c.inc
21
+++ b/target/riscv/translate.c
21
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
22
@@ -XXX,XX +XXX,XX @@ static void decode_save_opc(DisasContext *ctx)
22
@@ -XXX,XX +XXX,XX @@ static bool opivx_widen_check(DisasContext *s, arg_rmrr *a)
23
vext_check_ds(s, a->rd, a->rs2, a->vm);
23
}
24
}
24
25
25
static void gen_pc_plus_diff(TCGv target, DisasContext *ctx,
26
-static bool do_opivx_widen(DisasContext *s, arg_rmrr *a,
26
- target_ulong dest)
27
- gen_helper_opivx *fn)
27
+ target_long diff)
28
-{
28
{
29
- if (opivx_widen_check(s, a)) {
29
+ target_ulong dest = ctx->base.pc_next + diff;
30
- return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s);
30
+
31
- }
31
if (get_xl(ctx) == MXL_RV32) {
32
- return false;
32
dest = (int32_t)dest;
33
-}
33
}
34
-
34
@@ -XXX,XX +XXX,XX @@ static void gen_pc_plus_diff(TCGv target, DisasContext *ctx,
35
-#define GEN_OPIVX_WIDEN_TRANS(NAME) \
35
36
-static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
36
static void gen_update_pc(DisasContext *ctx, target_long diff)
37
-{ \
37
{
38
- static gen_helper_opivx * const fns[3] = { \
38
- gen_pc_plus_diff(cpu_pc, ctx, ctx->base.pc_next + diff);
39
- gen_helper_##NAME##_b, \
39
+ gen_pc_plus_diff(cpu_pc, ctx, diff);
40
- gen_helper_##NAME##_h, \
41
- gen_helper_##NAME##_w \
42
- }; \
43
- return do_opivx_widen(s, a, fns[s->sew]); \
44
+#define GEN_OPIVX_WIDEN_TRANS(NAME, CHECK) \
45
+static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
46
+{ \
47
+ if (CHECK(s, a)) { \
48
+ static gen_helper_opivx * const fns[3] = { \
49
+ gen_helper_##NAME##_b, \
50
+ gen_helper_##NAME##_h, \
51
+ gen_helper_##NAME##_w \
52
+ }; \
53
+ return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s); \
54
+ } \
55
+ return false; \
40
}
56
}
41
57
42
static void generate_exception(DisasContext *ctx, int excp)
58
-GEN_OPIVX_WIDEN_TRANS(vwaddu_vx)
43
@@ -XXX,XX +XXX,XX @@ static void gen_set_fpr_d(DisasContext *ctx, int reg_num, TCGv_i64 t)
59
-GEN_OPIVX_WIDEN_TRANS(vwadd_vx)
44
60
-GEN_OPIVX_WIDEN_TRANS(vwsubu_vx)
45
static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
61
-GEN_OPIVX_WIDEN_TRANS(vwsub_vx)
46
{
62
+GEN_OPIVX_WIDEN_TRANS(vwaddu_vx, opivx_widen_check)
47
- target_ulong next_pc;
63
+GEN_OPIVX_WIDEN_TRANS(vwadd_vx, opivx_widen_check)
48
-
64
+GEN_OPIVX_WIDEN_TRANS(vwsubu_vx, opivx_widen_check)
49
/* check misaligned: */
65
+GEN_OPIVX_WIDEN_TRANS(vwsub_vx, opivx_widen_check)
50
- next_pc = ctx->base.pc_next + imm;
66
51
if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca) {
67
/* WIDEN OPIVV with WIDEN */
52
- if ((next_pc & 0x3) != 0) {
68
static bool opiwv_widen_check(DisasContext *s, arg_rmrr *a)
53
+ if ((imm & 0x3) != 0) {
69
@@ -XXX,XX +XXX,XX @@ GEN_OPIVX_TRANS(vrem_vx, opivx_check)
54
TCGv target_pc = tcg_temp_new();
70
GEN_OPIVV_WIDEN_TRANS(vwmul_vv, opivv_widen_check)
55
- gen_pc_plus_diff(target_pc, ctx, next_pc);
71
GEN_OPIVV_WIDEN_TRANS(vwmulu_vv, opivv_widen_check)
56
+ gen_pc_plus_diff(target_pc, ctx, imm);
72
GEN_OPIVV_WIDEN_TRANS(vwmulsu_vv, opivv_widen_check)
57
gen_exception_inst_addr_mis(ctx, target_pc);
73
-GEN_OPIVX_WIDEN_TRANS(vwmul_vx)
58
return;
74
-GEN_OPIVX_WIDEN_TRANS(vwmulu_vx)
59
}
75
-GEN_OPIVX_WIDEN_TRANS(vwmulsu_vx)
60
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
76
+GEN_OPIVX_WIDEN_TRANS(vwmul_vx, opivx_widen_check)
61
index XXXXXXX..XXXXXXX 100644
77
+GEN_OPIVX_WIDEN_TRANS(vwmulu_vx, opivx_widen_check)
62
--- a/target/riscv/insn_trans/trans_rvi.c.inc
78
+GEN_OPIVX_WIDEN_TRANS(vwmulsu_vx, opivx_widen_check)
63
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
79
64
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
80
/* Vector Single-Width Integer Multiply-Add Instructions */
65
TCGLabel *l = gen_new_label();
81
GEN_OPIVV_TRANS(vmacc_vv, opivv_check)
66
TCGv src1 = get_gpr(ctx, a->rs1, EXT_SIGN);
82
@@ -XXX,XX +XXX,XX @@ GEN_OPIVX_TRANS(vnmsub_vx, opivx_check)
67
TCGv src2 = get_gpr(ctx, a->rs2, EXT_SIGN);
83
GEN_OPIVV_WIDEN_TRANS(vwmaccu_vv, opivv_widen_check)
68
- target_ulong next_pc;
84
GEN_OPIVV_WIDEN_TRANS(vwmacc_vv, opivv_widen_check)
69
85
GEN_OPIVV_WIDEN_TRANS(vwmaccsu_vv, opivv_widen_check)
70
if (get_xl(ctx) == MXL_RV128) {
86
-GEN_OPIVX_WIDEN_TRANS(vwmaccu_vx)
71
TCGv src1h = get_gprh(ctx, a->rs1);
87
-GEN_OPIVX_WIDEN_TRANS(vwmacc_vx)
72
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
88
-GEN_OPIVX_WIDEN_TRANS(vwmaccsu_vx)
73
89
-GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx)
74
gen_set_label(l); /* branch taken */
90
+GEN_OPIVX_WIDEN_TRANS(vwmaccu_vx, opivx_widen_check)
75
91
+GEN_OPIVX_WIDEN_TRANS(vwmacc_vx, opivx_widen_check)
76
- next_pc = ctx->base.pc_next + a->imm;
92
+GEN_OPIVX_WIDEN_TRANS(vwmaccsu_vx, opivx_widen_check)
77
if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca &&
93
+GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx, opivx_widen_check)
78
- (next_pc & 0x3)) {
94
79
+ (a->imm & 0x3)) {
95
/* Vector Integer Merge and Move Instructions */
80
/* misaligned */
96
static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a)
81
TCGv target_pc = tcg_temp_new();
82
- gen_pc_plus_diff(target_pc, ctx, next_pc);
83
+ gen_pc_plus_diff(target_pc, ctx, a->imm);
84
gen_exception_inst_addr_mis(ctx, target_pc);
85
} else {
86
gen_goto_tb(ctx, 0, a->imm);
87
diff --git a/target/riscv/insn_trans/trans_rvzce.c.inc b/target/riscv/insn_trans/trans_rvzce.c.inc
88
index XXXXXXX..XXXXXXX 100644
89
--- a/target/riscv/insn_trans/trans_rvzce.c.inc
90
+++ b/target/riscv/insn_trans/trans_rvzce.c.inc
91
@@ -XXX,XX +XXX,XX @@ static bool trans_cm_jalt(DisasContext *ctx, arg_cm_jalt *a)
92
* Update pc to current for the non-unwinding exception
93
* that might come from cpu_ld*_code() in the helper.
94
*/
95
- tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next);
96
+ gen_update_pc(ctx, 0);
97
gen_helper_cm_jalt(cpu_pc, cpu_env, tcg_constant_i32(a->index));
98
99
/* c.jt vs c.jalt depends on the index. */
100
--
97
--
101
2.40.1
98
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
2
2
3
The function is a no-op if 'vta' is zero but we're still doing a lot of
3
Move some macros out of `vector_helper` and into `vector_internals`.
4
stuff in this function regardless. vext_set_elems_1s() will ignore every
4
This ensures they can be used by both vector and vector-crypto helpers
5
single time (since vta is zero) and we just wasted time.
5
(latter implemented in proceeding commits).
6
6
7
Skip it altogether in this case. Aside from the code simplification
7
Signed-off-by: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
8
there's a noticeable emulation performance gain by doing it. For a
9
regular C binary that does a vectors operation like this:
10
11
=======
12
#define SZ 10000000
13
14
int main ()
15
{
16
int *a = malloc (SZ * sizeof (int));
17
int *b = malloc (SZ * sizeof (int));
18
int *c = malloc (SZ * sizeof (int));
19
20
for (int i = 0; i < SZ; i++)
21
c[i] = a[i] + b[i];
22
return c[SZ - 1];
23
}
24
=======
25
26
Emulating it with qemu-riscv64 and RVV takes ~0.3 sec:
27
28
$ time ~/work/qemu/build/qemu-riscv64 \
29
-cpu rv64,debug=false,vext_spec=v1.0,v=true,vlen=128 ./foo.out
30
31
real 0m0.303s
32
user 0m0.281s
33
sys 0m0.023s
34
35
With this skip we take ~0.275 sec:
36
37
$ time ~/work/qemu/build/qemu-riscv64 \
38
-cpu rv64,debug=false,vext_spec=v1.0,v=true,vlen=128 ./foo.out
39
40
real 0m0.274s
41
user 0m0.252s
42
sys 0m0.019s
43
44
This performance gain adds up fast when executing heavy benchmarks like
45
SPEC.
46
47
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
48
Acked-by: Alistair Francis <alistair.francis@wdc.com>
49
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
50
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
51
Message-Id: <20230427205708.246679-2-dbarboza@ventanamicro.com>
9
Signed-off-by: Max Chou <max.chou@sifive.com>
10
Message-ID: <20230711165917.2629866-8-max.chou@sifive.com>
52
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
53
---
12
---
54
target/riscv/vector_helper.c | 11 ++++++++---
13
target/riscv/vector_internals.h | 46 +++++++++++++++++++++++++++++++++
55
1 file changed, 8 insertions(+), 3 deletions(-)
14
target/riscv/vector_helper.c | 42 ------------------------------
15
2 files changed, 46 insertions(+), 42 deletions(-)
56
16
17
diff --git a/target/riscv/vector_internals.h b/target/riscv/vector_internals.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/vector_internals.h
20
+++ b/target/riscv/vector_internals.h
21
@@ -XXX,XX +XXX,XX @@ void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt,
22
/* expand macro args before macro */
23
#define RVVCALL(macro, ...) macro(__VA_ARGS__)
24
25
+/* (TD, T2, TX2) */
26
+#define OP_UU_B uint8_t, uint8_t, uint8_t
27
+#define OP_UU_H uint16_t, uint16_t, uint16_t
28
+#define OP_UU_W uint32_t, uint32_t, uint32_t
29
+#define OP_UU_D uint64_t, uint64_t, uint64_t
30
+
31
/* (TD, T1, T2, TX1, TX2) */
32
#define OP_UUU_B uint8_t, uint8_t, uint8_t, uint8_t, uint8_t
33
#define OP_UUU_H uint16_t, uint16_t, uint16_t, uint16_t, uint16_t
34
#define OP_UUU_W uint32_t, uint32_t, uint32_t, uint32_t, uint32_t
35
#define OP_UUU_D uint64_t, uint64_t, uint64_t, uint64_t, uint64_t
36
37
+#define OPIVV1(NAME, TD, T2, TX2, HD, HS2, OP) \
38
+static void do_##NAME(void *vd, void *vs2, int i) \
39
+{ \
40
+ TX2 s2 = *((T2 *)vs2 + HS2(i)); \
41
+ *((TD *)vd + HD(i)) = OP(s2); \
42
+}
43
+
44
+#define GEN_VEXT_V(NAME, ESZ) \
45
+void HELPER(NAME)(void *vd, void *v0, void *vs2, \
46
+ CPURISCVState *env, uint32_t desc) \
47
+{ \
48
+ uint32_t vm = vext_vm(desc); \
49
+ uint32_t vl = env->vl; \
50
+ uint32_t total_elems = \
51
+ vext_get_total_elems(env, desc, ESZ); \
52
+ uint32_t vta = vext_vta(desc); \
53
+ uint32_t vma = vext_vma(desc); \
54
+ uint32_t i; \
55
+ \
56
+ for (i = env->vstart; i < vl; i++) { \
57
+ if (!vm && !vext_elem_mask(v0, i)) { \
58
+ /* set masked-off elements to 1s */ \
59
+ vext_set_elems_1s(vd, vma, i * ESZ, \
60
+ (i + 1) * ESZ); \
61
+ continue; \
62
+ } \
63
+ do_##NAME(vd, vs2, i); \
64
+ } \
65
+ env->vstart = 0; \
66
+ /* set tail elements to 1s */ \
67
+ vext_set_elems_1s(vd, vta, vl * ESZ, \
68
+ total_elems * ESZ); \
69
+}
70
+
71
/* operation of two vector elements */
72
typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i);
73
74
@@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \
75
do_##NAME, ESZ); \
76
}
77
78
+/* Three of the widening shortening macros: */
79
+/* (TD, T1, T2, TX1, TX2) */
80
+#define WOP_UUU_B uint16_t, uint8_t, uint8_t, uint16_t, uint16_t
81
+#define WOP_UUU_H uint32_t, uint16_t, uint16_t, uint32_t, uint32_t
82
+#define WOP_UUU_W uint64_t, uint32_t, uint32_t, uint64_t, uint64_t
83
+
84
#endif /* TARGET_RISCV_VECTOR_INTERNALS_H */
57
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
85
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
58
index XXXXXXX..XXXXXXX 100644
86
index XXXXXXX..XXXXXXX 100644
59
--- a/target/riscv/vector_helper.c
87
--- a/target/riscv/vector_helper.c
60
+++ b/target/riscv/vector_helper.c
88
+++ b/target/riscv/vector_helper.c
61
@@ -XXX,XX +XXX,XX @@ static void vext_set_tail_elems_1s(CPURISCVState *env, target_ulong vl,
89
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_ST_WHOLE(vs8r_v, int8_t, ste_b)
62
void *vd, uint32_t desc, uint32_t nf,
90
#define OP_SUS_H int16_t, uint16_t, int16_t, uint16_t, int16_t
63
uint32_t esz, uint32_t max_elems)
91
#define OP_SUS_W int32_t, uint32_t, int32_t, uint32_t, int32_t
92
#define OP_SUS_D int64_t, uint64_t, int64_t, uint64_t, int64_t
93
-#define WOP_UUU_B uint16_t, uint8_t, uint8_t, uint16_t, uint16_t
94
-#define WOP_UUU_H uint32_t, uint16_t, uint16_t, uint32_t, uint32_t
95
-#define WOP_UUU_W uint64_t, uint32_t, uint32_t, uint64_t, uint64_t
96
#define WOP_SSS_B int16_t, int8_t, int8_t, int16_t, int16_t
97
#define WOP_SSS_H int32_t, int16_t, int16_t, int32_t, int32_t
98
#define WOP_SSS_W int64_t, int32_t, int32_t, int64_t, int64_t
99
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_VF(vfwnmsac_vf_h, 4)
100
GEN_VEXT_VF(vfwnmsac_vf_w, 8)
101
102
/* Vector Floating-Point Square-Root Instruction */
103
-/* (TD, T2, TX2) */
104
-#define OP_UU_H uint16_t, uint16_t, uint16_t
105
-#define OP_UU_W uint32_t, uint32_t, uint32_t
106
-#define OP_UU_D uint64_t, uint64_t, uint64_t
107
-
108
#define OPFVV1(NAME, TD, T2, TX2, HD, HS2, OP) \
109
static void do_##NAME(void *vd, void *vs2, int i, \
110
CPURISCVState *env) \
111
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_CMP_VF(vmfge_vf_w, uint32_t, H4, vmfge32)
112
GEN_VEXT_CMP_VF(vmfge_vf_d, uint64_t, H8, vmfge64)
113
114
/* Vector Floating-Point Classify Instruction */
115
-#define OPIVV1(NAME, TD, T2, TX2, HD, HS2, OP) \
116
-static void do_##NAME(void *vd, void *vs2, int i) \
117
-{ \
118
- TX2 s2 = *((T2 *)vs2 + HS2(i)); \
119
- *((TD *)vd + HD(i)) = OP(s2); \
120
-}
121
-
122
-#define GEN_VEXT_V(NAME, ESZ) \
123
-void HELPER(NAME)(void *vd, void *v0, void *vs2, \
124
- CPURISCVState *env, uint32_t desc) \
125
-{ \
126
- uint32_t vm = vext_vm(desc); \
127
- uint32_t vl = env->vl; \
128
- uint32_t total_elems = \
129
- vext_get_total_elems(env, desc, ESZ); \
130
- uint32_t vta = vext_vta(desc); \
131
- uint32_t vma = vext_vma(desc); \
132
- uint32_t i; \
133
- \
134
- for (i = env->vstart; i < vl; i++) { \
135
- if (!vm && !vext_elem_mask(v0, i)) { \
136
- /* set masked-off elements to 1s */ \
137
- vext_set_elems_1s(vd, vma, i * ESZ, \
138
- (i + 1) * ESZ); \
139
- continue; \
140
- } \
141
- do_##NAME(vd, vs2, i); \
142
- } \
143
- env->vstart = 0; \
144
- /* set tail elements to 1s */ \
145
- vext_set_elems_1s(vd, vta, vl * ESZ, \
146
- total_elems * ESZ); \
147
-}
148
-
149
target_ulong fclass_h(uint64_t frs1)
64
{
150
{
65
- uint32_t total_elems = vext_get_total_elems(env, desc, esz);
151
float16 f = frs1;
66
- uint32_t vlenb = riscv_cpu_cfg(env)->vlen >> 3;
67
+ uint32_t total_elems, vlenb, registers_used;
68
uint32_t vta = vext_vta(desc);
69
- uint32_t registers_used;
70
int k;
71
72
+ if (vta == 0) {
73
+ return;
74
+ }
75
+
76
+ total_elems = vext_get_total_elems(env, desc, esz);
77
+ vlenb = riscv_cpu_cfg(env)->vlen >> 3;
78
+
79
for (k = 0; k < nf; ++k) {
80
vext_set_elems_1s(vd, vta, (k * max_elems + vl) * esz,
81
(k * max_elems + max_elems) * esz);
82
--
152
--
83
2.40.1
153
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Dickon Hood <dickon.hood@codethink.co.uk>
2
2
3
There is no need to init timers if we're not even sure that our
3
This commit adds support for the Zvbb vector-crypto extension, which
4
extensions are valid. Execute riscv_cpu_validate_set_extensions() before
4
consists of the following instructions:
5
riscv_timer_init().
6
5
7
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
6
* vrol.[vv,vx]
8
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
7
* vror.[vv,vx,vi]
9
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
* vbrev8.v
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
* vrev8.v
11
Message-Id: <20230517135714.211809-10-dbarboza@ventanamicro.com>
10
* vandn.[vv,vx]
11
* vbrev.v
12
* vclz.v
13
* vctz.v
14
* vcpop.v
15
* vwsll.[vv,vx,vi]
16
17
Translation functions are defined in
18
`target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in
19
`target/riscv/vcrypto_helper.c`.
20
21
Co-authored-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
22
Co-authored-by: William Salmon <will.salmon@codethink.co.uk>
23
Co-authored-by: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
24
[max.chou@sifive.com: Fix imm mode of vror.vi]
25
Signed-off-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
26
Signed-off-by: William Salmon <will.salmon@codethink.co.uk>
27
Signed-off-by: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
28
Signed-off-by: Dickon Hood <dickon.hood@codethink.co.uk>
29
Signed-off-by: Max Chou <max.chou@sifive.com>
30
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
31
[max.chou@sifive.com: Exposed x-zvbb property]
32
Message-ID: <20230711165917.2629866-9-max.chou@sifive.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
33
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
34
---
14
target/riscv/cpu.c | 11 ++++-------
35
target/riscv/cpu_cfg.h | 1 +
15
1 file changed, 4 insertions(+), 7 deletions(-)
36
target/riscv/helper.h | 62 +++++++++
37
target/riscv/insn32.decode | 20 +++
38
target/riscv/cpu.c | 12 ++
39
target/riscv/vcrypto_helper.c | 138 +++++++++++++++++++
40
target/riscv/insn_trans/trans_rvvk.c.inc | 164 +++++++++++++++++++++++
41
6 files changed, 397 insertions(+)
16
42
43
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/riscv/cpu_cfg.h
46
+++ b/target/riscv/cpu_cfg.h
47
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
48
bool ext_zve32f;
49
bool ext_zve64f;
50
bool ext_zve64d;
51
+ bool ext_zvbb;
52
bool ext_zvbc;
53
bool ext_zmmul;
54
bool ext_zvfbfmin;
55
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
56
index XXXXXXX..XXXXXXX 100644
57
--- a/target/riscv/helper.h
58
+++ b/target/riscv/helper.h
59
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vclmul_vv, void, ptr, ptr, ptr, ptr, env, i32)
60
DEF_HELPER_6(vclmul_vx, void, ptr, ptr, tl, ptr, env, i32)
61
DEF_HELPER_6(vclmulh_vv, void, ptr, ptr, ptr, ptr, env, i32)
62
DEF_HELPER_6(vclmulh_vx, void, ptr, ptr, tl, ptr, env, i32)
63
+
64
+DEF_HELPER_6(vror_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
65
+DEF_HELPER_6(vror_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
66
+DEF_HELPER_6(vror_vv_w, void, ptr, ptr, ptr, ptr, env, i32)
67
+DEF_HELPER_6(vror_vv_d, void, ptr, ptr, ptr, ptr, env, i32)
68
+
69
+DEF_HELPER_6(vror_vx_b, void, ptr, ptr, tl, ptr, env, i32)
70
+DEF_HELPER_6(vror_vx_h, void, ptr, ptr, tl, ptr, env, i32)
71
+DEF_HELPER_6(vror_vx_w, void, ptr, ptr, tl, ptr, env, i32)
72
+DEF_HELPER_6(vror_vx_d, void, ptr, ptr, tl, ptr, env, i32)
73
+
74
+DEF_HELPER_6(vrol_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
75
+DEF_HELPER_6(vrol_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
76
+DEF_HELPER_6(vrol_vv_w, void, ptr, ptr, ptr, ptr, env, i32)
77
+DEF_HELPER_6(vrol_vv_d, void, ptr, ptr, ptr, ptr, env, i32)
78
+
79
+DEF_HELPER_6(vrol_vx_b, void, ptr, ptr, tl, ptr, env, i32)
80
+DEF_HELPER_6(vrol_vx_h, void, ptr, ptr, tl, ptr, env, i32)
81
+DEF_HELPER_6(vrol_vx_w, void, ptr, ptr, tl, ptr, env, i32)
82
+DEF_HELPER_6(vrol_vx_d, void, ptr, ptr, tl, ptr, env, i32)
83
+
84
+DEF_HELPER_5(vrev8_v_b, void, ptr, ptr, ptr, env, i32)
85
+DEF_HELPER_5(vrev8_v_h, void, ptr, ptr, ptr, env, i32)
86
+DEF_HELPER_5(vrev8_v_w, void, ptr, ptr, ptr, env, i32)
87
+DEF_HELPER_5(vrev8_v_d, void, ptr, ptr, ptr, env, i32)
88
+DEF_HELPER_5(vbrev8_v_b, void, ptr, ptr, ptr, env, i32)
89
+DEF_HELPER_5(vbrev8_v_h, void, ptr, ptr, ptr, env, i32)
90
+DEF_HELPER_5(vbrev8_v_w, void, ptr, ptr, ptr, env, i32)
91
+DEF_HELPER_5(vbrev8_v_d, void, ptr, ptr, ptr, env, i32)
92
+DEF_HELPER_5(vbrev_v_b, void, ptr, ptr, ptr, env, i32)
93
+DEF_HELPER_5(vbrev_v_h, void, ptr, ptr, ptr, env, i32)
94
+DEF_HELPER_5(vbrev_v_w, void, ptr, ptr, ptr, env, i32)
95
+DEF_HELPER_5(vbrev_v_d, void, ptr, ptr, ptr, env, i32)
96
+
97
+DEF_HELPER_5(vclz_v_b, void, ptr, ptr, ptr, env, i32)
98
+DEF_HELPER_5(vclz_v_h, void, ptr, ptr, ptr, env, i32)
99
+DEF_HELPER_5(vclz_v_w, void, ptr, ptr, ptr, env, i32)
100
+DEF_HELPER_5(vclz_v_d, void, ptr, ptr, ptr, env, i32)
101
+DEF_HELPER_5(vctz_v_b, void, ptr, ptr, ptr, env, i32)
102
+DEF_HELPER_5(vctz_v_h, void, ptr, ptr, ptr, env, i32)
103
+DEF_HELPER_5(vctz_v_w, void, ptr, ptr, ptr, env, i32)
104
+DEF_HELPER_5(vctz_v_d, void, ptr, ptr, ptr, env, i32)
105
+DEF_HELPER_5(vcpop_v_b, void, ptr, ptr, ptr, env, i32)
106
+DEF_HELPER_5(vcpop_v_h, void, ptr, ptr, ptr, env, i32)
107
+DEF_HELPER_5(vcpop_v_w, void, ptr, ptr, ptr, env, i32)
108
+DEF_HELPER_5(vcpop_v_d, void, ptr, ptr, ptr, env, i32)
109
+
110
+DEF_HELPER_6(vwsll_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
111
+DEF_HELPER_6(vwsll_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
112
+DEF_HELPER_6(vwsll_vv_w, void, ptr, ptr, ptr, ptr, env, i32)
113
+DEF_HELPER_6(vwsll_vx_b, void, ptr, ptr, tl, ptr, env, i32)
114
+DEF_HELPER_6(vwsll_vx_h, void, ptr, ptr, tl, ptr, env, i32)
115
+DEF_HELPER_6(vwsll_vx_w, void, ptr, ptr, tl, ptr, env, i32)
116
+
117
+DEF_HELPER_6(vandn_vv_b, void, ptr, ptr, ptr, ptr, env, i32)
118
+DEF_HELPER_6(vandn_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
119
+DEF_HELPER_6(vandn_vv_w, void, ptr, ptr, ptr, ptr, env, i32)
120
+DEF_HELPER_6(vandn_vv_d, void, ptr, ptr, ptr, ptr, env, i32)
121
+DEF_HELPER_6(vandn_vx_b, void, ptr, ptr, tl, ptr, env, i32)
122
+DEF_HELPER_6(vandn_vx_h, void, ptr, ptr, tl, ptr, env, i32)
123
+DEF_HELPER_6(vandn_vx_w, void, ptr, ptr, tl, ptr, env, i32)
124
+DEF_HELPER_6(vandn_vx_d, void, ptr, ptr, tl, ptr, env, i32)
125
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
126
index XXXXXXX..XXXXXXX 100644
127
--- a/target/riscv/insn32.decode
128
+++ b/target/riscv/insn32.decode
129
@@ -XXX,XX +XXX,XX @@
130
%imm_u 12:s20 !function=ex_shift_12
131
%imm_bs 30:2 !function=ex_shift_3
132
%imm_rnum 20:4
133
+%imm_z6 26:1 15:5
134
135
# Argument sets:
136
&empty
137
@@ -XXX,XX +XXX,XX @@
138
@r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd
139
@r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd
140
@r_vm_0 ...... . ..... ..... ... ..... ....... &rmrr vm=0 %rs2 %rs1 %rd
141
+@r2_zimm6 ..... . vm:1 ..... ..... ... ..... ....... &rmrr %rs2 rs1=%imm_z6 %rd
142
@r2_zimm11 . zimm:11 ..... ... ..... ....... %rs1 %rd
143
@r2_zimm10 .. zimm:10 ..... ... ..... ....... %rs1 %rd
144
@r2_s ....... ..... ..... ... ..... ....... %rs2 %rs1
145
@@ -XXX,XX +XXX,XX @@ vclmul_vv 001100 . ..... ..... 010 ..... 1010111 @r_vm
146
vclmul_vx 001100 . ..... ..... 110 ..... 1010111 @r_vm
147
vclmulh_vv 001101 . ..... ..... 010 ..... 1010111 @r_vm
148
vclmulh_vx 001101 . ..... ..... 110 ..... 1010111 @r_vm
149
+
150
+# *** Zvbb vector crypto extension ***
151
+vrol_vv 010101 . ..... ..... 000 ..... 1010111 @r_vm
152
+vrol_vx 010101 . ..... ..... 100 ..... 1010111 @r_vm
153
+vror_vv 010100 . ..... ..... 000 ..... 1010111 @r_vm
154
+vror_vx 010100 . ..... ..... 100 ..... 1010111 @r_vm
155
+vror_vi 01010. . ..... ..... 011 ..... 1010111 @r2_zimm6
156
+vbrev8_v 010010 . ..... 01000 010 ..... 1010111 @r2_vm
157
+vrev8_v 010010 . ..... 01001 010 ..... 1010111 @r2_vm
158
+vandn_vv 000001 . ..... ..... 000 ..... 1010111 @r_vm
159
+vandn_vx 000001 . ..... ..... 100 ..... 1010111 @r_vm
160
+vbrev_v 010010 . ..... 01010 010 ..... 1010111 @r2_vm
161
+vclz_v 010010 . ..... 01100 010 ..... 1010111 @r2_vm
162
+vctz_v 010010 . ..... 01101 010 ..... 1010111 @r2_vm
163
+vcpop_v 010010 . ..... 01110 010 ..... 1010111 @r2_vm
164
+vwsll_vv 110101 . ..... ..... 000 ..... 1010111 @r_vm
165
+vwsll_vx 110101 . ..... ..... 100 ..... 1010111 @r_vm
166
+vwsll_vi 110101 . ..... ..... 011 ..... 1010111 @r_vm
17
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
167
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
18
index XXXXXXX..XXXXXXX 100644
168
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/cpu.c
169
--- a/target/riscv/cpu.c
20
+++ b/target/riscv/cpu.c
170
+++ b/target/riscv/cpu.c
21
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
171
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
172
ISA_EXT_DATA_ENTRY(zksed, PRIV_VERSION_1_12_0, ext_zksed),
173
ISA_EXT_DATA_ENTRY(zksh, PRIV_VERSION_1_12_0, ext_zksh),
174
ISA_EXT_DATA_ENTRY(zkt, PRIV_VERSION_1_12_0, ext_zkt),
175
+ ISA_EXT_DATA_ENTRY(zvbb, PRIV_VERSION_1_12_0, ext_zvbb),
176
ISA_EXT_DATA_ENTRY(zvbc, PRIV_VERSION_1_12_0, ext_zvbc),
177
ISA_EXT_DATA_ENTRY(zve32f, PRIV_VERSION_1_10_0, ext_zve32f),
178
ISA_EXT_DATA_ENTRY(zve64f, PRIV_VERSION_1_10_0, ext_zve64f),
179
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
22
return;
180
return;
23
}
181
}
24
182
25
-
183
+ /*
26
-#ifndef CONFIG_USER_ONLY
184
+ * In principle Zve*x would also suffice here, were they supported
27
- if (cpu->cfg.ext_sstc) {
185
+ * in qemu
28
- riscv_timer_init(cpu);
186
+ */
29
- }
187
+ if (cpu->cfg.ext_zvbb && !cpu->cfg.ext_zve32f) {
30
-#endif /* CONFIG_USER_ONLY */
188
+ error_setg(errp,
31
-
189
+ "Vector crypto extensions require V or Zve* extensions");
32
riscv_cpu_validate_set_extensions(cpu, &local_err);
190
+ return;
33
if (local_err != NULL) {
191
+ }
34
error_propagate(errp, local_err);
192
+
35
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
193
if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) {
36
}
194
error_setg(errp, "Zvbc extension requires V or Zve64{f,d} extensions");
37
195
return;
38
#ifndef CONFIG_USER_ONLY
196
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
39
+ if (cpu->cfg.ext_sstc) {
197
DEFINE_PROP_BOOL("x-zvfbfwma", RISCVCPU, cfg.ext_zvfbfwma, false),
40
+ riscv_timer_init(cpu);
198
41
+ }
199
/* Vector cryptography extensions */
42
+
200
+ DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false),
43
if (cpu->cfg.pmu_num) {
201
DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false),
44
if (!riscv_pmu_init(cpu, cpu->cfg.pmu_num) && cpu->cfg.ext_sscofpmf) {
202
45
cpu->pmu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
203
DEFINE_PROP_END_OF_LIST(),
204
diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c
205
index XXXXXXX..XXXXXXX 100644
206
--- a/target/riscv/vcrypto_helper.c
207
+++ b/target/riscv/vcrypto_helper.c
208
@@ -XXX,XX +XXX,XX @@
209
#include "qemu/osdep.h"
210
#include "qemu/host-utils.h"
211
#include "qemu/bitops.h"
212
+#include "qemu/bswap.h"
213
#include "cpu.h"
214
#include "exec/memop.h"
215
#include "exec/exec-all.h"
216
@@ -XXX,XX +XXX,XX @@ RVVCALL(OPIVV2, vclmulh_vv, OP_UUU_D, H8, H8, H8, clmulh64)
217
GEN_VEXT_VV(vclmulh_vv, 8)
218
RVVCALL(OPIVX2, vclmulh_vx, OP_UUU_D, H8, H8, clmulh64)
219
GEN_VEXT_VX(vclmulh_vx, 8)
220
+
221
+RVVCALL(OPIVV2, vror_vv_b, OP_UUU_B, H1, H1, H1, ror8)
222
+RVVCALL(OPIVV2, vror_vv_h, OP_UUU_H, H2, H2, H2, ror16)
223
+RVVCALL(OPIVV2, vror_vv_w, OP_UUU_W, H4, H4, H4, ror32)
224
+RVVCALL(OPIVV2, vror_vv_d, OP_UUU_D, H8, H8, H8, ror64)
225
+GEN_VEXT_VV(vror_vv_b, 1)
226
+GEN_VEXT_VV(vror_vv_h, 2)
227
+GEN_VEXT_VV(vror_vv_w, 4)
228
+GEN_VEXT_VV(vror_vv_d, 8)
229
+
230
+RVVCALL(OPIVX2, vror_vx_b, OP_UUU_B, H1, H1, ror8)
231
+RVVCALL(OPIVX2, vror_vx_h, OP_UUU_H, H2, H2, ror16)
232
+RVVCALL(OPIVX2, vror_vx_w, OP_UUU_W, H4, H4, ror32)
233
+RVVCALL(OPIVX2, vror_vx_d, OP_UUU_D, H8, H8, ror64)
234
+GEN_VEXT_VX(vror_vx_b, 1)
235
+GEN_VEXT_VX(vror_vx_h, 2)
236
+GEN_VEXT_VX(vror_vx_w, 4)
237
+GEN_VEXT_VX(vror_vx_d, 8)
238
+
239
+RVVCALL(OPIVV2, vrol_vv_b, OP_UUU_B, H1, H1, H1, rol8)
240
+RVVCALL(OPIVV2, vrol_vv_h, OP_UUU_H, H2, H2, H2, rol16)
241
+RVVCALL(OPIVV2, vrol_vv_w, OP_UUU_W, H4, H4, H4, rol32)
242
+RVVCALL(OPIVV2, vrol_vv_d, OP_UUU_D, H8, H8, H8, rol64)
243
+GEN_VEXT_VV(vrol_vv_b, 1)
244
+GEN_VEXT_VV(vrol_vv_h, 2)
245
+GEN_VEXT_VV(vrol_vv_w, 4)
246
+GEN_VEXT_VV(vrol_vv_d, 8)
247
+
248
+RVVCALL(OPIVX2, vrol_vx_b, OP_UUU_B, H1, H1, rol8)
249
+RVVCALL(OPIVX2, vrol_vx_h, OP_UUU_H, H2, H2, rol16)
250
+RVVCALL(OPIVX2, vrol_vx_w, OP_UUU_W, H4, H4, rol32)
251
+RVVCALL(OPIVX2, vrol_vx_d, OP_UUU_D, H8, H8, rol64)
252
+GEN_VEXT_VX(vrol_vx_b, 1)
253
+GEN_VEXT_VX(vrol_vx_h, 2)
254
+GEN_VEXT_VX(vrol_vx_w, 4)
255
+GEN_VEXT_VX(vrol_vx_d, 8)
256
+
257
+static uint64_t brev8(uint64_t val)
258
+{
259
+ val = ((val & 0x5555555555555555ull) << 1) |
260
+ ((val & 0xAAAAAAAAAAAAAAAAull) >> 1);
261
+ val = ((val & 0x3333333333333333ull) << 2) |
262
+ ((val & 0xCCCCCCCCCCCCCCCCull) >> 2);
263
+ val = ((val & 0x0F0F0F0F0F0F0F0Full) << 4) |
264
+ ((val & 0xF0F0F0F0F0F0F0F0ull) >> 4);
265
+
266
+ return val;
267
+}
268
+
269
+RVVCALL(OPIVV1, vbrev8_v_b, OP_UU_B, H1, H1, brev8)
270
+RVVCALL(OPIVV1, vbrev8_v_h, OP_UU_H, H2, H2, brev8)
271
+RVVCALL(OPIVV1, vbrev8_v_w, OP_UU_W, H4, H4, brev8)
272
+RVVCALL(OPIVV1, vbrev8_v_d, OP_UU_D, H8, H8, brev8)
273
+GEN_VEXT_V(vbrev8_v_b, 1)
274
+GEN_VEXT_V(vbrev8_v_h, 2)
275
+GEN_VEXT_V(vbrev8_v_w, 4)
276
+GEN_VEXT_V(vbrev8_v_d, 8)
277
+
278
+#define DO_IDENTITY(a) (a)
279
+RVVCALL(OPIVV1, vrev8_v_b, OP_UU_B, H1, H1, DO_IDENTITY)
280
+RVVCALL(OPIVV1, vrev8_v_h, OP_UU_H, H2, H2, bswap16)
281
+RVVCALL(OPIVV1, vrev8_v_w, OP_UU_W, H4, H4, bswap32)
282
+RVVCALL(OPIVV1, vrev8_v_d, OP_UU_D, H8, H8, bswap64)
283
+GEN_VEXT_V(vrev8_v_b, 1)
284
+GEN_VEXT_V(vrev8_v_h, 2)
285
+GEN_VEXT_V(vrev8_v_w, 4)
286
+GEN_VEXT_V(vrev8_v_d, 8)
287
+
288
+#define DO_ANDN(a, b) ((a) & ~(b))
289
+RVVCALL(OPIVV2, vandn_vv_b, OP_UUU_B, H1, H1, H1, DO_ANDN)
290
+RVVCALL(OPIVV2, vandn_vv_h, OP_UUU_H, H2, H2, H2, DO_ANDN)
291
+RVVCALL(OPIVV2, vandn_vv_w, OP_UUU_W, H4, H4, H4, DO_ANDN)
292
+RVVCALL(OPIVV2, vandn_vv_d, OP_UUU_D, H8, H8, H8, DO_ANDN)
293
+GEN_VEXT_VV(vandn_vv_b, 1)
294
+GEN_VEXT_VV(vandn_vv_h, 2)
295
+GEN_VEXT_VV(vandn_vv_w, 4)
296
+GEN_VEXT_VV(vandn_vv_d, 8)
297
+
298
+RVVCALL(OPIVX2, vandn_vx_b, OP_UUU_B, H1, H1, DO_ANDN)
299
+RVVCALL(OPIVX2, vandn_vx_h, OP_UUU_H, H2, H2, DO_ANDN)
300
+RVVCALL(OPIVX2, vandn_vx_w, OP_UUU_W, H4, H4, DO_ANDN)
301
+RVVCALL(OPIVX2, vandn_vx_d, OP_UUU_D, H8, H8, DO_ANDN)
302
+GEN_VEXT_VX(vandn_vx_b, 1)
303
+GEN_VEXT_VX(vandn_vx_h, 2)
304
+GEN_VEXT_VX(vandn_vx_w, 4)
305
+GEN_VEXT_VX(vandn_vx_d, 8)
306
+
307
+RVVCALL(OPIVV1, vbrev_v_b, OP_UU_B, H1, H1, revbit8)
308
+RVVCALL(OPIVV1, vbrev_v_h, OP_UU_H, H2, H2, revbit16)
309
+RVVCALL(OPIVV1, vbrev_v_w, OP_UU_W, H4, H4, revbit32)
310
+RVVCALL(OPIVV1, vbrev_v_d, OP_UU_D, H8, H8, revbit64)
311
+GEN_VEXT_V(vbrev_v_b, 1)
312
+GEN_VEXT_V(vbrev_v_h, 2)
313
+GEN_VEXT_V(vbrev_v_w, 4)
314
+GEN_VEXT_V(vbrev_v_d, 8)
315
+
316
+RVVCALL(OPIVV1, vclz_v_b, OP_UU_B, H1, H1, clz8)
317
+RVVCALL(OPIVV1, vclz_v_h, OP_UU_H, H2, H2, clz16)
318
+RVVCALL(OPIVV1, vclz_v_w, OP_UU_W, H4, H4, clz32)
319
+RVVCALL(OPIVV1, vclz_v_d, OP_UU_D, H8, H8, clz64)
320
+GEN_VEXT_V(vclz_v_b, 1)
321
+GEN_VEXT_V(vclz_v_h, 2)
322
+GEN_VEXT_V(vclz_v_w, 4)
323
+GEN_VEXT_V(vclz_v_d, 8)
324
+
325
+RVVCALL(OPIVV1, vctz_v_b, OP_UU_B, H1, H1, ctz8)
326
+RVVCALL(OPIVV1, vctz_v_h, OP_UU_H, H2, H2, ctz16)
327
+RVVCALL(OPIVV1, vctz_v_w, OP_UU_W, H4, H4, ctz32)
328
+RVVCALL(OPIVV1, vctz_v_d, OP_UU_D, H8, H8, ctz64)
329
+GEN_VEXT_V(vctz_v_b, 1)
330
+GEN_VEXT_V(vctz_v_h, 2)
331
+GEN_VEXT_V(vctz_v_w, 4)
332
+GEN_VEXT_V(vctz_v_d, 8)
333
+
334
+RVVCALL(OPIVV1, vcpop_v_b, OP_UU_B, H1, H1, ctpop8)
335
+RVVCALL(OPIVV1, vcpop_v_h, OP_UU_H, H2, H2, ctpop16)
336
+RVVCALL(OPIVV1, vcpop_v_w, OP_UU_W, H4, H4, ctpop32)
337
+RVVCALL(OPIVV1, vcpop_v_d, OP_UU_D, H8, H8, ctpop64)
338
+GEN_VEXT_V(vcpop_v_b, 1)
339
+GEN_VEXT_V(vcpop_v_h, 2)
340
+GEN_VEXT_V(vcpop_v_w, 4)
341
+GEN_VEXT_V(vcpop_v_d, 8)
342
+
343
+#define DO_SLL(N, M) (N << (M & (sizeof(N) * 8 - 1)))
344
+RVVCALL(OPIVV2, vwsll_vv_b, WOP_UUU_B, H2, H1, H1, DO_SLL)
345
+RVVCALL(OPIVV2, vwsll_vv_h, WOP_UUU_H, H4, H2, H2, DO_SLL)
346
+RVVCALL(OPIVV2, vwsll_vv_w, WOP_UUU_W, H8, H4, H4, DO_SLL)
347
+GEN_VEXT_VV(vwsll_vv_b, 2)
348
+GEN_VEXT_VV(vwsll_vv_h, 4)
349
+GEN_VEXT_VV(vwsll_vv_w, 8)
350
+
351
+RVVCALL(OPIVX2, vwsll_vx_b, WOP_UUU_B, H2, H1, DO_SLL)
352
+RVVCALL(OPIVX2, vwsll_vx_h, WOP_UUU_H, H4, H2, DO_SLL)
353
+RVVCALL(OPIVX2, vwsll_vx_w, WOP_UUU_W, H8, H4, DO_SLL)
354
+GEN_VEXT_VX(vwsll_vx_b, 2)
355
+GEN_VEXT_VX(vwsll_vx_h, 4)
356
+GEN_VEXT_VX(vwsll_vx_w, 8)
357
diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_trans/trans_rvvk.c.inc
358
index XXXXXXX..XXXXXXX 100644
359
--- a/target/riscv/insn_trans/trans_rvvk.c.inc
360
+++ b/target/riscv/insn_trans/trans_rvvk.c.inc
361
@@ -XXX,XX +XXX,XX @@ static bool vclmul_vx_check(DisasContext *s, arg_rmrr *a)
362
363
GEN_VX_MASKED_TRANS(vclmul_vx, vclmul_vx_check)
364
GEN_VX_MASKED_TRANS(vclmulh_vx, vclmul_vx_check)
365
+
366
+/*
367
+ * Zvbb
368
+ */
369
+
370
+#define GEN_OPIVI_GVEC_TRANS_CHECK(NAME, IMM_MODE, OPIVX, SUF, CHECK) \
371
+ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
372
+ { \
373
+ if (CHECK(s, a)) { \
374
+ static gen_helper_opivx *const fns[4] = { \
375
+ gen_helper_##OPIVX##_b, \
376
+ gen_helper_##OPIVX##_h, \
377
+ gen_helper_##OPIVX##_w, \
378
+ gen_helper_##OPIVX##_d, \
379
+ }; \
380
+ return do_opivi_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew], \
381
+ IMM_MODE); \
382
+ } \
383
+ return false; \
384
+ }
385
+
386
+#define GEN_OPIVV_GVEC_TRANS_CHECK(NAME, SUF, CHECK) \
387
+ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
388
+ { \
389
+ if (CHECK(s, a)) { \
390
+ static gen_helper_gvec_4_ptr *const fns[4] = { \
391
+ gen_helper_##NAME##_b, \
392
+ gen_helper_##NAME##_h, \
393
+ gen_helper_##NAME##_w, \
394
+ gen_helper_##NAME##_d, \
395
+ }; \
396
+ return do_opivv_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \
397
+ } \
398
+ return false; \
399
+ }
400
+
401
+#define GEN_OPIVX_GVEC_SHIFT_TRANS_CHECK(NAME, SUF, CHECK) \
402
+ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
403
+ { \
404
+ if (CHECK(s, a)) { \
405
+ static gen_helper_opivx *const fns[4] = { \
406
+ gen_helper_##NAME##_b, \
407
+ gen_helper_##NAME##_h, \
408
+ gen_helper_##NAME##_w, \
409
+ gen_helper_##NAME##_d, \
410
+ }; \
411
+ return do_opivx_gvec_shift(s, a, tcg_gen_gvec_##SUF, \
412
+ fns[s->sew]); \
413
+ } \
414
+ return false; \
415
+ }
416
+
417
+static bool zvbb_vv_check(DisasContext *s, arg_rmrr *a)
418
+{
419
+ return opivv_check(s, a) && s->cfg_ptr->ext_zvbb == true;
420
+}
421
+
422
+static bool zvbb_vx_check(DisasContext *s, arg_rmrr *a)
423
+{
424
+ return opivx_check(s, a) && s->cfg_ptr->ext_zvbb == true;
425
+}
426
+
427
+/* vrol.v[vx] */
428
+GEN_OPIVV_GVEC_TRANS_CHECK(vrol_vv, rotlv, zvbb_vv_check)
429
+GEN_OPIVX_GVEC_SHIFT_TRANS_CHECK(vrol_vx, rotls, zvbb_vx_check)
430
+
431
+/* vror.v[vxi] */
432
+GEN_OPIVV_GVEC_TRANS_CHECK(vror_vv, rotrv, zvbb_vv_check)
433
+GEN_OPIVX_GVEC_SHIFT_TRANS_CHECK(vror_vx, rotrs, zvbb_vx_check)
434
+GEN_OPIVI_GVEC_TRANS_CHECK(vror_vi, IMM_TRUNC_SEW, vror_vx, rotri, zvbb_vx_check)
435
+
436
+#define GEN_OPIVX_GVEC_TRANS_CHECK(NAME, SUF, CHECK) \
437
+ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
438
+ { \
439
+ if (CHECK(s, a)) { \
440
+ static gen_helper_opivx *const fns[4] = { \
441
+ gen_helper_##NAME##_b, \
442
+ gen_helper_##NAME##_h, \
443
+ gen_helper_##NAME##_w, \
444
+ gen_helper_##NAME##_d, \
445
+ }; \
446
+ return do_opivx_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \
447
+ } \
448
+ return false; \
449
+ }
450
+
451
+/* vandn.v[vx] */
452
+GEN_OPIVV_GVEC_TRANS_CHECK(vandn_vv, andc, zvbb_vv_check)
453
+GEN_OPIVX_GVEC_TRANS_CHECK(vandn_vx, andcs, zvbb_vx_check)
454
+
455
+#define GEN_OPIV_TRANS(NAME, CHECK) \
456
+ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
457
+ { \
458
+ if (CHECK(s, a)) { \
459
+ uint32_t data = 0; \
460
+ static gen_helper_gvec_3_ptr *const fns[4] = { \
461
+ gen_helper_##NAME##_b, \
462
+ gen_helper_##NAME##_h, \
463
+ gen_helper_##NAME##_w, \
464
+ gen_helper_##NAME##_d, \
465
+ }; \
466
+ TCGLabel *over = gen_new_label(); \
467
+ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
468
+ \
469
+ data = FIELD_DP32(data, VDATA, VM, a->vm); \
470
+ data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
471
+ data = FIELD_DP32(data, VDATA, VTA, s->vta); \
472
+ data = FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s); \
473
+ data = FIELD_DP32(data, VDATA, VMA, s->vma); \
474
+ tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
475
+ vreg_ofs(s, a->rs2), cpu_env, \
476
+ s->cfg_ptr->vlen / 8, s->cfg_ptr->vlen / 8, \
477
+ data, fns[s->sew]); \
478
+ mark_vs_dirty(s); \
479
+ gen_set_label(over); \
480
+ return true; \
481
+ } \
482
+ return false; \
483
+ }
484
+
485
+static bool zvbb_opiv_check(DisasContext *s, arg_rmr *a)
486
+{
487
+ return s->cfg_ptr->ext_zvbb == true &&
488
+ require_rvv(s) &&
489
+ vext_check_isa_ill(s) &&
490
+ vext_check_ss(s, a->rd, a->rs2, a->vm);
491
+}
492
+
493
+GEN_OPIV_TRANS(vbrev8_v, zvbb_opiv_check)
494
+GEN_OPIV_TRANS(vrev8_v, zvbb_opiv_check)
495
+GEN_OPIV_TRANS(vbrev_v, zvbb_opiv_check)
496
+GEN_OPIV_TRANS(vclz_v, zvbb_opiv_check)
497
+GEN_OPIV_TRANS(vctz_v, zvbb_opiv_check)
498
+GEN_OPIV_TRANS(vcpop_v, zvbb_opiv_check)
499
+
500
+static bool vwsll_vv_check(DisasContext *s, arg_rmrr *a)
501
+{
502
+ return s->cfg_ptr->ext_zvbb && opivv_widen_check(s, a);
503
+}
504
+
505
+static bool vwsll_vx_check(DisasContext *s, arg_rmrr *a)
506
+{
507
+ return s->cfg_ptr->ext_zvbb && opivx_widen_check(s, a);
508
+}
509
+
510
+/* OPIVI without GVEC IR */
511
+#define GEN_OPIVI_WIDEN_TRANS(NAME, IMM_MODE, OPIVX, CHECK) \
512
+ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
513
+ { \
514
+ if (CHECK(s, a)) { \
515
+ static gen_helper_opivx *const fns[3] = { \
516
+ gen_helper_##OPIVX##_b, \
517
+ gen_helper_##OPIVX##_h, \
518
+ gen_helper_##OPIVX##_w, \
519
+ }; \
520
+ return opivi_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s, \
521
+ IMM_MODE); \
522
+ } \
523
+ return false; \
524
+ }
525
+
526
+GEN_OPIVV_WIDEN_TRANS(vwsll_vv, vwsll_vv_check)
527
+GEN_OPIVX_WIDEN_TRANS(vwsll_vx, vwsll_vx_check)
528
+GEN_OPIVI_WIDEN_TRANS(vwsll_vi, IMM_ZX, vwsll_vx, vwsll_vx_check)
46
--
529
--
47
2.40.1
530
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
2
2
3
All these generic CPUs are using the latest priv available, at this
3
This commit adds support for the Zvkned vector-crypto extension, which
4
moment PRIV_VERSION_1_12_0:
4
consists of the following instructions:
5
5
6
- riscv_any_cpu_init()
6
* vaesef.[vv,vs]
7
- rv32_base_cpu_init()
7
* vaesdf.[vv,vs]
8
- rv64_base_cpu_init()
8
* vaesdm.[vv,vs]
9
- rv128_base_cpu_init()
9
* vaesz.vs
10
* vaesem.[vv,vs]
11
* vaeskf1.vi
12
* vaeskf2.vi
10
13
11
Create a new PRIV_VERSION_LATEST enum and use it in those cases. I'll
14
Translation functions are defined in
12
make it easier to update everything at once when a new priv version is
15
`target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in
13
available.
16
`target/riscv/vcrypto_helper.c`.
14
17
15
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
18
Co-authored-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Co-authored-by: William Salmon <will.salmon@codethink.co.uk>
17
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
20
[max.chou@sifive.com: Replaced vstart checking by TCG op]
18
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
21
Signed-off-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
19
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
22
Signed-off-by: William Salmon <will.salmon@codethink.co.uk>
20
Message-Id: <20230517135714.211809-5-dbarboza@ventanamicro.com>
23
Signed-off-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
24
Signed-off-by: Max Chou <max.chou@sifive.com>
25
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
26
[max.chou@sifive.com: Imported aes-round.h and exposed x-zvkned
27
property]
28
[max.chou@sifive.com: Fixed endian issues and replaced the vstart & vl
29
egs checking by helper function]
30
[max.chou@sifive.com: Replaced bswap32 calls in aes key expanding]
31
Message-ID: <20230711165917.2629866-10-max.chou@sifive.com>
21
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
32
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
22
---
33
---
23
target/riscv/cpu.h | 2 ++
34
target/riscv/cpu_cfg.h | 1 +
24
target/riscv/cpu.c | 8 ++++----
35
target/riscv/helper.h | 14 ++
25
2 files changed, 6 insertions(+), 4 deletions(-)
36
target/riscv/insn32.decode | 14 ++
37
target/riscv/cpu.c | 4 +-
38
target/riscv/vcrypto_helper.c | 202 +++++++++++++++++++++++
39
target/riscv/insn_trans/trans_rvvk.c.inc | 147 +++++++++++++++++
40
6 files changed, 381 insertions(+), 1 deletion(-)
26
41
27
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
42
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
28
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
29
--- a/target/riscv/cpu.h
44
--- a/target/riscv/cpu_cfg.h
30
+++ b/target/riscv/cpu.h
45
+++ b/target/riscv/cpu_cfg.h
31
@@ -XXX,XX +XXX,XX @@ enum {
46
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
32
PRIV_VERSION_1_10_0 = 0,
47
bool ext_zve64d;
33
PRIV_VERSION_1_11_0,
48
bool ext_zvbb;
34
PRIV_VERSION_1_12_0,
49
bool ext_zvbc;
35
+
50
+ bool ext_zvkned;
36
+ PRIV_VERSION_LATEST = PRIV_VERSION_1_12_0,
51
bool ext_zmmul;
37
};
52
bool ext_zvfbfmin;
38
53
bool ext_zvfbfwma;
39
#define VEXT_VERSION_1_00_0 0x00010000
54
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
55
index XXXXXXX..XXXXXXX 100644
56
--- a/target/riscv/helper.h
57
+++ b/target/riscv/helper.h
58
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vandn_vx_b, void, ptr, ptr, tl, ptr, env, i32)
59
DEF_HELPER_6(vandn_vx_h, void, ptr, ptr, tl, ptr, env, i32)
60
DEF_HELPER_6(vandn_vx_w, void, ptr, ptr, tl, ptr, env, i32)
61
DEF_HELPER_6(vandn_vx_d, void, ptr, ptr, tl, ptr, env, i32)
62
+
63
+DEF_HELPER_2(egs_check, void, i32, env)
64
+
65
+DEF_HELPER_4(vaesef_vv, void, ptr, ptr, env, i32)
66
+DEF_HELPER_4(vaesef_vs, void, ptr, ptr, env, i32)
67
+DEF_HELPER_4(vaesdf_vv, void, ptr, ptr, env, i32)
68
+DEF_HELPER_4(vaesdf_vs, void, ptr, ptr, env, i32)
69
+DEF_HELPER_4(vaesem_vv, void, ptr, ptr, env, i32)
70
+DEF_HELPER_4(vaesem_vs, void, ptr, ptr, env, i32)
71
+DEF_HELPER_4(vaesdm_vv, void, ptr, ptr, env, i32)
72
+DEF_HELPER_4(vaesdm_vs, void, ptr, ptr, env, i32)
73
+DEF_HELPER_4(vaesz_vs, void, ptr, ptr, env, i32)
74
+DEF_HELPER_5(vaeskf1_vi, void, ptr, ptr, i32, env, i32)
75
+DEF_HELPER_5(vaeskf2_vi, void, ptr, ptr, i32, env, i32)
76
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
77
index XXXXXXX..XXXXXXX 100644
78
--- a/target/riscv/insn32.decode
79
+++ b/target/riscv/insn32.decode
80
@@ -XXX,XX +XXX,XX @@
81
@r_rm ....... ..... ..... ... ..... ....... %rs2 %rs1 %rm %rd
82
@r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd
83
@r2 ....... ..... ..... ... ..... ....... &r2 %rs1 %rd
84
+@r2_vm_1 ...... . ..... ..... ... ..... ....... &rmr vm=1 %rs2 %rd
85
@r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd
86
@r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd
87
@r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd
88
@@ -XXX,XX +XXX,XX @@ vcpop_v 010010 . ..... 01110 010 ..... 1010111 @r2_vm
89
vwsll_vv 110101 . ..... ..... 000 ..... 1010111 @r_vm
90
vwsll_vx 110101 . ..... ..... 100 ..... 1010111 @r_vm
91
vwsll_vi 110101 . ..... ..... 011 ..... 1010111 @r_vm
92
+
93
+# *** Zvkned vector crypto extension ***
94
+vaesef_vv 101000 1 ..... 00011 010 ..... 1110111 @r2_vm_1
95
+vaesef_vs 101001 1 ..... 00011 010 ..... 1110111 @r2_vm_1
96
+vaesdf_vv 101000 1 ..... 00001 010 ..... 1110111 @r2_vm_1
97
+vaesdf_vs 101001 1 ..... 00001 010 ..... 1110111 @r2_vm_1
98
+vaesem_vv 101000 1 ..... 00010 010 ..... 1110111 @r2_vm_1
99
+vaesem_vs 101001 1 ..... 00010 010 ..... 1110111 @r2_vm_1
100
+vaesdm_vv 101000 1 ..... 00000 010 ..... 1110111 @r2_vm_1
101
+vaesdm_vs 101001 1 ..... 00000 010 ..... 1110111 @r2_vm_1
102
+vaesz_vs 101001 1 ..... 00111 010 ..... 1110111 @r2_vm_1
103
+vaeskf1_vi 100010 1 ..... ..... 010 ..... 1110111 @r_vm_1
104
+vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_vm_1
40
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
105
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
41
index XXXXXXX..XXXXXXX 100644
106
index XXXXXXX..XXXXXXX 100644
42
--- a/target/riscv/cpu.c
107
--- a/target/riscv/cpu.c
43
+++ b/target/riscv/cpu.c
108
+++ b/target/riscv/cpu.c
44
@@ -XXX,XX +XXX,XX @@ static void riscv_any_cpu_init(Object *obj)
109
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
45
VM_1_10_SV32 : VM_1_10_SV57);
110
ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma),
46
#endif
111
ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh),
47
112
ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin),
48
- env->priv_ver = PRIV_VERSION_1_12_0;
113
+ ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned),
49
+ env->priv_ver = PRIV_VERSION_LATEST;
114
ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx),
50
}
115
ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin),
51
116
ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia),
52
#if defined(TARGET_RISCV64)
117
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
53
@@ -XXX,XX +XXX,XX @@ static void rv64_base_cpu_init(Object *obj)
118
* In principle Zve*x would also suffice here, were they supported
54
set_misa(env, MXL_RV64, 0);
119
* in qemu
55
riscv_cpu_add_user_properties(obj);
120
*/
56
/* Set latest version of privileged specification */
121
- if (cpu->cfg.ext_zvbb && !cpu->cfg.ext_zve32f) {
57
- env->priv_ver = PRIV_VERSION_1_12_0;
122
+ if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned) && !cpu->cfg.ext_zve32f) {
58
+ env->priv_ver = PRIV_VERSION_LATEST;
123
error_setg(errp,
59
#ifndef CONFIG_USER_ONLY
124
"Vector crypto extensions require V or Zve* extensions");
60
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV57);
125
return;
61
#endif
126
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
62
@@ -XXX,XX +XXX,XX @@ static void rv128_base_cpu_init(Object *obj)
127
/* Vector cryptography extensions */
63
set_misa(env, MXL_RV128, 0);
128
DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false),
64
riscv_cpu_add_user_properties(obj);
129
DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false),
65
/* Set latest version of privileged specification */
130
+ DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false),
66
- env->priv_ver = PRIV_VERSION_1_12_0;
131
67
+ env->priv_ver = PRIV_VERSION_LATEST;
132
DEFINE_PROP_END_OF_LIST(),
68
#ifndef CONFIG_USER_ONLY
133
};
69
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV57);
134
diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c
70
#endif
135
index XXXXXXX..XXXXXXX 100644
71
@@ -XXX,XX +XXX,XX @@ static void rv32_base_cpu_init(Object *obj)
136
--- a/target/riscv/vcrypto_helper.c
72
set_misa(env, MXL_RV32, 0);
137
+++ b/target/riscv/vcrypto_helper.c
73
riscv_cpu_add_user_properties(obj);
138
@@ -XXX,XX +XXX,XX @@
74
/* Set latest version of privileged specification */
139
#include "qemu/bitops.h"
75
- env->priv_ver = PRIV_VERSION_1_12_0;
140
#include "qemu/bswap.h"
76
+ env->priv_ver = PRIV_VERSION_LATEST;
141
#include "cpu.h"
77
#ifndef CONFIG_USER_ONLY
142
+#include "crypto/aes.h"
78
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV32);
143
+#include "crypto/aes-round.h"
79
#endif
144
#include "exec/memop.h"
145
#include "exec/exec-all.h"
146
#include "exec/helper-proto.h"
147
@@ -XXX,XX +XXX,XX @@ RVVCALL(OPIVX2, vwsll_vx_w, WOP_UUU_W, H8, H4, DO_SLL)
148
GEN_VEXT_VX(vwsll_vx_b, 2)
149
GEN_VEXT_VX(vwsll_vx_h, 4)
150
GEN_VEXT_VX(vwsll_vx_w, 8)
151
+
152
+void HELPER(egs_check)(uint32_t egs, CPURISCVState *env)
153
+{
154
+ uint32_t vl = env->vl;
155
+ uint32_t vstart = env->vstart;
156
+
157
+ if (vl % egs != 0 || vstart % egs != 0) {
158
+ riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC());
159
+ }
160
+}
161
+
162
+static inline void xor_round_key(AESState *round_state, AESState *round_key)
163
+{
164
+ round_state->v = round_state->v ^ round_key->v;
165
+}
166
+
167
+#define GEN_ZVKNED_HELPER_VV(NAME, ...) \
168
+ void HELPER(NAME)(void *vd, void *vs2, CPURISCVState *env, \
169
+ uint32_t desc) \
170
+ { \
171
+ uint32_t vl = env->vl; \
172
+ uint32_t total_elems = vext_get_total_elems(env, desc, 4); \
173
+ uint32_t vta = vext_vta(desc); \
174
+ \
175
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) { \
176
+ AESState round_key; \
177
+ round_key.d[0] = *((uint64_t *)vs2 + H8(i * 2 + 0)); \
178
+ round_key.d[1] = *((uint64_t *)vs2 + H8(i * 2 + 1)); \
179
+ AESState round_state; \
180
+ round_state.d[0] = *((uint64_t *)vd + H8(i * 2 + 0)); \
181
+ round_state.d[1] = *((uint64_t *)vd + H8(i * 2 + 1)); \
182
+ __VA_ARGS__; \
183
+ *((uint64_t *)vd + H8(i * 2 + 0)) = round_state.d[0]; \
184
+ *((uint64_t *)vd + H8(i * 2 + 1)) = round_state.d[1]; \
185
+ } \
186
+ env->vstart = 0; \
187
+ /* set tail elements to 1s */ \
188
+ vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4); \
189
+ }
190
+
191
+#define GEN_ZVKNED_HELPER_VS(NAME, ...) \
192
+ void HELPER(NAME)(void *vd, void *vs2, CPURISCVState *env, \
193
+ uint32_t desc) \
194
+ { \
195
+ uint32_t vl = env->vl; \
196
+ uint32_t total_elems = vext_get_total_elems(env, desc, 4); \
197
+ uint32_t vta = vext_vta(desc); \
198
+ \
199
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) { \
200
+ AESState round_key; \
201
+ round_key.d[0] = *((uint64_t *)vs2 + H8(0)); \
202
+ round_key.d[1] = *((uint64_t *)vs2 + H8(1)); \
203
+ AESState round_state; \
204
+ round_state.d[0] = *((uint64_t *)vd + H8(i * 2 + 0)); \
205
+ round_state.d[1] = *((uint64_t *)vd + H8(i * 2 + 1)); \
206
+ __VA_ARGS__; \
207
+ *((uint64_t *)vd + H8(i * 2 + 0)) = round_state.d[0]; \
208
+ *((uint64_t *)vd + H8(i * 2 + 1)) = round_state.d[1]; \
209
+ } \
210
+ env->vstart = 0; \
211
+ /* set tail elements to 1s */ \
212
+ vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4); \
213
+ }
214
+
215
+GEN_ZVKNED_HELPER_VV(vaesef_vv, aesenc_SB_SR_AK(&round_state,
216
+ &round_state,
217
+ &round_key,
218
+ false);)
219
+GEN_ZVKNED_HELPER_VS(vaesef_vs, aesenc_SB_SR_AK(&round_state,
220
+ &round_state,
221
+ &round_key,
222
+ false);)
223
+GEN_ZVKNED_HELPER_VV(vaesdf_vv, aesdec_ISB_ISR_AK(&round_state,
224
+ &round_state,
225
+ &round_key,
226
+ false);)
227
+GEN_ZVKNED_HELPER_VS(vaesdf_vs, aesdec_ISB_ISR_AK(&round_state,
228
+ &round_state,
229
+ &round_key,
230
+ false);)
231
+GEN_ZVKNED_HELPER_VV(vaesem_vv, aesenc_SB_SR_MC_AK(&round_state,
232
+ &round_state,
233
+ &round_key,
234
+ false);)
235
+GEN_ZVKNED_HELPER_VS(vaesem_vs, aesenc_SB_SR_MC_AK(&round_state,
236
+ &round_state,
237
+ &round_key,
238
+ false);)
239
+GEN_ZVKNED_HELPER_VV(vaesdm_vv, aesdec_ISB_ISR_AK_IMC(&round_state,
240
+ &round_state,
241
+ &round_key,
242
+ false);)
243
+GEN_ZVKNED_HELPER_VS(vaesdm_vs, aesdec_ISB_ISR_AK_IMC(&round_state,
244
+ &round_state,
245
+ &round_key,
246
+ false);)
247
+GEN_ZVKNED_HELPER_VS(vaesz_vs, xor_round_key(&round_state, &round_key);)
248
+
249
+void HELPER(vaeskf1_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,
250
+ CPURISCVState *env, uint32_t desc)
251
+{
252
+ uint32_t *vd = vd_vptr;
253
+ uint32_t *vs2 = vs2_vptr;
254
+ uint32_t vl = env->vl;
255
+ uint32_t total_elems = vext_get_total_elems(env, desc, 4);
256
+ uint32_t vta = vext_vta(desc);
257
+
258
+ uimm &= 0b1111;
259
+ if (uimm > 10 || uimm == 0) {
260
+ uimm ^= 0b1000;
261
+ }
262
+
263
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
264
+ uint32_t rk[8], tmp;
265
+ static const uint32_t rcon[] = {
266
+ 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010,
267
+ 0x00000020, 0x00000040, 0x00000080, 0x0000001B, 0x00000036,
268
+ };
269
+
270
+ rk[0] = vs2[i * 4 + H4(0)];
271
+ rk[1] = vs2[i * 4 + H4(1)];
272
+ rk[2] = vs2[i * 4 + H4(2)];
273
+ rk[3] = vs2[i * 4 + H4(3)];
274
+ tmp = ror32(rk[3], 8);
275
+
276
+ rk[4] = rk[0] ^ (((uint32_t)AES_sbox[(tmp >> 24) & 0xff] << 24) |
277
+ ((uint32_t)AES_sbox[(tmp >> 16) & 0xff] << 16) |
278
+ ((uint32_t)AES_sbox[(tmp >> 8) & 0xff] << 8) |
279
+ ((uint32_t)AES_sbox[(tmp >> 0) & 0xff] << 0))
280
+ ^ rcon[uimm - 1];
281
+ rk[5] = rk[1] ^ rk[4];
282
+ rk[6] = rk[2] ^ rk[5];
283
+ rk[7] = rk[3] ^ rk[6];
284
+
285
+ vd[i * 4 + H4(0)] = rk[4];
286
+ vd[i * 4 + H4(1)] = rk[5];
287
+ vd[i * 4 + H4(2)] = rk[6];
288
+ vd[i * 4 + H4(3)] = rk[7];
289
+ }
290
+ env->vstart = 0;
291
+ /* set tail elements to 1s */
292
+ vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4);
293
+}
294
+
295
+void HELPER(vaeskf2_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,
296
+ CPURISCVState *env, uint32_t desc)
297
+{
298
+ uint32_t *vd = vd_vptr;
299
+ uint32_t *vs2 = vs2_vptr;
300
+ uint32_t vl = env->vl;
301
+ uint32_t total_elems = vext_get_total_elems(env, desc, 4);
302
+ uint32_t vta = vext_vta(desc);
303
+
304
+ uimm &= 0b1111;
305
+ if (uimm > 14 || uimm < 2) {
306
+ uimm ^= 0b1000;
307
+ }
308
+
309
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
310
+ uint32_t rk[12], tmp;
311
+ static const uint32_t rcon[] = {
312
+ 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010,
313
+ 0x00000020, 0x00000040, 0x00000080, 0x0000001B, 0x00000036,
314
+ };
315
+
316
+ rk[0] = vd[i * 4 + H4(0)];
317
+ rk[1] = vd[i * 4 + H4(1)];
318
+ rk[2] = vd[i * 4 + H4(2)];
319
+ rk[3] = vd[i * 4 + H4(3)];
320
+ rk[4] = vs2[i * 4 + H4(0)];
321
+ rk[5] = vs2[i * 4 + H4(1)];
322
+ rk[6] = vs2[i * 4 + H4(2)];
323
+ rk[7] = vs2[i * 4 + H4(3)];
324
+
325
+ if (uimm % 2 == 0) {
326
+ tmp = ror32(rk[7], 8);
327
+ rk[8] = rk[0] ^ (((uint32_t)AES_sbox[(tmp >> 24) & 0xff] << 24) |
328
+ ((uint32_t)AES_sbox[(tmp >> 16) & 0xff] << 16) |
329
+ ((uint32_t)AES_sbox[(tmp >> 8) & 0xff] << 8) |
330
+ ((uint32_t)AES_sbox[(tmp >> 0) & 0xff] << 0))
331
+ ^ rcon[(uimm - 1) / 2];
332
+ } else {
333
+ rk[8] = rk[0] ^ (((uint32_t)AES_sbox[(rk[7] >> 24) & 0xff] << 24) |
334
+ ((uint32_t)AES_sbox[(rk[7] >> 16) & 0xff] << 16) |
335
+ ((uint32_t)AES_sbox[(rk[7] >> 8) & 0xff] << 8) |
336
+ ((uint32_t)AES_sbox[(rk[7] >> 0) & 0xff] << 0));
337
+ }
338
+ rk[9] = rk[1] ^ rk[8];
339
+ rk[10] = rk[2] ^ rk[9];
340
+ rk[11] = rk[3] ^ rk[10];
341
+
342
+ vd[i * 4 + H4(0)] = rk[8];
343
+ vd[i * 4 + H4(1)] = rk[9];
344
+ vd[i * 4 + H4(2)] = rk[10];
345
+ vd[i * 4 + H4(3)] = rk[11];
346
+ }
347
+ env->vstart = 0;
348
+ /* set tail elements to 1s */
349
+ vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4);
350
+}
351
diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_trans/trans_rvvk.c.inc
352
index XXXXXXX..XXXXXXX 100644
353
--- a/target/riscv/insn_trans/trans_rvvk.c.inc
354
+++ b/target/riscv/insn_trans/trans_rvvk.c.inc
355
@@ -XXX,XX +XXX,XX @@ static bool vwsll_vx_check(DisasContext *s, arg_rmrr *a)
356
GEN_OPIVV_WIDEN_TRANS(vwsll_vv, vwsll_vv_check)
357
GEN_OPIVX_WIDEN_TRANS(vwsll_vx, vwsll_vx_check)
358
GEN_OPIVI_WIDEN_TRANS(vwsll_vi, IMM_ZX, vwsll_vx, vwsll_vx_check)
359
+
360
+/*
361
+ * Zvkned
362
+ */
363
+
364
+#define ZVKNED_EGS 4
365
+
366
+#define GEN_V_UNMASKED_TRANS(NAME, CHECK, EGS) \
367
+ static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
368
+ { \
369
+ if (CHECK(s, a)) { \
370
+ TCGv_ptr rd_v, rs2_v; \
371
+ TCGv_i32 desc, egs; \
372
+ uint32_t data = 0; \
373
+ TCGLabel *over = gen_new_label(); \
374
+ \
375
+ if (!s->vstart_eq_zero || !s->vl_eq_vlmax) { \
376
+ /* save opcode for unwinding in case we throw an exception */ \
377
+ decode_save_opc(s); \
378
+ egs = tcg_constant_i32(EGS); \
379
+ gen_helper_egs_check(egs, cpu_env); \
380
+ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
381
+ } \
382
+ \
383
+ data = FIELD_DP32(data, VDATA, VM, a->vm); \
384
+ data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
385
+ data = FIELD_DP32(data, VDATA, VTA, s->vta); \
386
+ data = FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s); \
387
+ data = FIELD_DP32(data, VDATA, VMA, s->vma); \
388
+ rd_v = tcg_temp_new_ptr(); \
389
+ rs2_v = tcg_temp_new_ptr(); \
390
+ desc = tcg_constant_i32( \
391
+ simd_desc(s->cfg_ptr->vlen / 8, s->cfg_ptr->vlen / 8, data)); \
392
+ tcg_gen_addi_ptr(rd_v, cpu_env, vreg_ofs(s, a->rd)); \
393
+ tcg_gen_addi_ptr(rs2_v, cpu_env, vreg_ofs(s, a->rs2)); \
394
+ gen_helper_##NAME(rd_v, rs2_v, cpu_env, desc); \
395
+ mark_vs_dirty(s); \
396
+ gen_set_label(over); \
397
+ return true; \
398
+ } \
399
+ return false; \
400
+ }
401
+
402
+static bool vaes_check_vv(DisasContext *s, arg_rmr *a)
403
+{
404
+ int egw_bytes = ZVKNED_EGS << s->sew;
405
+ return s->cfg_ptr->ext_zvkned == true &&
406
+ require_rvv(s) &&
407
+ vext_check_isa_ill(s) &&
408
+ MAXSZ(s) >= egw_bytes &&
409
+ require_align(a->rd, s->lmul) &&
410
+ require_align(a->rs2, s->lmul) &&
411
+ s->sew == MO_32;
412
+}
413
+
414
+static bool vaes_check_overlap(DisasContext *s, int vd, int vs2)
415
+{
416
+ int8_t op_size = s->lmul <= 0 ? 1 : 1 << s->lmul;
417
+ return !is_overlapped(vd, op_size, vs2, 1);
418
+}
419
+
420
+static bool vaes_check_vs(DisasContext *s, arg_rmr *a)
421
+{
422
+ int egw_bytes = ZVKNED_EGS << s->sew;
423
+ return vaes_check_overlap(s, a->rd, a->rs2) &&
424
+ MAXSZ(s) >= egw_bytes &&
425
+ s->cfg_ptr->ext_zvkned == true &&
426
+ require_rvv(s) &&
427
+ vext_check_isa_ill(s) &&
428
+ require_align(a->rd, s->lmul) &&
429
+ s->sew == MO_32;
430
+}
431
+
432
+GEN_V_UNMASKED_TRANS(vaesef_vv, vaes_check_vv, ZVKNED_EGS)
433
+GEN_V_UNMASKED_TRANS(vaesef_vs, vaes_check_vs, ZVKNED_EGS)
434
+GEN_V_UNMASKED_TRANS(vaesdf_vv, vaes_check_vv, ZVKNED_EGS)
435
+GEN_V_UNMASKED_TRANS(vaesdf_vs, vaes_check_vs, ZVKNED_EGS)
436
+GEN_V_UNMASKED_TRANS(vaesdm_vv, vaes_check_vv, ZVKNED_EGS)
437
+GEN_V_UNMASKED_TRANS(vaesdm_vs, vaes_check_vs, ZVKNED_EGS)
438
+GEN_V_UNMASKED_TRANS(vaesz_vs, vaes_check_vs, ZVKNED_EGS)
439
+GEN_V_UNMASKED_TRANS(vaesem_vv, vaes_check_vv, ZVKNED_EGS)
440
+GEN_V_UNMASKED_TRANS(vaesem_vs, vaes_check_vs, ZVKNED_EGS)
441
+
442
+#define GEN_VI_UNMASKED_TRANS(NAME, CHECK, EGS) \
443
+ static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
444
+ { \
445
+ if (CHECK(s, a)) { \
446
+ TCGv_ptr rd_v, rs2_v; \
447
+ TCGv_i32 uimm_v, desc, egs; \
448
+ uint32_t data = 0; \
449
+ TCGLabel *over = gen_new_label(); \
450
+ \
451
+ if (!s->vstart_eq_zero || !s->vl_eq_vlmax) { \
452
+ /* save opcode for unwinding in case we throw an exception */ \
453
+ decode_save_opc(s); \
454
+ egs = tcg_constant_i32(EGS); \
455
+ gen_helper_egs_check(egs, cpu_env); \
456
+ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
457
+ } \
458
+ \
459
+ data = FIELD_DP32(data, VDATA, VM, a->vm); \
460
+ data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
461
+ data = FIELD_DP32(data, VDATA, VTA, s->vta); \
462
+ data = FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s); \
463
+ data = FIELD_DP32(data, VDATA, VMA, s->vma); \
464
+ \
465
+ rd_v = tcg_temp_new_ptr(); \
466
+ rs2_v = tcg_temp_new_ptr(); \
467
+ uimm_v = tcg_constant_i32(a->rs1); \
468
+ desc = tcg_constant_i32( \
469
+ simd_desc(s->cfg_ptr->vlen / 8, s->cfg_ptr->vlen / 8, data)); \
470
+ tcg_gen_addi_ptr(rd_v, cpu_env, vreg_ofs(s, a->rd)); \
471
+ tcg_gen_addi_ptr(rs2_v, cpu_env, vreg_ofs(s, a->rs2)); \
472
+ gen_helper_##NAME(rd_v, rs2_v, uimm_v, cpu_env, desc); \
473
+ mark_vs_dirty(s); \
474
+ gen_set_label(over); \
475
+ return true; \
476
+ } \
477
+ return false; \
478
+ }
479
+
480
+static bool vaeskf1_check(DisasContext *s, arg_vaeskf1_vi *a)
481
+{
482
+ int egw_bytes = ZVKNED_EGS << s->sew;
483
+ return s->cfg_ptr->ext_zvkned == true &&
484
+ require_rvv(s) &&
485
+ vext_check_isa_ill(s) &&
486
+ MAXSZ(s) >= egw_bytes &&
487
+ s->sew == MO_32 &&
488
+ require_align(a->rd, s->lmul) &&
489
+ require_align(a->rs2, s->lmul);
490
+}
491
+
492
+static bool vaeskf2_check(DisasContext *s, arg_vaeskf2_vi *a)
493
+{
494
+ int egw_bytes = ZVKNED_EGS << s->sew;
495
+ return s->cfg_ptr->ext_zvkned == true &&
496
+ require_rvv(s) &&
497
+ vext_check_isa_ill(s) &&
498
+ MAXSZ(s) >= egw_bytes &&
499
+ s->sew == MO_32 &&
500
+ require_align(a->rd, s->lmul) &&
501
+ require_align(a->rs2, s->lmul);
502
+}
503
+
504
+GEN_VI_UNMASKED_TRANS(vaeskf1_vi, vaeskf1_check, ZVKNED_EGS)
505
+GEN_VI_UNMASKED_TRANS(vaeskf2_vi, vaeskf2_check, ZVKNED_EGS)
80
--
506
--
81
2.40.1
507
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
2
2
3
We're doing env->priv_spec validation and assignment at the start of
3
This commit adds support for the Zvknh vector-crypto extension, which
4
riscv_cpu_realize(), which is fine, but then we're doing a force disable
4
consists of the following instructions:
5
on extensions that aren't compatible with the priv version.
6
5
7
This second step is being done too early. The disabled extensions might be
6
* vsha2ms.vv
8
re-enabled again in riscv_cpu_validate_set_extensions() by accident. A
7
* vsha2c[hl].vv
9
better place to put this code is at the end of
10
riscv_cpu_validate_set_extensions() after all the validations are
11
completed.
12
8
13
Add a new helper, riscv_cpu_disable_priv_spec_isa_exts(), to disable the
9
Translation functions are defined in
14
extesions after the validation is done. While we're at it, create a
10
`target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in
15
riscv_cpu_validate_priv_spec() helper to host all env->priv_spec related
11
`target/riscv/vcrypto_helper.c`.
16
validation to unclog riscv_cpu_realize a bit.
17
12
18
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
13
Co-authored-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
19
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
14
Co-authored-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
20
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
15
[max.chou@sifive.com: Replaced vstart checking by TCG op]
21
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
16
Signed-off-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
22
Message-Id: <20230517135714.211809-8-dbarboza@ventanamicro.com>
17
Signed-off-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
18
Signed-off-by: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
19
Signed-off-by: Max Chou <max.chou@sifive.com>
20
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
21
[max.chou@sifive.com: Exposed x-zvknha & x-zvknhb properties]
22
[max.chou@sifive.com: Replaced SEW selection to happened during
23
translation]
24
Message-ID: <20230711165917.2629866-11-max.chou@sifive.com>
23
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
25
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
24
---
26
---
25
target/riscv/cpu.c | 91 ++++++++++++++++++++++++++++------------------
27
target/riscv/cpu_cfg.h | 2 +
26
1 file changed, 56 insertions(+), 35 deletions(-)
28
target/riscv/helper.h | 6 +
29
target/riscv/insn32.decode | 5 +
30
target/riscv/cpu.c | 13 +-
31
target/riscv/vcrypto_helper.c | 238 +++++++++++++++++++++++
32
target/riscv/insn_trans/trans_rvvk.c.inc | 129 ++++++++++++
33
6 files changed, 390 insertions(+), 3 deletions(-)
27
34
35
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/riscv/cpu_cfg.h
38
+++ b/target/riscv/cpu_cfg.h
39
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
40
bool ext_zvbb;
41
bool ext_zvbc;
42
bool ext_zvkned;
43
+ bool ext_zvknha;
44
+ bool ext_zvknhb;
45
bool ext_zmmul;
46
bool ext_zvfbfmin;
47
bool ext_zvfbfwma;
48
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
49
index XXXXXXX..XXXXXXX 100644
50
--- a/target/riscv/helper.h
51
+++ b/target/riscv/helper.h
52
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(vaesdm_vs, void, ptr, ptr, env, i32)
53
DEF_HELPER_4(vaesz_vs, void, ptr, ptr, env, i32)
54
DEF_HELPER_5(vaeskf1_vi, void, ptr, ptr, i32, env, i32)
55
DEF_HELPER_5(vaeskf2_vi, void, ptr, ptr, i32, env, i32)
56
+
57
+DEF_HELPER_5(vsha2ms_vv, void, ptr, ptr, ptr, env, i32)
58
+DEF_HELPER_5(vsha2ch32_vv, void, ptr, ptr, ptr, env, i32)
59
+DEF_HELPER_5(vsha2ch64_vv, void, ptr, ptr, ptr, env, i32)
60
+DEF_HELPER_5(vsha2cl32_vv, void, ptr, ptr, ptr, env, i32)
61
+DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32)
62
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
63
index XXXXXXX..XXXXXXX 100644
64
--- a/target/riscv/insn32.decode
65
+++ b/target/riscv/insn32.decode
66
@@ -XXX,XX +XXX,XX @@ vaesdm_vs 101001 1 ..... 00000 010 ..... 1110111 @r2_vm_1
67
vaesz_vs 101001 1 ..... 00111 010 ..... 1110111 @r2_vm_1
68
vaeskf1_vi 100010 1 ..... ..... 010 ..... 1110111 @r_vm_1
69
vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_vm_1
70
+
71
+# *** Zvknh vector crypto extension ***
72
+vsha2ms_vv 101101 1 ..... ..... 010 ..... 1110111 @r_vm_1
73
+vsha2ch_vv 101110 1 ..... ..... 010 ..... 1110111 @r_vm_1
74
+vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1
28
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
75
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
29
index XXXXXXX..XXXXXXX 100644
76
index XXXXXXX..XXXXXXX 100644
30
--- a/target/riscv/cpu.c
77
--- a/target/riscv/cpu.c
31
+++ b/target/riscv/cpu.c
78
+++ b/target/riscv/cpu.c
32
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg,
79
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
33
env->vext_ver = vext_version;
80
ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh),
34
}
81
ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin),
35
82
ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned),
36
+static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp)
83
+ ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha),
37
+{
84
+ ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),
38
+ CPURISCVState *env = &cpu->env;
85
ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx),
39
+ int priv_version = -1;
86
ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin),
40
+
87
ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia),
41
+ if (cpu->cfg.priv_spec) {
88
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
42
+ if (!g_strcmp0(cpu->cfg.priv_spec, "v1.12.0")) {
89
* In principle Zve*x would also suffice here, were they supported
43
+ priv_version = PRIV_VERSION_1_12_0;
90
* in qemu
44
+ } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.11.0")) {
91
*/
45
+ priv_version = PRIV_VERSION_1_11_0;
92
- if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned) && !cpu->cfg.ext_zve32f) {
46
+ } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.10.0")) {
93
+ if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha) &&
47
+ priv_version = PRIV_VERSION_1_10_0;
94
+ !cpu->cfg.ext_zve32f) {
48
+ } else {
95
error_setg(errp,
49
+ error_setg(errp,
96
"Vector crypto extensions require V or Zve* extensions");
50
+ "Unsupported privilege spec version '%s'",
51
+ cpu->cfg.priv_spec);
52
+ return;
53
+ }
54
+
55
+ env->priv_ver = priv_version;
56
+ }
57
+}
58
+
59
+static void riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu)
60
+{
61
+ CPURISCVState *env = &cpu->env;
62
+ int i;
63
+
64
+ /* Force disable extensions if priv spec version does not match */
65
+ for (i = 0; i < ARRAY_SIZE(isa_edata_arr); i++) {
66
+ if (isa_ext_is_enabled(cpu, &isa_edata_arr[i]) &&
67
+ (env->priv_ver < isa_edata_arr[i].min_version)) {
68
+ isa_ext_update_enabled(cpu, &isa_edata_arr[i], false);
69
+#ifndef CONFIG_USER_ONLY
70
+ warn_report("disabling %s extension for hart 0x" TARGET_FMT_lx
71
+ " because privilege spec version does not match",
72
+ isa_edata_arr[i].name, env->mhartid);
73
+#else
74
+ warn_report("disabling %s extension because "
75
+ "privilege spec version does not match",
76
+ isa_edata_arr[i].name);
77
+#endif
78
+ }
79
+ }
80
+}
81
+
82
/*
83
* Check consistency between chosen extensions while setting
84
* cpu->cfg accordingly.
85
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
86
cpu->cfg.ext_zksed = true;
87
cpu->cfg.ext_zksh = true;
88
}
89
+
90
+ /*
91
+ * Disable isa extensions based on priv spec after we
92
+ * validated and set everything we need.
93
+ */
94
+ riscv_cpu_disable_priv_spec_isa_exts(cpu);
95
}
96
97
#ifndef CONFIG_USER_ONLY
98
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
99
CPURISCVState *env = &cpu->env;
100
RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev);
101
CPUClass *cc = CPU_CLASS(mcc);
102
- int i, priv_version = -1;
103
Error *local_err = NULL;
104
105
cpu_exec_realizefn(cs, &local_err);
106
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
107
return;
97
return;
108
}
98
}
109
99
110
- if (cpu->cfg.priv_spec) {
100
- if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) {
111
- if (!g_strcmp0(cpu->cfg.priv_spec, "v1.12.0")) {
101
- error_setg(errp, "Zvbc extension requires V or Zve64{f,d} extensions");
112
- priv_version = PRIV_VERSION_1_12_0;
102
+ if ((cpu->cfg.ext_zvbc || cpu->cfg.ext_zvknhb) && !cpu->cfg.ext_zve64f) {
113
- } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.11.0")) {
103
+ error_setg(
114
- priv_version = PRIV_VERSION_1_11_0;
104
+ errp,
115
- } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.10.0")) {
105
+ "Zvbc and Zvknhb extensions require V or Zve64{f,d} extensions");
116
- priv_version = PRIV_VERSION_1_10_0;
117
- } else {
118
- error_setg(errp,
119
- "Unsupported privilege spec version '%s'",
120
- cpu->cfg.priv_spec);
121
- return;
122
- }
123
- }
124
-
125
- if (priv_version >= PRIV_VERSION_1_10_0) {
126
- env->priv_ver = priv_version;
127
+ riscv_cpu_validate_priv_spec(cpu, &local_err);
128
+ if (local_err != NULL) {
129
+ error_propagate(errp, local_err);
130
+ return;
131
}
132
133
riscv_cpu_validate_misa_priv(env, &local_err);
134
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
135
return;
106
return;
136
}
107
}
137
108
138
- /* Force disable extensions if priv spec version does not match */
109
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
139
- for (i = 0; i < ARRAY_SIZE(isa_edata_arr); i++) {
110
DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false),
140
- if (isa_ext_is_enabled(cpu, &isa_edata_arr[i]) &&
111
DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false),
141
- (env->priv_ver < isa_edata_arr[i].min_version)) {
112
DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false),
142
- isa_ext_update_enabled(cpu, &isa_edata_arr[i], false);
113
+ DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false),
143
-#ifndef CONFIG_USER_ONLY
114
+ DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),
144
- warn_report("disabling %s extension for hart 0x" TARGET_FMT_lx
115
145
- " because privilege spec version does not match",
116
DEFINE_PROP_END_OF_LIST(),
146
- isa_edata_arr[i].name, env->mhartid);
117
};
147
-#else
118
diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c
148
- warn_report("disabling %s extension because "
119
index XXXXXXX..XXXXXXX 100644
149
- "privilege spec version does not match",
120
--- a/target/riscv/vcrypto_helper.c
150
- isa_edata_arr[i].name);
121
+++ b/target/riscv/vcrypto_helper.c
151
-#endif
122
@@ -XXX,XX +XXX,XX @@ void HELPER(vaeskf2_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,
152
- }
123
/* set tail elements to 1s */
153
- }
124
vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4);
154
-
125
}
155
if (cpu->cfg.epmp && !cpu->cfg.pmp) {
126
+
156
/*
127
+static inline uint32_t sig0_sha256(uint32_t x)
157
* Enhanced PMP should only be available
128
+{
129
+ return ror32(x, 7) ^ ror32(x, 18) ^ (x >> 3);
130
+}
131
+
132
+static inline uint32_t sig1_sha256(uint32_t x)
133
+{
134
+ return ror32(x, 17) ^ ror32(x, 19) ^ (x >> 10);
135
+}
136
+
137
+static inline uint64_t sig0_sha512(uint64_t x)
138
+{
139
+ return ror64(x, 1) ^ ror64(x, 8) ^ (x >> 7);
140
+}
141
+
142
+static inline uint64_t sig1_sha512(uint64_t x)
143
+{
144
+ return ror64(x, 19) ^ ror64(x, 61) ^ (x >> 6);
145
+}
146
+
147
+static inline void vsha2ms_e32(uint32_t *vd, uint32_t *vs1, uint32_t *vs2)
148
+{
149
+ uint32_t res[4];
150
+ res[0] = sig1_sha256(vs1[H4(2)]) + vs2[H4(1)] + sig0_sha256(vd[H4(1)]) +
151
+ vd[H4(0)];
152
+ res[1] = sig1_sha256(vs1[H4(3)]) + vs2[H4(2)] + sig0_sha256(vd[H4(2)]) +
153
+ vd[H4(1)];
154
+ res[2] =
155
+ sig1_sha256(res[0]) + vs2[H4(3)] + sig0_sha256(vd[H4(3)]) + vd[H4(2)];
156
+ res[3] =
157
+ sig1_sha256(res[1]) + vs1[H4(0)] + sig0_sha256(vs2[H4(0)]) + vd[H4(3)];
158
+ vd[H4(3)] = res[3];
159
+ vd[H4(2)] = res[2];
160
+ vd[H4(1)] = res[1];
161
+ vd[H4(0)] = res[0];
162
+}
163
+
164
+static inline void vsha2ms_e64(uint64_t *vd, uint64_t *vs1, uint64_t *vs2)
165
+{
166
+ uint64_t res[4];
167
+ res[0] = sig1_sha512(vs1[2]) + vs2[1] + sig0_sha512(vd[1]) + vd[0];
168
+ res[1] = sig1_sha512(vs1[3]) + vs2[2] + sig0_sha512(vd[2]) + vd[1];
169
+ res[2] = sig1_sha512(res[0]) + vs2[3] + sig0_sha512(vd[3]) + vd[2];
170
+ res[3] = sig1_sha512(res[1]) + vs1[0] + sig0_sha512(vs2[0]) + vd[3];
171
+ vd[3] = res[3];
172
+ vd[2] = res[2];
173
+ vd[1] = res[1];
174
+ vd[0] = res[0];
175
+}
176
+
177
+void HELPER(vsha2ms_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
178
+ uint32_t desc)
179
+{
180
+ uint32_t sew = FIELD_EX64(env->vtype, VTYPE, VSEW);
181
+ uint32_t esz = sew == MO_32 ? 4 : 8;
182
+ uint32_t total_elems;
183
+ uint32_t vta = vext_vta(desc);
184
+
185
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
186
+ if (sew == MO_32) {
187
+ vsha2ms_e32(((uint32_t *)vd) + i * 4, ((uint32_t *)vs1) + i * 4,
188
+ ((uint32_t *)vs2) + i * 4);
189
+ } else {
190
+ /* If not 32 then SEW should be 64 */
191
+ vsha2ms_e64(((uint64_t *)vd) + i * 4, ((uint64_t *)vs1) + i * 4,
192
+ ((uint64_t *)vs2) + i * 4);
193
+ }
194
+ }
195
+ /* set tail elements to 1s */
196
+ total_elems = vext_get_total_elems(env, desc, esz);
197
+ vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz);
198
+ env->vstart = 0;
199
+}
200
+
201
+static inline uint64_t sum0_64(uint64_t x)
202
+{
203
+ return ror64(x, 28) ^ ror64(x, 34) ^ ror64(x, 39);
204
+}
205
+
206
+static inline uint32_t sum0_32(uint32_t x)
207
+{
208
+ return ror32(x, 2) ^ ror32(x, 13) ^ ror32(x, 22);
209
+}
210
+
211
+static inline uint64_t sum1_64(uint64_t x)
212
+{
213
+ return ror64(x, 14) ^ ror64(x, 18) ^ ror64(x, 41);
214
+}
215
+
216
+static inline uint32_t sum1_32(uint32_t x)
217
+{
218
+ return ror32(x, 6) ^ ror32(x, 11) ^ ror32(x, 25);
219
+}
220
+
221
+#define ch(x, y, z) ((x & y) ^ ((~x) & z))
222
+
223
+#define maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
224
+
225
+static void vsha2c_64(uint64_t *vs2, uint64_t *vd, uint64_t *vs1)
226
+{
227
+ uint64_t a = vs2[3], b = vs2[2], e = vs2[1], f = vs2[0];
228
+ uint64_t c = vd[3], d = vd[2], g = vd[1], h = vd[0];
229
+ uint64_t W0 = vs1[0], W1 = vs1[1];
230
+ uint64_t T1 = h + sum1_64(e) + ch(e, f, g) + W0;
231
+ uint64_t T2 = sum0_64(a) + maj(a, b, c);
232
+
233
+ h = g;
234
+ g = f;
235
+ f = e;
236
+ e = d + T1;
237
+ d = c;
238
+ c = b;
239
+ b = a;
240
+ a = T1 + T2;
241
+
242
+ T1 = h + sum1_64(e) + ch(e, f, g) + W1;
243
+ T2 = sum0_64(a) + maj(a, b, c);
244
+ h = g;
245
+ g = f;
246
+ f = e;
247
+ e = d + T1;
248
+ d = c;
249
+ c = b;
250
+ b = a;
251
+ a = T1 + T2;
252
+
253
+ vd[0] = f;
254
+ vd[1] = e;
255
+ vd[2] = b;
256
+ vd[3] = a;
257
+}
258
+
259
+static void vsha2c_32(uint32_t *vs2, uint32_t *vd, uint32_t *vs1)
260
+{
261
+ uint32_t a = vs2[H4(3)], b = vs2[H4(2)], e = vs2[H4(1)], f = vs2[H4(0)];
262
+ uint32_t c = vd[H4(3)], d = vd[H4(2)], g = vd[H4(1)], h = vd[H4(0)];
263
+ uint32_t W0 = vs1[H4(0)], W1 = vs1[H4(1)];
264
+ uint32_t T1 = h + sum1_32(e) + ch(e, f, g) + W0;
265
+ uint32_t T2 = sum0_32(a) + maj(a, b, c);
266
+
267
+ h = g;
268
+ g = f;
269
+ f = e;
270
+ e = d + T1;
271
+ d = c;
272
+ c = b;
273
+ b = a;
274
+ a = T1 + T2;
275
+
276
+ T1 = h + sum1_32(e) + ch(e, f, g) + W1;
277
+ T2 = sum0_32(a) + maj(a, b, c);
278
+ h = g;
279
+ g = f;
280
+ f = e;
281
+ e = d + T1;
282
+ d = c;
283
+ c = b;
284
+ b = a;
285
+ a = T1 + T2;
286
+
287
+ vd[H4(0)] = f;
288
+ vd[H4(1)] = e;
289
+ vd[H4(2)] = b;
290
+ vd[H4(3)] = a;
291
+}
292
+
293
+void HELPER(vsha2ch32_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
294
+ uint32_t desc)
295
+{
296
+ const uint32_t esz = 4;
297
+ uint32_t total_elems;
298
+ uint32_t vta = vext_vta(desc);
299
+
300
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
301
+ vsha2c_32(((uint32_t *)vs2) + 4 * i, ((uint32_t *)vd) + 4 * i,
302
+ ((uint32_t *)vs1) + 4 * i + 2);
303
+ }
304
+
305
+ /* set tail elements to 1s */
306
+ total_elems = vext_get_total_elems(env, desc, esz);
307
+ vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz);
308
+ env->vstart = 0;
309
+}
310
+
311
+void HELPER(vsha2ch64_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
312
+ uint32_t desc)
313
+{
314
+ const uint32_t esz = 8;
315
+ uint32_t total_elems;
316
+ uint32_t vta = vext_vta(desc);
317
+
318
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
319
+ vsha2c_64(((uint64_t *)vs2) + 4 * i, ((uint64_t *)vd) + 4 * i,
320
+ ((uint64_t *)vs1) + 4 * i + 2);
321
+ }
322
+
323
+ /* set tail elements to 1s */
324
+ total_elems = vext_get_total_elems(env, desc, esz);
325
+ vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz);
326
+ env->vstart = 0;
327
+}
328
+
329
+void HELPER(vsha2cl32_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
330
+ uint32_t desc)
331
+{
332
+ const uint32_t esz = 4;
333
+ uint32_t total_elems;
334
+ uint32_t vta = vext_vta(desc);
335
+
336
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
337
+ vsha2c_32(((uint32_t *)vs2) + 4 * i, ((uint32_t *)vd) + 4 * i,
338
+ (((uint32_t *)vs1) + 4 * i));
339
+ }
340
+
341
+ /* set tail elements to 1s */
342
+ total_elems = vext_get_total_elems(env, desc, esz);
343
+ vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz);
344
+ env->vstart = 0;
345
+}
346
+
347
+void HELPER(vsha2cl64_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
348
+ uint32_t desc)
349
+{
350
+ uint32_t esz = 8;
351
+ uint32_t total_elems;
352
+ uint32_t vta = vext_vta(desc);
353
+
354
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
355
+ vsha2c_64(((uint64_t *)vs2) + 4 * i, ((uint64_t *)vd) + 4 * i,
356
+ (((uint64_t *)vs1) + 4 * i));
357
+ }
358
+
359
+ /* set tail elements to 1s */
360
+ total_elems = vext_get_total_elems(env, desc, esz);
361
+ vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz);
362
+ env->vstart = 0;
363
+}
364
diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_trans/trans_rvvk.c.inc
365
index XXXXXXX..XXXXXXX 100644
366
--- a/target/riscv/insn_trans/trans_rvvk.c.inc
367
+++ b/target/riscv/insn_trans/trans_rvvk.c.inc
368
@@ -XXX,XX +XXX,XX @@ static bool vaeskf2_check(DisasContext *s, arg_vaeskf2_vi *a)
369
370
GEN_VI_UNMASKED_TRANS(vaeskf1_vi, vaeskf1_check, ZVKNED_EGS)
371
GEN_VI_UNMASKED_TRANS(vaeskf2_vi, vaeskf2_check, ZVKNED_EGS)
372
+
373
+/*
374
+ * Zvknh
375
+ */
376
+
377
+#define ZVKNH_EGS 4
378
+
379
+#define GEN_VV_UNMASKED_TRANS(NAME, CHECK, EGS) \
380
+ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
381
+ { \
382
+ if (CHECK(s, a)) { \
383
+ uint32_t data = 0; \
384
+ TCGLabel *over = gen_new_label(); \
385
+ TCGv_i32 egs; \
386
+ \
387
+ if (!s->vstart_eq_zero || !s->vl_eq_vlmax) { \
388
+ /* save opcode for unwinding in case we throw an exception */ \
389
+ decode_save_opc(s); \
390
+ egs = tcg_constant_i32(EGS); \
391
+ gen_helper_egs_check(egs, cpu_env); \
392
+ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \
393
+ } \
394
+ \
395
+ data = FIELD_DP32(data, VDATA, VM, a->vm); \
396
+ data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
397
+ data = FIELD_DP32(data, VDATA, VTA, s->vta); \
398
+ data = FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s); \
399
+ data = FIELD_DP32(data, VDATA, VMA, s->vma); \
400
+ \
401
+ tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1), \
402
+ vreg_ofs(s, a->rs2), cpu_env, \
403
+ s->cfg_ptr->vlen / 8, s->cfg_ptr->vlen / 8, \
404
+ data, gen_helper_##NAME); \
405
+ \
406
+ mark_vs_dirty(s); \
407
+ gen_set_label(over); \
408
+ return true; \
409
+ } \
410
+ return false; \
411
+ }
412
+
413
+static bool vsha_check_sew(DisasContext *s)
414
+{
415
+ return (s->cfg_ptr->ext_zvknha == true && s->sew == MO_32) ||
416
+ (s->cfg_ptr->ext_zvknhb == true &&
417
+ (s->sew == MO_32 || s->sew == MO_64));
418
+}
419
+
420
+static bool vsha_check(DisasContext *s, arg_rmrr *a)
421
+{
422
+ int egw_bytes = ZVKNH_EGS << s->sew;
423
+ int mult = 1 << MAX(s->lmul, 0);
424
+ return opivv_check(s, a) &&
425
+ vsha_check_sew(s) &&
426
+ MAXSZ(s) >= egw_bytes &&
427
+ !is_overlapped(a->rd, mult, a->rs1, mult) &&
428
+ !is_overlapped(a->rd, mult, a->rs2, mult) &&
429
+ s->lmul >= 0;
430
+}
431
+
432
+GEN_VV_UNMASKED_TRANS(vsha2ms_vv, vsha_check, ZVKNH_EGS)
433
+
434
+static bool trans_vsha2cl_vv(DisasContext *s, arg_rmrr *a)
435
+{
436
+ if (vsha_check(s, a)) {
437
+ uint32_t data = 0;
438
+ TCGLabel *over = gen_new_label();
439
+ TCGv_i32 egs;
440
+
441
+ if (!s->vstart_eq_zero || !s->vl_eq_vlmax) {
442
+ /* save opcode for unwinding in case we throw an exception */
443
+ decode_save_opc(s);
444
+ egs = tcg_constant_i32(ZVKNH_EGS);
445
+ gen_helper_egs_check(egs, cpu_env);
446
+ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
447
+ }
448
+
449
+ data = FIELD_DP32(data, VDATA, VM, a->vm);
450
+ data = FIELD_DP32(data, VDATA, LMUL, s->lmul);
451
+ data = FIELD_DP32(data, VDATA, VTA, s->vta);
452
+ data = FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s);
453
+ data = FIELD_DP32(data, VDATA, VMA, s->vma);
454
+
455
+ tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1),
456
+ vreg_ofs(s, a->rs2), cpu_env, s->cfg_ptr->vlen / 8,
457
+ s->cfg_ptr->vlen / 8, data,
458
+ s->sew == MO_32 ?
459
+ gen_helper_vsha2cl32_vv : gen_helper_vsha2cl64_vv);
460
+
461
+ mark_vs_dirty(s);
462
+ gen_set_label(over);
463
+ return true;
464
+ }
465
+ return false;
466
+}
467
+
468
+static bool trans_vsha2ch_vv(DisasContext *s, arg_rmrr *a)
469
+{
470
+ if (vsha_check(s, a)) {
471
+ uint32_t data = 0;
472
+ TCGLabel *over = gen_new_label();
473
+ TCGv_i32 egs;
474
+
475
+ if (!s->vstart_eq_zero || !s->vl_eq_vlmax) {
476
+ /* save opcode for unwinding in case we throw an exception */
477
+ decode_save_opc(s);
478
+ egs = tcg_constant_i32(ZVKNH_EGS);
479
+ gen_helper_egs_check(egs, cpu_env);
480
+ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
481
+ }
482
+
483
+ data = FIELD_DP32(data, VDATA, VM, a->vm);
484
+ data = FIELD_DP32(data, VDATA, LMUL, s->lmul);
485
+ data = FIELD_DP32(data, VDATA, VTA, s->vta);
486
+ data = FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s);
487
+ data = FIELD_DP32(data, VDATA, VMA, s->vma);
488
+
489
+ tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1),
490
+ vreg_ofs(s, a->rs2), cpu_env, s->cfg_ptr->vlen / 8,
491
+ s->cfg_ptr->vlen / 8, data,
492
+ s->sew == MO_32 ?
493
+ gen_helper_vsha2ch32_vv : gen_helper_vsha2ch64_vv);
494
+
495
+ mark_vs_dirty(s);
496
+ gen_set_label(over);
497
+ return true;
498
+ }
499
+ return false;
500
+}
158
--
501
--
159
2.40.1
502
2.41.0
diff view generated by jsdifflib
1
From: Mayuresh Chitale <mchitale@ventanamicro.com>
1
From: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
2
2
3
Add knobs to allow users to enable smstateen and also export it via the
3
This commit adds support for the Zvksh vector-crypto extension, which
4
ISA extension string.
4
consists of the following instructions:
5
5
6
Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
6
* vsm3me.vv
7
Reviewed-by: Weiwei Li<liweiwei@iscas.ac.cn>
7
* vsm3c.vi
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
9
Message-Id: <20230518175058.2772506-4-mchitale@ventanamicro.com>
9
Translation functions are defined in
10
`target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in
11
`target/riscv/vcrypto_helper.c`.
12
13
Co-authored-by: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
14
[max.chou@sifive.com: Replaced vstart checking by TCG op]
15
Signed-off-by: Kiran Ostrolenk <kiran.ostrolenk@codethink.co.uk>
16
Signed-off-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
17
Signed-off-by: Max Chou <max.chou@sifive.com>
18
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
19
[max.chou@sifive.com: Exposed x-zvksh property]
20
Message-ID: <20230711165917.2629866-12-max.chou@sifive.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
21
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
22
---
12
target/riscv/cpu.c | 3 ++-
23
target/riscv/cpu_cfg.h | 1 +
13
1 file changed, 2 insertions(+), 1 deletion(-)
24
target/riscv/helper.h | 3 +
14
25
target/riscv/insn32.decode | 4 +
26
target/riscv/cpu.c | 6 +-
27
target/riscv/vcrypto_helper.c | 134 +++++++++++++++++++++++
28
target/riscv/insn_trans/trans_rvvk.c.inc | 31 ++++++
29
6 files changed, 177 insertions(+), 2 deletions(-)
30
31
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
32
index XXXXXXX..XXXXXXX 100644
33
--- a/target/riscv/cpu_cfg.h
34
+++ b/target/riscv/cpu_cfg.h
35
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
36
bool ext_zvkned;
37
bool ext_zvknha;
38
bool ext_zvknhb;
39
+ bool ext_zvksh;
40
bool ext_zmmul;
41
bool ext_zvfbfmin;
42
bool ext_zvfbfwma;
43
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/riscv/helper.h
46
+++ b/target/riscv/helper.h
47
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vsha2ch32_vv, void, ptr, ptr, ptr, env, i32)
48
DEF_HELPER_5(vsha2ch64_vv, void, ptr, ptr, ptr, env, i32)
49
DEF_HELPER_5(vsha2cl32_vv, void, ptr, ptr, ptr, env, i32)
50
DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32)
51
+
52
+DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32)
53
+DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32)
54
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
55
index XXXXXXX..XXXXXXX 100644
56
--- a/target/riscv/insn32.decode
57
+++ b/target/riscv/insn32.decode
58
@@ -XXX,XX +XXX,XX @@ vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_vm_1
59
vsha2ms_vv 101101 1 ..... ..... 010 ..... 1110111 @r_vm_1
60
vsha2ch_vv 101110 1 ..... ..... 010 ..... 1110111 @r_vm_1
61
vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1
62
+
63
+# *** Zvksh vector crypto extension ***
64
+vsm3me_vv 100000 1 ..... ..... 010 ..... 1110111 @r_vm_1
65
+vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1
15
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
66
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
16
index XXXXXXX..XXXXXXX 100644
67
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/cpu.c
68
--- a/target/riscv/cpu.c
18
+++ b/target/riscv/cpu.c
69
+++ b/target/riscv/cpu.c
19
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
70
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
71
ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned),
72
ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha),
73
ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),
74
+ ISA_EXT_DATA_ENTRY(zvksh, PRIV_VERSION_1_12_0, ext_zvksh),
20
ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx),
75
ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx),
21
ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin),
76
ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin),
22
ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia),
77
ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia),
23
+ ISA_EXT_DATA_ENTRY(smstateen, PRIV_VERSION_1_12_0, ext_smstateen),
78
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
24
ISA_EXT_DATA_ENTRY(ssaia, PRIV_VERSION_1_12_0, ext_ssaia),
79
* In principle Zve*x would also suffice here, were they supported
25
ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf),
80
* in qemu
26
ISA_EXT_DATA_ENTRY(sstc, PRIV_VERSION_1_12_0, ext_sstc),
81
*/
82
- if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha) &&
83
- !cpu->cfg.ext_zve32f) {
84
+ if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha ||
85
+ cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {
86
error_setg(errp,
87
"Vector crypto extensions require V or Zve* extensions");
88
return;
27
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
89
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
28
DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128),
90
DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false),
29
DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64),
91
DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false),
30
92
DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),
31
+ DEFINE_PROP_BOOL("smstateen", RISCVCPU, cfg.ext_smstateen, false),
93
+ DEFINE_PROP_BOOL("x-zvksh", RISCVCPU, cfg.ext_zvksh, false),
32
DEFINE_PROP_BOOL("svadu", RISCVCPU, cfg.ext_svadu, true),
94
33
-
95
DEFINE_PROP_END_OF_LIST(),
34
DEFINE_PROP_BOOL("svinval", RISCVCPU, cfg.ext_svinval, false),
96
};
35
DEFINE_PROP_BOOL("svnapot", RISCVCPU, cfg.ext_svnapot, false),
97
diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c
36
DEFINE_PROP_BOOL("svpbmt", RISCVCPU, cfg.ext_svpbmt, false),
98
index XXXXXXX..XXXXXXX 100644
99
--- a/target/riscv/vcrypto_helper.c
100
+++ b/target/riscv/vcrypto_helper.c
101
@@ -XXX,XX +XXX,XX @@ void HELPER(vsha2cl64_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
102
vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz);
103
env->vstart = 0;
104
}
105
+
106
+static inline uint32_t p1(uint32_t x)
107
+{
108
+ return x ^ rol32(x, 15) ^ rol32(x, 23);
109
+}
110
+
111
+static inline uint32_t zvksh_w(uint32_t m16, uint32_t m9, uint32_t m3,
112
+ uint32_t m13, uint32_t m6)
113
+{
114
+ return p1(m16 ^ m9 ^ rol32(m3, 15)) ^ rol32(m13, 7) ^ m6;
115
+}
116
+
117
+void HELPER(vsm3me_vv)(void *vd_vptr, void *vs1_vptr, void *vs2_vptr,
118
+ CPURISCVState *env, uint32_t desc)
119
+{
120
+ uint32_t esz = memop_size(FIELD_EX64(env->vtype, VTYPE, VSEW));
121
+ uint32_t total_elems = vext_get_total_elems(env, desc, esz);
122
+ uint32_t vta = vext_vta(desc);
123
+ uint32_t *vd = vd_vptr;
124
+ uint32_t *vs1 = vs1_vptr;
125
+ uint32_t *vs2 = vs2_vptr;
126
+
127
+ for (int i = env->vstart / 8; i < env->vl / 8; i++) {
128
+ uint32_t w[24];
129
+ for (int j = 0; j < 8; j++) {
130
+ w[j] = bswap32(vs1[H4((i * 8) + j)]);
131
+ w[j + 8] = bswap32(vs2[H4((i * 8) + j)]);
132
+ }
133
+ for (int j = 0; j < 8; j++) {
134
+ w[j + 16] =
135
+ zvksh_w(w[j], w[j + 7], w[j + 13], w[j + 3], w[j + 10]);
136
+ }
137
+ for (int j = 0; j < 8; j++) {
138
+ vd[(i * 8) + j] = bswap32(w[H4(j + 16)]);
139
+ }
140
+ }
141
+ vext_set_elems_1s(vd_vptr, vta, env->vl * esz, total_elems * esz);
142
+ env->vstart = 0;
143
+}
144
+
145
+static inline uint32_t ff1(uint32_t x, uint32_t y, uint32_t z)
146
+{
147
+ return x ^ y ^ z;
148
+}
149
+
150
+static inline uint32_t ff2(uint32_t x, uint32_t y, uint32_t z)
151
+{
152
+ return (x & y) | (x & z) | (y & z);
153
+}
154
+
155
+static inline uint32_t ff_j(uint32_t x, uint32_t y, uint32_t z, uint32_t j)
156
+{
157
+ return (j <= 15) ? ff1(x, y, z) : ff2(x, y, z);
158
+}
159
+
160
+static inline uint32_t gg1(uint32_t x, uint32_t y, uint32_t z)
161
+{
162
+ return x ^ y ^ z;
163
+}
164
+
165
+static inline uint32_t gg2(uint32_t x, uint32_t y, uint32_t z)
166
+{
167
+ return (x & y) | (~x & z);
168
+}
169
+
170
+static inline uint32_t gg_j(uint32_t x, uint32_t y, uint32_t z, uint32_t j)
171
+{
172
+ return (j <= 15) ? gg1(x, y, z) : gg2(x, y, z);
173
+}
174
+
175
+static inline uint32_t t_j(uint32_t j)
176
+{
177
+ return (j <= 15) ? 0x79cc4519 : 0x7a879d8a;
178
+}
179
+
180
+static inline uint32_t p_0(uint32_t x)
181
+{
182
+ return x ^ rol32(x, 9) ^ rol32(x, 17);
183
+}
184
+
185
+static void sm3c(uint32_t *vd, uint32_t *vs1, uint32_t *vs2, uint32_t uimm)
186
+{
187
+ uint32_t x0, x1;
188
+ uint32_t j;
189
+ uint32_t ss1, ss2, tt1, tt2;
190
+ x0 = vs2[0] ^ vs2[4];
191
+ x1 = vs2[1] ^ vs2[5];
192
+ j = 2 * uimm;
193
+ ss1 = rol32(rol32(vs1[0], 12) + vs1[4] + rol32(t_j(j), j % 32), 7);
194
+ ss2 = ss1 ^ rol32(vs1[0], 12);
195
+ tt1 = ff_j(vs1[0], vs1[1], vs1[2], j) + vs1[3] + ss2 + x0;
196
+ tt2 = gg_j(vs1[4], vs1[5], vs1[6], j) + vs1[7] + ss1 + vs2[0];
197
+ vs1[3] = vs1[2];
198
+ vd[3] = rol32(vs1[1], 9);
199
+ vs1[1] = vs1[0];
200
+ vd[1] = tt1;
201
+ vs1[7] = vs1[6];
202
+ vd[7] = rol32(vs1[5], 19);
203
+ vs1[5] = vs1[4];
204
+ vd[5] = p_0(tt2);
205
+ j = 2 * uimm + 1;
206
+ ss1 = rol32(rol32(vd[1], 12) + vd[5] + rol32(t_j(j), j % 32), 7);
207
+ ss2 = ss1 ^ rol32(vd[1], 12);
208
+ tt1 = ff_j(vd[1], vs1[1], vd[3], j) + vs1[3] + ss2 + x1;
209
+ tt2 = gg_j(vd[5], vs1[5], vd[7], j) + vs1[7] + ss1 + vs2[1];
210
+ vd[2] = rol32(vs1[1], 9);
211
+ vd[0] = tt1;
212
+ vd[6] = rol32(vs1[5], 19);
213
+ vd[4] = p_0(tt2);
214
+}
215
+
216
+void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,
217
+ CPURISCVState *env, uint32_t desc)
218
+{
219
+ uint32_t esz = memop_size(FIELD_EX64(env->vtype, VTYPE, VSEW));
220
+ uint32_t total_elems = vext_get_total_elems(env, desc, esz);
221
+ uint32_t vta = vext_vta(desc);
222
+ uint32_t *vd = vd_vptr;
223
+ uint32_t *vs2 = vs2_vptr;
224
+ uint32_t v1[8], v2[8], v3[8];
225
+
226
+ for (int i = env->vstart / 8; i < env->vl / 8; i++) {
227
+ for (int k = 0; k < 8; k++) {
228
+ v2[k] = bswap32(vd[H4(i * 8 + k)]);
229
+ v3[k] = bswap32(vs2[H4(i * 8 + k)]);
230
+ }
231
+ sm3c(v1, v2, v3, uimm);
232
+ for (int k = 0; k < 8; k++) {
233
+ vd[i * 8 + k] = bswap32(v1[H4(k)]);
234
+ }
235
+ }
236
+ vext_set_elems_1s(vd_vptr, vta, env->vl * esz, total_elems * esz);
237
+ env->vstart = 0;
238
+}
239
diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_trans/trans_rvvk.c.inc
240
index XXXXXXX..XXXXXXX 100644
241
--- a/target/riscv/insn_trans/trans_rvvk.c.inc
242
+++ b/target/riscv/insn_trans/trans_rvvk.c.inc
243
@@ -XXX,XX +XXX,XX @@ static bool trans_vsha2ch_vv(DisasContext *s, arg_rmrr *a)
244
}
245
return false;
246
}
247
+
248
+/*
249
+ * Zvksh
250
+ */
251
+
252
+#define ZVKSH_EGS 8
253
+
254
+static inline bool vsm3_check(DisasContext *s, arg_rmrr *a)
255
+{
256
+ int egw_bytes = ZVKSH_EGS << s->sew;
257
+ int mult = 1 << MAX(s->lmul, 0);
258
+ return s->cfg_ptr->ext_zvksh == true &&
259
+ require_rvv(s) &&
260
+ vext_check_isa_ill(s) &&
261
+ !is_overlapped(a->rd, mult, a->rs2, mult) &&
262
+ MAXSZ(s) >= egw_bytes &&
263
+ s->sew == MO_32;
264
+}
265
+
266
+static inline bool vsm3me_check(DisasContext *s, arg_rmrr *a)
267
+{
268
+ return vsm3_check(s, a) && vext_check_sss(s, a->rd, a->rs1, a->rs2, a->vm);
269
+}
270
+
271
+static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a)
272
+{
273
+ return vsm3_check(s, a) && vext_check_ss(s, a->rd, a->rs2, a->vm);
274
+}
275
+
276
+GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS)
277
+GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS)
37
--
278
--
38
2.40.1
279
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
2
2
3
Add a base pc_save for PC-relative translation(CF_PCREL).
3
This commit adds support for the Zvkg vector-crypto extension, which
4
Diable the directly sync pc from tb by riscv_cpu_synchronize_from_tb.
4
consists of the following instructions:
5
Use gen_pc_plus_diff to get the pc-relative address.
5
6
Enable CF_PCREL in System mode.
6
* vgmul.vv
7
7
* vghsh.vv
8
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
9
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
9
Translation functions are defined in
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
`target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
`target/riscv/vcrypto_helper.c`.
12
Message-Id: <20230526072124.298466-7-liweiwei@iscas.ac.cn>
12
13
Co-authored-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
14
[max.chou@sifive.com: Replaced vstart checking by TCG op]
15
Signed-off-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk>
16
Signed-off-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk>
17
Signed-off-by: Max Chou <max.chou@sifive.com>
18
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
19
[max.chou@sifive.com: Exposed x-zvkg property]
20
[max.chou@sifive.com: Replaced uint by int for cross win32 build]
21
Message-ID: <20230711165917.2629866-13-max.chou@sifive.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
22
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
23
---
15
target/riscv/cpu.c | 31 ++++++++++-----
24
target/riscv/cpu_cfg.h | 1 +
16
target/riscv/translate.c | 47 +++++++++++++++++++----
25
target/riscv/helper.h | 3 +
17
target/riscv/insn_trans/trans_rvi.c.inc | 12 +++++-
26
target/riscv/insn32.decode | 4 ++
18
target/riscv/insn_trans/trans_rvzce.c.inc | 4 +-
27
target/riscv/cpu.c | 6 +-
19
4 files changed, 74 insertions(+), 20 deletions(-)
28
target/riscv/vcrypto_helper.c | 72 ++++++++++++++++++++++++
20
29
target/riscv/insn_trans/trans_rvvk.c.inc | 30 ++++++++++
30
6 files changed, 114 insertions(+), 2 deletions(-)
31
32
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/riscv/cpu_cfg.h
35
+++ b/target/riscv/cpu_cfg.h
36
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
37
bool ext_zve64d;
38
bool ext_zvbb;
39
bool ext_zvbc;
40
+ bool ext_zvkg;
41
bool ext_zvkned;
42
bool ext_zvknha;
43
bool ext_zvknhb;
44
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/riscv/helper.h
47
+++ b/target/riscv/helper.h
48
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32)
49
50
DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32)
51
DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32)
52
+
53
+DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32)
54
+DEF_HELPER_4(vgmul_vv, void, ptr, ptr, env, i32)
55
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
56
index XXXXXXX..XXXXXXX 100644
57
--- a/target/riscv/insn32.decode
58
+++ b/target/riscv/insn32.decode
59
@@ -XXX,XX +XXX,XX @@ vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1
60
# *** Zvksh vector crypto extension ***
61
vsm3me_vv 100000 1 ..... ..... 010 ..... 1110111 @r_vm_1
62
vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1
63
+
64
+# *** Zvkg vector crypto extension ***
65
+vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1
66
+vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1
21
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
67
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
22
index XXXXXXX..XXXXXXX 100644
68
index XXXXXXX..XXXXXXX 100644
23
--- a/target/riscv/cpu.c
69
--- a/target/riscv/cpu.c
24
+++ b/target/riscv/cpu.c
70
+++ b/target/riscv/cpu.c
25
@@ -XXX,XX +XXX,XX @@ static vaddr riscv_cpu_get_pc(CPUState *cs)
71
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
26
static void riscv_cpu_synchronize_from_tb(CPUState *cs,
72
ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma),
27
const TranslationBlock *tb)
73
ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh),
28
{
74
ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin),
29
- RISCVCPU *cpu = RISCV_CPU(cs);
75
+ ISA_EXT_DATA_ENTRY(zvkg, PRIV_VERSION_1_12_0, ext_zvkg),
30
- CPURISCVState *env = &cpu->env;
76
ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned),
31
- RISCVMXL xl = FIELD_EX32(tb->flags, TB_FLAGS, XL);
77
ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha),
32
+ if (!(tb_cflags(tb) & CF_PCREL)) {
78
ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),
33
+ RISCVCPU *cpu = RISCV_CPU(cs);
79
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
34
+ CPURISCVState *env = &cpu->env;
80
* In principle Zve*x would also suffice here, were they supported
35
+ RISCVMXL xl = FIELD_EX32(tb->flags, TB_FLAGS, XL);
81
* in qemu
36
82
*/
37
- tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL));
83
- if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha ||
38
+ tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL));
84
- cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {
39
85
+ if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned ||
40
- if (xl == MXL_RV32) {
86
+ cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {
41
- env->pc = (int32_t) tb->pc;
87
error_setg(errp,
42
- } else {
88
"Vector crypto extensions require V or Zve* extensions");
43
- env->pc = tb->pc;
89
return;
44
+ if (xl == MXL_RV32) {
90
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
45
+ env->pc = (int32_t) tb->pc;
91
/* Vector cryptography extensions */
46
+ } else {
92
DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false),
47
+ env->pc = tb->pc;
93
DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false),
94
+ DEFINE_PROP_BOOL("x-zvkg", RISCVCPU, cfg.ext_zvkg, false),
95
DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false),
96
DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false),
97
DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),
98
diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c
99
index XXXXXXX..XXXXXXX 100644
100
--- a/target/riscv/vcrypto_helper.c
101
+++ b/target/riscv/vcrypto_helper.c
102
@@ -XXX,XX +XXX,XX @@ void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,
103
vext_set_elems_1s(vd_vptr, vta, env->vl * esz, total_elems * esz);
104
env->vstart = 0;
105
}
106
+
107
+void HELPER(vghsh_vv)(void *vd_vptr, void *vs1_vptr, void *vs2_vptr,
108
+ CPURISCVState *env, uint32_t desc)
109
+{
110
+ uint64_t *vd = vd_vptr;
111
+ uint64_t *vs1 = vs1_vptr;
112
+ uint64_t *vs2 = vs2_vptr;
113
+ uint32_t vta = vext_vta(desc);
114
+ uint32_t total_elems = vext_get_total_elems(env, desc, 4);
115
+
116
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
117
+ uint64_t Y[2] = {vd[i * 2 + 0], vd[i * 2 + 1]};
118
+ uint64_t H[2] = {brev8(vs2[i * 2 + 0]), brev8(vs2[i * 2 + 1])};
119
+ uint64_t X[2] = {vs1[i * 2 + 0], vs1[i * 2 + 1]};
120
+ uint64_t Z[2] = {0, 0};
121
+
122
+ uint64_t S[2] = {brev8(Y[0] ^ X[0]), brev8(Y[1] ^ X[1])};
123
+
124
+ for (int j = 0; j < 128; j++) {
125
+ if ((S[j / 64] >> (j % 64)) & 1) {
126
+ Z[0] ^= H[0];
127
+ Z[1] ^= H[1];
128
+ }
129
+ bool reduce = ((H[1] >> 63) & 1);
130
+ H[1] = H[1] << 1 | H[0] >> 63;
131
+ H[0] = H[0] << 1;
132
+ if (reduce) {
133
+ H[0] ^= 0x87;
134
+ }
48
+ }
135
+ }
49
}
136
+
50
}
137
+ vd[i * 2 + 0] = brev8(Z[0]);
51
138
+ vd[i * 2 + 1] = brev8(Z[1]);
52
@@ -XXX,XX +XXX,XX @@ static void riscv_restore_state_to_opc(CPUState *cs,
53
RISCVCPU *cpu = RISCV_CPU(cs);
54
CPURISCVState *env = &cpu->env;
55
RISCVMXL xl = FIELD_EX32(tb->flags, TB_FLAGS, XL);
56
+ target_ulong pc;
57
+
58
+ if (tb_cflags(tb) & CF_PCREL) {
59
+ pc = (env->pc & TARGET_PAGE_MASK) | data[0];
60
+ } else {
61
+ pc = data[0];
62
+ }
139
+ }
63
140
+ /* set tail elements to 1s */
64
if (xl == MXL_RV32) {
141
+ vext_set_elems_1s(vd, vta, env->vl * 4, total_elems * 4);
65
- env->pc = (int32_t)data[0];
142
+ env->vstart = 0;
66
+ env->pc = (int32_t)pc;
143
+}
67
} else {
144
+
68
- env->pc = data[0];
145
+void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, CPURISCVState *env,
69
+ env->pc = pc;
146
+ uint32_t desc)
70
}
147
+{
71
env->bins = data[1];
148
+ uint64_t *vd = vd_vptr;
72
}
149
+ uint64_t *vs2 = vs2_vptr;
73
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
150
+ uint32_t vta = vext_vta(desc);
74
}
151
+ uint32_t total_elems = vext_get_total_elems(env, desc, 4);
75
152
+
76
#ifndef CONFIG_USER_ONLY
153
+ for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
77
+ cs->tcg_cflags |= CF_PCREL;
154
+ uint64_t Y[2] = {brev8(vd[i * 2 + 0]), brev8(vd[i * 2 + 1])};
78
+
155
+ uint64_t H[2] = {brev8(vs2[i * 2 + 0]), brev8(vs2[i * 2 + 1])};
79
if (cpu->cfg.ext_sstc) {
156
+ uint64_t Z[2] = {0, 0};
80
riscv_timer_init(cpu);
157
+
81
}
158
+ for (int j = 0; j < 128; j++) {
82
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
159
+ if ((Y[j / 64] >> (j % 64)) & 1) {
83
index XXXXXXX..XXXXXXX 100644
160
+ Z[0] ^= H[0];
84
--- a/target/riscv/translate.c
161
+ Z[1] ^= H[1];
85
+++ b/target/riscv/translate.c
162
+ }
86
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
163
+ bool reduce = ((H[1] >> 63) & 1);
87
/* pc_succ_insn points to the instruction following base.pc_next */
164
+ H[1] = H[1] << 1 | H[0] >> 63;
88
target_ulong pc_succ_insn;
165
+ H[0] = H[0] << 1;
89
target_ulong cur_insn_len;
166
+ if (reduce) {
90
+ target_ulong pc_save;
167
+ H[0] ^= 0x87;
91
target_ulong priv_ver;
168
+ }
92
RISCVMXL misa_mxl_max;
93
RISCVMXL xl;
94
@@ -XXX,XX +XXX,XX @@ static void gen_pc_plus_diff(TCGv target, DisasContext *ctx,
95
{
96
target_ulong dest = ctx->base.pc_next + diff;
97
98
- if (get_xl(ctx) == MXL_RV32) {
99
- dest = (int32_t)dest;
100
+ assert(ctx->pc_save != -1);
101
+ if (tb_cflags(ctx->base.tb) & CF_PCREL) {
102
+ tcg_gen_addi_tl(target, cpu_pc, dest - ctx->pc_save);
103
+ if (get_xl(ctx) == MXL_RV32) {
104
+ tcg_gen_ext32s_tl(target, target);
105
+ }
169
+ }
106
+ } else {
170
+
107
+ if (get_xl(ctx) == MXL_RV32) {
171
+ vd[i * 2 + 0] = brev8(Z[0]);
108
+ dest = (int32_t)dest;
172
+ vd[i * 2 + 1] = brev8(Z[1]);
109
+ }
110
+ tcg_gen_movi_tl(target, dest);
111
}
112
- tcg_gen_movi_tl(target, dest);
113
}
114
115
static void gen_update_pc(DisasContext *ctx, target_long diff)
116
{
117
gen_pc_plus_diff(cpu_pc, ctx, diff);
118
+ ctx->pc_save = ctx->base.pc_next + diff;
119
}
120
121
static void generate_exception(DisasContext *ctx, int excp)
122
@@ -XXX,XX +XXX,XX @@ static void gen_goto_tb(DisasContext *ctx, int n, target_long diff)
123
* direct block chain benefits will be small.
124
*/
125
if (translator_use_goto_tb(&ctx->base, dest) && !ctx->itrigger) {
126
- tcg_gen_goto_tb(n);
127
- gen_update_pc(ctx, diff);
128
+ /*
129
+ * For pcrel, the pc must always be up-to-date on entry to
130
+ * the linked TB, so that it can use simple additions for all
131
+ * further adjustments. For !pcrel, the linked TB is compiled
132
+ * to know its full virtual address, so we can delay the
133
+ * update to pc to the unlinked path. A long chain of links
134
+ * can thus avoid many updates to the PC.
135
+ */
136
+ if (tb_cflags(ctx->base.tb) & CF_PCREL) {
137
+ gen_update_pc(ctx, diff);
138
+ tcg_gen_goto_tb(n);
139
+ } else {
140
+ tcg_gen_goto_tb(n);
141
+ gen_update_pc(ctx, diff);
142
+ }
143
tcg_gen_exit_tb(ctx->base.tb, n);
144
} else {
145
gen_update_pc(ctx, diff);
146
@@ -XXX,XX +XXX,XX @@ static void gen_set_fpr_d(DisasContext *ctx, int reg_num, TCGv_i64 t)
147
148
static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
149
{
150
+ TCGv succ_pc = dest_gpr(ctx, rd);
151
+
152
/* check misaligned: */
153
if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca) {
154
if ((imm & 0x3) != 0) {
155
@@ -XXX,XX +XXX,XX @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
156
}
157
}
158
159
- gen_set_gpri(ctx, rd, ctx->pc_succ_insn);
160
+ gen_pc_plus_diff(succ_pc, ctx, ctx->cur_insn_len);
161
+ gen_set_gpr(ctx, rd, succ_pc);
162
+
163
gen_goto_tb(ctx, 0, imm); /* must use this for safety */
164
ctx->base.is_jmp = DISAS_NORETURN;
165
}
166
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
167
RISCVCPU *cpu = RISCV_CPU(cs);
168
uint32_t tb_flags = ctx->base.tb->flags;
169
170
+ ctx->pc_save = ctx->base.pc_first;
171
ctx->pc_succ_insn = ctx->base.pc_first;
172
ctx->priv = FIELD_EX32(tb_flags, TB_FLAGS, PRIV);
173
ctx->mem_idx = FIELD_EX32(tb_flags, TB_FLAGS, MEM_IDX);
174
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_tb_start(DisasContextBase *db, CPUState *cpu)
175
static void riscv_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
176
{
177
DisasContext *ctx = container_of(dcbase, DisasContext, base);
178
+ target_ulong pc_next = ctx->base.pc_next;
179
+
180
+ if (tb_cflags(dcbase->tb) & CF_PCREL) {
181
+ pc_next &= ~TARGET_PAGE_MASK;
182
+ }
173
+ }
183
174
+ /* set tail elements to 1s */
184
- tcg_gen_insn_start(ctx->base.pc_next, 0);
175
+ vext_set_elems_1s(vd, vta, env->vl * 4, total_elems * 4);
185
+ tcg_gen_insn_start(pc_next, 0);
176
+ env->vstart = 0;
186
ctx->insn_start = tcg_last_op();
177
+}
187
}
178
diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_trans/trans_rvvk.c.inc
188
179
index XXXXXXX..XXXXXXX 100644
189
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
180
--- a/target/riscv/insn_trans/trans_rvvk.c.inc
190
index XXXXXXX..XXXXXXX 100644
181
+++ b/target/riscv/insn_trans/trans_rvvk.c.inc
191
--- a/target/riscv/insn_trans/trans_rvi.c.inc
182
@@ -XXX,XX +XXX,XX @@ static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a)
192
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
183
193
@@ -XXX,XX +XXX,XX @@ static bool trans_lui(DisasContext *ctx, arg_lui *a)
184
GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS)
194
185
GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS)
195
static bool trans_auipc(DisasContext *ctx, arg_auipc *a)
186
+
196
{
187
+/*
197
- gen_set_gpri(ctx, a->rd, a->imm + ctx->base.pc_next);
188
+ * Zvkg
198
+ TCGv target_pc = dest_gpr(ctx, a->rd);
189
+ */
199
+ gen_pc_plus_diff(target_pc, ctx, a->imm);
190
+
200
+ gen_set_gpr(ctx, a->rd, target_pc);
191
+#define ZVKG_EGS 4
201
return true;
192
+
202
}
193
+static bool vgmul_check(DisasContext *s, arg_rmr *a)
203
194
+{
204
@@ -XXX,XX +XXX,XX @@ static bool trans_jalr(DisasContext *ctx, arg_jalr *a)
195
+ int egw_bytes = ZVKG_EGS << s->sew;
205
{
196
+ return s->cfg_ptr->ext_zvkg == true &&
206
TCGLabel *misaligned = NULL;
197
+ vext_check_isa_ill(s) &&
207
TCGv target_pc = tcg_temp_new();
198
+ require_rvv(s) &&
208
+ TCGv succ_pc = dest_gpr(ctx, a->rd);
199
+ MAXSZ(s) >= egw_bytes &&
209
200
+ vext_check_ss(s, a->rd, a->rs2, a->vm) &&
210
tcg_gen_addi_tl(target_pc, get_gpr(ctx, a->rs1, EXT_NONE), a->imm);
201
+ s->sew == MO_32;
211
tcg_gen_andi_tl(target_pc, target_pc, (target_ulong)-2);
202
+}
212
@@ -XXX,XX +XXX,XX @@ static bool trans_jalr(DisasContext *ctx, arg_jalr *a)
203
+
213
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0x0, misaligned);
204
+GEN_V_UNMASKED_TRANS(vgmul_vv, vgmul_check, ZVKG_EGS)
214
}
205
+
215
206
+static bool vghsh_check(DisasContext *s, arg_rmrr *a)
216
- gen_set_gpri(ctx, a->rd, ctx->pc_succ_insn);
207
+{
217
+ gen_pc_plus_diff(succ_pc, ctx, ctx->cur_insn_len);
208
+ int egw_bytes = ZVKG_EGS << s->sew;
218
+ gen_set_gpr(ctx, a->rd, succ_pc);
209
+ return s->cfg_ptr->ext_zvkg == true &&
219
+
210
+ opivv_check(s, a) &&
220
tcg_gen_mov_tl(cpu_pc, target_pc);
211
+ MAXSZ(s) >= egw_bytes &&
221
lookup_and_goto_ptr(ctx);
212
+ s->sew == MO_32;
222
213
+}
223
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
214
+
224
TCGLabel *l = gen_new_label();
215
+GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS)
225
TCGv src1 = get_gpr(ctx, a->rs1, EXT_SIGN);
226
TCGv src2 = get_gpr(ctx, a->rs2, EXT_SIGN);
227
+ target_ulong orig_pc_save = ctx->pc_save;
228
229
if (get_xl(ctx) == MXL_RV128) {
230
TCGv src1h = get_gprh(ctx, a->rs1);
231
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
232
tcg_gen_brcond_tl(cond, src1, src2, l);
233
}
234
gen_goto_tb(ctx, 1, ctx->cur_insn_len);
235
+ ctx->pc_save = orig_pc_save;
236
237
gen_set_label(l); /* branch taken */
238
239
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
240
} else {
241
gen_goto_tb(ctx, 0, a->imm);
242
}
243
+ ctx->pc_save = -1;
244
ctx->base.is_jmp = DISAS_NORETURN;
245
246
return true;
247
diff --git a/target/riscv/insn_trans/trans_rvzce.c.inc b/target/riscv/insn_trans/trans_rvzce.c.inc
248
index XXXXXXX..XXXXXXX 100644
249
--- a/target/riscv/insn_trans/trans_rvzce.c.inc
250
+++ b/target/riscv/insn_trans/trans_rvzce.c.inc
251
@@ -XXX,XX +XXX,XX @@ static bool trans_cm_jalt(DisasContext *ctx, arg_cm_jalt *a)
252
253
/* c.jt vs c.jalt depends on the index. */
254
if (a->index >= 32) {
255
- gen_set_gpri(ctx, xRA, ctx->pc_succ_insn);
256
+ TCGv succ_pc = dest_gpr(ctx, xRA);
257
+ gen_pc_plus_diff(succ_pc, ctx, ctx->cur_insn_len);
258
+ gen_set_gpr(ctx, xRA, succ_pc);
259
}
260
261
tcg_gen_lookup_and_goto_ptr();
262
--
216
--
263
2.40.1
217
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Max Chou <max.chou@sifive.com>
2
2
3
MMWP and MML bits may affect the allowed privs of PMP entries and the
3
Allows sharing of sm4_subword between different targets.
4
default privs, both of which may change the allowed privs of exsited
5
TLB entries. So we need flush TLB when they are changed.
6
4
7
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
5
Signed-off-by: Max Chou <max.chou@sifive.com>
8
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
6
Reviewed-by: Frank Chang <frank.chang@sifive.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-Id: <20230517091519.34439-8-liweiwei@iscas.ac.cn>
8
Signed-off-by: Max Chou <max.chou@sifive.com>
9
Message-ID: <20230711165917.2629866-14-max.chou@sifive.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
11
---
13
target/riscv/pmp.c | 3 +++
12
include/crypto/sm4.h | 8 ++++++++
14
1 file changed, 3 insertions(+)
13
target/arm/tcg/crypto_helper.c | 10 ++--------
14
2 files changed, 10 insertions(+), 8 deletions(-)
15
15
16
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
16
diff --git a/include/crypto/sm4.h b/include/crypto/sm4.h
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/pmp.c
18
--- a/include/crypto/sm4.h
19
+++ b/target/riscv/pmp.c
19
+++ b/include/crypto/sm4.h
20
@@ -XXX,XX +XXX,XX @@ void mseccfg_csr_write(CPURISCVState *env, target_ulong val)
20
@@ -XXX,XX +XXX,XX @@
21
if (riscv_cpu_cfg(env)->epmp) {
21
22
/* Sticky bits */
22
extern const uint8_t sm4_sbox[256];
23
val |= (env->mseccfg & (MSECCFG_MMWP | MSECCFG_MML));
23
24
+ if ((val ^ env->mseccfg) & (MSECCFG_MMWP | MSECCFG_MML)) {
24
+static inline uint32_t sm4_subword(uint32_t word)
25
+ tlb_flush(env_cpu(env));
25
+{
26
+ }
26
+ return sm4_sbox[word & 0xff] |
27
} else {
27
+ sm4_sbox[(word >> 8) & 0xff] << 8 |
28
val &= ~(MSECCFG_MMWP | MSECCFG_MML | MSECCFG_RLB);
28
+ sm4_sbox[(word >> 16) & 0xff] << 16 |
29
+ sm4_sbox[(word >> 24) & 0xff] << 24;
30
+}
31
+
32
#endif
33
diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/tcg/crypto_helper.c
36
+++ b/target/arm/tcg/crypto_helper.c
37
@@ -XXX,XX +XXX,XX @@ static void do_crypto_sm4e(uint64_t *rd, uint64_t *rn, uint64_t *rm)
38
CR_ST_WORD(d, (i + 3) % 4) ^
39
CR_ST_WORD(n, i);
40
41
- t = sm4_sbox[t & 0xff] |
42
- sm4_sbox[(t >> 8) & 0xff] << 8 |
43
- sm4_sbox[(t >> 16) & 0xff] << 16 |
44
- sm4_sbox[(t >> 24) & 0xff] << 24;
45
+ t = sm4_subword(t);
46
47
CR_ST_WORD(d, i) ^= t ^ rol32(t, 2) ^ rol32(t, 10) ^ rol32(t, 18) ^
48
rol32(t, 24);
49
@@ -XXX,XX +XXX,XX @@ static void do_crypto_sm4ekey(uint64_t *rd, uint64_t *rn, uint64_t *rm)
50
CR_ST_WORD(d, (i + 3) % 4) ^
51
CR_ST_WORD(m, i);
52
53
- t = sm4_sbox[t & 0xff] |
54
- sm4_sbox[(t >> 8) & 0xff] << 8 |
55
- sm4_sbox[(t >> 16) & 0xff] << 16 |
56
- sm4_sbox[(t >> 24) & 0xff] << 24;
57
+ t = sm4_subword(t);
58
59
CR_ST_WORD(d, i) ^= t ^ rol32(t, 13) ^ rol32(t, 23);
29
}
60
}
30
--
61
--
31
2.40.1
62
2.41.0
diff view generated by jsdifflib
1
From: Ivan Klokov <ivan.klokov@syntacore.com>
1
From: Max Chou <max.chou@sifive.com>
2
2
3
Added QEMU option 'vpu' to log vector extension registers such as gpr\fpu.
3
Adds sm4_ck constant for use in sm4 cryptography across different targets.
4
4
5
Signed-off-by: Ivan Klokov <ivan.klokov@syntacore.com>
5
Signed-off-by: Max Chou <max.chou@sifive.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Frank Chang <frank.chang@sifive.com>
7
Message-Id: <20230410124451.15929-2-ivan.klokov@syntacore.com>
7
Signed-off-by: Max Chou <max.chou@sifive.com>
8
Message-ID: <20230711165917.2629866-15-max.chou@sifive.com>
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
---
10
include/hw/core/cpu.h | 2 ++
11
include/crypto/sm4.h | 1 +
11
include/qemu/log.h | 1 +
12
crypto/sm4.c | 10 ++++++++++
12
accel/tcg/cpu-exec.c | 3 +++
13
2 files changed, 11 insertions(+)
13
util/log.c | 2 ++
14
4 files changed, 8 insertions(+)
15
14
16
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
15
diff --git a/include/crypto/sm4.h b/include/crypto/sm4.h
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/core/cpu.h
17
--- a/include/crypto/sm4.h
19
+++ b/include/hw/core/cpu.h
18
+++ b/include/crypto/sm4.h
20
@@ -XXX,XX +XXX,XX @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu);
19
@@ -XXX,XX +XXX,XX @@
21
* @CPU_DUMP_CODE:
20
#define QEMU_SM4_H
22
* @CPU_DUMP_FPU: dump FPU register state, not just integer
21
23
* @CPU_DUMP_CCOP: dump info about TCG QEMU's condition code optimization state
22
extern const uint8_t sm4_sbox[256];
24
+ * @CPU_DUMP_VPU: dump VPU registers
23
+extern const uint32_t sm4_ck[32];
25
*/
24
26
enum CPUDumpFlags {
25
static inline uint32_t sm4_subword(uint32_t word)
27
CPU_DUMP_CODE = 0x00010000,
26
{
28
CPU_DUMP_FPU = 0x00020000,
27
diff --git a/crypto/sm4.c b/crypto/sm4.c
29
CPU_DUMP_CCOP = 0x00040000,
28
index XXXXXXX..XXXXXXX 100644
30
+ CPU_DUMP_VPU = 0x00080000,
29
--- a/crypto/sm4.c
30
+++ b/crypto/sm4.c
31
@@ -XXX,XX +XXX,XX @@ uint8_t const sm4_sbox[] = {
32
0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48,
31
};
33
};
32
34
33
/**
35
+uint32_t const sm4_ck[] = {
34
diff --git a/include/qemu/log.h b/include/qemu/log.h
36
+ 0x00070e15, 0x1c232a31, 0x383f464d, 0x545b6269,
35
index XXXXXXX..XXXXXXX 100644
37
+ 0x70777e85, 0x8c939aa1, 0xa8afb6bd, 0xc4cbd2d9,
36
--- a/include/qemu/log.h
38
+ 0xe0e7eef5, 0xfc030a11, 0x181f262d, 0x343b4249,
37
+++ b/include/qemu/log.h
39
+ 0x50575e65, 0x6c737a81, 0x888f969d, 0xa4abb2b9,
38
@@ -XXX,XX +XXX,XX @@ bool qemu_log_separate(void);
40
+ 0xc0c7ced5, 0xdce3eaf1, 0xf8ff060d, 0x141b2229,
39
/* LOG_STRACE is used for user-mode strace logging. */
41
+ 0x30373e45, 0x4c535a61, 0x686f767d, 0x848b9299,
40
#define LOG_STRACE (1 << 19)
42
+ 0xa0a7aeb5, 0xbcc3cad1, 0xd8dfe6ed, 0xf4fb0209,
41
#define LOG_PER_THREAD (1 << 20)
43
+ 0x10171e25, 0x2c333a41, 0x484f565d, 0x646b7279
42
+#define CPU_LOG_TB_VPU (1 << 21)
44
+};
43
44
/* Lock/unlock output. */
45
46
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/accel/tcg/cpu-exec.c
49
+++ b/accel/tcg/cpu-exec.c
50
@@ -XXX,XX +XXX,XX @@ static void log_cpu_exec(target_ulong pc, CPUState *cpu,
51
#if defined(TARGET_I386)
52
flags |= CPU_DUMP_CCOP;
53
#endif
54
+ if (qemu_loglevel_mask(CPU_LOG_TB_VPU)) {
55
+ flags |= CPU_DUMP_VPU;
56
+ }
57
cpu_dump_state(cpu, logfile, flags);
58
qemu_log_unlock(logfile);
59
}
60
diff --git a/util/log.c b/util/log.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/util/log.c
63
+++ b/util/log.c
64
@@ -XXX,XX +XXX,XX @@ const QEMULogItem qemu_log_items[] = {
65
"log every user-mode syscall, its input, and its result" },
66
{ LOG_PER_THREAD, "tid",
67
"open a separate log file per thread; filename must contain '%d'" },
68
+ { CPU_LOG_TB_VPU, "vpu",
69
+ "include VPU registers in the 'cpu' logging" },
70
{ 0, NULL, NULL },
71
};
72
73
--
45
--
74
2.40.1
46
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Max Chou <max.chou@sifive.com>
2
2
3
The setter is doing nothing special. Just set env->priv_ver directly.
3
This commit adds support for the Zvksed vector-crypto extension, which
4
4
consists of the following instructions:
5
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
5
6
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
6
* vsm4k.vi
7
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
* vsm4r.[vv,vs]
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
9
Message-Id: <20230517135714.211809-4-dbarboza@ventanamicro.com>
9
Translation functions are defined in
10
`target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in
11
`target/riscv/vcrypto_helper.c`.
12
13
Signed-off-by: Max Chou <max.chou@sifive.com>
14
Reviewed-by: Frank Chang <frank.chang@sifive.com>
15
[lawrence.hunter@codethink.co.uk: Moved SM4 functions from
16
crypto_helper.c to vcrypto_helper.c]
17
[nazar.kazakov@codethink.co.uk: Added alignment checks, refactored code to
18
use macros, and minor style changes]
19
Signed-off-by: Max Chou <max.chou@sifive.com>
20
Message-ID: <20230711165917.2629866-16-max.chou@sifive.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
21
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
22
---
12
target/riscv/cpu.c | 29 ++++++++++++-----------------
23
target/riscv/cpu_cfg.h | 1 +
13
1 file changed, 12 insertions(+), 17 deletions(-)
24
target/riscv/helper.h | 4 +
14
25
target/riscv/insn32.decode | 5 +
26
target/riscv/cpu.c | 5 +-
27
target/riscv/vcrypto_helper.c | 127 +++++++++++++++++++++++
28
target/riscv/insn_trans/trans_rvvk.c.inc | 43 ++++++++
29
6 files changed, 184 insertions(+), 1 deletion(-)
30
31
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
32
index XXXXXXX..XXXXXXX 100644
33
--- a/target/riscv/cpu_cfg.h
34
+++ b/target/riscv/cpu_cfg.h
35
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
36
bool ext_zvkned;
37
bool ext_zvknha;
38
bool ext_zvknhb;
39
+ bool ext_zvksed;
40
bool ext_zvksh;
41
bool ext_zmmul;
42
bool ext_zvfbfmin;
43
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/riscv/helper.h
46
+++ b/target/riscv/helper.h
47
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32)
48
49
DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32)
50
DEF_HELPER_4(vgmul_vv, void, ptr, ptr, env, i32)
51
+
52
+DEF_HELPER_5(vsm4k_vi, void, ptr, ptr, i32, env, i32)
53
+DEF_HELPER_4(vsm4r_vv, void, ptr, ptr, env, i32)
54
+DEF_HELPER_4(vsm4r_vs, void, ptr, ptr, env, i32)
55
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
56
index XXXXXXX..XXXXXXX 100644
57
--- a/target/riscv/insn32.decode
58
+++ b/target/riscv/insn32.decode
59
@@ -XXX,XX +XXX,XX @@ vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1
60
# *** Zvkg vector crypto extension ***
61
vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1
62
vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1
63
+
64
+# *** Zvksed vector crypto extension ***
65
+vsm4k_vi 100001 1 ..... ..... 010 ..... 1110111 @r_vm_1
66
+vsm4r_vv 101000 1 ..... 10000 010 ..... 1110111 @r2_vm_1
67
+vsm4r_vs 101001 1 ..... 10000 010 ..... 1110111 @r2_vm_1
15
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
68
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
16
index XXXXXXX..XXXXXXX 100644
69
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/cpu.c
70
--- a/target/riscv/cpu.c
18
+++ b/target/riscv/cpu.c
71
+++ b/target/riscv/cpu.c
19
@@ -XXX,XX +XXX,XX @@ static void set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext)
72
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
20
env->misa_ext_mask = env->misa_ext = ext;
73
ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned),
74
ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha),
75
ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),
76
+ ISA_EXT_DATA_ENTRY(zvksed, PRIV_VERSION_1_12_0, ext_zvksed),
77
ISA_EXT_DATA_ENTRY(zvksh, PRIV_VERSION_1_12_0, ext_zvksh),
78
ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx),
79
ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin),
80
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
81
* in qemu
82
*/
83
if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned ||
84
- cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {
85
+ cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksed || cpu->cfg.ext_zvksh) &&
86
+ !cpu->cfg.ext_zve32f) {
87
error_setg(errp,
88
"Vector crypto extensions require V or Zve* extensions");
89
return;
90
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
91
DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false),
92
DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false),
93
DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),
94
+ DEFINE_PROP_BOOL("x-zvksed", RISCVCPU, cfg.ext_zvksed, false),
95
DEFINE_PROP_BOOL("x-zvksh", RISCVCPU, cfg.ext_zvksh, false),
96
97
DEFINE_PROP_END_OF_LIST(),
98
diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c
99
index XXXXXXX..XXXXXXX 100644
100
--- a/target/riscv/vcrypto_helper.c
101
+++ b/target/riscv/vcrypto_helper.c
102
@@ -XXX,XX +XXX,XX @@
103
#include "cpu.h"
104
#include "crypto/aes.h"
105
#include "crypto/aes-round.h"
106
+#include "crypto/sm4.h"
107
#include "exec/memop.h"
108
#include "exec/exec-all.h"
109
#include "exec/helper-proto.h"
110
@@ -XXX,XX +XXX,XX @@ void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, CPURISCVState *env,
111
vext_set_elems_1s(vd, vta, env->vl * 4, total_elems * 4);
112
env->vstart = 0;
21
}
113
}
22
114
+
23
-static void set_priv_version(CPURISCVState *env, int priv_ver)
115
+void HELPER(vsm4k_vi)(void *vd, void *vs2, uint32_t uimm5, CPURISCVState *env,
24
-{
116
+ uint32_t desc)
25
- env->priv_ver = priv_ver;
117
+{
26
-}
118
+ const uint32_t egs = 4;
27
-
119
+ uint32_t rnd = uimm5 & 0x7;
28
#ifndef CONFIG_USER_ONLY
120
+ uint32_t group_start = env->vstart / egs;
29
static uint8_t satp_mode_from_str(const char *satp_mode_str)
121
+ uint32_t group_end = env->vl / egs;
30
{
122
+ uint32_t esz = sizeof(uint32_t);
31
@@ -XXX,XX +XXX,XX @@ static void riscv_any_cpu_init(Object *obj)
123
+ uint32_t total_elems = vext_get_total_elems(env, desc, esz);
32
VM_1_10_SV32 : VM_1_10_SV57);
124
+
33
#endif
125
+ for (uint32_t i = group_start; i < group_end; ++i) {
34
126
+ uint32_t vstart = i * egs;
35
- set_priv_version(env, PRIV_VERSION_1_12_0);
127
+ uint32_t vend = (i + 1) * egs;
36
+ env->priv_ver = PRIV_VERSION_1_12_0;
128
+ uint32_t rk[4] = {0};
129
+ uint32_t tmp[8] = {0};
130
+
131
+ for (uint32_t j = vstart; j < vend; ++j) {
132
+ rk[j - vstart] = *((uint32_t *)vs2 + H4(j));
133
+ }
134
+
135
+ for (uint32_t j = 0; j < egs; ++j) {
136
+ tmp[j] = rk[j];
137
+ }
138
+
139
+ for (uint32_t j = 0; j < egs; ++j) {
140
+ uint32_t b, s;
141
+ b = tmp[j + 1] ^ tmp[j + 2] ^ tmp[j + 3] ^ sm4_ck[rnd * 4 + j];
142
+
143
+ s = sm4_subword(b);
144
+
145
+ tmp[j + 4] = tmp[j] ^ (s ^ rol32(s, 13) ^ rol32(s, 23));
146
+ }
147
+
148
+ for (uint32_t j = vstart; j < vend; ++j) {
149
+ *((uint32_t *)vd + H4(j)) = tmp[egs + (j - vstart)];
150
+ }
151
+ }
152
+
153
+ env->vstart = 0;
154
+ /* set tail elements to 1s */
155
+ vext_set_elems_1s(vd, vext_vta(desc), env->vl * esz, total_elems * esz);
156
+}
157
+
158
+static void do_sm4_round(uint32_t *rk, uint32_t *buf)
159
+{
160
+ const uint32_t egs = 4;
161
+ uint32_t s, b;
162
+
163
+ for (uint32_t j = egs; j < egs * 2; ++j) {
164
+ b = buf[j - 3] ^ buf[j - 2] ^ buf[j - 1] ^ rk[j - 4];
165
+
166
+ s = sm4_subword(b);
167
+
168
+ buf[j] = buf[j - 4] ^ (s ^ rol32(s, 2) ^ rol32(s, 10) ^ rol32(s, 18) ^
169
+ rol32(s, 24));
170
+ }
171
+}
172
+
173
+void HELPER(vsm4r_vv)(void *vd, void *vs2, CPURISCVState *env, uint32_t desc)
174
+{
175
+ const uint32_t egs = 4;
176
+ uint32_t group_start = env->vstart / egs;
177
+ uint32_t group_end = env->vl / egs;
178
+ uint32_t esz = sizeof(uint32_t);
179
+ uint32_t total_elems = vext_get_total_elems(env, desc, esz);
180
+
181
+ for (uint32_t i = group_start; i < group_end; ++i) {
182
+ uint32_t vstart = i * egs;
183
+ uint32_t vend = (i + 1) * egs;
184
+ uint32_t rk[4] = {0};
185
+ uint32_t tmp[8] = {0};
186
+
187
+ for (uint32_t j = vstart; j < vend; ++j) {
188
+ rk[j - vstart] = *((uint32_t *)vs2 + H4(j));
189
+ }
190
+
191
+ for (uint32_t j = vstart; j < vend; ++j) {
192
+ tmp[j - vstart] = *((uint32_t *)vd + H4(j));
193
+ }
194
+
195
+ do_sm4_round(rk, tmp);
196
+
197
+ for (uint32_t j = vstart; j < vend; ++j) {
198
+ *((uint32_t *)vd + H4(j)) = tmp[egs + (j - vstart)];
199
+ }
200
+ }
201
+
202
+ env->vstart = 0;
203
+ /* set tail elements to 1s */
204
+ vext_set_elems_1s(vd, vext_vta(desc), env->vl * esz, total_elems * esz);
205
+}
206
+
207
+void HELPER(vsm4r_vs)(void *vd, void *vs2, CPURISCVState *env, uint32_t desc)
208
+{
209
+ const uint32_t egs = 4;
210
+ uint32_t group_start = env->vstart / egs;
211
+ uint32_t group_end = env->vl / egs;
212
+ uint32_t esz = sizeof(uint32_t);
213
+ uint32_t total_elems = vext_get_total_elems(env, desc, esz);
214
+
215
+ for (uint32_t i = group_start; i < group_end; ++i) {
216
+ uint32_t vstart = i * egs;
217
+ uint32_t vend = (i + 1) * egs;
218
+ uint32_t rk[4] = {0};
219
+ uint32_t tmp[8] = {0};
220
+
221
+ for (uint32_t j = 0; j < egs; ++j) {
222
+ rk[j] = *((uint32_t *)vs2 + H4(j));
223
+ }
224
+
225
+ for (uint32_t j = vstart; j < vend; ++j) {
226
+ tmp[j - vstart] = *((uint32_t *)vd + H4(j));
227
+ }
228
+
229
+ do_sm4_round(rk, tmp);
230
+
231
+ for (uint32_t j = vstart; j < vend; ++j) {
232
+ *((uint32_t *)vd + H4(j)) = tmp[egs + (j - vstart)];
233
+ }
234
+ }
235
+
236
+ env->vstart = 0;
237
+ /* set tail elements to 1s */
238
+ vext_set_elems_1s(vd, vext_vta(desc), env->vl * esz, total_elems * esz);
239
+}
240
diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_trans/trans_rvvk.c.inc
241
index XXXXXXX..XXXXXXX 100644
242
--- a/target/riscv/insn_trans/trans_rvvk.c.inc
243
+++ b/target/riscv/insn_trans/trans_rvvk.c.inc
244
@@ -XXX,XX +XXX,XX @@ static bool vghsh_check(DisasContext *s, arg_rmrr *a)
37
}
245
}
38
246
39
#if defined(TARGET_RISCV64)
247
GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS)
40
@@ -XXX,XX +XXX,XX @@ static void rv64_base_cpu_init(Object *obj)
248
+
41
set_misa(env, MXL_RV64, 0);
249
+/*
42
riscv_cpu_add_user_properties(obj);
250
+ * Zvksed
43
/* Set latest version of privileged specification */
251
+ */
44
- set_priv_version(env, PRIV_VERSION_1_12_0);
252
+
45
+ env->priv_ver = PRIV_VERSION_1_12_0;
253
+#define ZVKSED_EGS 4
46
#ifndef CONFIG_USER_ONLY
254
+
47
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV57);
255
+static bool zvksed_check(DisasContext *s)
48
#endif
256
+{
49
@@ -XXX,XX +XXX,XX @@ static void rv64_sifive_u_cpu_init(Object *obj)
257
+ int egw_bytes = ZVKSED_EGS << s->sew;
50
{
258
+ return s->cfg_ptr->ext_zvksed == true &&
51
CPURISCVState *env = &RISCV_CPU(obj)->env;
259
+ require_rvv(s) &&
52
set_misa(env, MXL_RV64, RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
260
+ vext_check_isa_ill(s) &&
53
- set_priv_version(env, PRIV_VERSION_1_10_0);
261
+ MAXSZ(s) >= egw_bytes &&
54
+ env->priv_ver = PRIV_VERSION_1_10_0;
262
+ s->sew == MO_32;
55
#ifndef CONFIG_USER_ONLY
263
+}
56
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV39);
264
+
57
#endif
265
+static bool vsm4k_vi_check(DisasContext *s, arg_rmrr *a)
58
@@ -XXX,XX +XXX,XX @@ static void rv64_sifive_e_cpu_init(Object *obj)
266
+{
59
RISCVCPU *cpu = RISCV_CPU(obj);
267
+ return zvksed_check(s) &&
60
268
+ require_align(a->rd, s->lmul) &&
61
set_misa(env, MXL_RV64, RVI | RVM | RVA | RVC | RVU);
269
+ require_align(a->rs2, s->lmul);
62
- set_priv_version(env, PRIV_VERSION_1_10_0);
270
+}
63
+ env->priv_ver = PRIV_VERSION_1_10_0;
271
+
64
cpu->cfg.mmu = false;
272
+GEN_VI_UNMASKED_TRANS(vsm4k_vi, vsm4k_vi_check, ZVKSED_EGS)
65
#ifndef CONFIG_USER_ONLY
273
+
66
set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
274
+static bool vsm4r_vv_check(DisasContext *s, arg_rmr *a)
67
@@ -XXX,XX +XXX,XX @@ static void rv64_thead_c906_cpu_init(Object *obj)
275
+{
68
RISCVCPU *cpu = RISCV_CPU(obj);
276
+ return zvksed_check(s) &&
69
277
+ require_align(a->rd, s->lmul) &&
70
set_misa(env, MXL_RV64, RVG | RVC | RVS | RVU);
278
+ require_align(a->rs2, s->lmul);
71
- set_priv_version(env, PRIV_VERSION_1_11_0);
279
+}
72
+ env->priv_ver = PRIV_VERSION_1_11_0;
280
+
73
281
+GEN_V_UNMASKED_TRANS(vsm4r_vv, vsm4r_vv_check, ZVKSED_EGS)
74
cpu->cfg.ext_zfh = true;
282
+
75
cpu->cfg.mmu = true;
283
+static bool vsm4r_vs_check(DisasContext *s, arg_rmr *a)
76
@@ -XXX,XX +XXX,XX @@ static void rv128_base_cpu_init(Object *obj)
284
+{
77
set_misa(env, MXL_RV128, 0);
285
+ return zvksed_check(s) &&
78
riscv_cpu_add_user_properties(obj);
286
+ !is_overlapped(a->rd, 1 << MAX(s->lmul, 0), a->rs2, 1) &&
79
/* Set latest version of privileged specification */
287
+ require_align(a->rd, s->lmul);
80
- set_priv_version(env, PRIV_VERSION_1_12_0);
288
+}
81
+ env->priv_ver = PRIV_VERSION_1_12_0;
289
+
82
#ifndef CONFIG_USER_ONLY
290
+GEN_V_UNMASKED_TRANS(vsm4r_vs, vsm4r_vs_check, ZVKSED_EGS)
83
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV57);
84
#endif
85
@@ -XXX,XX +XXX,XX @@ static void rv32_base_cpu_init(Object *obj)
86
set_misa(env, MXL_RV32, 0);
87
riscv_cpu_add_user_properties(obj);
88
/* Set latest version of privileged specification */
89
- set_priv_version(env, PRIV_VERSION_1_12_0);
90
+ env->priv_ver = PRIV_VERSION_1_12_0;
91
#ifndef CONFIG_USER_ONLY
92
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV32);
93
#endif
94
@@ -XXX,XX +XXX,XX @@ static void rv32_sifive_u_cpu_init(Object *obj)
95
{
96
CPURISCVState *env = &RISCV_CPU(obj)->env;
97
set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
98
- set_priv_version(env, PRIV_VERSION_1_10_0);
99
+ env->priv_ver = PRIV_VERSION_1_10_0;
100
#ifndef CONFIG_USER_ONLY
101
set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV32);
102
#endif
103
@@ -XXX,XX +XXX,XX @@ static void rv32_sifive_e_cpu_init(Object *obj)
104
RISCVCPU *cpu = RISCV_CPU(obj);
105
106
set_misa(env, MXL_RV32, RVI | RVM | RVA | RVC | RVU);
107
- set_priv_version(env, PRIV_VERSION_1_10_0);
108
+ env->priv_ver = PRIV_VERSION_1_10_0;
109
cpu->cfg.mmu = false;
110
#ifndef CONFIG_USER_ONLY
111
set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
112
@@ -XXX,XX +XXX,XX @@ static void rv32_ibex_cpu_init(Object *obj)
113
RISCVCPU *cpu = RISCV_CPU(obj);
114
115
set_misa(env, MXL_RV32, RVI | RVM | RVC | RVU);
116
- set_priv_version(env, PRIV_VERSION_1_11_0);
117
+ env->priv_ver = PRIV_VERSION_1_11_0;
118
cpu->cfg.mmu = false;
119
#ifndef CONFIG_USER_ONLY
120
set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
121
@@ -XXX,XX +XXX,XX @@ static void rv32_imafcu_nommu_cpu_init(Object *obj)
122
RISCVCPU *cpu = RISCV_CPU(obj);
123
124
set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVC | RVU);
125
- set_priv_version(env, PRIV_VERSION_1_10_0);
126
+ env->priv_ver = PRIV_VERSION_1_10_0;
127
cpu->cfg.mmu = false;
128
#ifndef CONFIG_USER_ONLY
129
set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
130
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
131
}
132
133
if (priv_version >= PRIV_VERSION_1_10_0) {
134
- set_priv_version(env, priv_version);
135
+ env->priv_ver = priv_version;
136
}
137
138
riscv_cpu_validate_misa_priv(env, &local_err);
139
--
291
--
140
2.40.1
292
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Rob Bradford <rbradford@rivosinc.com>
2
2
3
write_mstatus() can only change current xl when in debug mode.
3
These are WARL fields - zero out the bits for unavailable counters and
4
And we need update cur_pmmask/base in this case.
4
special case the TM bit in mcountinhibit which is hardwired to zero.
5
This patch achieves this by modifying the value written so that any use
6
of the field will see the correctly masked bits.
5
7
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
Tested by modifying OpenSBI to write max value to these CSRs and upon
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
9
subsequent read the appropriate number of bits for number of PMUs is
8
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
10
enabled and the TM bit is zero in mcountinhibit.
9
Message-Id: <20230524015933.17349-3-liweiwei@iscas.ac.cn>
11
12
Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
13
Acked-by: Alistair Francis <alistair.francis@wdc.com>
14
Reviewed-by: Atish Patra <atishp@rivosinc.com>
15
Message-ID: <20230802124906.24197-1-rbradford@rivosinc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
17
---
12
target/riscv/csr.c | 9 ++++++++-
18
target/riscv/csr.c | 11 +++++++++--
13
1 file changed, 8 insertions(+), 1 deletion(-)
19
1 file changed, 9 insertions(+), 2 deletions(-)
14
20
15
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
21
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/csr.c
23
--- a/target/riscv/csr.c
18
+++ b/target/riscv/csr.c
24
+++ b/target/riscv/csr.c
19
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno,
25
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mcountinhibit(CPURISCVState *env, int csrno,
20
mstatus = set_field(mstatus, MSTATUS64_SXL, xl);
26
{
21
}
27
int cidx;
22
env->mstatus = mstatus;
28
PMUCTRState *counter;
23
- env->xl = cpu_recompute_xl(env);
29
+ RISCVCPU *cpu = env_archcpu(env);
24
30
25
+ /*
31
- env->mcountinhibit = val;
26
+ * Except in debug mode, UXL/SXL can only be modified by higher
32
+ /* WARL register - disable unavailable counters; TM bit is always 0 */
27
+ * privilege mode. So xl will not be changed in normal mode.
33
+ env->mcountinhibit =
28
+ */
34
+ val & (cpu->pmu_avail_ctrs | COUNTEREN_CY | COUNTEREN_IR);
29
+ if (env->debugger) {
35
30
+ env->xl = cpu_recompute_xl(env);
36
/* Check if any other counter is also monitoring cycles/instructions */
31
+ riscv_cpu_update_mask(env);
37
for (cidx = 0; cidx < RV_MAX_MHPMCOUNTERS; cidx++) {
32
+ }
38
@@ -XXX,XX +XXX,XX @@ static RISCVException read_mcounteren(CPURISCVState *env, int csrno,
39
static RISCVException write_mcounteren(CPURISCVState *env, int csrno,
40
target_ulong val)
41
{
42
- env->mcounteren = val;
43
+ RISCVCPU *cpu = env_archcpu(env);
44
+
45
+ /* WARL register - disable unavailable counters */
46
+ env->mcounteren = val & (cpu->pmu_avail_ctrs | COUNTEREN_CY | COUNTEREN_TM |
47
+ COUNTEREN_IR);
33
return RISCV_EXCP_NONE;
48
return RISCV_EXCP_NONE;
34
}
49
}
35
50
36
--
51
--
37
2.40.1
52
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Jason Chien <jason.chien@sifive.com>
2
2
3
Using implicitly enabled extensions such as Zca/Zcf/Zcd instead of their
3
RVA23 Profiles states:
4
super extensions can simplify the extension related check. However, they
4
The RVA23 profiles are intended to be used for 64-bit application
5
may have higher priv version than their super extensions. So we should mask
5
processors that will run rich OS stacks from standard binary OS
6
them in the isa_string based on priv version to make them invisible to user
6
distributions and with a substantial number of third-party binary user
7
if the specified priv version is lower than their minimal priv version.
7
applications that will be supported over a considerable length of time
8
in the field.
8
9
9
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
10
The chapter 4 of the unprivileged spec introduces the Zihintntl extension
10
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
11
and Zihintntl is a mandatory extension presented in RVA23 Profiles, whose
11
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
12
purpose is to enable application and operating system portability across
12
Acked-by: Alistair Francis <alistair.francis@wdc.com>
13
different implementations. Thus the DTS should contain the Zihintntl ISA
13
Message-Id: <20230517135714.211809-6-dbarboza@ventanamicro.com>
14
string in order to pass to software.
15
16
The unprivileged spec states:
17
Like any HINTs, these instructions may be freely ignored. Hence, although
18
they are described in terms of cache-based memory hierarchies, they do not
19
mandate the provision of caches.
20
21
These instructions are encoded with non-used opcode, e.g. ADD x0, x0, x2,
22
which QEMU already supports, and QEMU does not emulate cache. Therefore
23
these instructions can be considered as a no-op, and we only need to add
24
a new property for the Zihintntl extension.
25
26
Reviewed-by: Frank Chang <frank.chang@sifive.com>
27
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
28
Signed-off-by: Jason Chien <jason.chien@sifive.com>
29
Message-ID: <20230726074049.19505-2-jason.chien@sifive.com>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
30
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
---
31
---
16
target/riscv/cpu.c | 3 ++-
32
target/riscv/cpu_cfg.h | 1 +
17
1 file changed, 2 insertions(+), 1 deletion(-)
33
target/riscv/cpu.c | 2 ++
34
2 files changed, 3 insertions(+)
18
35
36
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/riscv/cpu_cfg.h
39
+++ b/target/riscv/cpu_cfg.h
40
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
41
bool ext_icbom;
42
bool ext_icboz;
43
bool ext_zicond;
44
+ bool ext_zihintntl;
45
bool ext_zihintpause;
46
bool ext_smstateen;
47
bool ext_sstc;
19
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
48
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
20
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
21
--- a/target/riscv/cpu.c
50
--- a/target/riscv/cpu.c
22
+++ b/target/riscv/cpu.c
51
+++ b/target/riscv/cpu.c
23
@@ -XXX,XX +XXX,XX @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str,
52
@@ -XXX,XX +XXX,XX @@ static const struct isa_ext_data isa_edata_arr[] = {
24
int i;
53
ISA_EXT_DATA_ENTRY(zicond, PRIV_VERSION_1_12_0, ext_zicond),
25
54
ISA_EXT_DATA_ENTRY(zicsr, PRIV_VERSION_1_10_0, ext_icsr),
26
for (i = 0; i < ARRAY_SIZE(isa_edata_arr); i++) {
55
ISA_EXT_DATA_ENTRY(zifencei, PRIV_VERSION_1_10_0, ext_ifencei),
27
- if (isa_ext_is_enabled(cpu, &isa_edata_arr[i])) {
56
+ ISA_EXT_DATA_ENTRY(zihintntl, PRIV_VERSION_1_10_0, ext_zihintntl),
28
+ if (cpu->env.priv_ver >= isa_edata_arr[i].min_version &&
57
ISA_EXT_DATA_ENTRY(zihintpause, PRIV_VERSION_1_10_0, ext_zihintpause),
29
+ isa_ext_is_enabled(cpu, &isa_edata_arr[i])) {
58
ISA_EXT_DATA_ENTRY(zmmul, PRIV_VERSION_1_12_0, ext_zmmul),
30
new = g_strconcat(old, "_", isa_edata_arr[i].name, NULL);
59
ISA_EXT_DATA_ENTRY(zawrs, PRIV_VERSION_1_12_0, ext_zawrs),
31
g_free(old);
60
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
32
old = new;
61
DEFINE_PROP_BOOL("sscofpmf", RISCVCPU, cfg.ext_sscofpmf, false),
62
DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true),
63
DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true),
64
+ DEFINE_PROP_BOOL("Zihintntl", RISCVCPU, cfg.ext_zihintntl, true),
65
DEFINE_PROP_BOOL("Zihintpause", RISCVCPU, cfg.ext_zihintpause, true),
66
DEFINE_PROP_BOOL("Zawrs", RISCVCPU, cfg.ext_zawrs, true),
67
DEFINE_PROP_BOOL("Zfa", RISCVCPU, cfg.ext_zfa, true),
33
--
68
--
34
2.40.1
69
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
2
2
3
We initialize cur_pmmask as -1(UINT32_MAX/UINT64_MAX) and regard it
3
Commit a47842d ("riscv: Add support for the Zfa extension") implemented the zfa extension.
4
as if pointer mask is disabled in current implementation. However,
4
However, it has some typos for fleq.d and fltq.d. Both of them misused the fltq.s
5
the addresses for vector load/store will be adjusted to zero in this
5
helper function.
6
case and -1(UINT32_MAX/UINT64_MAX) is valid value for pmmask when
7
pointer mask is enabled.
8
6
9
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Fixes: a47842d ("riscv: Add support for the Zfa extension")
10
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Signed-off-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
11
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
9
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
12
Message-Id: <20230610094651.43786-1-liweiwei@iscas.ac.cn>
10
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
11
Message-ID: <20230728003906.768-1-zhiwei_liu@linux.alibaba.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
13
---
15
target/riscv/cpu_helper.c | 4 ++--
14
target/riscv/insn_trans/trans_rvzfa.c.inc | 4 ++--
16
1 file changed, 2 insertions(+), 2 deletions(-)
15
1 file changed, 2 insertions(+), 2 deletions(-)
17
16
18
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
17
diff --git a/target/riscv/insn_trans/trans_rvzfa.c.inc b/target/riscv/insn_trans/trans_rvzfa.c.inc
19
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
20
--- a/target/riscv/cpu_helper.c
19
--- a/target/riscv/insn_trans/trans_rvzfa.c.inc
21
+++ b/target/riscv/cpu_helper.c
20
+++ b/target/riscv/insn_trans/trans_rvzfa.c.inc
22
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
21
@@ -XXX,XX +XXX,XX @@ bool trans_fleq_d(DisasContext *ctx, arg_fleq_d *a)
23
flags = FIELD_DP32(flags, TB_FLAGS, FS, fs);
22
TCGv_i64 src1 = get_fpr_hs(ctx, a->rs1);
24
flags = FIELD_DP32(flags, TB_FLAGS, VS, vs);
23
TCGv_i64 src2 = get_fpr_hs(ctx, a->rs2);
25
flags = FIELD_DP32(flags, TB_FLAGS, XL, env->xl);
24
26
- if (env->cur_pmmask < (env->xl == MXL_RV32 ? UINT32_MAX : UINT64_MAX)) {
25
- gen_helper_fltq_s(dest, cpu_env, src1, src2);
27
+ if (env->cur_pmmask != 0) {
26
+ gen_helper_fleq_d(dest, cpu_env, src1, src2);
28
flags = FIELD_DP32(flags, TB_FLAGS, PM_MASK_ENABLED, 1);
27
gen_set_gpr(ctx, a->rd, dest);
29
}
28
return true;
30
if (env->cur_pmbase != 0) {
29
}
31
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
30
@@ -XXX,XX +XXX,XX @@ bool trans_fltq_d(DisasContext *ctx, arg_fltq_d *a)
32
31
TCGv_i64 src1 = get_fpr_hs(ctx, a->rs1);
33
void riscv_cpu_update_mask(CPURISCVState *env)
32
TCGv_i64 src2 = get_fpr_hs(ctx, a->rs2);
34
{
33
35
- target_ulong mask = -1, base = 0;
34
- gen_helper_fltq_s(dest, cpu_env, src1, src2);
36
+ target_ulong mask = 0, base = 0;
35
+ gen_helper_fltq_d(dest, cpu_env, src1, src2);
37
/*
36
gen_set_gpr(ctx, a->rd, dest);
38
* TODO: Current RVJ spec does not specify
37
return true;
39
* how the extension interacts with XLEN.
38
}
40
--
39
--
41
2.40.1
40
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Jason Chien <jason.chien@sifive.com>
2
2
3
pc_succ_insn is no longer useful after the introduce of cur_insn_len
3
When writing the upper mtime, we should keep the original lower mtime
4
and all pc related value use diff value instead of absolute value.
4
whose value is given by cpu_riscv_read_rtc() instead of
5
cpu_riscv_read_rtc_raw(). The same logic applies to writes to lower mtime.
5
6
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Jason Chien <jason.chien@sifive.com>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-Id: <20230526072124.298466-8-liweiwei@iscas.ac.cn>
9
Message-ID: <20230728082502.26439-1-jason.chien@sifive.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
11
---
13
target/riscv/translate.c | 7 +------
12
hw/intc/riscv_aclint.c | 5 +++--
14
1 file changed, 1 insertion(+), 6 deletions(-)
13
1 file changed, 3 insertions(+), 2 deletions(-)
15
14
16
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
15
diff --git a/hw/intc/riscv_aclint.c b/hw/intc/riscv_aclint.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/translate.c
17
--- a/hw/intc/riscv_aclint.c
19
+++ b/target/riscv/translate.c
18
+++ b/hw/intc/riscv_aclint.c
20
@@ -XXX,XX +XXX,XX @@ typedef enum {
19
@@ -XXX,XX +XXX,XX @@ static void riscv_aclint_mtimer_write(void *opaque, hwaddr addr,
21
20
return;
22
typedef struct DisasContext {
21
} else if (addr == mtimer->time_base || addr == mtimer->time_base + 4) {
23
DisasContextBase base;
22
uint64_t rtc_r = cpu_riscv_read_rtc_raw(mtimer->timebase_freq);
24
- /* pc_succ_insn points to the instruction following base.pc_next */
23
+ uint64_t rtc = cpu_riscv_read_rtc(mtimer);
25
- target_ulong pc_succ_insn;
24
26
target_ulong cur_insn_len;
25
if (addr == mtimer->time_base) {
27
target_ulong pc_save;
26
if (size == 4) {
28
target_ulong priv_ver;
27
/* time_lo for RV32/RV64 */
29
@@ -XXX,XX +XXX,XX @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
28
- mtimer->time_delta = ((rtc_r & ~0xFFFFFFFFULL) | value) - rtc_r;
30
/* Check for compressed insn */
29
+ mtimer->time_delta = ((rtc & ~0xFFFFFFFFULL) | value) - rtc_r;
31
if (ctx->cur_insn_len == 2) {
30
} else {
32
ctx->opcode = opcode;
31
/* time for RV64 */
33
- ctx->pc_succ_insn = ctx->base.pc_next + 2;
32
mtimer->time_delta = value - rtc_r;
34
/*
33
@@ -XXX,XX +XXX,XX @@ static void riscv_aclint_mtimer_write(void *opaque, hwaddr addr,
35
* The Zca extension is added as way to refer to instructions in the C
34
} else {
36
* extension that do not include the floating-point loads and stores
35
if (size == 4) {
37
@@ -XXX,XX +XXX,XX @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
36
/* time_hi for RV32/RV64 */
38
translator_lduw(env, &ctx->base,
37
- mtimer->time_delta = (value << 32 | (rtc_r & 0xFFFFFFFF)) - rtc_r;
39
ctx->base.pc_next + 2));
38
+ mtimer->time_delta = (value << 32 | (rtc & 0xFFFFFFFF)) - rtc_r;
40
ctx->opcode = opcode32;
39
} else {
41
- ctx->pc_succ_insn = ctx->base.pc_next + 4;
40
qemu_log_mask(LOG_GUEST_ERROR,
42
41
"aclint-mtimer: invalid time_hi write: %08x",
43
for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i) {
44
if (decoders[i].guard_func(ctx) &&
45
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
46
uint32_t tb_flags = ctx->base.tb->flags;
47
48
ctx->pc_save = ctx->base.pc_first;
49
- ctx->pc_succ_insn = ctx->base.pc_first;
50
ctx->priv = FIELD_EX32(tb_flags, TB_FLAGS, PRIV);
51
ctx->mem_idx = FIELD_EX32(tb_flags, TB_FLAGS, MEM_IDX);
52
ctx->mstatus_fs = FIELD_EX32(tb_flags, TB_FLAGS, FS);
53
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
54
55
ctx->ol = ctx->xl;
56
decode_opc(env, ctx, opcode16);
57
- ctx->base.pc_next = ctx->pc_succ_insn;
58
+ ctx->base.pc_next += ctx->cur_insn_len;
59
60
/* Only the first insn within a TB is allowed to cross a page boundary. */
61
if (ctx->base.is_jmp == DISAS_NEXT) {
62
--
42
--
63
2.40.1
43
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Jason Chien <jason.chien@sifive.com>
2
2
3
Reduce reliance on absolute value to prepare for PC-relative translation.
3
The variables whose values are given by cpu_riscv_read_rtc() should be named
4
"rtc". The variables whose value are given by cpu_riscv_read_rtc_raw()
5
should be named "rtc_r".
4
6
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Jason Chien <jason.chien@sifive.com>
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <20230526072124.298466-4-liweiwei@iscas.ac.cn>
9
Message-ID: <20230728082502.26439-2-jason.chien@sifive.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
11
---
12
target/riscv/translate.c | 8 +++++---
12
hw/intc/riscv_aclint.c | 6 +++---
13
target/riscv/insn_trans/trans_rvi.c.inc | 4 ++--
13
1 file changed, 3 insertions(+), 3 deletions(-)
14
2 files changed, 7 insertions(+), 5 deletions(-)
15
14
16
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
15
diff --git a/hw/intc/riscv_aclint.c b/hw/intc/riscv_aclint.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/translate.c
17
--- a/hw/intc/riscv_aclint.c
19
+++ b/target/riscv/translate.c
18
+++ b/hw/intc/riscv_aclint.c
20
@@ -XXX,XX +XXX,XX @@ static void exit_tb(DisasContext *ctx)
19
@@ -XXX,XX +XXX,XX @@ static void riscv_aclint_mtimer_write_timecmp(RISCVAclintMTimerState *mtimer,
21
tcg_gen_exit_tb(NULL, 0);
20
uint64_t next;
22
}
21
uint64_t diff;
23
22
24
-static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
23
- uint64_t rtc_r = cpu_riscv_read_rtc(mtimer);
25
+static void gen_goto_tb(DisasContext *ctx, int n, target_long diff)
24
+ uint64_t rtc = cpu_riscv_read_rtc(mtimer);
26
{
25
27
+ target_ulong dest = ctx->base.pc_next + diff;
26
/* Compute the relative hartid w.r.t the socket */
28
+
27
hartid = hartid - mtimer->hartid_base;
29
/*
28
30
* Under itrigger, instruction executes one by one like singlestep,
29
mtimer->timecmp[hartid] = value;
31
* direct block chain benefits will be small.
30
- if (mtimer->timecmp[hartid] <= rtc_r) {
32
@@ -XXX,XX +XXX,XX @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
31
+ if (mtimer->timecmp[hartid] <= rtc) {
33
}
32
/*
34
33
* If we're setting an MTIMECMP value in the "past",
35
gen_set_gpri(ctx, rd, ctx->pc_succ_insn);
34
* immediately raise the timer interrupt
36
- gen_goto_tb(ctx, 0, ctx->base.pc_next + imm); /* must use this for safety */
35
@@ -XXX,XX +XXX,XX @@ static void riscv_aclint_mtimer_write_timecmp(RISCVAclintMTimerState *mtimer,
37
+ gen_goto_tb(ctx, 0, imm); /* must use this for safety */
36
38
ctx->base.is_jmp = DISAS_NORETURN;
37
/* otherwise, set up the future timer interrupt */
39
}
38
qemu_irq_lower(mtimer->timer_irqs[hartid]);
40
39
- diff = mtimer->timecmp[hartid] - rtc_r;
41
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
40
+ diff = mtimer->timecmp[hartid] - rtc;
42
41
/* back to ns (note args switched in muldiv64) */
43
switch (ctx->base.is_jmp) {
42
uint64_t ns_diff = muldiv64(diff, NANOSECONDS_PER_SECOND, timebase_freq);
44
case DISAS_TOO_MANY:
45
- gen_goto_tb(ctx, 0, ctx->base.pc_next);
46
+ gen_goto_tb(ctx, 0, 0);
47
break;
48
case DISAS_NORETURN:
49
break;
50
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/riscv/insn_trans/trans_rvi.c.inc
53
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
54
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
55
} else {
56
tcg_gen_brcond_tl(cond, src1, src2, l);
57
}
58
- gen_goto_tb(ctx, 1, ctx->pc_succ_insn);
59
+ gen_goto_tb(ctx, 1, ctx->cur_insn_len);
60
61
gen_set_label(l); /* branch taken */
62
63
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
64
gen_pc_plus_diff(target_pc, ctx, next_pc);
65
gen_exception_inst_addr_mis(ctx, target_pc);
66
} else {
67
- gen_goto_tb(ctx, 0, ctx->base.pc_next + a->imm);
68
+ gen_goto_tb(ctx, 0, a->imm);
69
}
70
ctx->base.is_jmp = DISAS_NORETURN;
71
43
72
--
44
--
73
2.40.1
45
2.41.0
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
2
2
3
Expand the DEFINE_MACHINE() macro, converting the class_init()
3
We should not use types dependend on host arch for target_ucontext.
4
handler.
4
This bug is found when run rv32 applications.
5
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Signed-off-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
9
Message-Id: <20230520054510.68822-5-philmd@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Message-ID: <20230811055438.1945-1-zhiwei_liu@linux.alibaba.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
---
12
include/hw/riscv/opentitan.h | 3 ++-
13
linux-user/riscv/signal.c | 4 ++--
13
hw/riscv/opentitan.c | 10 +++++++---
14
1 file changed, 2 insertions(+), 2 deletions(-)
14
2 files changed, 9 insertions(+), 4 deletions(-)
15
15
16
diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h
16
diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/riscv/opentitan.h
18
--- a/linux-user/riscv/signal.c
19
+++ b/include/hw/riscv/opentitan.h
19
+++ b/linux-user/riscv/signal.c
20
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ struct target_sigcontext {
21
#include "hw/char/ibex_uart.h"
21
}; /* cf. riscv-linux:arch/riscv/include/uapi/asm/ptrace.h */
22
#include "hw/timer/ibex_timer.h"
22
23
#include "hw/ssi/ibex_spi_host.h"
23
struct target_ucontext {
24
+#include "hw/boards.h"
24
- unsigned long uc_flags;
25
#include "qom/object.h"
25
- struct target_ucontext *uc_link;
26
26
+ abi_ulong uc_flags;
27
#define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc"
27
+ abi_ptr uc_link;
28
@@ -XXX,XX +XXX,XX @@ struct LowRISCIbexSoCState {
28
target_stack_t uc_stack;
29
MemoryRegion flash_alias;
29
target_sigset_t uc_sigmask;
30
};
30
uint8_t __unused[1024 / 8 - sizeof(target_sigset_t)];
31
32
-#define TYPE_OPENTITAN_MACHINE "opentitan"
33
+#define TYPE_OPENTITAN_MACHINE MACHINE_TYPE_NAME("opentitan")
34
35
typedef struct OpenTitanState {
36
/*< private >*/
37
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/riscv/opentitan.c
40
+++ b/hw/riscv/opentitan.c
41
@@ -XXX,XX +XXX,XX @@ static void opentitan_machine_init(MachineState *machine)
42
}
43
}
44
45
-static void opentitan_machine_class_init(MachineClass *mc)
46
+static void opentitan_machine_class_init(ObjectClass *oc, void *data)
47
{
48
+ MachineClass *mc = MACHINE_CLASS(oc);
49
+
50
mc->desc = "RISC-V Board compatible with OpenTitan";
51
mc->init = opentitan_machine_init;
52
mc->max_cpus = 1;
53
@@ -XXX,XX +XXX,XX @@ static void opentitan_machine_class_init(MachineClass *mc)
54
mc->default_ram_size = ibex_memmap[IBEX_DEV_RAM].size;
55
}
56
57
-DEFINE_MACHINE(TYPE_OPENTITAN_MACHINE, opentitan_machine_class_init)
58
-
59
static void lowrisc_ibex_soc_init(Object *obj)
60
{
61
LowRISCIbexSoCState *s = RISCV_IBEX_SOC(obj);
62
@@ -XXX,XX +XXX,XX @@ static const TypeInfo open_titan_types[] = {
63
.instance_size = sizeof(LowRISCIbexSoCState),
64
.instance_init = lowrisc_ibex_soc_init,
65
.class_init = lowrisc_ibex_soc_class_init,
66
+ }, {
67
+ .name = TYPE_OPENTITAN_MACHINE,
68
+ .parent = TYPE_MACHINE,
69
+ .class_init = opentitan_machine_class_init,
70
}
71
};
72
73
--
31
--
74
2.40.1
32
2.41.0
75
33
76
34
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Yong-Xuan Wang <yongxuan.wang@sifive.com>
2
2
3
Compute the target address before storing it into badaddr
3
In this patch, we create the APLIC and IMSIC FDT helper functions and
4
when mis-aligned exception is triggered.
4
remove M mode AIA devices when using KVM acceleration.
5
Use a target_pc temp to store the target address to avoid
6
the confusing operation that udpate target address into
7
cpu_pc before misalign check, then update it into badaddr
8
and restore cpu_pc to current pc if exception is triggered.
9
5
10
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
6
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
11
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
Reviewed-by: Jim Shu <jim.shu@sifive.com>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
14
Message-Id: <20230526072124.298466-2-liweiwei@iscas.ac.cn>
10
Message-ID: <20230727102439.22554-2-yongxuan.wang@sifive.com>
15
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
---
12
---
17
target/riscv/translate.c | 21 ++++++++++-----------
13
hw/riscv/virt.c | 290 +++++++++++++++++++++++-------------------------
18
target/riscv/insn_trans/trans_rvi.c.inc | 23 ++++++++++++++++-------
14
1 file changed, 137 insertions(+), 153 deletions(-)
19
target/riscv/insn_trans/trans_rvzce.c.inc | 4 ++--
20
3 files changed, 28 insertions(+), 20 deletions(-)
21
15
22
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
16
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
23
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
24
--- a/target/riscv/translate.c
18
--- a/hw/riscv/virt.c
25
+++ b/target/riscv/translate.c
19
+++ b/hw/riscv/virt.c
26
@@ -XXX,XX +XXX,XX @@ static void decode_save_opc(DisasContext *ctx)
20
@@ -XXX,XX +XXX,XX @@ static uint32_t imsic_num_bits(uint32_t count)
27
ctx->insn_start = NULL;
21
return ret;
28
}
22
}
29
23
30
-static void gen_set_pc_imm(DisasContext *ctx, target_ulong dest)
24
-static void create_fdt_imsic(RISCVVirtState *s, const MemMapEntry *memmap,
31
+static void gen_pc_plus_diff(TCGv target, DisasContext *ctx,
25
- uint32_t *phandle, uint32_t *intc_phandles,
32
+ target_ulong dest)
26
- uint32_t *msi_m_phandle, uint32_t *msi_s_phandle)
27
+static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr,
28
+ uint32_t *intc_phandles, uint32_t msi_phandle,
29
+ bool m_mode, uint32_t imsic_guest_bits)
33
{
30
{
34
if (get_xl(ctx) == MXL_RV32) {
31
int cpu, socket;
35
dest = (int32_t)dest;
32
char *imsic_name;
36
}
33
MachineState *ms = MACHINE(s);
37
- tcg_gen_movi_tl(cpu_pc, dest);
34
int socket_count = riscv_socket_count(ms);
38
+ tcg_gen_movi_tl(target, dest);
35
- uint32_t imsic_max_hart_per_socket, imsic_guest_bits;
36
+ uint32_t imsic_max_hart_per_socket;
37
uint32_t *imsic_cells, *imsic_regs, imsic_addr, imsic_size;
38
39
- *msi_m_phandle = (*phandle)++;
40
- *msi_s_phandle = (*phandle)++;
41
imsic_cells = g_new0(uint32_t, ms->smp.cpus * 2);
42
imsic_regs = g_new0(uint32_t, socket_count * 4);
43
44
- /* M-level IMSIC node */
45
for (cpu = 0; cpu < ms->smp.cpus; cpu++) {
46
imsic_cells[cpu * 2 + 0] = cpu_to_be32(intc_phandles[cpu]);
47
- imsic_cells[cpu * 2 + 1] = cpu_to_be32(IRQ_M_EXT);
48
+ imsic_cells[cpu * 2 + 1] = cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_S_EXT);
49
}
50
- imsic_max_hart_per_socket = 0;
51
- for (socket = 0; socket < socket_count; socket++) {
52
- imsic_addr = memmap[VIRT_IMSIC_M].base +
53
- socket * VIRT_IMSIC_GROUP_MAX_SIZE;
54
- imsic_size = IMSIC_HART_SIZE(0) * s->soc[socket].num_harts;
55
- imsic_regs[socket * 4 + 0] = 0;
56
- imsic_regs[socket * 4 + 1] = cpu_to_be32(imsic_addr);
57
- imsic_regs[socket * 4 + 2] = 0;
58
- imsic_regs[socket * 4 + 3] = cpu_to_be32(imsic_size);
59
- if (imsic_max_hart_per_socket < s->soc[socket].num_harts) {
60
- imsic_max_hart_per_socket = s->soc[socket].num_harts;
61
- }
62
- }
63
- imsic_name = g_strdup_printf("/soc/imsics@%lx",
64
- (unsigned long)memmap[VIRT_IMSIC_M].base);
65
- qemu_fdt_add_subnode(ms->fdt, imsic_name);
66
- qemu_fdt_setprop_string(ms->fdt, imsic_name, "compatible",
67
- "riscv,imsics");
68
- qemu_fdt_setprop_cell(ms->fdt, imsic_name, "#interrupt-cells",
69
- FDT_IMSIC_INT_CELLS);
70
- qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller",
71
- NULL, 0);
72
- qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller",
73
- NULL, 0);
74
- qemu_fdt_setprop(ms->fdt, imsic_name, "interrupts-extended",
75
- imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2);
76
- qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs,
77
- socket_count * sizeof(uint32_t) * 4);
78
- qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,num-ids",
79
- VIRT_IRQCHIP_NUM_MSIS);
80
- if (socket_count > 1) {
81
- qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,hart-index-bits",
82
- imsic_num_bits(imsic_max_hart_per_socket));
83
- qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,group-index-bits",
84
- imsic_num_bits(socket_count));
85
- qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,group-index-shift",
86
- IMSIC_MMIO_GROUP_MIN_SHIFT);
87
- }
88
- qemu_fdt_setprop_cell(ms->fdt, imsic_name, "phandle", *msi_m_phandle);
89
-
90
- g_free(imsic_name);
91
92
- /* S-level IMSIC node */
93
- for (cpu = 0; cpu < ms->smp.cpus; cpu++) {
94
- imsic_cells[cpu * 2 + 0] = cpu_to_be32(intc_phandles[cpu]);
95
- imsic_cells[cpu * 2 + 1] = cpu_to_be32(IRQ_S_EXT);
96
- }
97
- imsic_guest_bits = imsic_num_bits(s->aia_guests + 1);
98
imsic_max_hart_per_socket = 0;
99
for (socket = 0; socket < socket_count; socket++) {
100
- imsic_addr = memmap[VIRT_IMSIC_S].base +
101
- socket * VIRT_IMSIC_GROUP_MAX_SIZE;
102
+ imsic_addr = base_addr + socket * VIRT_IMSIC_GROUP_MAX_SIZE;
103
imsic_size = IMSIC_HART_SIZE(imsic_guest_bits) *
104
s->soc[socket].num_harts;
105
imsic_regs[socket * 4 + 0] = 0;
106
@@ -XXX,XX +XXX,XX @@ static void create_fdt_imsic(RISCVVirtState *s, const MemMapEntry *memmap,
107
imsic_max_hart_per_socket = s->soc[socket].num_harts;
108
}
109
}
110
- imsic_name = g_strdup_printf("/soc/imsics@%lx",
111
- (unsigned long)memmap[VIRT_IMSIC_S].base);
112
+
113
+ imsic_name = g_strdup_printf("/soc/imsics@%lx", (unsigned long)base_addr);
114
qemu_fdt_add_subnode(ms->fdt, imsic_name);
115
- qemu_fdt_setprop_string(ms->fdt, imsic_name, "compatible",
116
- "riscv,imsics");
117
+ qemu_fdt_setprop_string(ms->fdt, imsic_name, "compatible", "riscv,imsics");
118
qemu_fdt_setprop_cell(ms->fdt, imsic_name, "#interrupt-cells",
119
- FDT_IMSIC_INT_CELLS);
120
- qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller",
121
- NULL, 0);
122
- qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller",
123
- NULL, 0);
124
+ FDT_IMSIC_INT_CELLS);
125
+ qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", NULL, 0);
126
+ qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller", NULL, 0);
127
qemu_fdt_setprop(ms->fdt, imsic_name, "interrupts-extended",
128
- imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2);
129
+ imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2);
130
qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs,
131
- socket_count * sizeof(uint32_t) * 4);
132
+ socket_count * sizeof(uint32_t) * 4);
133
qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,num-ids",
134
- VIRT_IRQCHIP_NUM_MSIS);
135
+ VIRT_IRQCHIP_NUM_MSIS);
136
+
137
if (imsic_guest_bits) {
138
qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,guest-index-bits",
139
- imsic_guest_bits);
140
+ imsic_guest_bits);
141
}
142
+
143
if (socket_count > 1) {
144
qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,hart-index-bits",
145
- imsic_num_bits(imsic_max_hart_per_socket));
146
+ imsic_num_bits(imsic_max_hart_per_socket));
147
qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,group-index-bits",
148
- imsic_num_bits(socket_count));
149
+ imsic_num_bits(socket_count));
150
qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,group-index-shift",
151
- IMSIC_MMIO_GROUP_MIN_SHIFT);
152
+ IMSIC_MMIO_GROUP_MIN_SHIFT);
153
}
154
- qemu_fdt_setprop_cell(ms->fdt, imsic_name, "phandle", *msi_s_phandle);
155
- g_free(imsic_name);
156
+ qemu_fdt_setprop_cell(ms->fdt, imsic_name, "phandle", msi_phandle);
157
158
+ g_free(imsic_name);
159
g_free(imsic_regs);
160
g_free(imsic_cells);
39
}
161
}
40
162
41
-static void gen_set_pc(DisasContext *ctx, TCGv dest)
163
-static void create_fdt_socket_aplic(RISCVVirtState *s,
42
+static void gen_set_pc_imm(DisasContext *ctx, target_ulong dest)
164
- const MemMapEntry *memmap, int socket,
165
- uint32_t msi_m_phandle,
166
- uint32_t msi_s_phandle,
167
- uint32_t *phandle,
168
- uint32_t *intc_phandles,
169
- uint32_t *aplic_phandles)
170
+static void create_fdt_imsic(RISCVVirtState *s, const MemMapEntry *memmap,
171
+ uint32_t *phandle, uint32_t *intc_phandles,
172
+ uint32_t *msi_m_phandle, uint32_t *msi_s_phandle)
173
+{
174
+ *msi_m_phandle = (*phandle)++;
175
+ *msi_s_phandle = (*phandle)++;
176
+
177
+ if (!kvm_enabled()) {
178
+ /* M-level IMSIC node */
179
+ create_fdt_one_imsic(s, memmap[VIRT_IMSIC_M].base, intc_phandles,
180
+ *msi_m_phandle, true, 0);
181
+ }
182
+
183
+ /* S-level IMSIC node */
184
+ create_fdt_one_imsic(s, memmap[VIRT_IMSIC_S].base, intc_phandles,
185
+ *msi_s_phandle, false,
186
+ imsic_num_bits(s->aia_guests + 1));
187
+
188
+}
189
+
190
+static void create_fdt_one_aplic(RISCVVirtState *s, int socket,
191
+ unsigned long aplic_addr, uint32_t aplic_size,
192
+ uint32_t msi_phandle,
193
+ uint32_t *intc_phandles,
194
+ uint32_t aplic_phandle,
195
+ uint32_t aplic_child_phandle,
196
+ bool m_mode)
43
{
197
{
44
- if (get_xl(ctx) == MXL_RV32) {
198
int cpu;
45
- tcg_gen_ext32s_tl(cpu_pc, dest);
199
char *aplic_name;
200
uint32_t *aplic_cells;
201
- unsigned long aplic_addr;
202
MachineState *ms = MACHINE(s);
203
- uint32_t aplic_m_phandle, aplic_s_phandle;
204
205
- aplic_m_phandle = (*phandle)++;
206
- aplic_s_phandle = (*phandle)++;
207
aplic_cells = g_new0(uint32_t, s->soc[socket].num_harts * 2);
208
209
- /* M-level APLIC node */
210
for (cpu = 0; cpu < s->soc[socket].num_harts; cpu++) {
211
aplic_cells[cpu * 2 + 0] = cpu_to_be32(intc_phandles[cpu]);
212
- aplic_cells[cpu * 2 + 1] = cpu_to_be32(IRQ_M_EXT);
213
+ aplic_cells[cpu * 2 + 1] = cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_S_EXT);
214
}
215
- aplic_addr = memmap[VIRT_APLIC_M].base +
216
- (memmap[VIRT_APLIC_M].size * socket);
217
+
218
aplic_name = g_strdup_printf("/soc/aplic@%lx", aplic_addr);
219
qemu_fdt_add_subnode(ms->fdt, aplic_name);
220
qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,aplic");
221
qemu_fdt_setprop_cell(ms->fdt, aplic_name,
222
- "#interrupt-cells", FDT_APLIC_INT_CELLS);
223
+ "#interrupt-cells", FDT_APLIC_INT_CELLS);
224
qemu_fdt_setprop(ms->fdt, aplic_name, "interrupt-controller", NULL, 0);
225
+
226
if (s->aia_type == VIRT_AIA_TYPE_APLIC) {
227
qemu_fdt_setprop(ms->fdt, aplic_name, "interrupts-extended",
228
- aplic_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 2);
229
+ aplic_cells,
230
+ s->soc[socket].num_harts * sizeof(uint32_t) * 2);
231
} else {
232
- qemu_fdt_setprop_cell(ms->fdt, aplic_name, "msi-parent",
233
- msi_m_phandle);
234
+ qemu_fdt_setprop_cell(ms->fdt, aplic_name, "msi-parent", msi_phandle);
235
}
236
+
237
qemu_fdt_setprop_cells(ms->fdt, aplic_name, "reg",
238
- 0x0, aplic_addr, 0x0, memmap[VIRT_APLIC_M].size);
239
+ 0x0, aplic_addr, 0x0, aplic_size);
240
qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,num-sources",
241
- VIRT_IRQCHIP_NUM_SOURCES);
242
- qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,children",
243
- aplic_s_phandle);
244
- qemu_fdt_setprop_cells(ms->fdt, aplic_name, "riscv,delegate",
245
- aplic_s_phandle, 0x1, VIRT_IRQCHIP_NUM_SOURCES);
246
+ VIRT_IRQCHIP_NUM_SOURCES);
247
+
248
+ if (aplic_child_phandle) {
249
+ qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,children",
250
+ aplic_child_phandle);
251
+ qemu_fdt_setprop_cells(ms->fdt, aplic_name, "riscv,delegate",
252
+ aplic_child_phandle, 0x1,
253
+ VIRT_IRQCHIP_NUM_SOURCES);
254
+ }
255
+
256
riscv_socket_fdt_write_id(ms, aplic_name, socket);
257
- qemu_fdt_setprop_cell(ms->fdt, aplic_name, "phandle", aplic_m_phandle);
258
+ qemu_fdt_setprop_cell(ms->fdt, aplic_name, "phandle", aplic_phandle);
259
+
260
g_free(aplic_name);
261
+ g_free(aplic_cells);
262
+}
263
264
- /* S-level APLIC node */
265
- for (cpu = 0; cpu < s->soc[socket].num_harts; cpu++) {
266
- aplic_cells[cpu * 2 + 0] = cpu_to_be32(intc_phandles[cpu]);
267
- aplic_cells[cpu * 2 + 1] = cpu_to_be32(IRQ_S_EXT);
268
+static void create_fdt_socket_aplic(RISCVVirtState *s,
269
+ const MemMapEntry *memmap, int socket,
270
+ uint32_t msi_m_phandle,
271
+ uint32_t msi_s_phandle,
272
+ uint32_t *phandle,
273
+ uint32_t *intc_phandles,
274
+ uint32_t *aplic_phandles)
275
+{
276
+ char *aplic_name;
277
+ unsigned long aplic_addr;
278
+ MachineState *ms = MACHINE(s);
279
+ uint32_t aplic_m_phandle, aplic_s_phandle;
280
+
281
+ aplic_m_phandle = (*phandle)++;
282
+ aplic_s_phandle = (*phandle)++;
283
+
284
+ if (!kvm_enabled()) {
285
+ /* M-level APLIC node */
286
+ aplic_addr = memmap[VIRT_APLIC_M].base +
287
+ (memmap[VIRT_APLIC_M].size * socket);
288
+ create_fdt_one_aplic(s, socket, aplic_addr, memmap[VIRT_APLIC_M].size,
289
+ msi_m_phandle, intc_phandles,
290
+ aplic_m_phandle, aplic_s_phandle,
291
+ true);
292
}
293
+
294
+ /* S-level APLIC node */
295
aplic_addr = memmap[VIRT_APLIC_S].base +
296
(memmap[VIRT_APLIC_S].size * socket);
297
+ create_fdt_one_aplic(s, socket, aplic_addr, memmap[VIRT_APLIC_S].size,
298
+ msi_s_phandle, intc_phandles,
299
+ aplic_s_phandle, 0,
300
+ false);
301
+
302
aplic_name = g_strdup_printf("/soc/aplic@%lx", aplic_addr);
303
- qemu_fdt_add_subnode(ms->fdt, aplic_name);
304
- qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,aplic");
305
- qemu_fdt_setprop_cell(ms->fdt, aplic_name,
306
- "#interrupt-cells", FDT_APLIC_INT_CELLS);
307
- qemu_fdt_setprop(ms->fdt, aplic_name, "interrupt-controller", NULL, 0);
308
- if (s->aia_type == VIRT_AIA_TYPE_APLIC) {
309
- qemu_fdt_setprop(ms->fdt, aplic_name, "interrupts-extended",
310
- aplic_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 2);
46
- } else {
311
- } else {
47
- tcg_gen_mov_tl(cpu_pc, dest);
312
- qemu_fdt_setprop_cell(ms->fdt, aplic_name, "msi-parent",
313
- msi_s_phandle);
48
- }
314
- }
49
+ gen_pc_plus_diff(cpu_pc, ctx, dest);
315
- qemu_fdt_setprop_cells(ms->fdt, aplic_name, "reg",
316
- 0x0, aplic_addr, 0x0, memmap[VIRT_APLIC_S].size);
317
- qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,num-sources",
318
- VIRT_IRQCHIP_NUM_SOURCES);
319
- riscv_socket_fdt_write_id(ms, aplic_name, socket);
320
- qemu_fdt_setprop_cell(ms->fdt, aplic_name, "phandle", aplic_s_phandle);
321
322
if (!socket) {
323
platform_bus_add_all_fdt_nodes(ms->fdt, aplic_name,
324
@@ -XXX,XX +XXX,XX @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
325
326
g_free(aplic_name);
327
328
- g_free(aplic_cells);
329
aplic_phandles[socket] = aplic_s_phandle;
50
}
330
}
51
331
52
static void generate_exception(DisasContext *ctx, int excp)
332
@@ -XXX,XX +XXX,XX @@ static DeviceState *virt_create_aia(RISCVVirtAIAType aia_type, int aia_guests,
53
@@ -XXX,XX +XXX,XX @@ static void gen_exception_illegal(DisasContext *ctx)
333
int i;
54
}
334
hwaddr addr;
335
uint32_t guest_bits;
336
- DeviceState *aplic_m;
337
- bool msimode = (aia_type == VIRT_AIA_TYPE_APLIC_IMSIC) ? true : false;
338
+ DeviceState *aplic_s = NULL;
339
+ DeviceState *aplic_m = NULL;
340
+ bool msimode = aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
341
342
if (msimode) {
343
- /* Per-socket M-level IMSICs */
344
- addr = memmap[VIRT_IMSIC_M].base + socket * VIRT_IMSIC_GROUP_MAX_SIZE;
345
- for (i = 0; i < hart_count; i++) {
346
- riscv_imsic_create(addr + i * IMSIC_HART_SIZE(0),
347
- base_hartid + i, true, 1,
348
- VIRT_IRQCHIP_NUM_MSIS);
349
+ if (!kvm_enabled()) {
350
+ /* Per-socket M-level IMSICs */
351
+ addr = memmap[VIRT_IMSIC_M].base +
352
+ socket * VIRT_IMSIC_GROUP_MAX_SIZE;
353
+ for (i = 0; i < hart_count; i++) {
354
+ riscv_imsic_create(addr + i * IMSIC_HART_SIZE(0),
355
+ base_hartid + i, true, 1,
356
+ VIRT_IRQCHIP_NUM_MSIS);
357
+ }
358
}
359
360
/* Per-socket S-level IMSICs */
361
@@ -XXX,XX +XXX,XX @@ static DeviceState *virt_create_aia(RISCVVirtAIAType aia_type, int aia_guests,
362
}
363
}
364
365
- /* Per-socket M-level APLIC */
366
- aplic_m = riscv_aplic_create(
367
- memmap[VIRT_APLIC_M].base + socket * memmap[VIRT_APLIC_M].size,
368
- memmap[VIRT_APLIC_M].size,
369
- (msimode) ? 0 : base_hartid,
370
- (msimode) ? 0 : hart_count,
371
- VIRT_IRQCHIP_NUM_SOURCES,
372
- VIRT_IRQCHIP_NUM_PRIO_BITS,
373
- msimode, true, NULL);
374
-
375
- if (aplic_m) {
376
- /* Per-socket S-level APLIC */
377
- riscv_aplic_create(
378
- memmap[VIRT_APLIC_S].base + socket * memmap[VIRT_APLIC_S].size,
379
- memmap[VIRT_APLIC_S].size,
380
- (msimode) ? 0 : base_hartid,
381
- (msimode) ? 0 : hart_count,
382
- VIRT_IRQCHIP_NUM_SOURCES,
383
- VIRT_IRQCHIP_NUM_PRIO_BITS,
384
- msimode, false, aplic_m);
385
+ if (!kvm_enabled()) {
386
+ /* Per-socket M-level APLIC */
387
+ aplic_m = riscv_aplic_create(memmap[VIRT_APLIC_M].base +
388
+ socket * memmap[VIRT_APLIC_M].size,
389
+ memmap[VIRT_APLIC_M].size,
390
+ (msimode) ? 0 : base_hartid,
391
+ (msimode) ? 0 : hart_count,
392
+ VIRT_IRQCHIP_NUM_SOURCES,
393
+ VIRT_IRQCHIP_NUM_PRIO_BITS,
394
+ msimode, true, NULL);
395
}
396
397
- return aplic_m;
398
+ /* Per-socket S-level APLIC */
399
+ aplic_s = riscv_aplic_create(memmap[VIRT_APLIC_S].base +
400
+ socket * memmap[VIRT_APLIC_S].size,
401
+ memmap[VIRT_APLIC_S].size,
402
+ (msimode) ? 0 : base_hartid,
403
+ (msimode) ? 0 : hart_count,
404
+ VIRT_IRQCHIP_NUM_SOURCES,
405
+ VIRT_IRQCHIP_NUM_PRIO_BITS,
406
+ msimode, false, aplic_m);
407
+
408
+ return kvm_enabled() ? aplic_s : aplic_m;
55
}
409
}
56
410
57
-static void gen_exception_inst_addr_mis(DisasContext *ctx)
411
static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip)
58
+static void gen_exception_inst_addr_mis(DisasContext *ctx, TCGv target)
59
{
60
- tcg_gen_st_tl(cpu_pc, cpu_env, offsetof(CPURISCVState, badaddr));
61
+ tcg_gen_st_tl(target, cpu_env, offsetof(CPURISCVState, badaddr));
62
generate_exception(ctx, RISCV_EXCP_INST_ADDR_MIS);
63
}
64
65
@@ -XXX,XX +XXX,XX @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
66
next_pc = ctx->base.pc_next + imm;
67
if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca) {
68
if ((next_pc & 0x3) != 0) {
69
- gen_exception_inst_addr_mis(ctx);
70
+ TCGv target_pc = tcg_temp_new();
71
+ gen_pc_plus_diff(target_pc, ctx, next_pc);
72
+ gen_exception_inst_addr_mis(ctx, target_pc);
73
return;
74
}
75
}
76
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
77
index XXXXXXX..XXXXXXX 100644
78
--- a/target/riscv/insn_trans/trans_rvi.c.inc
79
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
80
@@ -XXX,XX +XXX,XX @@ static bool trans_jal(DisasContext *ctx, arg_jal *a)
81
static bool trans_jalr(DisasContext *ctx, arg_jalr *a)
82
{
83
TCGLabel *misaligned = NULL;
84
+ TCGv target_pc = tcg_temp_new();
85
86
- tcg_gen_addi_tl(cpu_pc, get_gpr(ctx, a->rs1, EXT_NONE), a->imm);
87
- tcg_gen_andi_tl(cpu_pc, cpu_pc, (target_ulong)-2);
88
+ tcg_gen_addi_tl(target_pc, get_gpr(ctx, a->rs1, EXT_NONE), a->imm);
89
+ tcg_gen_andi_tl(target_pc, target_pc, (target_ulong)-2);
90
+
91
+ if (get_xl(ctx) == MXL_RV32) {
92
+ tcg_gen_ext32s_tl(target_pc, target_pc);
93
+ }
94
95
- gen_set_pc(ctx, cpu_pc);
96
if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca) {
97
TCGv t0 = tcg_temp_new();
98
99
misaligned = gen_new_label();
100
- tcg_gen_andi_tl(t0, cpu_pc, 0x2);
101
+ tcg_gen_andi_tl(t0, target_pc, 0x2);
102
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0x0, misaligned);
103
}
104
105
gen_set_gpri(ctx, a->rd, ctx->pc_succ_insn);
106
+ tcg_gen_mov_tl(cpu_pc, target_pc);
107
lookup_and_goto_ptr(ctx);
108
109
if (misaligned) {
110
gen_set_label(misaligned);
111
- gen_exception_inst_addr_mis(ctx);
112
+ gen_exception_inst_addr_mis(ctx, target_pc);
113
}
114
ctx->base.is_jmp = DISAS_NORETURN;
115
116
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
117
TCGLabel *l = gen_new_label();
118
TCGv src1 = get_gpr(ctx, a->rs1, EXT_SIGN);
119
TCGv src2 = get_gpr(ctx, a->rs2, EXT_SIGN);
120
+ target_ulong next_pc;
121
122
if (get_xl(ctx) == MXL_RV128) {
123
TCGv src1h = get_gprh(ctx, a->rs1);
124
@@ -XXX,XX +XXX,XX @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond)
125
126
gen_set_label(l); /* branch taken */
127
128
+ next_pc = ctx->base.pc_next + a->imm;
129
if (!has_ext(ctx, RVC) && !ctx->cfg_ptr->ext_zca &&
130
- ((ctx->base.pc_next + a->imm) & 0x3)) {
131
+ (next_pc & 0x3)) {
132
/* misaligned */
133
- gen_exception_inst_addr_mis(ctx);
134
+ TCGv target_pc = tcg_temp_new();
135
+ gen_pc_plus_diff(target_pc, ctx, next_pc);
136
+ gen_exception_inst_addr_mis(ctx, target_pc);
137
} else {
138
gen_goto_tb(ctx, 0, ctx->base.pc_next + a->imm);
139
}
140
diff --git a/target/riscv/insn_trans/trans_rvzce.c.inc b/target/riscv/insn_trans/trans_rvzce.c.inc
141
index XXXXXXX..XXXXXXX 100644
142
--- a/target/riscv/insn_trans/trans_rvzce.c.inc
143
+++ b/target/riscv/insn_trans/trans_rvzce.c.inc
144
@@ -XXX,XX +XXX,XX @@ static bool gen_pop(DisasContext *ctx, arg_cmpp *a, bool ret, bool ret_val)
145
}
146
147
if (ret) {
148
- TCGv ret_addr = get_gpr(ctx, xRA, EXT_NONE);
149
- gen_set_pc(ctx, ret_addr);
150
+ TCGv ret_addr = get_gpr(ctx, xRA, EXT_SIGN);
151
+ tcg_gen_mov_tl(cpu_pc, ret_addr);
152
tcg_gen_lookup_and_goto_ptr();
153
ctx->base.is_jmp = DISAS_NORETURN;
154
}
155
--
412
--
156
2.40.1
413
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Yong-Xuan Wang <yongxuan.wang@sifive.com>
2
2
3
PMP entries before (including) the matched PMP entry may only cover partial
3
We check the in-kernel irqchip support when using KVM acceleration.
4
of the TLB page, and this may split the page into regions with different
5
permissions. Such as for PMP0 (0x80000008~0x8000000F, R) and PMP1 (0x80000000~
6
0x80000FFF, RWX), write access to 0x80000000 will match PMP1. However we cannot
7
cache the translation result in the TLB since this will make the write access
8
to 0x80000008 bypass the check of PMP0. So we should check all of them instead
9
of the matched PMP entry in pmp_get_tlb_size() and set the tlb_size to 1 in
10
this case.
11
Set tlb_size to TARGET_PAGE_SIZE if PMP is not support or there is no PMP rules.
12
4
13
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
5
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
14
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
6
Reviewed-by: Jim Shu <jim.shu@sifive.com>
15
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
7
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
16
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
17
Message-Id: <20230517091519.34439-2-liweiwei@iscas.ac.cn>
9
Message-ID: <20230727102439.22554-3-yongxuan.wang@sifive.com>
18
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
19
---
11
---
20
target/riscv/pmp.h | 3 +-
12
target/riscv/kvm.c | 10 +++++++++-
21
target/riscv/cpu_helper.c | 7 ++--
13
1 file changed, 9 insertions(+), 1 deletion(-)
22
target/riscv/pmp.c | 69 ++++++++++++++++++++++++++++++---------
23
3 files changed, 57 insertions(+), 22 deletions(-)
24
14
25
diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h
15
diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
26
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
27
--- a/target/riscv/pmp.h
17
--- a/target/riscv/kvm.c
28
+++ b/target/riscv/pmp.h
18
+++ b/target/riscv/kvm.c
29
@@ -XXX,XX +XXX,XX @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
19
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init(MachineState *ms, KVMState *s)
30
target_ulong size, pmp_priv_t privs,
20
31
pmp_priv_t *allowed_privs,
21
int kvm_arch_irqchip_create(KVMState *s)
32
target_ulong mode);
33
-target_ulong pmp_get_tlb_size(CPURISCVState *env, int pmp_index,
34
- target_ulong tlb_sa, target_ulong tlb_ea);
35
+target_ulong pmp_get_tlb_size(CPURISCVState *env, target_ulong addr);
36
void pmp_update_rule_addr(CPURISCVState *env, uint32_t pmp_index);
37
void pmp_update_rule_nums(CPURISCVState *env);
38
uint32_t pmp_get_num_rules(CPURISCVState *env);
39
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/riscv/cpu_helper.c
42
+++ b/target/riscv/cpu_helper.c
43
@@ -XXX,XX +XXX,XX @@ static int get_physical_address_pmp(CPURISCVState *env, int *prot,
44
}
45
46
*prot = pmp_priv_to_page_prot(pmp_priv);
47
- if ((tlb_size != NULL) && pmp_index != MAX_RISCV_PMPS) {
48
- target_ulong tlb_sa = addr & ~(TARGET_PAGE_SIZE - 1);
49
- target_ulong tlb_ea = tlb_sa + TARGET_PAGE_SIZE - 1;
50
-
51
- *tlb_size = pmp_get_tlb_size(env, pmp_index, tlb_sa, tlb_ea);
52
+ if (tlb_size != NULL) {
53
+ *tlb_size = pmp_get_tlb_size(env, addr);
54
}
55
56
return TRANSLATE_SUCCESS;
57
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
58
index XXXXXXX..XXXXXXX 100644
59
--- a/target/riscv/pmp.c
60
+++ b/target/riscv/pmp.c
61
@@ -XXX,XX +XXX,XX @@ target_ulong mseccfg_csr_read(CPURISCVState *env)
62
}
63
64
/*
65
- * Calculate the TLB size if the start address or the end address of
66
- * PMP entry is presented in the TLB page.
67
+ * Calculate the TLB size.
68
+ * It's possible that PMP regions only cover partial of the TLB page, and
69
+ * this may split the page into regions with different permissions.
70
+ * For example if PMP0 is (0x80000008~0x8000000F, R) and PMP1 is (0x80000000
71
+ * ~0x80000FFF, RWX), then region 0x80000008~0x8000000F has R permission, and
72
+ * the other regions in this page have RWX permissions.
73
+ * A write access to 0x80000000 will match PMP1. However we cannot cache the
74
+ * translation result in the TLB since this will make the write access to
75
+ * 0x80000008 bypass the check of PMP0.
76
+ * To avoid this we return a size of 1 (which means no caching) if the PMP
77
+ * region only covers partial of the TLB page.
78
*/
79
-target_ulong pmp_get_tlb_size(CPURISCVState *env, int pmp_index,
80
- target_ulong tlb_sa, target_ulong tlb_ea)
81
+target_ulong pmp_get_tlb_size(CPURISCVState *env, target_ulong addr)
82
{
22
{
83
- target_ulong pmp_sa = env->pmp_state.addr[pmp_index].sa;
23
- return 0;
84
- target_ulong pmp_ea = env->pmp_state.addr[pmp_index].ea;
24
+ if (kvm_kernel_irqchip_split()) {
85
+ target_ulong pmp_sa;
25
+ error_report("-machine kernel_irqchip=split is not supported on RISC-V.");
86
+ target_ulong pmp_ea;
26
+ exit(1);
87
+ target_ulong tlb_sa = addr & ~(TARGET_PAGE_SIZE - 1);
88
+ target_ulong tlb_ea = tlb_sa + TARGET_PAGE_SIZE - 1;
89
+ int i;
90
91
- if (pmp_sa <= tlb_sa && pmp_ea >= tlb_ea) {
92
+ /*
93
+ * If PMP is not supported or there are no PMP rules, the TLB page will not
94
+ * be split into regions with different permissions by PMP so we set the
95
+ * size to TARGET_PAGE_SIZE.
96
+ */
97
+ if (!riscv_cpu_cfg(env)->pmp || !pmp_get_num_rules(env)) {
98
return TARGET_PAGE_SIZE;
99
- } else {
100
+ }
27
+ }
101
+
28
+
102
+ for (i = 0; i < MAX_RISCV_PMPS; i++) {
103
+ if (pmp_get_a_field(env->pmp_state.pmp[i].cfg_reg) == PMP_AMATCH_OFF) {
104
+ continue;
105
+ }
106
+
107
+ pmp_sa = env->pmp_state.addr[i].sa;
108
+ pmp_ea = env->pmp_state.addr[i].ea;
109
+
110
/*
111
- * At this point we have a tlb_size that is the smallest possible size
112
- * That fits within a TARGET_PAGE_SIZE and the PMP region.
113
- *
114
- * If the size is less then TARGET_PAGE_SIZE we drop the size to 1.
115
- * This means the result isn't cached in the TLB and is only used for
116
- * a single translation.
117
+ * Only the first PMP entry that covers (whole or partial of) the TLB
118
+ * page really matters:
119
+ * If it covers the whole TLB page, set the size to TARGET_PAGE_SIZE,
120
+ * since the following PMP entries have lower priority and will not
121
+ * affect the permissions of the page.
122
+ * If it only covers partial of the TLB page, set the size to 1 since
123
+ * the allowed permissions of the region may be different from other
124
+ * region of the page.
125
*/
126
- return 1;
127
+ if (pmp_sa <= tlb_sa && pmp_ea >= tlb_ea) {
128
+ return TARGET_PAGE_SIZE;
129
+ } else if ((pmp_sa >= tlb_sa && pmp_sa <= tlb_ea) ||
130
+ (pmp_ea >= tlb_sa && pmp_ea <= tlb_ea)) {
131
+ return 1;
132
+ }
133
}
134
+
135
+ /*
29
+ /*
136
+ * If no PMP entry matches the TLB page, the TLB page will also not be
30
+ * We can create the VAIA using the newer device control API.
137
+ * split into regions with different permissions by PMP so we set the size
138
+ * to TARGET_PAGE_SIZE.
139
+ */
31
+ */
140
+ return TARGET_PAGE_SIZE;
32
+ return kvm_check_extension(s, KVM_CAP_DEVICE_CTRL);
141
}
33
}
142
34
143
/*
35
int kvm_arch_process_async_events(CPUState *cs)
144
--
36
--
145
2.40.1
37
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Yong-Xuan Wang <yongxuan.wang@sifive.com>
2
2
3
Use pmp_update_rule_addr() and pmp_update_rule_nums() separately to
3
We create a vAIA chip by using the KVM_DEV_TYPE_RISCV_AIA and then set up
4
update rule nums only once for each pmpcfg_csr_write. Then remove
4
the chip with the KVM_DEV_RISCV_AIA_GRP_* APIs.
5
pmp_update_rule() since it become unused.
5
We also extend KVM accelerator to specify the KVM AIA mode. The "riscv-aia"
6
parameter is passed along with --accel in QEMU command-line.
7
1) "riscv-aia=emul": IMSIC is emulated by hypervisor
8
2) "riscv-aia=hwaccel": use hardware guest IMSIC
9
3) "riscv-aia=auto": use the hardware guest IMSICs whenever available
10
otherwise we fallback to software emulation.
6
11
7
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
12
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
8
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
13
Reviewed-by: Jim Shu <jim.shu@sifive.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
14
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
10
Message-Id: <20230517091519.34439-12-liweiwei@iscas.ac.cn>
15
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
16
Message-ID: <20230727102439.22554-4-yongxuan.wang@sifive.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
18
---
13
target/riscv/pmp.c | 16 ++--------------
19
target/riscv/kvm_riscv.h | 4 +
14
1 file changed, 2 insertions(+), 14 deletions(-)
20
target/riscv/kvm.c | 186 +++++++++++++++++++++++++++++++++++++++
21
2 files changed, 190 insertions(+)
15
22
16
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
23
diff --git a/target/riscv/kvm_riscv.h b/target/riscv/kvm_riscv.h
17
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/pmp.c
25
--- a/target/riscv/kvm_riscv.h
19
+++ b/target/riscv/pmp.c
26
+++ b/target/riscv/kvm_riscv.h
20
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@
21
static bool pmp_write_cfg(CPURISCVState *env, uint32_t addr_index,
28
void kvm_riscv_init_user_properties(Object *cpu_obj);
22
uint8_t val);
29
void kvm_riscv_reset_vcpu(RISCVCPU *cpu);
23
static uint8_t pmp_read_cfg(CPURISCVState *env, uint32_t addr_index);
30
void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level);
24
-static void pmp_update_rule(CPURISCVState *env, uint32_t pmp_index);
31
+void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift,
25
32
+ uint64_t aia_irq_num, uint64_t aia_msi_num,
26
/*
33
+ uint64_t aplic_base, uint64_t imsic_base,
27
* Accessor method to extract address matching type 'a field' from cfg reg
34
+ uint64_t guest_num);
28
@@ -XXX,XX +XXX,XX @@ static bool pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)
35
29
qemu_log_mask(LOG_GUEST_ERROR, "ignoring pmpcfg write - locked\n");
36
#endif
30
} else if (env->pmp_state.pmp[pmp_index].cfg_reg != val) {
37
diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
31
env->pmp_state.pmp[pmp_index].cfg_reg = val;
38
index XXXXXXX..XXXXXXX 100644
32
- pmp_update_rule(env, pmp_index);
39
--- a/target/riscv/kvm.c
33
+ pmp_update_rule_addr(env, pmp_index);
40
+++ b/target/riscv/kvm.c
34
return true;
41
@@ -XXX,XX +XXX,XX @@
35
}
42
#include "exec/address-spaces.h"
36
} else {
43
#include "hw/boards.h"
37
@@ -XXX,XX +XXX,XX @@ void pmp_update_rule_nums(CPURISCVState *env)
44
#include "hw/irq.h"
38
}
45
+#include "hw/intc/riscv_imsic.h"
46
#include "qemu/log.h"
47
#include "hw/loader.h"
48
#include "kvm_riscv.h"
49
@@ -XXX,XX +XXX,XX @@
50
#include "chardev/char-fe.h"
51
#include "migration/migration.h"
52
#include "sysemu/runstate.h"
53
+#include "hw/riscv/numa.h"
54
55
static uint64_t kvm_riscv_reg_id(CPURISCVState *env, uint64_t type,
56
uint64_t idx)
57
@@ -XXX,XX +XXX,XX @@ bool kvm_arch_cpu_check_are_resettable(void)
58
return true;
39
}
59
}
40
60
41
-/*
61
+static int aia_mode;
42
- * Convert cfg/addr reg values here into simple 'sa' --> start address and 'ea'
62
+
43
- * end address values.
63
+static const char *kvm_aia_mode_str(uint64_t mode)
44
- * This function is called relatively infrequently whereas the check that
64
+{
45
- * an address is within a pmp rule is called often, so optimise that one
65
+ switch (mode) {
46
- */
66
+ case KVM_DEV_RISCV_AIA_MODE_EMUL:
47
-static void pmp_update_rule(CPURISCVState *env, uint32_t pmp_index)
67
+ return "emul";
48
-{
68
+ case KVM_DEV_RISCV_AIA_MODE_HWACCEL:
49
- pmp_update_rule_addr(env, pmp_index);
69
+ return "hwaccel";
50
- pmp_update_rule_nums(env);
70
+ case KVM_DEV_RISCV_AIA_MODE_AUTO:
51
-}
71
+ default:
52
-
72
+ return "auto";
53
static int pmp_is_in_range(CPURISCVState *env, int pmp_index,
73
+ };
54
target_ulong addr)
74
+}
75
+
76
+static char *riscv_get_kvm_aia(Object *obj, Error **errp)
77
+{
78
+ return g_strdup(kvm_aia_mode_str(aia_mode));
79
+}
80
+
81
+static void riscv_set_kvm_aia(Object *obj, const char *val, Error **errp)
82
+{
83
+ if (!strcmp(val, "emul")) {
84
+ aia_mode = KVM_DEV_RISCV_AIA_MODE_EMUL;
85
+ } else if (!strcmp(val, "hwaccel")) {
86
+ aia_mode = KVM_DEV_RISCV_AIA_MODE_HWACCEL;
87
+ } else if (!strcmp(val, "auto")) {
88
+ aia_mode = KVM_DEV_RISCV_AIA_MODE_AUTO;
89
+ } else {
90
+ error_setg(errp, "Invalid KVM AIA mode");
91
+ error_append_hint(errp, "Valid values are emul, hwaccel, and auto.\n");
92
+ }
93
+}
94
+
95
void kvm_arch_accel_class_init(ObjectClass *oc)
55
{
96
{
56
@@ -XXX,XX +XXX,XX @@ void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index,
97
+ object_class_property_add_str(oc, "riscv-aia", riscv_get_kvm_aia,
57
98
+ riscv_set_kvm_aia);
58
/* If PMP permission of any addr has been changed, flush TLB pages. */
99
+ object_class_property_set_description(oc, "riscv-aia",
59
if (modified) {
100
+ "Set KVM AIA mode. Valid values are "
60
+ pmp_update_rule_nums(env);
101
+ "emul, hwaccel, and auto. Default "
61
tlb_flush(env_cpu(env));
102
+ "is auto.");
62
}
103
+ object_property_set_default_str(object_class_property_find(oc, "riscv-aia"),
104
+ "auto");
105
+}
106
+
107
+void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift,
108
+ uint64_t aia_irq_num, uint64_t aia_msi_num,
109
+ uint64_t aplic_base, uint64_t imsic_base,
110
+ uint64_t guest_num)
111
+{
112
+ int ret, i;
113
+ int aia_fd = -1;
114
+ uint64_t default_aia_mode;
115
+ uint64_t socket_count = riscv_socket_count(machine);
116
+ uint64_t max_hart_per_socket = 0;
117
+ uint64_t socket, base_hart, hart_count, socket_imsic_base, imsic_addr;
118
+ uint64_t socket_bits, hart_bits, guest_bits;
119
+
120
+ aia_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_RISCV_AIA, false);
121
+
122
+ if (aia_fd < 0) {
123
+ error_report("Unable to create in-kernel irqchip");
124
+ exit(1);
125
+ }
126
+
127
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
128
+ KVM_DEV_RISCV_AIA_CONFIG_MODE,
129
+ &default_aia_mode, false, NULL);
130
+ if (ret < 0) {
131
+ error_report("KVM AIA: failed to get current KVM AIA mode");
132
+ exit(1);
133
+ }
134
+ qemu_log("KVM AIA: default mode is %s\n",
135
+ kvm_aia_mode_str(default_aia_mode));
136
+
137
+ if (default_aia_mode != aia_mode) {
138
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
139
+ KVM_DEV_RISCV_AIA_CONFIG_MODE,
140
+ &aia_mode, true, NULL);
141
+ if (ret < 0)
142
+ warn_report("KVM AIA: failed to set KVM AIA mode");
143
+ else
144
+ qemu_log("KVM AIA: set current mode to %s\n",
145
+ kvm_aia_mode_str(aia_mode));
146
+ }
147
+
148
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
149
+ KVM_DEV_RISCV_AIA_CONFIG_SRCS,
150
+ &aia_irq_num, true, NULL);
151
+ if (ret < 0) {
152
+ error_report("KVM AIA: failed to set number of input irq lines");
153
+ exit(1);
154
+ }
155
+
156
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
157
+ KVM_DEV_RISCV_AIA_CONFIG_IDS,
158
+ &aia_msi_num, true, NULL);
159
+ if (ret < 0) {
160
+ error_report("KVM AIA: failed to set number of msi");
161
+ exit(1);
162
+ }
163
+
164
+ socket_bits = find_last_bit(&socket_count, BITS_PER_LONG) + 1;
165
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
166
+ KVM_DEV_RISCV_AIA_CONFIG_GROUP_BITS,
167
+ &socket_bits, true, NULL);
168
+ if (ret < 0) {
169
+ error_report("KVM AIA: failed to set group_bits");
170
+ exit(1);
171
+ }
172
+
173
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
174
+ KVM_DEV_RISCV_AIA_CONFIG_GROUP_SHIFT,
175
+ &group_shift, true, NULL);
176
+ if (ret < 0) {
177
+ error_report("KVM AIA: failed to set group_shift");
178
+ exit(1);
179
+ }
180
+
181
+ guest_bits = guest_num == 0 ? 0 :
182
+ find_last_bit(&guest_num, BITS_PER_LONG) + 1;
183
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
184
+ KVM_DEV_RISCV_AIA_CONFIG_GUEST_BITS,
185
+ &guest_bits, true, NULL);
186
+ if (ret < 0) {
187
+ error_report("KVM AIA: failed to set guest_bits");
188
+ exit(1);
189
+ }
190
+
191
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_ADDR,
192
+ KVM_DEV_RISCV_AIA_ADDR_APLIC,
193
+ &aplic_base, true, NULL);
194
+ if (ret < 0) {
195
+ error_report("KVM AIA: failed to set the base address of APLIC");
196
+ exit(1);
197
+ }
198
+
199
+ for (socket = 0; socket < socket_count; socket++) {
200
+ socket_imsic_base = imsic_base + socket * (1U << group_shift);
201
+ hart_count = riscv_socket_hart_count(machine, socket);
202
+ base_hart = riscv_socket_first_hartid(machine, socket);
203
+
204
+ if (max_hart_per_socket < hart_count) {
205
+ max_hart_per_socket = hart_count;
206
+ }
207
+
208
+ for (i = 0; i < hart_count; i++) {
209
+ imsic_addr = socket_imsic_base + i * IMSIC_HART_SIZE(guest_bits);
210
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_ADDR,
211
+ KVM_DEV_RISCV_AIA_ADDR_IMSIC(i + base_hart),
212
+ &imsic_addr, true, NULL);
213
+ if (ret < 0) {
214
+ error_report("KVM AIA: failed to set the IMSIC address for hart %d", i);
215
+ exit(1);
216
+ }
217
+ }
218
+ }
219
+
220
+ hart_bits = find_last_bit(&max_hart_per_socket, BITS_PER_LONG) + 1;
221
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
222
+ KVM_DEV_RISCV_AIA_CONFIG_HART_BITS,
223
+ &hart_bits, true, NULL);
224
+ if (ret < 0) {
225
+ error_report("KVM AIA: failed to set hart_bits");
226
+ exit(1);
227
+ }
228
+
229
+ if (kvm_has_gsi_routing()) {
230
+ for (uint64_t idx = 0; idx < aia_irq_num + 1; ++idx) {
231
+ /* KVM AIA only has one APLIC instance */
232
+ kvm_irqchip_add_irq_route(kvm_state, idx, 0, idx);
233
+ }
234
+ kvm_gsi_routing_allowed = true;
235
+ kvm_irqchip_commit_routes(kvm_state);
236
+ }
237
+
238
+ ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CTRL,
239
+ KVM_DEV_RISCV_AIA_CTRL_INIT,
240
+ NULL, true, NULL);
241
+ if (ret < 0) {
242
+ error_report("KVM AIA: initialized fail");
243
+ exit(1);
244
+ }
245
+
246
+ kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
63
}
247
}
64
--
248
--
65
2.40.1
249
2.41.0
diff view generated by jsdifflib
1
From: Tommy Wu <tommy.wu@sifive.com>
1
From: Yong-Xuan Wang <yongxuan.wang@sifive.com>
2
2
3
According to the `The RISC-V Advanced Interrupt Architecture`
3
KVM AIA can't emulate APLIC only. When "aia=aplic" parameter is passed,
4
document, if register `mmsiaddrcfgh` of the domain has bit L set
4
APLIC devices is emulated by QEMU. For "aia=aplic-imsic", remove the
5
to one, then `smsiaddrcfg` and `smsiaddrcfgh` are locked as
5
mmio operations of APLIC when using KVM AIA and send wired interrupt
6
read-only alongside `mmsiaddrcfg` and `mmsiaddrcfgh`.
6
signal via KVM_IRQ_LINE API.
7
After KVM AIA enabled, MSI messages are delivered by KVM_SIGNAL_MSI API
8
when the IMSICs receive mmio write requests.
7
9
8
Signed-off-by: Tommy Wu <tommy.wu@sifive.com>
10
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
9
Reviewed-by: Frank Chang <frank.chang@sifive.com>
11
Reviewed-by: Jim Shu <jim.shu@sifive.com>
10
Acked-by: Alistair Francis <alistair.francis@wdc.com>
12
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
11
Reviewed-by: Anup Patel <anup@brainfault.org>
13
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
12
Message-Id: <20230609055936.3925438-1-tommy.wu@sifive.com>
14
Message-ID: <20230727102439.22554-5-yongxuan.wang@sifive.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
16
---
15
hw/intc/riscv_aplic.c | 4 ++--
17
hw/intc/riscv_aplic.c | 56 ++++++++++++++++++++++++++++++-------------
16
1 file changed, 2 insertions(+), 2 deletions(-)
18
hw/intc/riscv_imsic.c | 25 +++++++++++++++----
19
2 files changed, 61 insertions(+), 20 deletions(-)
17
20
18
diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
21
diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
19
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/intc/riscv_aplic.c
23
--- a/hw/intc/riscv_aplic.c
21
+++ b/hw/intc/riscv_aplic.c
24
+++ b/hw/intc/riscv_aplic.c
22
@@ -XXX,XX +XXX,XX @@ static void riscv_aplic_write(void *opaque, hwaddr addr, uint64_t value,
25
@@ -XXX,XX +XXX,XX @@
23
* domains).
26
#include "hw/irq.h"
24
*/
27
#include "target/riscv/cpu.h"
25
if (aplic->num_children &&
28
#include "sysemu/sysemu.h"
26
- !(aplic->smsicfgaddrH & APLIC_xMSICFGADDRH_L)) {
29
+#include "sysemu/kvm.h"
27
+ !(aplic->mmsicfgaddrH & APLIC_xMSICFGADDRH_L)) {
30
#include "migration/vmstate.h"
28
aplic->smsicfgaddr = value;
31
32
#define APLIC_MAX_IDC (1UL << 14)
33
@@ -XXX,XX +XXX,XX @@
34
35
#define APLIC_IDC_CLAIMI 0x1c
36
37
+/*
38
+ * KVM AIA only supports APLIC MSI, fallback to QEMU emulation if we want to use
39
+ * APLIC Wired.
40
+ */
41
+static bool is_kvm_aia(bool msimode)
42
+{
43
+ return kvm_irqchip_in_kernel() && msimode;
44
+}
45
+
46
static uint32_t riscv_aplic_read_input_word(RISCVAPLICState *aplic,
47
uint32_t word)
48
{
49
@@ -XXX,XX +XXX,XX @@ static uint32_t riscv_aplic_idc_claimi(RISCVAPLICState *aplic, uint32_t idc)
50
return topi;
51
}
52
53
+static void riscv_kvm_aplic_request(void *opaque, int irq, int level)
54
+{
55
+ kvm_set_irq(kvm_state, irq, !!level);
56
+}
57
+
58
static void riscv_aplic_request(void *opaque, int irq, int level)
59
{
60
bool update = false;
61
@@ -XXX,XX +XXX,XX @@ static void riscv_aplic_realize(DeviceState *dev, Error **errp)
62
uint32_t i;
63
RISCVAPLICState *aplic = RISCV_APLIC(dev);
64
65
- aplic->bitfield_words = (aplic->num_irqs + 31) >> 5;
66
- aplic->sourcecfg = g_new0(uint32_t, aplic->num_irqs);
67
- aplic->state = g_new0(uint32_t, aplic->num_irqs);
68
- aplic->target = g_new0(uint32_t, aplic->num_irqs);
69
- if (!aplic->msimode) {
70
- for (i = 0; i < aplic->num_irqs; i++) {
71
- aplic->target[i] = 1;
72
+ if (!is_kvm_aia(aplic->msimode)) {
73
+ aplic->bitfield_words = (aplic->num_irqs + 31) >> 5;
74
+ aplic->sourcecfg = g_new0(uint32_t, aplic->num_irqs);
75
+ aplic->state = g_new0(uint32_t, aplic->num_irqs);
76
+ aplic->target = g_new0(uint32_t, aplic->num_irqs);
77
+ if (!aplic->msimode) {
78
+ for (i = 0; i < aplic->num_irqs; i++) {
79
+ aplic->target[i] = 1;
80
+ }
29
}
81
}
30
} else if (aplic->mmode && aplic->msimode &&
82
- }
31
(addr == APLIC_SMSICFGADDRH)) {
83
- aplic->idelivery = g_new0(uint32_t, aplic->num_harts);
32
if (aplic->num_children &&
84
- aplic->iforce = g_new0(uint32_t, aplic->num_harts);
33
- !(aplic->smsicfgaddrH & APLIC_xMSICFGADDRH_L)) {
85
- aplic->ithreshold = g_new0(uint32_t, aplic->num_harts);
34
+ !(aplic->mmsicfgaddrH & APLIC_xMSICFGADDRH_L)) {
86
+ aplic->idelivery = g_new0(uint32_t, aplic->num_harts);
35
aplic->smsicfgaddrH = value & APLIC_xMSICFGADDRH_VALID_MASK;
87
+ aplic->iforce = g_new0(uint32_t, aplic->num_harts);
36
}
88
+ aplic->ithreshold = g_new0(uint32_t, aplic->num_harts);
37
} else if ((APLIC_SETIP_BASE <= addr) &&
89
90
- memory_region_init_io(&aplic->mmio, OBJECT(dev), &riscv_aplic_ops, aplic,
91
- TYPE_RISCV_APLIC, aplic->aperture_size);
92
- sysbus_init_mmio(SYS_BUS_DEVICE(dev), &aplic->mmio);
93
+ memory_region_init_io(&aplic->mmio, OBJECT(dev), &riscv_aplic_ops,
94
+ aplic, TYPE_RISCV_APLIC, aplic->aperture_size);
95
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &aplic->mmio);
96
+ }
97
98
/*
99
* Only root APLICs have hardware IRQ lines. All non-root APLICs
100
* have IRQ lines delegated by their parent APLIC.
101
*/
102
if (!aplic->parent) {
103
- qdev_init_gpio_in(dev, riscv_aplic_request, aplic->num_irqs);
104
+ if (is_kvm_aia(aplic->msimode)) {
105
+ qdev_init_gpio_in(dev, riscv_kvm_aplic_request, aplic->num_irqs);
106
+ } else {
107
+ qdev_init_gpio_in(dev, riscv_aplic_request, aplic->num_irqs);
108
+ }
109
}
110
111
/* Create output IRQ lines for non-MSI mode */
112
@@ -XXX,XX +XXX,XX @@ DeviceState *riscv_aplic_create(hwaddr addr, hwaddr size,
113
qdev_prop_set_bit(dev, "mmode", mmode);
114
115
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
116
- sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr);
117
+
118
+ if (!is_kvm_aia(msimode)) {
119
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr);
120
+ }
121
122
if (parent) {
123
riscv_aplic_add_child(parent, dev);
124
diff --git a/hw/intc/riscv_imsic.c b/hw/intc/riscv_imsic.c
125
index XXXXXXX..XXXXXXX 100644
126
--- a/hw/intc/riscv_imsic.c
127
+++ b/hw/intc/riscv_imsic.c
128
@@ -XXX,XX +XXX,XX @@
129
#include "target/riscv/cpu.h"
130
#include "target/riscv/cpu_bits.h"
131
#include "sysemu/sysemu.h"
132
+#include "sysemu/kvm.h"
133
#include "migration/vmstate.h"
134
135
#define IMSIC_MMIO_PAGE_LE 0x00
136
@@ -XXX,XX +XXX,XX @@ static void riscv_imsic_write(void *opaque, hwaddr addr, uint64_t value,
137
goto err;
138
}
139
140
+#if defined(CONFIG_KVM)
141
+ if (kvm_irqchip_in_kernel()) {
142
+ struct kvm_msi msi;
143
+
144
+ msi.address_lo = extract64(imsic->mmio.addr + addr, 0, 32);
145
+ msi.address_hi = extract64(imsic->mmio.addr + addr, 32, 32);
146
+ msi.data = le32_to_cpu(value);
147
+
148
+ kvm_vm_ioctl(kvm_state, KVM_SIGNAL_MSI, &msi);
149
+
150
+ return;
151
+ }
152
+#endif
153
+
154
/* Writes only supported for MSI little-endian registers */
155
page = addr >> IMSIC_MMIO_PAGE_SHIFT;
156
if ((addr & (IMSIC_MMIO_PAGE_SZ - 1)) == IMSIC_MMIO_PAGE_LE) {
157
@@ -XXX,XX +XXX,XX @@ static void riscv_imsic_realize(DeviceState *dev, Error **errp)
158
CPUState *cpu = cpu_by_arch_id(imsic->hartid);
159
CPURISCVState *env = cpu ? cpu->env_ptr : NULL;
160
161
- imsic->num_eistate = imsic->num_pages * imsic->num_irqs;
162
- imsic->eidelivery = g_new0(uint32_t, imsic->num_pages);
163
- imsic->eithreshold = g_new0(uint32_t, imsic->num_pages);
164
- imsic->eistate = g_new0(uint32_t, imsic->num_eistate);
165
+ if (!kvm_irqchip_in_kernel()) {
166
+ imsic->num_eistate = imsic->num_pages * imsic->num_irqs;
167
+ imsic->eidelivery = g_new0(uint32_t, imsic->num_pages);
168
+ imsic->eithreshold = g_new0(uint32_t, imsic->num_pages);
169
+ imsic->eistate = g_new0(uint32_t, imsic->num_eistate);
170
+ }
171
172
memory_region_init_io(&imsic->mmio, OBJECT(dev), &riscv_imsic_ops,
173
imsic, TYPE_RISCV_IMSIC,
38
--
174
--
39
2.40.1
175
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Yong-Xuan Wang <yongxuan.wang@sifive.com>
2
2
3
We no longer need the pmp_index for matched PMP entry now.
3
Select KVM AIA when the host kernel has in-kernel AIA chip support.
4
Since KVM AIA only has one APLIC instance, we map the QEMU APLIC
5
devices to KVM APLIC.
4
6
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Jim Shu <jim.shu@sifive.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
Message-Id: <20230517091519.34439-5-liweiwei@iscas.ac.cn>
10
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
11
Message-ID: <20230727102439.22554-6-yongxuan.wang@sifive.com>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
13
---
11
target/riscv/pmp.h | 8 ++++----
14
hw/riscv/virt.c | 94 +++++++++++++++++++++++++++++++++----------------
12
target/riscv/cpu_helper.c | 8 ++++----
15
1 file changed, 63 insertions(+), 31 deletions(-)
13
target/riscv/pmp.c | 32 +++++++++++++-------------------
14
3 files changed, 21 insertions(+), 27 deletions(-)
15
16
16
diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h
17
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/pmp.h
19
--- a/hw/riscv/virt.c
19
+++ b/target/riscv/pmp.h
20
+++ b/hw/riscv/virt.c
20
@@ -XXX,XX +XXX,XX @@ target_ulong mseccfg_csr_read(CPURISCVState *env);
21
@@ -XXX,XX +XXX,XX @@
21
void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index,
22
#include "hw/riscv/virt.h"
22
target_ulong val);
23
#include "hw/riscv/boot.h"
23
target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t addr_index);
24
#include "hw/riscv/numa.h"
24
-int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
25
+#include "kvm_riscv.h"
25
- target_ulong size, pmp_priv_t privs,
26
#include "hw/intc/riscv_aclint.h"
26
- pmp_priv_t *allowed_privs,
27
#include "hw/intc/riscv_aplic.h"
27
- target_ulong mode);
28
#include "hw/intc/riscv_imsic.h"
28
+bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
29
@@ -XXX,XX +XXX,XX @@
29
+ target_ulong size, pmp_priv_t privs,
30
#error "Can't accommodate all IMSIC groups in address space"
30
+ pmp_priv_t *allowed_privs,
31
#endif
31
+ target_ulong mode);
32
32
target_ulong pmp_get_tlb_size(CPURISCVState *env, target_ulong addr);
33
+/* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU. */
33
void pmp_update_rule_addr(CPURISCVState *env, uint32_t pmp_index);
34
+static bool virt_use_kvm_aia(RISCVVirtState *s)
34
void pmp_update_rule_nums(CPURISCVState *env);
35
+{
35
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
36
+ return kvm_irqchip_in_kernel() && s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
36
index XXXXXXX..XXXXXXX 100644
37
+}
37
--- a/target/riscv/cpu_helper.c
38
+
38
+++ b/target/riscv/cpu_helper.c
39
static const MemMapEntry virt_memmap[] = {
39
@@ -XXX,XX +XXX,XX @@ static int get_physical_address_pmp(CPURISCVState *env, int *prot, hwaddr addr,
40
[VIRT_DEBUG] = { 0x0, 0x100 },
40
int mode)
41
[VIRT_MROM] = { 0x1000, 0xf000 },
42
@@ -XXX,XX +XXX,XX @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket,
43
uint32_t *intc_phandles,
44
uint32_t aplic_phandle,
45
uint32_t aplic_child_phandle,
46
- bool m_mode)
47
+ bool m_mode, int num_harts)
41
{
48
{
42
pmp_priv_t pmp_priv;
49
int cpu;
43
- int pmp_index = -1;
50
char *aplic_name;
44
+ bool pmp_has_privs;
51
uint32_t *aplic_cells;
45
52
MachineState *ms = MACHINE(s);
46
if (!riscv_cpu_cfg(env)->pmp) {
53
47
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
54
- aplic_cells = g_new0(uint32_t, s->soc[socket].num_harts * 2);
48
return TRANSLATE_SUCCESS;
55
+ aplic_cells = g_new0(uint32_t, num_harts * 2);
56
57
- for (cpu = 0; cpu < s->soc[socket].num_harts; cpu++) {
58
+ for (cpu = 0; cpu < num_harts; cpu++) {
59
aplic_cells[cpu * 2 + 0] = cpu_to_be32(intc_phandles[cpu]);
60
aplic_cells[cpu * 2 + 1] = cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_S_EXT);
49
}
61
}
50
62
@@ -XXX,XX +XXX,XX @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket,
51
- pmp_index = pmp_hart_has_privs(env, addr, size, 1 << access_type,
63
52
- &pmp_priv, mode);
64
if (s->aia_type == VIRT_AIA_TYPE_APLIC) {
53
- if (pmp_index < 0) {
65
qemu_fdt_setprop(ms->fdt, aplic_name, "interrupts-extended",
54
+ pmp_has_privs = pmp_hart_has_privs(env, addr, size, 1 << access_type,
66
- aplic_cells,
55
+ &pmp_priv, mode);
67
- s->soc[socket].num_harts * sizeof(uint32_t) * 2);
56
+ if (!pmp_has_privs) {
68
+ aplic_cells, num_harts * sizeof(uint32_t) * 2);
57
*prot = 0;
69
} else {
58
return TRANSLATE_PMP_FAIL;
70
qemu_fdt_setprop_cell(ms->fdt, aplic_name, "msi-parent", msi_phandle);
59
}
71
}
60
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
72
@@ -XXX,XX +XXX,XX @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
61
index XXXXXXX..XXXXXXX 100644
73
uint32_t msi_s_phandle,
62
--- a/target/riscv/pmp.c
74
uint32_t *phandle,
63
+++ b/target/riscv/pmp.c
75
uint32_t *intc_phandles,
64
@@ -XXX,XX +XXX,XX @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr,
76
- uint32_t *aplic_phandles)
65
77
+ uint32_t *aplic_phandles,
66
/*
78
+ int num_harts)
67
* Check if the address has required RWX privs to complete desired operation
68
- * Return PMP rule index if a pmp rule match
69
- * Return MAX_RISCV_PMPS if default match
70
- * Return negtive value if no match
71
+ * Return true if a pmp rule match or default match
72
+ * Return false if no match
73
*/
74
-int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
75
- target_ulong size, pmp_priv_t privs,
76
- pmp_priv_t *allowed_privs, target_ulong mode)
77
+bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
78
+ target_ulong size, pmp_priv_t privs,
79
+ pmp_priv_t *allowed_privs, target_ulong mode)
80
{
79
{
81
int i = 0;
80
char *aplic_name;
82
- int ret = -1;
81
unsigned long aplic_addr;
83
+ bool ret = false;
82
@@ -XXX,XX +XXX,XX @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
84
int pmp_size = 0;
83
create_fdt_one_aplic(s, socket, aplic_addr, memmap[VIRT_APLIC_M].size,
85
target_ulong s = 0;
84
msi_m_phandle, intc_phandles,
86
target_ulong e = 0;
85
aplic_m_phandle, aplic_s_phandle,
87
86
- true);
88
/* Short cut if no rules */
87
+ true, num_harts);
89
if (0 == pmp_get_num_rules(env)) {
90
- if (pmp_hart_has_privs_default(env, addr, size, privs,
91
- allowed_privs, mode)) {
92
- ret = MAX_RISCV_PMPS;
93
- }
94
- return ret;
95
+ return pmp_hart_has_privs_default(env, addr, size, privs,
96
+ allowed_privs, mode);
97
}
88
}
98
89
99
if (size == 0) {
90
/* S-level APLIC node */
100
@@ -XXX,XX +XXX,XX @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
91
@@ -XXX,XX +XXX,XX @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
101
if ((s + e) == 1) {
92
create_fdt_one_aplic(s, socket, aplic_addr, memmap[VIRT_APLIC_S].size,
102
qemu_log_mask(LOG_GUEST_ERROR,
93
msi_s_phandle, intc_phandles,
103
"pmp violation - access is partially inside\n");
94
aplic_s_phandle, 0,
104
- ret = -1;
95
- false);
105
+ ret = false;
96
+ false, num_harts);
106
break;
97
107
}
98
aplic_name = g_strdup_printf("/soc/aplic@%lx", aplic_addr);
108
99
109
@@ -XXX,XX +XXX,XX @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
100
@@ -XXX,XX +XXX,XX @@ static void create_fdt_sockets(RISCVVirtState *s, const MemMapEntry *memmap,
110
* defined with PMP must be used. We shouldn't fallback on
101
*msi_pcie_phandle = msi_s_phandle;
111
* finding default privileges.
102
}
112
*/
103
113
- ret = i;
104
- phandle_pos = ms->smp.cpus;
114
+ ret = true;
105
- for (socket = (socket_count - 1); socket >= 0; socket--) {
115
break;
106
- phandle_pos -= s->soc[socket].num_harts;
107
-
108
- if (s->aia_type == VIRT_AIA_TYPE_NONE) {
109
- create_fdt_socket_plic(s, memmap, socket, phandle,
110
- &intc_phandles[phandle_pos], xplic_phandles);
111
- } else {
112
- create_fdt_socket_aplic(s, memmap, socket,
113
- msi_m_phandle, msi_s_phandle, phandle,
114
- &intc_phandles[phandle_pos], xplic_phandles);
115
+ /* KVM AIA only has one APLIC instance */
116
+ if (virt_use_kvm_aia(s)) {
117
+ create_fdt_socket_aplic(s, memmap, 0,
118
+ msi_m_phandle, msi_s_phandle, phandle,
119
+ &intc_phandles[0], xplic_phandles,
120
+ ms->smp.cpus);
121
+ } else {
122
+ phandle_pos = ms->smp.cpus;
123
+ for (socket = (socket_count - 1); socket >= 0; socket--) {
124
+ phandle_pos -= s->soc[socket].num_harts;
125
+
126
+ if (s->aia_type == VIRT_AIA_TYPE_NONE) {
127
+ create_fdt_socket_plic(s, memmap, socket, phandle,
128
+ &intc_phandles[phandle_pos],
129
+ xplic_phandles);
130
+ } else {
131
+ create_fdt_socket_aplic(s, memmap, socket,
132
+ msi_m_phandle, msi_s_phandle, phandle,
133
+ &intc_phandles[phandle_pos],
134
+ xplic_phandles,
135
+ s->soc[socket].num_harts);
136
+ }
116
}
137
}
117
}
138
}
118
139
119
/* No rule matched */
140
g_free(intc_phandles);
120
- if (ret == -1) {
141
121
- if (pmp_hart_has_privs_default(env, addr, size, privs,
142
- for (socket = 0; socket < socket_count; socket++) {
122
- allowed_privs, mode)) {
143
- if (socket == 0) {
123
- ret = MAX_RISCV_PMPS;
144
- *irq_mmio_phandle = xplic_phandles[socket];
145
- *irq_virtio_phandle = xplic_phandles[socket];
146
- *irq_pcie_phandle = xplic_phandles[socket];
124
- }
147
- }
125
+ if (!ret) {
148
- if (socket == 1) {
126
+ ret = pmp_hart_has_privs_default(env, addr, size, privs,
149
- *irq_virtio_phandle = xplic_phandles[socket];
127
+ allowed_privs, mode);
150
- *irq_pcie_phandle = xplic_phandles[socket];
151
- }
152
- if (socket == 2) {
153
- *irq_pcie_phandle = xplic_phandles[socket];
154
+ if (virt_use_kvm_aia(s)) {
155
+ *irq_mmio_phandle = xplic_phandles[0];
156
+ *irq_virtio_phandle = xplic_phandles[0];
157
+ *irq_pcie_phandle = xplic_phandles[0];
158
+ } else {
159
+ for (socket = 0; socket < socket_count; socket++) {
160
+ if (socket == 0) {
161
+ *irq_mmio_phandle = xplic_phandles[socket];
162
+ *irq_virtio_phandle = xplic_phandles[socket];
163
+ *irq_pcie_phandle = xplic_phandles[socket];
164
+ }
165
+ if (socket == 1) {
166
+ *irq_virtio_phandle = xplic_phandles[socket];
167
+ *irq_pcie_phandle = xplic_phandles[socket];
168
+ }
169
+ if (socket == 2) {
170
+ *irq_pcie_phandle = xplic_phandles[socket];
171
+ }
172
}
128
}
173
}
129
174
130
return ret;
175
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
176
}
177
}
178
179
+ if (virt_use_kvm_aia(s)) {
180
+ kvm_riscv_aia_create(machine, IMSIC_MMIO_GROUP_MIN_SHIFT,
181
+ VIRT_IRQCHIP_NUM_SOURCES, VIRT_IRQCHIP_NUM_MSIS,
182
+ memmap[VIRT_APLIC_S].base,
183
+ memmap[VIRT_IMSIC_S].base,
184
+ s->aia_guests);
185
+ }
186
+
187
if (riscv_is_32bit(&s->soc[0])) {
188
#if HOST_LONG_BITS == 64
189
/* limit RAM size in a 32-bit system */
131
--
190
--
132
2.40.1
191
2.41.0
diff view generated by jsdifflib
1
From: Sunil V L <sunilvl@ventanamicro.com>
1
From: Conor Dooley <conor.dooley@microchip.com>
2
2
3
Currently, virt machine supports two pflash instances each with
3
On a dtb dumped from the virt machine, dt-validate complains:
4
32MB size. However, the first pflash is always assumed to
4
soc: pmu: {'riscv,event-to-mhpmcounters': [[1, 1, 524281], [2, 2, 524284], [65561, 65561, 524280], [65563, 65563, 524280], [65569, 65569, 524280]], 'compatible': ['riscv,pmu']} should not be valid under {'type': 'object'}
5
contain M-mode firmware and reset vector is set to this if
5
from schema $id: http://devicetree.org/schemas/simple-bus.yaml#
6
enabled. Hence, for S-mode payloads like EDK2, only one pflash
6
That's pretty cryptic, but running the dtb back through dtc produces
7
instance is available for use. This means both code and NV variables
7
something a lot more reasonable:
8
of EDK2 will need to use the same pflash.
8
Warning (simple_bus_reg): /soc/pmu: missing or empty reg/ranges property
9
9
10
The OS distros keep the EDK2 FW code as readonly. When non-volatile
10
Moving the riscv,pmu node out of the soc bus solves the problem.
11
variables also need to share the same pflash, it is not possible
12
to keep it as readonly since variables need write access.
13
11
14
To resolve this issue, the code and NV variables need to be separated.
12
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
15
But in that case we need an extra flash. Hence, modify the convention
13
Acked-by: Alistair Francis <alistair.francis@wdc.com>
16
for non-KVM guests such that, pflash0 will contain the M-mode FW
14
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
17
only when "-bios none" option is used. Otherwise, pflash0 will contain
15
Message-ID: <20230727-groom-decline-2c57ce42841c@spud>
18
the S-mode payload FW. This enables both pflash instances available
19
for EDK2 use.
20
21
When KVM is enabled, pflash0 is always assumed to contain the
22
S-mode payload firmware only.
23
24
Example usage:
25
1) pflash0 containing M-mode FW
26
qemu-system-riscv64 -bios none -pflash <mmode_fw> -machine virt
27
or
28
qemu-system-riscv64 -bios none \
29
-drive file=<mmode_fw>,if=pflash,format=raw,unit=0 -machine virt
30
31
2) pflash0 containing S-mode payload like EDK2
32
qemu-system-riscv64 -pflash <smode_fw_code> -pflash <smode_vars> -machine virt
33
or
34
qemu-system-riscv64 -bios <opensbi_fw> \
35
-pflash <smode_fw_code> \
36
-pflash <smode_vars> \
37
-machine virt
38
or
39
qemu-system-riscv64 -bios <opensbi_fw> \
40
-drive file=<smode_fw_code>,if=pflash,format=raw,unit=0,readonly=on \
41
-drive file=<smode_fw_vars>,if=pflash,format=raw,unit=1 \
42
-machine virt
43
44
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
45
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
46
Tested-by: Andrea Bolognani <abologna@redhat.com>
47
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
48
Message-Id: <20230601045910.18646-2-sunilvl@ventanamicro.com>
49
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
50
---
17
---
51
hw/riscv/virt.c | 53 ++++++++++++++++++++-----------------------------
18
hw/riscv/virt.c | 2 +-
52
1 file changed, 21 insertions(+), 32 deletions(-)
19
1 file changed, 1 insertion(+), 1 deletion(-)
53
20
54
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
21
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
55
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/riscv/virt.c
23
--- a/hw/riscv/virt.c
57
+++ b/hw/riscv/virt.c
24
+++ b/hw/riscv/virt.c
58
@@ -XXX,XX +XXX,XX @@ static void virt_machine_done(Notifier *notifier, void *data)
25
@@ -XXX,XX +XXX,XX @@ static void create_fdt_pmu(RISCVVirtState *s)
59
target_ulong firmware_end_addr, kernel_start_addr;
26
MachineState *ms = MACHINE(s);
60
const char *firmware_name = riscv_default_firmware_name(&s->soc[0]);
27
RISCVCPU hart = s->soc[0].harts[0];
61
uint32_t fdt_load_addr;
28
62
- uint64_t kernel_entry;
29
- pmu_name = g_strdup_printf("/soc/pmu");
63
+ uint64_t kernel_entry = 0;
30
+ pmu_name = g_strdup_printf("/pmu");
64
31
qemu_fdt_add_subnode(ms->fdt, pmu_name);
65
/*
32
qemu_fdt_setprop_string(ms->fdt, pmu_name, "compatible", "riscv,pmu");
66
* Only direct boot kernel is currently supported for KVM VM,
33
riscv_pmu_generate_fdt_node(ms->fdt, hart.cfg.pmu_num, pmu_name);
67
@@ -XXX,XX +XXX,XX @@ static void virt_machine_done(Notifier *notifier, void *data)
68
firmware_end_addr = riscv_find_and_load_firmware(machine, firmware_name,
69
start_addr, NULL);
70
71
- if (drive_get(IF_PFLASH, 0, 1)) {
72
- /*
73
- * S-mode FW like EDK2 will be kept in second plash (unit 1).
74
- * When both kernel, initrd and pflash options are provided in the
75
- * command line, the kernel and initrd will be copied to the fw_cfg
76
- * table and opensbi will jump to the flash address which is the
77
- * entry point of S-mode FW. It is the job of the S-mode FW to load
78
- * the kernel and initrd using fw_cfg table.
79
- *
80
- * If only pflash is given but not -kernel, then it is the job of
81
- * of the S-mode firmware to locate and load the kernel.
82
- * In either case, the next_addr for opensbi will be the flash address.
83
- */
84
- riscv_setup_firmware_boot(machine);
85
- kernel_entry = virt_memmap[VIRT_FLASH].base +
86
- virt_memmap[VIRT_FLASH].size / 2;
87
- } else if (machine->kernel_filename) {
88
+ if (drive_get(IF_PFLASH, 0, 0)) {
89
+ if (machine->firmware && !strcmp(machine->firmware, "none") &&
90
+ !kvm_enabled()) {
91
+ /*
92
+ * Pflash was supplied but bios is none and not KVM guest,
93
+ * let's overwrite the address we jump to after reset to
94
+ * the base of the flash.
95
+ */
96
+ start_addr = virt_memmap[VIRT_FLASH].base;
97
+ } else {
98
+ /*
99
+ * Pflash was supplied but either KVM guest or bios is not none.
100
+ * In this case, base of the flash would contain S-mode payload.
101
+ */
102
+ riscv_setup_firmware_boot(machine);
103
+ kernel_entry = virt_memmap[VIRT_FLASH].base;
104
+ }
105
+ }
106
+
107
+ if (machine->kernel_filename && !kernel_entry) {
108
kernel_start_addr = riscv_calc_kernel_start_addr(&s->soc[0],
109
firmware_end_addr);
110
111
kernel_entry = riscv_load_kernel(machine, &s->soc[0],
112
kernel_start_addr, true, NULL);
113
- } else {
114
- /*
115
- * If dynamic firmware is used, it doesn't know where is the next mode
116
- * if kernel argument is not set.
117
- */
118
- kernel_entry = 0;
119
- }
120
-
121
- if (drive_get(IF_PFLASH, 0, 0)) {
122
- /*
123
- * Pflash was supplied, let's overwrite the address we jump to after
124
- * reset to the base of the flash.
125
- */
126
- start_addr = virt_memmap[VIRT_FLASH].base;
127
}
128
129
fdt_load_addr = riscv_compute_fdt_addr(memmap[VIRT_DRAM].base,
130
--
34
--
131
2.40.1
35
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
2
3
Pass RISCVCPUConfig as disassemble_info.target_info to support disas
3
The Svadu specification updated the name of the *envcfg bit from
4
of conflict instructions related to specific extensions.
4
HADE to ADUE.
5
5
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-ID: <20230816141916.66898-1-liweiwei@iscas.ac.cn>
10
Message-Id: <20230523093539.203909-4-liweiwei@iscas.ac.cn>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
11
---
13
disas/riscv.c | 10 +++++++---
12
target/riscv/cpu_bits.h | 8 ++++----
14
target/riscv/cpu.c | 1 +
13
target/riscv/cpu.c | 4 ++--
15
2 files changed, 8 insertions(+), 3 deletions(-)
14
target/riscv/cpu_helper.c | 6 +++---
15
target/riscv/csr.c | 12 ++++++------
16
4 files changed, 15 insertions(+), 15 deletions(-)
16
17
17
diff --git a/disas/riscv.c b/disas/riscv.c
18
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/disas/riscv.c
20
--- a/target/riscv/cpu_bits.h
20
+++ b/disas/riscv.c
21
+++ b/target/riscv/cpu_bits.h
21
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ typedef enum RISCVException {
22
23
#define MENVCFG_CBIE (3UL << 4)
23
#include "qemu/osdep.h"
24
#define MENVCFG_CBCFE BIT(6)
24
#include "disas/dis-asm.h"
25
#define MENVCFG_CBZE BIT(7)
25
-
26
-#define MENVCFG_HADE (1ULL << 61)
26
+#include "target/riscv/cpu_cfg.h"
27
+#define MENVCFG_ADUE (1ULL << 61)
27
28
#define MENVCFG_PBMTE (1ULL << 62)
28
/* types */
29
#define MENVCFG_STCE (1ULL << 63)
29
30
30
@@ -XXX,XX +XXX,XX @@ typedef enum {
31
/* For RV32 */
31
/* structures */
32
-#define MENVCFGH_HADE BIT(29)
32
33
+#define MENVCFGH_ADUE BIT(29)
33
typedef struct {
34
#define MENVCFGH_PBMTE BIT(30)
34
+ RISCVCPUConfig *cfg;
35
#define MENVCFGH_STCE BIT(31)
35
uint64_t pc;
36
36
uint64_t inst;
37
@@ -XXX,XX +XXX,XX @@ typedef enum RISCVException {
37
int32_t imm;
38
#define HENVCFG_CBIE MENVCFG_CBIE
38
@@ -XXX,XX +XXX,XX @@ static void decode_inst_decompress(rv_decode *dec, rv_isa isa)
39
#define HENVCFG_CBCFE MENVCFG_CBCFE
39
/* disassemble instruction */
40
#define HENVCFG_CBZE MENVCFG_CBZE
40
41
-#define HENVCFG_HADE MENVCFG_HADE
41
static void
42
+#define HENVCFG_ADUE MENVCFG_ADUE
42
-disasm_inst(char *buf, size_t buflen, rv_isa isa, uint64_t pc, rv_inst inst)
43
#define HENVCFG_PBMTE MENVCFG_PBMTE
43
+disasm_inst(char *buf, size_t buflen, rv_isa isa, uint64_t pc, rv_inst inst,
44
#define HENVCFG_STCE MENVCFG_STCE
44
+ RISCVCPUConfig *cfg)
45
45
{
46
/* For RV32 */
46
rv_decode dec = { 0 };
47
-#define HENVCFGH_HADE MENVCFGH_HADE
47
dec.pc = pc;
48
+#define HENVCFGH_ADUE MENVCFGH_ADUE
48
dec.inst = inst;
49
#define HENVCFGH_PBMTE MENVCFGH_PBMTE
49
+ dec.cfg = cfg;
50
#define HENVCFGH_STCE MENVCFGH_STCE
50
decode_inst_opcode(&dec, isa);
51
51
decode_inst_operands(&dec, isa);
52
decode_inst_decompress(&dec, isa);
53
@@ -XXX,XX +XXX,XX @@ print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa)
54
break;
55
}
56
57
- disasm_inst(buf, sizeof(buf), isa, memaddr, inst);
58
+ disasm_inst(buf, sizeof(buf), isa, memaddr, inst,
59
+ (RISCVCPUConfig *)info->target_info);
60
(*info->fprintf_func)(info->stream, "%s", buf);
61
62
return len;
63
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
52
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
64
index XXXXXXX..XXXXXXX 100644
53
index XXXXXXX..XXXXXXX 100644
65
--- a/target/riscv/cpu.c
54
--- a/target/riscv/cpu.c
66
+++ b/target/riscv/cpu.c
55
+++ b/target/riscv/cpu.c
67
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj)
56
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj)
68
static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)
57
env->two_stage_lookup = false;
58
59
env->menvcfg = (cpu->cfg.ext_svpbmt ? MENVCFG_PBMTE : 0) |
60
- (cpu->cfg.ext_svadu ? MENVCFG_HADE : 0);
61
+ (cpu->cfg.ext_svadu ? MENVCFG_ADUE : 0);
62
env->henvcfg = (cpu->cfg.ext_svpbmt ? HENVCFG_PBMTE : 0) |
63
- (cpu->cfg.ext_svadu ? HENVCFG_HADE : 0);
64
+ (cpu->cfg.ext_svadu ? HENVCFG_ADUE : 0);
65
66
/* Initialized default priorities of local interrupts. */
67
for (i = 0; i < ARRAY_SIZE(env->miprio); i++) {
68
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/target/riscv/cpu_helper.c
71
+++ b/target/riscv/cpu_helper.c
72
@@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical,
73
}
74
75
bool pbmte = env->menvcfg & MENVCFG_PBMTE;
76
- bool hade = env->menvcfg & MENVCFG_HADE;
77
+ bool adue = env->menvcfg & MENVCFG_ADUE;
78
79
if (first_stage && two_stage && env->virt_enabled) {
80
pbmte = pbmte && (env->henvcfg & HENVCFG_PBMTE);
81
- hade = hade && (env->henvcfg & HENVCFG_HADE);
82
+ adue = adue && (env->henvcfg & HENVCFG_ADUE);
83
}
84
85
int ptshift = (levels - 1) * ptidxbits;
86
@@ -XXX,XX +XXX,XX @@ restart:
87
88
/* Page table updates need to be atomic with MTTCG enabled */
89
if (updated_pte != pte && !is_debug) {
90
- if (!hade) {
91
+ if (!adue) {
92
return TRANSLATE_FAIL;
93
}
94
95
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
96
index XXXXXXX..XXXXXXX 100644
97
--- a/target/riscv/csr.c
98
+++ b/target/riscv/csr.c
99
@@ -XXX,XX +XXX,XX @@ static RISCVException write_menvcfg(CPURISCVState *env, int csrno,
100
if (riscv_cpu_mxl(env) == MXL_RV64) {
101
mask |= (cfg->ext_svpbmt ? MENVCFG_PBMTE : 0) |
102
(cfg->ext_sstc ? MENVCFG_STCE : 0) |
103
- (cfg->ext_svadu ? MENVCFG_HADE : 0);
104
+ (cfg->ext_svadu ? MENVCFG_ADUE : 0);
105
}
106
env->menvcfg = (env->menvcfg & ~mask) | (val & mask);
107
108
@@ -XXX,XX +XXX,XX @@ static RISCVException write_menvcfgh(CPURISCVState *env, int csrno,
109
const RISCVCPUConfig *cfg = riscv_cpu_cfg(env);
110
uint64_t mask = (cfg->ext_svpbmt ? MENVCFG_PBMTE : 0) |
111
(cfg->ext_sstc ? MENVCFG_STCE : 0) |
112
- (cfg->ext_svadu ? MENVCFG_HADE : 0);
113
+ (cfg->ext_svadu ? MENVCFG_ADUE : 0);
114
uint64_t valh = (uint64_t)val << 32;
115
116
env->menvcfg = (env->menvcfg & ~mask) | (valh & mask);
117
@@ -XXX,XX +XXX,XX @@ static RISCVException read_henvcfg(CPURISCVState *env, int csrno,
118
* henvcfg.stce is read_only 0 when menvcfg.stce = 0
119
* henvcfg.hade is read_only 0 when menvcfg.hade = 0
120
*/
121
- *val = env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_HADE) |
122
+ *val = env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE) |
123
env->menvcfg);
124
return RISCV_EXCP_NONE;
125
}
126
@@ -XXX,XX +XXX,XX @@ static RISCVException write_henvcfg(CPURISCVState *env, int csrno,
127
}
128
129
if (riscv_cpu_mxl(env) == MXL_RV64) {
130
- mask |= env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_HADE);
131
+ mask |= env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE);
132
}
133
134
env->henvcfg = (env->henvcfg & ~mask) | (val & mask);
135
@@ -XXX,XX +XXX,XX @@ static RISCVException read_henvcfgh(CPURISCVState *env, int csrno,
136
return ret;
137
}
138
139
- *val = (env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_HADE) |
140
+ *val = (env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE) |
141
env->menvcfg)) >> 32;
142
return RISCV_EXCP_NONE;
143
}
144
@@ -XXX,XX +XXX,XX @@ static RISCVException write_henvcfgh(CPURISCVState *env, int csrno,
145
target_ulong val)
69
{
146
{
70
RISCVCPU *cpu = RISCV_CPU(s);
147
uint64_t mask = env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE |
71
+ info->target_info = &cpu->cfg;
148
- HENVCFG_HADE);
72
149
+ HENVCFG_ADUE);
73
switch (riscv_cpu_mxl(&cpu->env)) {
150
uint64_t valh = (uint64_t)val << 32;
74
case MXL_RV32:
151
RISCVException ret;
152
75
--
153
--
76
2.40.1
154
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2
2
3
The RVV verification will error out if fails and it's being done at the
3
In the same emulated RISC-V host, the 'host' KVM CPU takes 4 times
4
end of riscv_cpu_validate_set_extensions(), after we've already set some
4
longer to boot than the 'rv64' KVM CPU.
5
extensions that are dependent on RVV. Let's put it in its own function
6
and do it earlier.
7
5
6
The reason is an unintended behavior of riscv_cpu_satp_mode_finalize()
7
when satp_mode.supported = 0, i.e. when cpu_init() does not set
8
satp_mode_max_supported(). satp_mode_max_from_map(map) does:
9
10
31 - __builtin_clz(map)
11
12
This means that, if satp_mode.supported = 0, satp_mode_supported_max
13
wil be '31 - 32'. But this is C, so satp_mode_supported_max will gladly
14
set it to UINT_MAX (4294967295). After that, if the user didn't set a
15
satp_mode, set_satp_mode_default_map(cpu) will make
16
17
cfg.satp_mode.map = cfg.satp_mode.supported
18
19
So satp_mode.map = 0. And then satp_mode_map_max will be set to
20
satp_mode_max_from_map(cpu->cfg.satp_mode.map), i.e. also UINT_MAX. The
21
guard "satp_mode_map_max > satp_mode_supported_max" doesn't protect us
22
here since both are UINT_MAX.
23
24
And finally we have 2 loops:
25
26
for (int i = satp_mode_map_max - 1; i >= 0; --i) {
27
28
Which are, in fact, 2 loops from UINT_MAX -1 to -1. This is where the
29
extra delay when booting the 'host' CPU is coming from.
30
31
Commit 43d1de32f8 already set a precedence for satp_mode.supported = 0
32
in a different manner. We're doing the same here. If supported == 0,
33
interpret as 'the CPU wants the OS to handle satp mode alone' and skip
34
satp_mode_finalize().
35
36
We'll also put a guard in satp_mode_max_from_map() to assert out if map
37
is 0 since the function is not ready to deal with it.
38
39
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
40
Fixes: 6f23aaeb9b ("riscv: Allow user to set the satp mode")
8
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
41
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
9
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
42
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
10
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
43
Message-ID: <20230817152903.694926-1-dbarboza@ventanamicro.com>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-Id: <20230517135714.211809-2-dbarboza@ventanamicro.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
44
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
45
---
15
target/riscv/cpu.c | 89 +++++++++++++++++++++++++---------------------
46
target/riscv/cpu.c | 23 ++++++++++++++++++++---
16
1 file changed, 48 insertions(+), 41 deletions(-)
47
1 file changed, 20 insertions(+), 3 deletions(-)
17
48
18
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
49
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
19
index XXXXXXX..XXXXXXX 100644
50
index XXXXXXX..XXXXXXX 100644
20
--- a/target/riscv/cpu.c
51
--- a/target/riscv/cpu.c
21
+++ b/target/riscv/cpu.c
52
+++ b/target/riscv/cpu.c
22
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)
53
@@ -XXX,XX +XXX,XX @@ static uint8_t satp_mode_from_str(const char *satp_mode_str)
23
}
54
55
uint8_t satp_mode_max_from_map(uint32_t map)
56
{
57
+ /*
58
+ * 'map = 0' will make us return (31 - 32), which C will
59
+ * happily overflow to UINT_MAX. There's no good result to
60
+ * return if 'map = 0' (e.g. returning 0 will be ambiguous
61
+ * with the result for 'map = 1').
62
+ *
63
+ * Assert out if map = 0. Callers will have to deal with
64
+ * it outside of this function.
65
+ */
66
+ g_assert(map > 0);
67
+
68
/* map here has at least one bit set, so no problem with clz */
69
return 31 - __builtin_clz(map);
24
}
70
}
25
71
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
26
+static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg,
72
static void riscv_cpu_satp_mode_finalize(RISCVCPU *cpu, Error **errp)
27
+ Error **errp)
73
{
28
+{
74
bool rv32 = riscv_cpu_mxl(&cpu->env) == MXL_RV32;
29
+ int vext_version = VEXT_VERSION_1_00_0;
75
- uint8_t satp_mode_map_max;
76
- uint8_t satp_mode_supported_max =
77
- satp_mode_max_from_map(cpu->cfg.satp_mode.supported);
78
+ uint8_t satp_mode_map_max, satp_mode_supported_max;
30
+
79
+
31
+ if (!is_power_of_2(cfg->vlen)) {
80
+ /* The CPU wants the OS to decide which satp mode to use */
32
+ error_setg(errp, "Vector extension VLEN must be power of 2");
81
+ if (cpu->cfg.satp_mode.supported == 0) {
33
+ return;
82
+ return;
34
+ }
83
+ }
35
+ if (cfg->vlen > RV_VLEN_MAX || cfg->vlen < 128) {
36
+ error_setg(errp,
37
+ "Vector extension implementation only supports VLEN "
38
+ "in the range [128, %d]", RV_VLEN_MAX);
39
+ return;
40
+ }
41
+ if (!is_power_of_2(cfg->elen)) {
42
+ error_setg(errp, "Vector extension ELEN must be power of 2");
43
+ return;
44
+ }
45
+ if (cfg->elen > 64 || cfg->elen < 8) {
46
+ error_setg(errp,
47
+ "Vector extension implementation only supports ELEN "
48
+ "in the range [8, 64]");
49
+ return;
50
+ }
51
+ if (cfg->vext_spec) {
52
+ if (!g_strcmp0(cfg->vext_spec, "v1.0")) {
53
+ vext_version = VEXT_VERSION_1_00_0;
54
+ } else {
55
+ error_setg(errp, "Unsupported vector spec version '%s'",
56
+ cfg->vext_spec);
57
+ return;
58
+ }
59
+ } else {
60
+ qemu_log("vector version is not specified, "
61
+ "use the default value v1.0\n");
62
+ }
63
+ set_vext_version(env, vext_version);
64
+}
65
+
84
+
66
/*
85
+ satp_mode_supported_max =
67
* Check consistency between chosen extensions while setting
86
+ satp_mode_max_from_map(cpu->cfg.satp_mode.supported);
68
* cpu->cfg accordingly.
87
69
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)
88
if (cpu->cfg.satp_mode.map == 0) {
70
static void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
89
if (cpu->cfg.satp_mode.init == 0) {
71
{
72
CPURISCVState *env = &cpu->env;
73
+ Error *local_err = NULL;
74
75
/* Do some ISA extension error checking */
76
if (riscv_has_ext(env, RVG) &&
77
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
78
return;
79
}
80
81
- /* The V vector extension depends on the Zve64d extension */
82
if (riscv_has_ext(env, RVV)) {
83
+ riscv_cpu_validate_v(env, &cpu->cfg, &local_err);
84
+ if (local_err != NULL) {
85
+ error_propagate(errp, local_err);
86
+ return;
87
+ }
88
+
89
+ /* The V vector extension depends on the Zve64d extension */
90
cpu->cfg.ext_zve64d = true;
91
}
92
93
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
94
cpu->cfg.ext_zksed = true;
95
cpu->cfg.ext_zksh = true;
96
}
97
-
98
- if (riscv_has_ext(env, RVV)) {
99
- int vext_version = VEXT_VERSION_1_00_0;
100
- if (!is_power_of_2(cpu->cfg.vlen)) {
101
- error_setg(errp,
102
- "Vector extension VLEN must be power of 2");
103
- return;
104
- }
105
- if (cpu->cfg.vlen > RV_VLEN_MAX || cpu->cfg.vlen < 128) {
106
- error_setg(errp,
107
- "Vector extension implementation only supports VLEN "
108
- "in the range [128, %d]", RV_VLEN_MAX);
109
- return;
110
- }
111
- if (!is_power_of_2(cpu->cfg.elen)) {
112
- error_setg(errp,
113
- "Vector extension ELEN must be power of 2");
114
- return;
115
- }
116
- if (cpu->cfg.elen > 64 || cpu->cfg.elen < 8) {
117
- error_setg(errp,
118
- "Vector extension implementation only supports ELEN "
119
- "in the range [8, 64]");
120
- return;
121
- }
122
- if (cpu->cfg.vext_spec) {
123
- if (!g_strcmp0(cpu->cfg.vext_spec, "v1.0")) {
124
- vext_version = VEXT_VERSION_1_00_0;
125
- } else {
126
- error_setg(errp,
127
- "Unsupported vector spec version '%s'",
128
- cpu->cfg.vext_spec);
129
- return;
130
- }
131
- } else {
132
- qemu_log("vector version is not specified, "
133
- "use the default value v1.0\n");
134
- }
135
- set_vext_version(env, vext_version);
136
- }
137
}
138
139
#ifndef CONFIG_USER_ONLY
140
--
90
--
141
2.40.1
91
2.41.0
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Vineet Gupta <vineetg@rivosinc.com>
2
2
3
Zc* extensions (version 1.0) are ratified.
3
zicond is now codegen supported in both llvm and gcc.
4
4
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
5
This change allows seamless enabling/testing of zicond in downstream
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
6
projects. e.g. currently riscv-gnu-toolchain parses elf attributes
7
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
7
to create a cmdline for qemu but fails short of enabling it because of
8
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
8
the "x-" prefix.
9
Message-Id: <20230510030040.20528-1-liweiwei@iscas.ac.cn>
9
10
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
11
Message-ID: <20230808181715.436395-1-vineetg@rivosinc.com>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
14
---
12
target/riscv/cpu.c | 16 ++++++++--------
15
target/riscv/cpu.c | 2 +-
13
1 file changed, 8 insertions(+), 8 deletions(-)
16
1 file changed, 1 insertion(+), 1 deletion(-)
14
17
15
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
18
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
16
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/cpu.c
20
--- a/target/riscv/cpu.c
18
+++ b/target/riscv/cpu.c
21
+++ b/target/riscv/cpu.c
19
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
22
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
20
23
DEFINE_PROP_BOOL("zcf", RISCVCPU, cfg.ext_zcf, false),
21
DEFINE_PROP_BOOL("zmmul", RISCVCPU, cfg.ext_zmmul, false),
24
DEFINE_PROP_BOOL("zcmp", RISCVCPU, cfg.ext_zcmp, false),
22
25
DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false),
23
+ DEFINE_PROP_BOOL("zca", RISCVCPU, cfg.ext_zca, false),
26
+ DEFINE_PROP_BOOL("zicond", RISCVCPU, cfg.ext_zicond, false),
24
+ DEFINE_PROP_BOOL("zcb", RISCVCPU, cfg.ext_zcb, false),
27
25
+ DEFINE_PROP_BOOL("zcd", RISCVCPU, cfg.ext_zcd, false),
26
+ DEFINE_PROP_BOOL("zce", RISCVCPU, cfg.ext_zce, false),
27
+ DEFINE_PROP_BOOL("zcf", RISCVCPU, cfg.ext_zcf, false),
28
+ DEFINE_PROP_BOOL("zcmp", RISCVCPU, cfg.ext_zcmp, false),
29
+ DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false),
30
+
31
/* Vendor-specific custom extensions */
28
/* Vendor-specific custom extensions */
32
DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false),
29
DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false),
33
DEFINE_PROP_BOOL("xtheadbb", RISCVCPU, cfg.ext_xtheadbb, false),
34
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
30
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_extensions[] = {
31
DEFINE_PROP_BOOL("xventanacondops", RISCVCPU, cfg.ext_XVentanaCondOps, false),
32
35
/* These are experimental so mark with 'x-' */
33
/* These are experimental so mark with 'x-' */
36
DEFINE_PROP_BOOL("x-zicond", RISCVCPU, cfg.ext_zicond, false),
34
- DEFINE_PROP_BOOL("x-zicond", RISCVCPU, cfg.ext_zicond, false),
37
35
38
- DEFINE_PROP_BOOL("x-zca", RISCVCPU, cfg.ext_zca, false),
39
- DEFINE_PROP_BOOL("x-zcb", RISCVCPU, cfg.ext_zcb, false),
40
- DEFINE_PROP_BOOL("x-zcd", RISCVCPU, cfg.ext_zcd, false),
41
- DEFINE_PROP_BOOL("x-zce", RISCVCPU, cfg.ext_zce, false),
42
- DEFINE_PROP_BOOL("x-zcf", RISCVCPU, cfg.ext_zcf, false),
43
- DEFINE_PROP_BOOL("x-zcmp", RISCVCPU, cfg.ext_zcmp, false),
44
- DEFINE_PROP_BOOL("x-zcmt", RISCVCPU, cfg.ext_zcmt, false),
45
-
46
/* ePMP 0.9.3 */
36
/* ePMP 0.9.3 */
47
DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false),
37
DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false),
48
DEFINE_PROP_BOOL("x-smaia", RISCVCPU, cfg.ext_smaia, false),
49
--
38
--
50
2.40.1
39
2.41.0
diff view generated by jsdifflib
1
From: Sunil V L <sunilvl@ventanamicro.com>
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2
2
3
Currently, pflash devices can be configured only via -pflash
3
A build with --enable-debug and without KVM will fail as follows:
4
or -drive options. This is the legacy way and the
5
better way is to use -blockdev as in other architectures.
6
libvirt also has moved to use -blockdev method.
7
4
8
To support -blockdev option, pflash devices need to be
5
/usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_riscv_virt.c.o: in function `virt_machine_init':
9
created in instance_init itself. So, update the code to
6
./qemu/build/../hw/riscv/virt.c:1465: undefined reference to `kvm_riscv_aia_create'
10
move the virt_flash_create() to instance_init. Also, use
11
standard interfaces to detect whether pflash0 is
12
configured or not.
13
7
14
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
8
This happens because the code block with "if virt_use_kvm_aia(s)" isn't
15
Reported-by: Andrea Bolognani <abologna@redhat.com>
9
being ignored by the debug build, resulting in an undefined reference to
16
Tested-by: Andrea Bolognani <abologna@redhat.com>
10
a KVM only function.
11
12
Add a 'kvm_enabled()' conditional together with virt_use_kvm_aia() will
13
make the compiler crop the kvm_riscv_aia_create() call entirely from a
14
non-KVM build. Note that adding the 'kvm_enabled()' conditional inside
15
virt_use_kvm_aia() won't fix the build because this function would need
16
to be inlined multiple times to make the compiler zero out the entire
17
block.
18
19
While we're at it, use kvm_enabled() in all instances where
20
virt_use_kvm_aia() is checked to allow the compiler to elide these other
21
kvm-only instances as well.
22
23
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
24
Fixes: dbdb99948e ("target/riscv: select KVM AIA in riscv virt machine")
25
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
26
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
17
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
27
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
18
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
28
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-Id: <20230601045910.18646-3-sunilvl@ventanamicro.com>
29
Message-ID: <20230830133503.711138-2-dbarboza@ventanamicro.com>
20
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
30
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
21
---
31
---
22
hw/riscv/virt.c | 8 +++++---
32
hw/riscv/virt.c | 6 +++---
23
1 file changed, 5 insertions(+), 3 deletions(-)
33
1 file changed, 3 insertions(+), 3 deletions(-)
24
34
25
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
35
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
26
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/riscv/virt.c
37
--- a/hw/riscv/virt.c
28
+++ b/hw/riscv/virt.c
38
+++ b/hw/riscv/virt.c
29
@@ -XXX,XX +XXX,XX @@ static void virt_machine_done(Notifier *notifier, void *data)
39
@@ -XXX,XX +XXX,XX @@ static void create_fdt_sockets(RISCVVirtState *s, const MemMapEntry *memmap,
30
const char *firmware_name = riscv_default_firmware_name(&s->soc[0]);
40
}
31
uint32_t fdt_load_addr;
41
32
uint64_t kernel_entry = 0;
42
/* KVM AIA only has one APLIC instance */
33
+ BlockBackend *pflash_blk0;
43
- if (virt_use_kvm_aia(s)) {
34
44
+ if (kvm_enabled() && virt_use_kvm_aia(s)) {
35
/*
45
create_fdt_socket_aplic(s, memmap, 0,
36
* Only direct boot kernel is currently supported for KVM VM,
46
msi_m_phandle, msi_s_phandle, phandle,
37
@@ -XXX,XX +XXX,XX @@ static void virt_machine_done(Notifier *notifier, void *data)
47
&intc_phandles[0], xplic_phandles,
38
firmware_end_addr = riscv_find_and_load_firmware(machine, firmware_name,
48
@@ -XXX,XX +XXX,XX @@ static void create_fdt_sockets(RISCVVirtState *s, const MemMapEntry *memmap,
39
start_addr, NULL);
49
40
50
g_free(intc_phandles);
41
- if (drive_get(IF_PFLASH, 0, 0)) {
51
42
+ pflash_blk0 = pflash_cfi01_get_blk(s->flash[0]);
52
- if (virt_use_kvm_aia(s)) {
43
+ if (pflash_blk0) {
53
+ if (kvm_enabled() && virt_use_kvm_aia(s)) {
44
if (machine->firmware && !strcmp(machine->firmware, "none") &&
54
*irq_mmio_phandle = xplic_phandles[0];
45
!kvm_enabled()) {
55
*irq_virtio_phandle = xplic_phandles[0];
46
/*
56
*irq_pcie_phandle = xplic_phandles[0];
47
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
57
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
48
sysbus_create_simple("goldfish_rtc", memmap[VIRT_RTC].base,
58
}
49
qdev_get_gpio_in(mmio_irqchip, RTC_IRQ));
59
}
50
60
51
- virt_flash_create(s);
61
- if (virt_use_kvm_aia(s)) {
52
-
62
+ if (kvm_enabled() && virt_use_kvm_aia(s)) {
53
for (i = 0; i < ARRAY_SIZE(s->flash); i++) {
63
kvm_riscv_aia_create(machine, IMSIC_MMIO_GROUP_MIN_SHIFT,
54
/* Map legacy -drive if=pflash to machine properties */
64
VIRT_IRQCHIP_NUM_SOURCES, VIRT_IRQCHIP_NUM_MSIS,
55
pflash_cfi01_legacy_drive(s->flash[i],
65
memmap[VIRT_APLIC_S].base,
56
@@ -XXX,XX +XXX,XX @@ static void virt_machine_instance_init(Object *obj)
57
{
58
RISCVVirtState *s = RISCV_VIRT_MACHINE(obj);
59
60
+ virt_flash_create(s);
61
+
62
s->oem_id = g_strndup(ACPI_BUILD_APPNAME6, 6);
63
s->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8);
64
s->acpi = ON_OFF_AUTO_AUTO;
65
--
66
--
66
2.40.1
67
2.41.0
67
68
68
69
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
2
2
3
When multiple QOM types are registered in the same file,
3
Commit 6df0b37e2ab breaks a --enable-debug build in a non-KVM
4
it is simpler to use the the DEFINE_TYPES() macro. Replace
4
environment with the following error:
5
the type_init() / type_register_static() combination. This
6
is in preparation of adding the OpenTitan machine type to
7
this array in a pair of commits.
8
5
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
/usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_intc_riscv_aplic.c.o: in function `riscv_kvm_aplic_request':
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
./qemu/build/../hw/intc/riscv_aplic.c:486: undefined reference to `kvm_set_irq'
11
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
collect2: error: ld returned 1 exit status
12
Message-Id: <20230520054510.68822-3-philmd@linaro.org>
9
10
This happens because the debug build will poke into the
11
'if (is_kvm_aia(aplic->msimode))' block and fail to find a reference to
12
the KVM only function riscv_kvm_aplic_request().
13
14
There are multiple solutions to fix this. We'll go with the same
15
solution from the previous patch, i.e. add a kvm_enabled() conditional
16
to filter out the block. But there's a catch: riscv_kvm_aplic_request()
17
is a local function that would end up being used if the compiler crops
18
the block, and this won't work. Quoting Richard Henderson's explanation
19
in [1]:
20
21
"(...) the compiler won't eliminate entire unused functions with -O0"
22
23
We'll solve it by moving riscv_kvm_aplic_request() to kvm.c and add its
24
declaration in kvm_riscv.h, where all other KVM specific public
25
functions are already declared. Other archs handles KVM specific code in
26
this manner and we expect to do the same from now on.
27
28
[1] https://lore.kernel.org/qemu-riscv/d2f1ad02-eb03-138f-9d08-db676deeed05@linaro.org/
29
30
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
31
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
32
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
33
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
34
Message-ID: <20230830133503.711138-3-dbarboza@ventanamicro.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
35
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
36
---
15
hw/riscv/opentitan.c | 21 +++++++++------------
37
target/riscv/kvm_riscv.h | 1 +
16
1 file changed, 9 insertions(+), 12 deletions(-)
38
hw/intc/riscv_aplic.c | 8 ++------
39
target/riscv/kvm.c | 5 +++++
40
3 files changed, 8 insertions(+), 6 deletions(-)
17
41
18
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
42
diff --git a/target/riscv/kvm_riscv.h b/target/riscv/kvm_riscv.h
19
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/riscv/opentitan.c
44
--- a/target/riscv/kvm_riscv.h
21
+++ b/hw/riscv/opentitan.c
45
+++ b/target/riscv/kvm_riscv.h
22
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_class_init(ObjectClass *oc, void *data)
46
@@ -XXX,XX +XXX,XX @@ void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift,
23
dc->user_creatable = false;
47
uint64_t aia_irq_num, uint64_t aia_msi_num,
48
uint64_t aplic_base, uint64_t imsic_base,
49
uint64_t guest_num);
50
+void riscv_kvm_aplic_request(void *opaque, int irq, int level);
51
52
#endif
53
diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/hw/intc/riscv_aplic.c
56
+++ b/hw/intc/riscv_aplic.c
57
@@ -XXX,XX +XXX,XX @@
58
#include "target/riscv/cpu.h"
59
#include "sysemu/sysemu.h"
60
#include "sysemu/kvm.h"
61
+#include "kvm_riscv.h"
62
#include "migration/vmstate.h"
63
64
#define APLIC_MAX_IDC (1UL << 14)
65
@@ -XXX,XX +XXX,XX @@ static uint32_t riscv_aplic_idc_claimi(RISCVAPLICState *aplic, uint32_t idc)
66
return topi;
24
}
67
}
25
68
26
-static const TypeInfo lowrisc_ibex_soc_type_info = {
69
-static void riscv_kvm_aplic_request(void *opaque, int irq, int level)
27
- .name = TYPE_RISCV_IBEX_SOC,
28
- .parent = TYPE_DEVICE,
29
- .instance_size = sizeof(LowRISCIbexSoCState),
30
- .instance_init = lowrisc_ibex_soc_init,
31
- .class_init = lowrisc_ibex_soc_class_init,
32
+static const TypeInfo open_titan_types[] = {
33
+ {
34
+ .name = TYPE_RISCV_IBEX_SOC,
35
+ .parent = TYPE_DEVICE,
36
+ .instance_size = sizeof(LowRISCIbexSoCState),
37
+ .instance_init = lowrisc_ibex_soc_init,
38
+ .class_init = lowrisc_ibex_soc_class_init,
39
+ }
40
};
41
42
-static void lowrisc_ibex_soc_register_types(void)
43
-{
70
-{
44
- type_register_static(&lowrisc_ibex_soc_type_info);
71
- kvm_set_irq(kvm_state, irq, !!level);
45
-}
72
-}
46
-
73
-
47
-type_init(lowrisc_ibex_soc_register_types)
74
static void riscv_aplic_request(void *opaque, int irq, int level)
48
+DEFINE_TYPES(open_titan_types)
75
{
76
bool update = false;
77
@@ -XXX,XX +XXX,XX @@ static void riscv_aplic_realize(DeviceState *dev, Error **errp)
78
* have IRQ lines delegated by their parent APLIC.
79
*/
80
if (!aplic->parent) {
81
- if (is_kvm_aia(aplic->msimode)) {
82
+ if (kvm_enabled() && is_kvm_aia(aplic->msimode)) {
83
qdev_init_gpio_in(dev, riscv_kvm_aplic_request, aplic->num_irqs);
84
} else {
85
qdev_init_gpio_in(dev, riscv_aplic_request, aplic->num_irqs);
86
diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/target/riscv/kvm.c
89
+++ b/target/riscv/kvm.c
90
@@ -XXX,XX +XXX,XX @@
91
#include "sysemu/runstate.h"
92
#include "hw/riscv/numa.h"
93
94
+void riscv_kvm_aplic_request(void *opaque, int irq, int level)
95
+{
96
+ kvm_set_irq(kvm_state, irq, !!level);
97
+}
98
+
99
static uint64_t kvm_riscv_reg_id(CPURISCVState *env, uint64_t type,
100
uint64_t idx)
101
{
49
--
102
--
50
2.40.1
103
2.41.0
51
104
52
105
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Robbin Ehn <rehn@rivosinc.com>
2
2
3
Use cur_insn_len to store the length of the current instruction to
3
This patch adds the new extensions in
4
prepare for PC-relative translation.
4
linux 6.5 to the hwprobe syscall.
5
5
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
6
And fixes RVC check to OR with correct value.
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
The previous variable contains 0 therefore it
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
did work.
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
10
Message-Id: <20230526072124.298466-3-liweiwei@iscas.ac.cn>
10
Signed-off-by: Robbin Ehn <rehn@rivosinc.com>
11
Acked-by: Richard Henderson <richard.henderson@linaro.org>
12
Acked-by: Alistair Francis <alistair.francis@wdc.com>
13
Message-ID: <bc82203b72d7efb30f1b4a8f9eb3d94699799dc8.camel@rivosinc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
15
---
13
target/riscv/translate.c | 4 +++-
16
linux-user/syscall.c | 14 +++++++++++++-
14
1 file changed, 3 insertions(+), 1 deletion(-)
17
1 file changed, 13 insertions(+), 1 deletion(-)
15
18
16
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
19
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/translate.c
21
--- a/linux-user/syscall.c
19
+++ b/target/riscv/translate.c
22
+++ b/linux-user/syscall.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
23
@@ -XXX,XX +XXX,XX @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count)
21
DisasContextBase base;
24
#define RISCV_HWPROBE_KEY_IMA_EXT_0 4
22
/* pc_succ_insn points to the instruction following base.pc_next */
25
#define RISCV_HWPROBE_IMA_FD (1 << 0)
23
target_ulong pc_succ_insn;
26
#define RISCV_HWPROBE_IMA_C (1 << 1)
24
+ target_ulong cur_insn_len;
27
+#define RISCV_HWPROBE_IMA_V (1 << 2)
25
target_ulong priv_ver;
28
+#define RISCV_HWPROBE_EXT_ZBA (1 << 3)
26
RISCVMXL misa_mxl_max;
29
+#define RISCV_HWPROBE_EXT_ZBB (1 << 4)
27
RISCVMXL xl;
30
+#define RISCV_HWPROBE_EXT_ZBS (1 << 5)
28
@@ -XXX,XX +XXX,XX @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
31
29
};
32
#define RISCV_HWPROBE_KEY_CPUPERF_0 5
30
33
#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)
31
ctx->virt_inst_excp = false;
34
@@ -XXX,XX +XXX,XX @@ static void risc_hwprobe_fill_pairs(CPURISCVState *env,
32
+ ctx->cur_insn_len = insn_len(opcode);
35
riscv_has_ext(env, RVD) ?
33
/* Check for compressed insn */
36
RISCV_HWPROBE_IMA_FD : 0;
34
- if (insn_len(opcode) == 2) {
37
value |= riscv_has_ext(env, RVC) ?
35
+ if (ctx->cur_insn_len == 2) {
38
- RISCV_HWPROBE_IMA_C : pair->value;
36
ctx->opcode = opcode;
39
+ RISCV_HWPROBE_IMA_C : 0;
37
ctx->pc_succ_insn = ctx->base.pc_next + 2;
40
+ value |= riscv_has_ext(env, RVV) ?
38
/*
41
+ RISCV_HWPROBE_IMA_V : 0;
42
+ value |= cfg->ext_zba ?
43
+ RISCV_HWPROBE_EXT_ZBA : 0;
44
+ value |= cfg->ext_zbb ?
45
+ RISCV_HWPROBE_EXT_ZBB : 0;
46
+ value |= cfg->ext_zbs ?
47
+ RISCV_HWPROBE_EXT_ZBS : 0;
48
__put_user(value, &pair->value);
49
break;
50
case RISCV_HWPROBE_KEY_CPUPERF_0:
39
--
51
--
40
2.40.1
52
2.41.0
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Ard Biesheuvel <ardb@kernel.org>
2
2
3
QOM type names are usually defined as TYPE_FOO.
3
Use the accelerated SubBytes/ShiftRows/AddRoundKey AES helper to
4
implement the first half of the key schedule derivation. This does not
5
actually involve shifting rows, so clone the same value into all four
6
columns of the AES vector to counter that operation.
4
7
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Cc: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
10
Cc: Palmer Dabbelt <palmer@dabbelt.com>
8
Message-Id: <20230520054510.68822-4-philmd@linaro.org>
11
Cc: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-ID: <20230831154118.138727-1-ardb@kernel.org>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
17
---
11
include/hw/riscv/opentitan.h | 2 ++
18
target/riscv/crypto_helper.c | 17 +++++------------
12
hw/riscv/opentitan.c | 2 +-
19
1 file changed, 5 insertions(+), 12 deletions(-)
13
2 files changed, 3 insertions(+), 1 deletion(-)
14
20
15
diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h
21
diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/riscv/opentitan.h
23
--- a/target/riscv/crypto_helper.c
18
+++ b/include/hw/riscv/opentitan.h
24
+++ b/target/riscv/crypto_helper.c
19
@@ -XXX,XX +XXX,XX @@ struct LowRISCIbexSoCState {
25
@@ -XXX,XX +XXX,XX @@ target_ulong HELPER(aes64ks1i)(target_ulong rs1, target_ulong rnum)
20
MemoryRegion flash_alias;
26
21
};
27
uint8_t enc_rnum = rnum;
22
28
uint32_t temp = (RS1 >> 32) & 0xFFFFFFFF;
23
+#define TYPE_OPENTITAN_MACHINE "opentitan"
29
- uint8_t rcon_ = 0;
24
+
30
- target_ulong result;
25
typedef struct OpenTitanState {
31
+ AESState t, rc = {};
26
/*< private >*/
32
27
SysBusDevice parent_obj;
33
if (enc_rnum != 0xA) {
28
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
34
temp = ror32(temp, 8); /* Rotate right by 8 */
29
index XXXXXXX..XXXXXXX 100644
35
- rcon_ = round_consts[enc_rnum];
30
--- a/hw/riscv/opentitan.c
36
+ rc.w[0] = rc.w[1] = round_consts[enc_rnum];
31
+++ b/hw/riscv/opentitan.c
37
}
32
@@ -XXX,XX +XXX,XX @@ static void opentitan_machine_class_init(MachineClass *mc)
38
33
mc->default_ram_size = ibex_memmap[IBEX_DEV_RAM].size;
39
- temp = ((uint32_t)AES_sbox[(temp >> 24) & 0xFF] << 24) |
40
- ((uint32_t)AES_sbox[(temp >> 16) & 0xFF] << 16) |
41
- ((uint32_t)AES_sbox[(temp >> 8) & 0xFF] << 8) |
42
- ((uint32_t)AES_sbox[(temp >> 0) & 0xFF] << 0);
43
+ t.w[0] = t.w[1] = t.w[2] = t.w[3] = temp;
44
+ aesenc_SB_SR_AK(&t, &t, &rc, false);
45
46
- temp ^= rcon_;
47
-
48
- result = ((uint64_t)temp << 32) | temp;
49
-
50
- return result;
51
+ return t.d[0];
34
}
52
}
35
53
36
-DEFINE_MACHINE("opentitan", opentitan_machine_class_init)
54
target_ulong HELPER(aes64im)(target_ulong rs1)
37
+DEFINE_MACHINE(TYPE_OPENTITAN_MACHINE, opentitan_machine_class_init)
38
39
static void lowrisc_ibex_soc_init(Object *obj)
40
{
41
--
55
--
42
2.40.1
56
2.41.0
43
57
44
58
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
2
3
Follow QOM style which declares FOO_init() as instance
3
riscv_trigger_init() had been called on reset events that can happen
4
initializer and FOO_class_init() as class initializer:
4
several times for a CPU and it allocated timers for itrigger. If old
5
rename the OpenTitan machine class/instance init()
5
timers were present, they were simply overwritten by the new timers,
6
accordingly.
6
resulting in a memory leak.
7
7
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Divide riscv_trigger_init() into two functions, namely
9
riscv_trigger_realize() and riscv_trigger_reset() and call them in
10
appropriate timing. The timer allocation will happen only once for a
11
CPU in riscv_trigger_realize().
12
13
Fixes: 5a4ae64cac ("target/riscv: Add itrigger support when icount is enabled")
14
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
17
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
18
Message-ID: <20230818034059.9146-1-akihiko.odaki@daynix.com>
11
Message-Id: <20230520054510.68822-2-philmd@linaro.org>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
19
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
20
---
14
hw/riscv/opentitan.c | 8 ++++----
21
target/riscv/debug.h | 3 ++-
15
1 file changed, 4 insertions(+), 4 deletions(-)
22
target/riscv/cpu.c | 8 +++++++-
23
target/riscv/debug.c | 15 ++++++++++++---
24
3 files changed, 21 insertions(+), 5 deletions(-)
16
25
17
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
26
diff --git a/target/riscv/debug.h b/target/riscv/debug.h
18
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/riscv/opentitan.c
28
--- a/target/riscv/debug.h
20
+++ b/hw/riscv/opentitan.c
29
+++ b/target/riscv/debug.h
21
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry ibex_memmap[] = {
30
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_debug_excp_handler(CPUState *cs);
22
[IBEX_DEV_FLASH_VIRTUAL] = { 0x80000000, 0x80000 },
31
bool riscv_cpu_debug_check_breakpoint(CPUState *cs);
23
};
32
bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp);
24
33
25
-static void opentitan_board_init(MachineState *machine)
34
-void riscv_trigger_init(CPURISCVState *env);
26
+static void opentitan_machine_init(MachineState *machine)
35
+void riscv_trigger_realize(CPURISCVState *env);
36
+void riscv_trigger_reset_hold(CPURISCVState *env);
37
38
bool riscv_itrigger_enabled(CPURISCVState *env);
39
void riscv_itrigger_update_priv(CPURISCVState *env);
40
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/riscv/cpu.c
43
+++ b/target/riscv/cpu.c
44
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj)
45
46
#ifndef CONFIG_USER_ONLY
47
if (cpu->cfg.debug) {
48
- riscv_trigger_init(env);
49
+ riscv_trigger_reset_hold(env);
50
}
51
52
if (kvm_enabled()) {
53
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
54
55
riscv_cpu_register_gdb_regs_for_features(cs);
56
57
+#ifndef CONFIG_USER_ONLY
58
+ if (cpu->cfg.debug) {
59
+ riscv_trigger_realize(&cpu->env);
60
+ }
61
+#endif
62
+
63
qemu_init_vcpu(cs);
64
cpu_reset(cs);
65
66
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/riscv/debug.c
69
+++ b/target/riscv/debug.c
70
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
71
return false;
72
}
73
74
-void riscv_trigger_init(CPURISCVState *env)
75
+void riscv_trigger_realize(CPURISCVState *env)
76
+{
77
+ int i;
78
+
79
+ for (i = 0; i < RV_MAX_TRIGGERS; i++) {
80
+ env->itrigger_timer[i] = timer_new_ns(QEMU_CLOCK_VIRTUAL,
81
+ riscv_itrigger_timer_cb, env);
82
+ }
83
+}
84
+
85
+void riscv_trigger_reset_hold(CPURISCVState *env)
27
{
86
{
28
MachineClass *mc = MACHINE_GET_CLASS(machine);
87
target_ulong tdata1 = build_tdata1(env, TRIGGER_TYPE_AD_MATCH, 0, 0);
29
const MemMapEntry *memmap = ibex_memmap;
88
int i;
30
@@ -XXX,XX +XXX,XX @@ static void opentitan_board_init(MachineState *machine)
89
@@ -XXX,XX +XXX,XX @@ void riscv_trigger_init(CPURISCVState *env)
90
env->tdata3[i] = 0;
91
env->cpu_breakpoint[i] = NULL;
92
env->cpu_watchpoint[i] = NULL;
93
- env->itrigger_timer[i] = timer_new_ns(QEMU_CLOCK_VIRTUAL,
94
- riscv_itrigger_timer_cb, env);
95
+ timer_del(env->itrigger_timer[i]);
31
}
96
}
32
}
97
}
33
34
-static void opentitan_machine_init(MachineClass *mc)
35
+static void opentitan_machine_class_init(MachineClass *mc)
36
{
37
mc->desc = "RISC-V Board compatible with OpenTitan";
38
- mc->init = opentitan_board_init;
39
+ mc->init = opentitan_machine_init;
40
mc->max_cpus = 1;
41
mc->default_cpu_type = TYPE_RISCV_CPU_IBEX;
42
mc->default_ram_id = "riscv.lowrisc.ibex.ram";
43
mc->default_ram_size = ibex_memmap[IBEX_DEV_RAM].size;
44
}
45
46
-DEFINE_MACHINE("opentitan", opentitan_machine_init)
47
+DEFINE_MACHINE("opentitan", opentitan_machine_class_init)
48
49
static void lowrisc_ibex_soc_init(Object *obj)
50
{
51
--
98
--
52
2.40.1
99
2.41.0
53
100
54
101
diff view generated by jsdifflib
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
1
From: Leon Schuermann <leons@opentitan.org>
2
2
3
RLB/MML/MMWP bits in mseccfg CSR are introduced by Smepmp extension.
3
When the rule-lock bypass (RLB) bit is set in the mseccfg CSR, the PMP
4
So they can only be writable and set to 1s when cfg.epmp is true.
4
configuration lock bits must not apply. While this behavior is
5
Then we also need't check on epmp in pmp_hart_has_privs_default().
5
implemented for the pmpcfgX CSRs, this bit is not respected for
6
changes to the pmpaddrX CSRs. This patch ensures that pmpaddrX CSR
7
writes work even on locked regions when the global rule-lock bypass is
8
enabled.
6
9
7
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
10
Signed-off-by: Leon Schuermann <leons@opentitan.org>
8
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
11
Reviewed-by: Mayuresh Chitale <mchitale@ventanamicro.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-Id: <20230517091519.34439-6-liweiwei@iscas.ac.cn>
13
Message-ID: <20230829215046.1430463-1-leon@is.currently.online>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
15
---
13
target/riscv/pmp.c | 50 ++++++++++++++++++++++++----------------------
16
target/riscv/pmp.c | 4 ++++
14
1 file changed, 26 insertions(+), 24 deletions(-)
17
1 file changed, 4 insertions(+)
15
18
16
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
19
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/pmp.c
21
--- a/target/riscv/pmp.c
19
+++ b/target/riscv/pmp.c
22
+++ b/target/riscv/pmp.c
20
@@ -XXX,XX +XXX,XX @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr,
23
@@ -XXX,XX +XXX,XX @@ static inline uint8_t pmp_get_a_field(uint8_t cfg)
24
*/
25
static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index)
21
{
26
{
22
bool ret;
27
+ /* mseccfg.RLB is set */
23
28
+ if (MSECCFG_RLB_ISSET(env)) {
24
- if (riscv_cpu_cfg(env)->epmp) {
29
+ return 0;
25
- if (MSECCFG_MMWP_ISSET(env)) {
26
- /*
27
- * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set
28
- * so we default to deny all, even for M-mode.
29
- */
30
+ if (MSECCFG_MMWP_ISSET(env)) {
31
+ /*
32
+ * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set
33
+ * so we default to deny all, even for M-mode.
34
+ */
35
+ *allowed_privs = 0;
36
+ return false;
37
+ } else if (MSECCFG_MML_ISSET(env)) {
38
+ /*
39
+ * The Machine Mode Lockdown (mseccfg.MML) bit is set
40
+ * so we can only execute code in M-mode with an applicable
41
+ * rule. Other modes are disabled.
42
+ */
43
+ if (mode == PRV_M && !(privs & PMP_EXEC)) {
44
+ ret = true;
45
+ *allowed_privs = PMP_READ | PMP_WRITE;
46
+ } else {
47
+ ret = false;
48
*allowed_privs = 0;
49
- return false;
50
- } else if (MSECCFG_MML_ISSET(env)) {
51
- /*
52
- * The Machine Mode Lockdown (mseccfg.MML) bit is set
53
- * so we can only execute code in M-mode with an applicable
54
- * rule. Other modes are disabled.
55
- */
56
- if (mode == PRV_M && !(privs & PMP_EXEC)) {
57
- ret = true;
58
- *allowed_privs = PMP_READ | PMP_WRITE;
59
- } else {
60
- ret = false;
61
- *allowed_privs = 0;
62
- }
63
-
64
- return ret;
65
}
66
+
67
+ return ret;
68
}
69
70
if (!riscv_cpu_cfg(env)->pmp || (mode == PRV_M)) {
71
@@ -XXX,XX +XXX,XX @@ void mseccfg_csr_write(CPURISCVState *env, target_ulong val)
72
}
73
}
74
75
- /* Sticky bits */
76
- val |= (env->mseccfg & (MSECCFG_MMWP | MSECCFG_MML));
77
+ if (riscv_cpu_cfg(env)->epmp) {
78
+ /* Sticky bits */
79
+ val |= (env->mseccfg & (MSECCFG_MMWP | MSECCFG_MML));
80
+ } else {
81
+ val &= ~(MSECCFG_MMWP | MSECCFG_MML | MSECCFG_RLB);
82
+ }
30
+ }
83
31
84
env->mseccfg = val;
32
if (env->pmp_state.pmp[pmp_index].cfg_reg & PMP_LOCK) {
85
}
33
return 1;
86
--
34
--
87
2.40.1
35
2.41.0
diff view generated by jsdifflib
1
From: Mayuresh Chitale <mchitale@ventanamicro.com>
1
From: Tommy Wu <tommy.wu@sifive.com>
2
2
3
Implement the s/h/mstateen.fcsr bit as defined in the smstateen spec
3
According to the new spec, when vsiselect has a reserved value, attempts
4
and check for it when accessing the fcsr register and its fields.
4
from M-mode or HS-mode to access vsireg, or from VS-mode to access
5
sireg, should preferably raise an illegal instruction exception.
5
6
6
Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
7
Signed-off-by: Tommy Wu <tommy.wu@sifive.com>
7
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
Reviewed-by: Frank Chang <frank.chang@sifive.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-ID: <20230816061647.600672-1-tommy.wu@sifive.com>
9
Message-Id: <20230518175058.2772506-2-mchitale@ventanamicro.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
11
---
12
target/riscv/csr.c | 15 +++++++++++++++
12
target/riscv/csr.c | 7 +++++--
13
1 file changed, 15 insertions(+)
13
1 file changed, 5 insertions(+), 2 deletions(-)
14
14
15
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
15
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/csr.c
17
--- a/target/riscv/csr.c
18
+++ b/target/riscv/csr.c
18
+++ b/target/riscv/csr.c
19
@@ -XXX,XX +XXX,XX @@ static RISCVException fs(CPURISCVState *env, int csrno)
19
@@ -XXX,XX +XXX,XX @@ static int rmw_iprio(target_ulong xlen,
20
!riscv_cpu_cfg(env)->ext_zfinx) {
20
static int rmw_xireg(CPURISCVState *env, int csrno, target_ulong *val,
21
return RISCV_EXCP_ILLEGAL_INST;
21
target_ulong new_val, target_ulong wr_mask)
22
{
23
- bool virt;
24
+ bool virt, isel_reserved;
25
uint8_t *iprio;
26
int ret = -EINVAL;
27
target_ulong priv, isel, vgein;
28
@@ -XXX,XX +XXX,XX @@ static int rmw_xireg(CPURISCVState *env, int csrno, target_ulong *val,
29
30
/* Decode register details from CSR number */
31
virt = false;
32
+ isel_reserved = false;
33
switch (csrno) {
34
case CSR_MIREG:
35
iprio = env->miprio;
36
@@ -XXX,XX +XXX,XX @@ static int rmw_xireg(CPURISCVState *env, int csrno, target_ulong *val,
37
riscv_cpu_mxl_bits(env)),
38
val, new_val, wr_mask);
39
}
40
+ } else {
41
+ isel_reserved = true;
22
}
42
}
23
+
43
24
+ if (!env->debugger && !riscv_cpu_fp_enabled(env)) {
44
done:
25
+ return smstateen_acc_ok(env, 0, SMSTATEEN0_FCSR);
45
if (ret) {
26
+ }
46
- return (env->virt_enabled && virt) ?
27
#endif
47
+ return (env->virt_enabled && virt && !isel_reserved) ?
48
RISCV_EXCP_VIRT_INSTRUCTION_FAULT : RISCV_EXCP_ILLEGAL_INST;
49
}
28
return RISCV_EXCP_NONE;
50
return RISCV_EXCP_NONE;
29
}
30
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mstateen0(CPURISCVState *env, int csrno,
31
target_ulong new_val)
32
{
33
uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG;
34
+ if (!riscv_has_ext(env, RVF)) {
35
+ wr_mask |= SMSTATEEN0_FCSR;
36
+ }
37
38
return write_mstateen(env, csrno, wr_mask, new_val);
39
}
40
@@ -XXX,XX +XXX,XX @@ static RISCVException write_hstateen0(CPURISCVState *env, int csrno,
41
{
42
uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG;
43
44
+ if (!riscv_has_ext(env, RVF)) {
45
+ wr_mask |= SMSTATEEN0_FCSR;
46
+ }
47
+
48
return write_hstateen(env, csrno, wr_mask, new_val);
49
}
50
51
@@ -XXX,XX +XXX,XX @@ static RISCVException write_sstateen0(CPURISCVState *env, int csrno,
52
{
53
uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG;
54
55
+ if (!riscv_has_ext(env, RVF)) {
56
+ wr_mask |= SMSTATEEN0_FCSR;
57
+ }
58
+
59
return write_sstateen(env, csrno, wr_mask, new_val);
60
}
61
62
--
51
--
63
2.40.1
52
2.41.0
diff view generated by jsdifflib
1
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
1
From: Nikita Shubin <n.shubin@yadro.com>
2
2
3
write_misa() must use as much common logic as possible. We want to open
3
As per ISA:
4
code just the bits that are exclusive to the CSR write operation and TCG
5
internals.
6
4
7
Our validation is done with riscv_cpu_validate_set_extensions(), but we
5
"For CSRRWI, if rd=x0, then the instruction shall not read the CSR and
8
need a small tweak first. When enabling RVG we're doing:
6
shall not cause any of the side effects that might occur on a CSR read."
9
7
10
env->misa_ext |= RVI | RVM | RVA | RVF | RVD;
8
trans_csrrwi() and trans_csrrw() call do_csrw() if rd=x0, do_csrw() calls
11
env->misa_ext_mask = env->misa_ext;
9
riscv_csrrw_do64(), via helper_csrw() passing NULL as *ret_value.
12
10
13
This works fine for realize() time but this can potentially overwrite
11
Signed-off-by: Nikita Shubin <n.shubin@yadro.com>
14
env->misa_ext_mask if we reutilize the function for write_misa().
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
13
Message-ID: <20230808090914.17634-1-nikita.shubin@maquefel.me>
16
Instead of doing misa_ext_mask = misa_ext, sum up the RVG extensions in
17
misa_ext_mask as well. This won't change realize() time behavior
18
(misa_ext_mask will be == misa_ext) and will ensure that write_misa()
19
won't change misa_ext_mask by accident.
20
21
After that, rewrite write_misa() to work as follows:
22
23
- mask the write using misa_ext_mask to avoid enabling unsupported
24
extensions;
25
26
- suppress RVC if the next insn isn't aligned;
27
28
- disable RVG if any of RVG dependencies are being disabled by the user;
29
30
- assign env->misa_ext and run riscv_cpu_validate_set_extensions(). On
31
error, rollback env->misa_ext to its original value, logging a
32
GUEST_ERROR to inform the user about the failed write;
33
34
- handle RVF and MSTATUS_FS and continue as usual.
35
36
Let's keep write_misa() as experimental for now until this logic gains
37
enough mileage.
38
39
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
40
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
41
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
42
Message-Id: <20230517135714.211809-12-dbarboza@ventanamicro.com>
43
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
44
---
15
---
45
target/riscv/cpu.h | 1 +
16
target/riscv/csr.c | 24 +++++++++++++++---------
46
target/riscv/cpu.c | 4 ++--
17
1 file changed, 15 insertions(+), 9 deletions(-)
47
target/riscv/csr.c | 51 ++++++++++++++++++++++------------------------
48
3 files changed, 27 insertions(+), 29 deletions(-)
49
18
50
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/riscv/cpu.h
53
+++ b/target/riscv/cpu.h
54
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
55
bool probe, uintptr_t retaddr);
56
char *riscv_isa_string(RISCVCPU *cpu);
57
void riscv_cpu_list(void);
58
+void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp);
59
60
#define cpu_list riscv_cpu_list
61
#define cpu_mmu_index riscv_cpu_mmu_index
62
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/target/riscv/cpu.c
65
+++ b/target/riscv/cpu.c
66
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu, Error **errp)
67
* Check consistency between chosen extensions while setting
68
* cpu->cfg accordingly.
69
*/
70
-static void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
71
+void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
72
{
73
CPURISCVState *env = &cpu->env;
74
Error *local_err = NULL;
75
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
76
cpu->cfg.ext_ifencei = true;
77
78
env->misa_ext |= RVI | RVM | RVA | RVF | RVD;
79
- env->misa_ext_mask = env->misa_ext;
80
+ env->misa_ext_mask |= RVI | RVM | RVA | RVF | RVD;
81
}
82
83
if (riscv_has_ext(env, RVI) && riscv_has_ext(env, RVE)) {
84
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
19
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
85
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
86
--- a/target/riscv/csr.c
21
--- a/target/riscv/csr.c
87
+++ b/target/riscv/csr.c
22
+++ b/target/riscv/csr.c
88
@@ -XXX,XX +XXX,XX @@ static RISCVException read_misa(CPURISCVState *env, int csrno,
23
@@ -XXX,XX +XXX,XX @@ static RISCVException riscv_csrrw_do64(CPURISCVState *env, int csrno,
89
static RISCVException write_misa(CPURISCVState *env, int csrno,
24
target_ulong write_mask)
90
target_ulong val)
91
{
25
{
92
+ RISCVCPU *cpu = env_archcpu(env);
26
RISCVException ret;
93
+ uint32_t orig_misa_ext = env->misa_ext;
27
- target_ulong old_value;
94
+ Error *local_err = NULL;
28
+ target_ulong old_value = 0;
95
+
29
96
if (!riscv_cpu_cfg(env)->misa_w) {
30
/* execute combined read/write operation if it exists */
97
/* drop write to misa */
31
if (csr_ops[csrno].op) {
98
return RISCV_EXCP_NONE;
32
return csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask);
99
}
33
}
100
34
101
- /* 'I' or 'E' must be present */
35
- /* if no accessor exists then return failure */
102
- if (!(val & (RVI | RVE))) {
36
- if (!csr_ops[csrno].read) {
103
- /* It is not, drop write to misa */
37
- return RISCV_EXCP_ILLEGAL_INST;
104
- return RISCV_EXCP_NONE;
105
- }
38
- }
106
-
39
- /* read old value */
107
- /* 'E' excludes all other extensions */
40
- ret = csr_ops[csrno].read(env, csrno, &old_value);
108
- if (val & RVE) {
41
- if (ret != RISCV_EXCP_NONE) {
109
- /*
42
- return ret;
110
- * when we support 'E' we can do "val = RVE;" however
43
+ /*
111
- * for now we just drop writes if 'E' is present.
44
+ * ret_value == NULL means that rd=x0 and we're coming from helper_csrw()
112
- */
45
+ * and we can't throw side effects caused by CSR reads.
113
- return RISCV_EXCP_NONE;
46
+ */
114
- }
47
+ if (ret_value) {
115
-
48
+ /* if no accessor exists then return failure */
116
- /*
49
+ if (!csr_ops[csrno].read) {
117
- * misa.MXL writes are not supported by QEMU.
50
+ return RISCV_EXCP_ILLEGAL_INST;
118
- * Drop writes to those bits.
51
+ }
119
- */
52
+ /* read old value */
120
-
53
+ ret = csr_ops[csrno].read(env, csrno, &old_value);
121
/* Mask extensions that are not supported by this hart */
54
+ if (ret != RISCV_EXCP_NONE) {
122
val &= env->misa_ext_mask;
55
+ return ret;
123
56
+ }
124
- /* 'D' depends on 'F', so clear 'D' if 'F' is not present */
125
- if ((val & RVD) && !(val & RVF)) {
126
- val &= ~RVD;
127
- }
128
-
129
/*
130
* Suppress 'C' if next instruction is not aligned
131
* TODO: this should check next_pc
132
@@ -XXX,XX +XXX,XX @@ static RISCVException write_misa(CPURISCVState *env, int csrno,
133
val &= ~RVC;
134
}
57
}
135
58
136
+ /* Disable RVG if any of its dependencies are disabled */
59
/* write value if writable and write mask set, otherwise drop writes */
137
+ if (!(val & RVI && val & RVM && val & RVA &&
138
+ val & RVF && val & RVD)) {
139
+ val &= ~RVG;
140
+ }
141
+
142
/* If nothing changed, do nothing. */
143
if (val == env->misa_ext) {
144
return RISCV_EXCP_NONE;
145
}
146
147
- if (!(val & RVF)) {
148
+ env->misa_ext = val;
149
+ riscv_cpu_validate_set_extensions(cpu, &local_err);
150
+ if (local_err != NULL) {
151
+ /* Rollback on validation error */
152
+ qemu_log_mask(LOG_GUEST_ERROR, "Unable to write MISA ext value "
153
+ "0x%x, keeping existing MISA ext 0x%x\n",
154
+ env->misa_ext, orig_misa_ext);
155
+
156
+ env->misa_ext = orig_misa_ext;
157
+
158
+ return RISCV_EXCP_NONE;
159
+ }
160
+
161
+ if (!(env->misa_ext & RVF)) {
162
env->mstatus &= ~MSTATUS_FS;
163
}
164
165
/* flush translation cache */
166
tb_flush(env_cpu(env));
167
- env->misa_ext = val;
168
env->xl = riscv_cpu_mxl(env);
169
return RISCV_EXCP_NONE;
170
}
171
--
60
--
172
2.40.1
61
2.41.0
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
pmp_get_tlb_size can be separated from get_physical_address_pmp and is only
4
needed when ret == TRANSLATE_SUCCESS.
5
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-Id: <20230517091519.34439-3-liweiwei@iscas.ac.cn>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
target/riscv/cpu_helper.c | 16 ++++++----------
14
1 file changed, 6 insertions(+), 10 deletions(-)
15
16
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/cpu_helper.c
19
+++ b/target/riscv/cpu_helper.c
20
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv)
21
*
22
* @env: CPURISCVState
23
* @prot: The returned protection attributes
24
- * @tlb_size: TLB page size containing addr. It could be modified after PMP
25
- * permission checking. NULL if not set TLB page for addr.
26
* @addr: The physical address to be checked permission
27
* @access_type: The type of MMU access
28
* @mode: Indicates current privilege level.
29
*/
30
-static int get_physical_address_pmp(CPURISCVState *env, int *prot,
31
- target_ulong *tlb_size, hwaddr addr,
32
+static int get_physical_address_pmp(CPURISCVState *env, int *prot, hwaddr addr,
33
int size, MMUAccessType access_type,
34
int mode)
35
{
36
@@ -XXX,XX +XXX,XX @@ static int get_physical_address_pmp(CPURISCVState *env, int *prot,
37
}
38
39
*prot = pmp_priv_to_page_prot(pmp_priv);
40
- if (tlb_size != NULL) {
41
- *tlb_size = pmp_get_tlb_size(env, addr);
42
- }
43
44
return TRANSLATE_SUCCESS;
45
}
46
@@ -XXX,XX +XXX,XX @@ restart:
47
}
48
49
int pmp_prot;
50
- int pmp_ret = get_physical_address_pmp(env, &pmp_prot, NULL, pte_addr,
51
+ int pmp_ret = get_physical_address_pmp(env, &pmp_prot, pte_addr,
52
sizeof(target_ulong),
53
MMU_DATA_LOAD, PRV_S);
54
if (pmp_ret != TRANSLATE_SUCCESS) {
55
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
56
prot &= prot2;
57
58
if (ret == TRANSLATE_SUCCESS) {
59
- ret = get_physical_address_pmp(env, &prot_pmp, &tlb_size, pa,
60
+ ret = get_physical_address_pmp(env, &prot_pmp, pa,
61
size, access_type, mode);
62
+ tlb_size = pmp_get_tlb_size(env, pa);
63
64
qemu_log_mask(CPU_LOG_MMU,
65
"%s PMP address=" HWADDR_FMT_plx " ret %d prot"
66
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
67
__func__, address, ret, pa, prot);
68
69
if (ret == TRANSLATE_SUCCESS) {
70
- ret = get_physical_address_pmp(env, &prot_pmp, &tlb_size, pa,
71
+ ret = get_physical_address_pmp(env, &prot_pmp, pa,
72
size, access_type, mode);
73
+ tlb_size = pmp_get_tlb_size(env, pa);
74
75
qemu_log_mask(CPU_LOG_MMU,
76
"%s PMP address=" HWADDR_FMT_plx " ret %d prot"
77
--
78
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Return the result directly for short cut, since We needn't do the
4
following check on the PMP entries if there is no PMP rules.
5
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <20230517091519.34439-4-liweiwei@iscas.ac.cn>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
target/riscv/pmp.c | 1 +
13
1 file changed, 1 insertion(+)
14
15
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/pmp.c
18
+++ b/target/riscv/pmp.c
19
@@ -XXX,XX +XXX,XX @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
20
allowed_privs, mode)) {
21
ret = MAX_RISCV_PMPS;
22
}
23
+ return ret;
24
}
25
26
if (size == 0) {
27
--
28
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
The addr and size parameters in pmp_hart_has_privs_default() are unused.
4
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-Id: <20230517091519.34439-7-liweiwei@iscas.ac.cn>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
11
target/riscv/pmp.c | 9 +++------
12
1 file changed, 3 insertions(+), 6 deletions(-)
13
14
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/riscv/pmp.c
17
+++ b/target/riscv/pmp.c
18
@@ -XXX,XX +XXX,XX @@ static int pmp_is_in_range(CPURISCVState *env, int pmp_index,
19
/*
20
* Check if the address has required RWX privs when no PMP entry is matched.
21
*/
22
-static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr,
23
- target_ulong size, pmp_priv_t privs,
24
+static bool pmp_hart_has_privs_default(CPURISCVState *env, pmp_priv_t privs,
25
pmp_priv_t *allowed_privs,
26
target_ulong mode)
27
{
28
@@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
29
30
/* Short cut if no rules */
31
if (0 == pmp_get_num_rules(env)) {
32
- return pmp_hart_has_privs_default(env, addr, size, privs,
33
- allowed_privs, mode);
34
+ return pmp_hart_has_privs_default(env, privs, allowed_privs, mode);
35
}
36
37
if (size == 0) {
38
@@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
39
40
/* No rule matched */
41
if (!ret) {
42
- ret = pmp_hart_has_privs_default(env, addr, size, privs,
43
- allowed_privs, mode);
44
+ ret = pmp_hart_has_privs_default(env, privs, allowed_privs, mode);
45
}
46
47
return ret;
48
--
49
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Currently only the rule addr of the same index of pmpaddr is updated
4
when pmpaddr CSR is modified. However, the rule addr of next PMP entry
5
may also be affected if its A field is PMP_AMATCH_TOR. So we should
6
also update it in this case.
7
8
Write to pmpaddr CSR will not affect the rule nums, So we needn't update
9
call pmp_update_rule_nums() in pmpaddr_csr_write().
10
11
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
12
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
14
Message-Id: <20230517091519.34439-9-liweiwei@iscas.ac.cn>
15
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
---
17
target/riscv/pmp.c | 10 +++++++---
18
1 file changed, 7 insertions(+), 3 deletions(-)
19
20
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/riscv/pmp.c
23
+++ b/target/riscv/pmp.c
24
@@ -XXX,XX +XXX,XX @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index,
25
target_ulong val)
26
{
27
trace_pmpaddr_csr_write(env->mhartid, addr_index, val);
28
+ bool is_next_cfg_tor = false;
29
30
if (addr_index < MAX_RISCV_PMPS) {
31
/*
32
@@ -XXX,XX +XXX,XX @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index,
33
*/
34
if (addr_index + 1 < MAX_RISCV_PMPS) {
35
uint8_t pmp_cfg = env->pmp_state.pmp[addr_index + 1].cfg_reg;
36
+ is_next_cfg_tor = PMP_AMATCH_TOR == pmp_get_a_field(pmp_cfg);
37
38
- if (pmp_cfg & PMP_LOCK &&
39
- PMP_AMATCH_TOR == pmp_get_a_field(pmp_cfg)) {
40
+ if (pmp_cfg & PMP_LOCK && is_next_cfg_tor) {
41
qemu_log_mask(LOG_GUEST_ERROR,
42
"ignoring pmpaddr write - pmpcfg + 1 locked\n");
43
return;
44
@@ -XXX,XX +XXX,XX @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index,
45
46
if (!pmp_is_locked(env, addr_index)) {
47
env->pmp_state.pmp[addr_index].addr_reg = val;
48
- pmp_update_rule(env, addr_index);
49
+ pmp_update_rule_addr(env, addr_index);
50
+ if (is_next_cfg_tor) {
51
+ pmp_update_rule_addr(env, addr_index + 1);
52
+ }
53
} else {
54
qemu_log_mask(LOG_GUEST_ERROR,
55
"ignoring pmpaddr write - locked\n");
56
--
57
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
TLB should be flushed not only for pmpcfg csr changes, but also for
4
pmpaddr csr changes.
5
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
10
Message-Id: <20230517091519.34439-10-liweiwei@iscas.ac.cn>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
target/riscv/pmp.c | 1 +
14
1 file changed, 1 insertion(+)
15
16
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/pmp.c
19
+++ b/target/riscv/pmp.c
20
@@ -XXX,XX +XXX,XX @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index,
21
if (is_next_cfg_tor) {
22
pmp_update_rule_addr(env, addr_index + 1);
23
}
24
+ tlb_flush(env_cpu(env));
25
} else {
26
qemu_log_mask(LOG_GUEST_ERROR,
27
"ignoring pmpaddr write - locked\n");
28
--
29
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
TLB needn't be flushed when pmpcfg/pmpaddr don't changes.
4
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
9
Message-Id: <20230517091519.34439-11-liweiwei@iscas.ac.cn>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
target/riscv/pmp.c | 28 ++++++++++++++++++----------
13
1 file changed, 18 insertions(+), 10 deletions(-)
14
15
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/pmp.c
18
+++ b/target/riscv/pmp.c
19
@@ -XXX,XX +XXX,XX @@
20
#include "trace.h"
21
#include "exec/exec-all.h"
22
23
-static void pmp_write_cfg(CPURISCVState *env, uint32_t addr_index,
24
+static bool pmp_write_cfg(CPURISCVState *env, uint32_t addr_index,
25
uint8_t val);
26
static uint8_t pmp_read_cfg(CPURISCVState *env, uint32_t addr_index);
27
static void pmp_update_rule(CPURISCVState *env, uint32_t pmp_index);
28
@@ -XXX,XX +XXX,XX @@ static inline uint8_t pmp_read_cfg(CPURISCVState *env, uint32_t pmp_index)
29
* Accessor to set the cfg reg for a specific PMP/HART
30
* Bounds checks and relevant lock bit.
31
*/
32
-static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)
33
+static bool pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)
34
{
35
if (pmp_index < MAX_RISCV_PMPS) {
36
bool locked = true;
37
@@ -XXX,XX +XXX,XX @@ static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)
38
39
if (locked) {
40
qemu_log_mask(LOG_GUEST_ERROR, "ignoring pmpcfg write - locked\n");
41
- } else {
42
+ } else if (env->pmp_state.pmp[pmp_index].cfg_reg != val) {
43
env->pmp_state.pmp[pmp_index].cfg_reg = val;
44
pmp_update_rule(env, pmp_index);
45
+ return true;
46
}
47
} else {
48
qemu_log_mask(LOG_GUEST_ERROR,
49
"ignoring pmpcfg write - out of bounds\n");
50
}
51
+
52
+ return false;
53
}
54
55
static void pmp_decode_napot(target_ulong a, target_ulong *sa,
56
@@ -XXX,XX +XXX,XX @@ void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index,
57
int i;
58
uint8_t cfg_val;
59
int pmpcfg_nums = 2 << riscv_cpu_mxl(env);
60
+ bool modified = false;
61
62
trace_pmpcfg_csr_write(env->mhartid, reg_index, val);
63
64
for (i = 0; i < pmpcfg_nums; i++) {
65
cfg_val = (val >> 8 * i) & 0xff;
66
- pmp_write_cfg(env, (reg_index * 4) + i, cfg_val);
67
+ modified |= pmp_write_cfg(env, (reg_index * 4) + i, cfg_val);
68
}
69
70
/* If PMP permission of any addr has been changed, flush TLB pages. */
71
- tlb_flush(env_cpu(env));
72
+ if (modified) {
73
+ tlb_flush(env_cpu(env));
74
+ }
75
}
76
77
78
@@ -XXX,XX +XXX,XX @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index,
79
}
80
81
if (!pmp_is_locked(env, addr_index)) {
82
- env->pmp_state.pmp[addr_index].addr_reg = val;
83
- pmp_update_rule_addr(env, addr_index);
84
- if (is_next_cfg_tor) {
85
- pmp_update_rule_addr(env, addr_index + 1);
86
+ if (env->pmp_state.pmp[addr_index].addr_reg != val) {
87
+ env->pmp_state.pmp[addr_index].addr_reg = val;
88
+ pmp_update_rule_addr(env, addr_index);
89
+ if (is_next_cfg_tor) {
90
+ pmp_update_rule_addr(env, addr_index + 1);
91
+ }
92
+ tlb_flush(env_cpu(env));
93
}
94
- tlb_flush(env_cpu(env));
95
} else {
96
qemu_log_mask(LOG_GUEST_ERROR,
97
"ignoring pmpaddr write - locked\n");
98
--
99
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Access will fail if access is partially inside the PMP entry.
4
However,only setting ret = false doesn't really mean pmp violation
5
since pmp_hart_has_privs_default() may return true at the end of
6
pmp_hart_has_privs().
7
8
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
9
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Message-Id: <20230517091519.34439-13-liweiwei@iscas.ac.cn>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
14
target/riscv/pmp.c | 4 ++--
15
1 file changed, 2 insertions(+), 2 deletions(-)
16
17
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/pmp.c
20
+++ b/target/riscv/pmp.c
21
@@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
22
if ((s + e) == 1) {
23
qemu_log_mask(LOG_GUEST_ERROR,
24
"pmp violation - access is partially inside\n");
25
- ret = false;
26
- break;
27
+ *allowed_privs = 0;
28
+ return false;
29
}
30
31
/* fully inside */
32
--
33
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Yin Wang <yin.wang@intel.com>
2
1
3
Command "qemu-system-riscv64 -machine virt
4
-m 2G -smp 1 -numa node,mem=1G -numa node,mem=1G"
5
would trigger this problem.Backtrace with:
6
#0 0x0000555555b5b1a4 in riscv_numa_get_default_cpu_node_id at ../hw/riscv/numa.c:211
7
#1 0x00005555558ce510 in machine_numa_finish_cpu_init at ../hw/core/machine.c:1230
8
#2 0x00005555558ce9d3 in machine_run_board_init at ../hw/core/machine.c:1346
9
#3 0x0000555555aaedc3 in qemu_init_board at ../softmmu/vl.c:2513
10
#4 0x0000555555aaf064 in qmp_x_exit_preconfig at ../softmmu/vl.c:2609
11
#5 0x0000555555ab1916 in qemu_init at ../softmmu/vl.c:3617
12
#6 0x000055555585463b in main at ../softmmu/main.c:47
13
This commit fixes the issue by adding parameter checks.
14
15
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
16
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
17
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
18
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
19
Signed-off-by: Yin Wang <yin.wang@intel.com>
20
Message-Id: <20230519023758.1759434-1-yin.wang@intel.com>
21
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
22
---
23
hw/riscv/numa.c | 6 ++++++
24
1 file changed, 6 insertions(+)
25
26
diff --git a/hw/riscv/numa.c b/hw/riscv/numa.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/riscv/numa.c
29
+++ b/hw/riscv/numa.c
30
@@ -XXX,XX +XXX,XX @@ int64_t riscv_numa_get_default_cpu_node_id(const MachineState *ms, int idx)
31
{
32
int64_t nidx = 0;
33
34
+ if (ms->numa_state->num_nodes > ms->smp.cpus) {
35
+ error_report("Number of NUMA nodes (%d)"
36
+ " cannot exceed the number of available CPUs (%d).",
37
+ ms->numa_state->num_nodes, ms->smp.max_cpus);
38
+ exit(EXIT_FAILURE);
39
+ }
40
if (ms->numa_state->num_nodes) {
41
nidx = idx / (ms->smp.cpus / ms->numa_state->num_nodes);
42
if (ms->numa_state->num_nodes <= nidx) {
43
--
44
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Mayuresh Chitale <mchitale@ventanamicro.com>
2
1
3
When misa.F is 0 tb->flags.FS field is unused and can be used to save
4
the current state of smstateen0.FCSR check which is needed by the
5
floating point translation routines.
6
7
Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
10
Message-Id: <20230518175058.2772506-3-mchitale@ventanamicro.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
target/riscv/cpu_helper.c | 6 ++++++
14
target/riscv/insn_trans/trans_rvf.c.inc | 7 ++++---
15
2 files changed, 10 insertions(+), 3 deletions(-)
16
17
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/cpu_helper.c
20
+++ b/target/riscv/cpu_helper.c
21
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
22
vs = MIN(vs, get_field(env->mstatus_hs, MSTATUS_VS));
23
}
24
25
+ /* With Zfinx, floating point is enabled/disabled by Smstateen. */
26
+ if (!riscv_has_ext(env, RVF)) {
27
+ fs = (smstateen_acc_ok(env, 0, SMSTATEEN0_FCSR) == RISCV_EXCP_NONE)
28
+ ? EXT_STATUS_DIRTY : EXT_STATUS_DISABLED;
29
+ }
30
+
31
if (cpu->cfg.debug && !icount_enabled()) {
32
flags = FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enabled);
33
}
34
diff --git a/target/riscv/insn_trans/trans_rvf.c.inc b/target/riscv/insn_trans/trans_rvf.c.inc
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/riscv/insn_trans/trans_rvf.c.inc
37
+++ b/target/riscv/insn_trans/trans_rvf.c.inc
38
@@ -XXX,XX +XXX,XX @@
39
*/
40
41
#define REQUIRE_FPU do {\
42
- if (ctx->mstatus_fs == EXT_STATUS_DISABLED) \
43
- if (!ctx->cfg_ptr->ext_zfinx) \
44
- return false; \
45
+ if (ctx->mstatus_fs == EXT_STATUS_DISABLED) { \
46
+ ctx->virt_inst_excp = ctx->virt_enabled && ctx->cfg_ptr->ext_zfinx; \
47
+ return false; \
48
+ } \
49
} while (0)
50
51
#define REQUIRE_ZFINX_OR_F(ctx) do {\
52
--
53
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Use pointer to pass more information of target to disasembler,
4
such as pass cpu.cfg related information in following commits.
5
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-Id: <20230523093539.203909-2-liweiwei@iscas.ac.cn>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
include/disas/dis-asm.h | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
15
16
diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/disas/dis-asm.h
19
+++ b/include/disas/dis-asm.h
20
@@ -XXX,XX +XXX,XX @@ typedef struct disassemble_info {
21
char * disassembler_options;
22
23
/* Field intended to be used by targets in any way they deem suitable. */
24
- int64_t target_info;
25
+ void *target_info;
26
27
/* Options for Capstone disassembly. */
28
int cap_arch;
29
--
30
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Support disas for Zcmt* instructions only when related extensions
4
are supported.
5
6
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
7
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
8
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-Id: <20230523093539.203909-5-liweiwei@iscas.ac.cn>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
disas/riscv.c | 8 +++++++-
14
1 file changed, 7 insertions(+), 1 deletion(-)
15
16
diff --git a/disas/riscv.c b/disas/riscv.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/disas/riscv.c
19
+++ b/disas/riscv.c
20
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
21
op = rv_op_c_sqsp;
22
} else {
23
op = rv_op_c_fsdsp;
24
- if (((inst >> 12) & 0b01)) {
25
+ if (dec->cfg->ext_zcmp && ((inst >> 12) & 0b01)) {
26
switch ((inst >> 8) & 0b01111) {
27
case 8:
28
if (((inst >> 4) & 0b01111) >= 4) {
29
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
30
} else {
31
switch ((inst >> 10) & 0b011) {
32
case 0:
33
+ if (!dec->cfg->ext_zcmt) {
34
+ break;
35
+ }
36
if (((inst >> 2) & 0xFF) >= 32) {
37
op = rv_op_cm_jalt;
38
} else {
39
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
40
}
41
break;
42
case 3:
43
+ if (!dec->cfg->ext_zcmp) {
44
+ break;
45
+ }
46
switch ((inst >> 5) & 0b011) {
47
case 1: op = rv_op_cm_mvsa01; break;
48
case 3: op = rv_op_cm_mva01s; break;
49
--
50
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Support disas for Z*inx instructions only when Zfinx extension is supported.
4
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <20230523093539.203909-6-liweiwei@iscas.ac.cn>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
disas/riscv.c | 16 ++++++++++++----
13
1 file changed, 12 insertions(+), 4 deletions(-)
14
15
diff --git a/disas/riscv.c b/disas/riscv.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/disas/riscv.c
18
+++ b/disas/riscv.c
19
@@ -XXX,XX +XXX,XX @@ static void format_inst(char *buf, size_t buflen, size_t tab, rv_decode *dec)
20
append(buf, rv_ireg_name_sym[dec->rs2], buflen);
21
break;
22
case '3':
23
- append(buf, rv_freg_name_sym[dec->rd], buflen);
24
+ append(buf, dec->cfg->ext_zfinx ? rv_ireg_name_sym[dec->rd] :
25
+ rv_freg_name_sym[dec->rd],
26
+ buflen);
27
break;
28
case '4':
29
- append(buf, rv_freg_name_sym[dec->rs1], buflen);
30
+ append(buf, dec->cfg->ext_zfinx ? rv_ireg_name_sym[dec->rs1] :
31
+ rv_freg_name_sym[dec->rs1],
32
+ buflen);
33
break;
34
case '5':
35
- append(buf, rv_freg_name_sym[dec->rs2], buflen);
36
+ append(buf, dec->cfg->ext_zfinx ? rv_ireg_name_sym[dec->rs2] :
37
+ rv_freg_name_sym[dec->rs2],
38
+ buflen);
39
break;
40
case '6':
41
- append(buf, rv_freg_name_sym[dec->rs3], buflen);
42
+ append(buf, dec->cfg->ext_zfinx ? rv_ireg_name_sym[dec->rs3] :
43
+ rv_freg_name_sym[dec->rs3],
44
+ buflen);
45
break;
46
case '7':
47
snprintf(tmp, sizeof(tmp), "%d", dec->rs1);
48
--
49
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Currently decomp_rv32 and decomp_rv64 value in opcode_data for vector
4
instructions are the same op index as their own. And they have no
5
functional decomp_data. So they have no functional difference from just
6
leaving them as zero.
7
8
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
9
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
10
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
11
Acked-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-Id: <20230523093539.203909-7-liweiwei@iscas.ac.cn>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
15
disas/riscv.c | 740 +++++++++++++++++++++++++-------------------------
16
1 file changed, 370 insertions(+), 370 deletions(-)
17
18
diff --git a/disas/riscv.c b/disas/riscv.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/disas/riscv.c
21
+++ b/disas/riscv.c
22
@@ -XXX,XX +XXX,XX @@ const rv_opcode_data opcode_data[] = {
23
{ "zip", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
24
{ "xperm4", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
25
{ "xperm8", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
26
- { "vle8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vle8_v, rv_op_vle8_v, 0 },
27
- { "vle16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vle16_v, rv_op_vle16_v, 0 },
28
- { "vle32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vle32_v, rv_op_vle32_v, 0 },
29
- { "vle64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vle64_v, rv_op_vle64_v, 0 },
30
- { "vse8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vse8_v, rv_op_vse8_v, 0 },
31
- { "vse16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vse16_v, rv_op_vse16_v, 0 },
32
- { "vse32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vse32_v, rv_op_vse32_v, 0 },
33
- { "vse64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vse64_v, rv_op_vse64_v, 0 },
34
- { "vlm.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vlm_v, rv_op_vlm_v, 0 },
35
- { "vsm.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vsm_v, rv_op_vsm_v, 0 },
36
- { "vlse8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, rv_op_vlse8_v, rv_op_vlse8_v, 0 },
37
- { "vlse16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, rv_op_vlse16_v, rv_op_vlse16_v, 0 },
38
- { "vlse32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, rv_op_vlse32_v, rv_op_vlse32_v, 0 },
39
- { "vlse64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, rv_op_vlse64_v, rv_op_vlse64_v, 0 },
40
- { "vsse8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, rv_op_vsse8_v, rv_op_vsse8_v, 0 },
41
- { "vsse16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, rv_op_vsse16_v, rv_op_vsse16_v, 0 },
42
- { "vsse32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, rv_op_vsse32_v, rv_op_vsse32_v, 0 },
43
- { "vsse64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, rv_op_vsse64_v, rv_op_vsse64_v, 0 },
44
- { "vluxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vluxei8_v, rv_op_vluxei8_v, 0 },
45
- { "vluxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vluxei16_v, rv_op_vluxei16_v, 0 },
46
- { "vluxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vluxei32_v, rv_op_vluxei32_v, 0 },
47
- { "vluxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vluxei64_v, rv_op_vluxei64_v, 0 },
48
- { "vloxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vloxei8_v, rv_op_vloxei8_v, 0 },
49
- { "vloxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vloxei16_v, rv_op_vloxei16_v, 0 },
50
- { "vloxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vloxei32_v, rv_op_vloxei32_v, 0 },
51
- { "vloxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vloxei64_v, rv_op_vloxei64_v, 0 },
52
- { "vsuxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vsuxei8_v, rv_op_vsuxei8_v, 0 },
53
- { "vsuxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vsuxei16_v, rv_op_vsuxei16_v, 0 },
54
- { "vsuxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vsuxei32_v, rv_op_vsuxei32_v, 0 },
55
- { "vsuxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vsuxei64_v, rv_op_vsuxei64_v, 0 },
56
- { "vsoxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vsoxei8_v, rv_op_vsoxei8_v, 0 },
57
- { "vsoxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vsoxei16_v, rv_op_vsoxei16_v, 0 },
58
- { "vsoxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vsoxei32_v, rv_op_vsoxei32_v, 0 },
59
- { "vsoxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, rv_op_vsoxei64_v, rv_op_vsoxei64_v, 0 },
60
- { "vle8ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vle8ff_v, rv_op_vle8ff_v, 0 },
61
- { "vle16ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vle16ff_v, rv_op_vle16ff_v, 0 },
62
- { "vle32ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vle32ff_v, rv_op_vle32ff_v, 0 },
63
- { "vle64ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vle64ff_v, rv_op_vle64ff_v, 0 },
64
- { "vl1re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl1re8_v, rv_op_vl1re8_v, 0 },
65
- { "vl1re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl1re16_v, rv_op_vl1re16_v, 0 },
66
- { "vl1re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl1re32_v, rv_op_vl1re32_v, 0 },
67
- { "vl1re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl1re64_v, rv_op_vl1re64_v, 0 },
68
- { "vl2re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl2re8_v, rv_op_vl2re8_v, 0 },
69
- { "vl2re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl2re16_v, rv_op_vl2re16_v, 0 },
70
- { "vl2re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl2re32_v, rv_op_vl2re32_v, 0 },
71
- { "vl2re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl2re64_v, rv_op_vl2re64_v, 0 },
72
- { "vl4re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl4re8_v, rv_op_vl4re8_v, 0 },
73
- { "vl4re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl4re16_v, rv_op_vl4re16_v, 0 },
74
- { "vl4re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl4re32_v, rv_op_vl4re32_v, 0 },
75
- { "vl4re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl4re64_v, rv_op_vl4re64_v, 0 },
76
- { "vl8re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl8re8_v, rv_op_vl8re8_v, 0 },
77
- { "vl8re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl8re16_v, rv_op_vl8re16_v, 0 },
78
- { "vl8re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl8re32_v, rv_op_vl8re32_v, 0 },
79
- { "vl8re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vl8re64_v, rv_op_vl8re64_v, 0 },
80
- { "vs1r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vs1r_v, rv_op_vs1r_v, 0 },
81
- { "vs2r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vs2r_v, rv_op_vs2r_v, 0 },
82
- { "vs4r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vs4r_v, rv_op_vs4r_v, 0 },
83
- { "vs8r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, rv_op_vs8r_v, rv_op_vs8r_v, 0 },
84
- { "vadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vadd_vv, rv_op_vadd_vv, 0 },
85
- { "vadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vadd_vx, rv_op_vadd_vx, 0 },
86
- { "vadd.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vadd_vi, rv_op_vadd_vi, 0 },
87
- { "vsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vsub_vv, rv_op_vsub_vv, 0 },
88
- { "vsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vsub_vx, rv_op_vsub_vx, 0 },
89
- { "vrsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vrsub_vx, rv_op_vrsub_vx, 0 },
90
- { "vrsub.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vrsub_vi, rv_op_vrsub_vi, 0 },
91
- { "vwaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwaddu_vv, rv_op_vwaddu_vv, 0 },
92
- { "vwaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwaddu_vx, rv_op_vwaddu_vx, 0 },
93
- { "vwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwadd_vv, rv_op_vwadd_vv, 0 },
94
- { "vwadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwadd_vx, rv_op_vwadd_vx, 0 },
95
- { "vwsubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwsubu_vv, rv_op_vwsubu_vv, 0 },
96
- { "vwsubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwsubu_vx, rv_op_vwsubu_vx, 0 },
97
- { "vwsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwsub_vv, rv_op_vwsub_vv, 0 },
98
- { "vwsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwsub_vx, rv_op_vwsub_vx, 0 },
99
- { "vwaddu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwaddu_wv, rv_op_vwaddu_wv, 0 },
100
- { "vwaddu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwaddu_wx, rv_op_vwaddu_wx, 0 },
101
- { "vwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwadd_wv, rv_op_vwadd_wv, 0 },
102
- { "vwadd.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwadd_wx, rv_op_vwadd_wx, 0 },
103
- { "vwsubu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwsubu_wv, rv_op_vwsubu_wv, 0 },
104
- { "vwsubu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwsubu_wx, rv_op_vwsubu_wx, 0 },
105
- { "vwsub.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwsub_wv, rv_op_vwsub_wv, 0 },
106
- { "vwsub.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwsub_wx, rv_op_vwsub_wx, 0 },
107
- { "vadc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, rv_op_vadc_vvm, rv_op_vadc_vvm, 0 },
108
- { "vadc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, rv_op_vadc_vxm, rv_op_vadc_vxm, 0 },
109
- { "vadc.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, rv_op_vadc_vim, rv_op_vadc_vim, 0 },
110
- { "vmadc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, rv_op_vmadc_vvm, rv_op_vmadc_vvm, 0 },
111
- { "vmadc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, rv_op_vmadc_vxm, rv_op_vmadc_vxm, 0 },
112
- { "vmadc.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, rv_op_vmadc_vim, rv_op_vmadc_vim, 0 },
113
- { "vsbc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, rv_op_vsbc_vvm, rv_op_vsbc_vvm, 0 },
114
- { "vsbc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, rv_op_vsbc_vxm, rv_op_vsbc_vxm, 0 },
115
- { "vmsbc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, rv_op_vmsbc_vvm, rv_op_vmsbc_vvm, 0 },
116
- { "vmsbc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, rv_op_vmsbc_vxm, rv_op_vmsbc_vxm, 0 },
117
- { "vand.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vand_vv, rv_op_vand_vv, 0 },
118
- { "vand.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vand_vx, rv_op_vand_vx, 0 },
119
- { "vand.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vand_vi, rv_op_vand_vi, 0 },
120
- { "vor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vor_vv, rv_op_vor_vv, 0 },
121
- { "vor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vor_vx, rv_op_vor_vx, 0 },
122
- { "vor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vor_vi, rv_op_vor_vi, 0 },
123
- { "vxor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vxor_vv, rv_op_vxor_vv, 0 },
124
- { "vxor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vxor_vx, rv_op_vxor_vx, 0 },
125
- { "vxor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vxor_vi, rv_op_vxor_vi, 0 },
126
- { "vsll.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vsll_vv, rv_op_vsll_vv, 0 },
127
- { "vsll.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vsll_vx, rv_op_vsll_vx, 0 },
128
- { "vsll.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vsll_vi, rv_op_vsll_vi, 0 },
129
- { "vsrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vsrl_vv, rv_op_vsrl_vv, 0 },
130
- { "vsrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vsrl_vx, rv_op_vsrl_vx, 0 },
131
- { "vsrl.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vsrl_vi, rv_op_vsrl_vi, 0 },
132
- { "vsra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vsra_vv, rv_op_vsra_vv, 0 },
133
- { "vsra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vsra_vx, rv_op_vsra_vx, 0 },
134
- { "vsra.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vsra_vi, rv_op_vsra_vi, 0 },
135
- { "vnsrl.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vnsrl_wv, rv_op_vnsrl_wv, 0 },
136
- { "vnsrl.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vnsrl_wx, rv_op_vnsrl_wx, 0 },
137
- { "vnsrl.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vnsrl_wi, rv_op_vnsrl_wi, 0 },
138
- { "vnsra.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vnsra_wv, rv_op_vnsra_wv, 0 },
139
- { "vnsra.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vnsra_wx, rv_op_vnsra_wx, 0 },
140
- { "vnsra.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vnsra_wi, rv_op_vnsra_wi, 0 },
141
- { "vmseq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmseq_vv, rv_op_vmseq_vv, 0 },
142
- { "vmseq.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmseq_vx, rv_op_vmseq_vx, 0 },
143
- { "vmseq.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vmseq_vi, rv_op_vmseq_vi, 0 },
144
- { "vmsne.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmsne_vv, rv_op_vmsne_vv, 0 },
145
- { "vmsne.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmsne_vx, rv_op_vmsne_vx, 0 },
146
- { "vmsne.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vmsne_vi, rv_op_vmsne_vi, 0 },
147
- { "vmsltu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmsltu_vv, rv_op_vmsltu_vv, 0 },
148
- { "vmsltu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmsltu_vx, rv_op_vmsltu_vx, 0 },
149
- { "vmslt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmslt_vv, rv_op_vmslt_vv, 0 },
150
- { "vmslt.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmslt_vx, rv_op_vmslt_vx, 0 },
151
- { "vmsleu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmsleu_vv, rv_op_vmsleu_vv, 0 },
152
- { "vmsleu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmsleu_vx, rv_op_vmsleu_vx, 0 },
153
- { "vmsleu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vmsleu_vi, rv_op_vmsleu_vi, 0 },
154
- { "vmsle.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmsle_vv, rv_op_vmsle_vv, 0 },
155
- { "vmsle.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmsle_vx, rv_op_vmsle_vx, 0 },
156
- { "vmsle.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vmsle_vi, rv_op_vmsle_vi, 0 },
157
- { "vmsgtu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmsgtu_vx, rv_op_vmsgtu_vx, 0 },
158
- { "vmsgtu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vmsgtu_vi, rv_op_vmsgtu_vi, 0 },
159
- { "vmsgt.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmsgt_vx, rv_op_vmsgt_vx, 0 },
160
- { "vmsgt.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vmsgt_vi, rv_op_vmsgt_vi, 0 },
161
- { "vminu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vminu_vv, rv_op_vminu_vv, 0 },
162
- { "vminu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vminu_vx, rv_op_vminu_vx, 0 },
163
- { "vmin.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmin_vv, rv_op_vmin_vv, 0 },
164
- { "vmin.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmin_vx, rv_op_vmin_vx, 0 },
165
- { "vmaxu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmaxu_vv, rv_op_vmaxu_vv, 0 },
166
- { "vmaxu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmaxu_vx, rv_op_vmaxu_vx, 0 },
167
- { "vmax.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmax_vv, rv_op_vmax_vv, 0 },
168
- { "vmax.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmax_vx, rv_op_vmax_vx, 0 },
169
- { "vmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmul_vv, rv_op_vmul_vv, 0 },
170
- { "vmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmul_vx, rv_op_vmul_vx, 0 },
171
- { "vmulh.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmulh_vv, rv_op_vmulh_vv, 0 },
172
- { "vmulh.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmulh_vx, rv_op_vmulh_vx, 0 },
173
- { "vmulhu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmulhu_vv, rv_op_vmulhu_vv, 0 },
174
- { "vmulhu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmulhu_vx, rv_op_vmulhu_vx, 0 },
175
- { "vmulhsu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmulhsu_vv, rv_op_vmulhsu_vv, 0 },
176
- { "vmulhsu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vmulhsu_vx, rv_op_vmulhsu_vx, 0 },
177
- { "vdivu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vdivu_vv, rv_op_vdivu_vv, 0 },
178
- { "vdivu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vdivu_vx, rv_op_vdivu_vx, 0 },
179
- { "vdiv.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vdiv_vv, rv_op_vdiv_vv, 0 },
180
- { "vdiv.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vdiv_vx, rv_op_vdiv_vx, 0 },
181
- { "vremu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vremu_vv, rv_op_vremu_vv, 0 },
182
- { "vremu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vremu_vx, rv_op_vremu_vx, 0 },
183
- { "vrem.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vrem_vv, rv_op_vrem_vv, 0 },
184
- { "vrem.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vrem_vx, rv_op_vrem_vx, 0 },
185
- { "vwmulu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwmulu_vv, rv_op_vwmulu_vv, 0 },
186
- { "vwmulu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwmulu_vx, rv_op_vwmulu_vx, 0 },
187
- { "vwmulsu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwmulsu_vv, rv_op_vwmulsu_vv, 0 },
188
- { "vwmulsu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwmulsu_vx, rv_op_vwmulsu_vx, 0 },
189
- { "vwmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwmul_vv, rv_op_vwmul_vv, 0 },
190
- { "vwmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vwmul_vx, rv_op_vwmul_vx, 0 },
191
- { "vmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vmacc_vv, rv_op_vmacc_vv, 0 },
192
- { "vmacc.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, rv_op_vmacc_vx, rv_op_vmacc_vx, 0 },
193
- { "vnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vnmsac_vv, rv_op_vnmsac_vv, 0 },
194
- { "vnmsac.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, rv_op_vnmsac_vx, rv_op_vnmsac_vx, 0 },
195
- { "vmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vmadd_vv, rv_op_vmadd_vv, 0 },
196
- { "vmadd.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, rv_op_vmadd_vx, rv_op_vmadd_vx, 0 },
197
- { "vnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vnmsub_vv, rv_op_vnmsub_vv, 0 },
198
- { "vnmsub.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, rv_op_vnmsub_vx, rv_op_vnmsub_vx, 0 },
199
- { "vwmaccu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vwmaccu_vv, rv_op_vwmaccu_vv, 0 },
200
- { "vwmaccu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, rv_op_vwmaccu_vx, rv_op_vwmaccu_vx, 0 },
201
- { "vwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vwmacc_vv, rv_op_vwmacc_vv, 0 },
202
- { "vwmacc.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, rv_op_vwmacc_vx, rv_op_vwmacc_vx, 0 },
203
- { "vwmaccsu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vwmaccsu_vv, rv_op_vwmaccsu_vv, 0 },
204
- { "vwmaccsu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, rv_op_vwmaccsu_vx, rv_op_vwmaccsu_vx, 0 },
205
- { "vwmaccus.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, rv_op_vwmaccus_vx, rv_op_vwmaccus_vx, 0 },
206
- { "vmv.v.v", rv_codec_v_r, rv_fmt_vd_vs1, NULL, rv_op_vmv_v_v, rv_op_vmv_v_v, 0 },
207
- { "vmv.v.x", rv_codec_v_r, rv_fmt_vd_rs1, NULL, rv_op_vmv_v_x, rv_op_vmv_v_x, 0 },
208
- { "vmv.v.i", rv_codec_v_i, rv_fmt_vd_imm, NULL, rv_op_vmv_v_i, rv_op_vmv_v_i, 0 },
209
- { "vmerge.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, rv_op_vmerge_vvm, rv_op_vmerge_vvm, 0 },
210
- { "vmerge.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, rv_op_vmerge_vxm, rv_op_vmerge_vxm, 0 },
211
- { "vmerge.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, rv_op_vmerge_vim, rv_op_vmerge_vim, 0 },
212
- { "vsaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vsaddu_vv, rv_op_vsaddu_vv, 0 },
213
- { "vsaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vsaddu_vx, rv_op_vsaddu_vx, 0 },
214
- { "vsaddu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vsaddu_vi, rv_op_vsaddu_vi, 0 },
215
- { "vsadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vsadd_vv, rv_op_vsadd_vv, 0 },
216
- { "vsadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vsadd_vx, rv_op_vsadd_vx, 0 },
217
- { "vsadd.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, rv_op_vsadd_vi, rv_op_vsadd_vi, 0 },
218
- { "vssubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vssubu_vv, rv_op_vssubu_vv, 0 },
219
- { "vssubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vssubu_vx, rv_op_vssubu_vx, 0 },
220
- { "vssub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vssub_vv, rv_op_vssub_vv, 0 },
221
- { "vssub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vssub_vx, rv_op_vssub_vx, 0 },
222
- { "vaadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vaadd_vv, rv_op_vaadd_vv, 0 },
223
- { "vaadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vaadd_vx, rv_op_vaadd_vx, 0 },
224
- { "vaaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vaaddu_vv, rv_op_vaaddu_vv, 0 },
225
- { "vaaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vaaddu_vx, rv_op_vaaddu_vx, 0 },
226
- { "vasub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vasub_vv, rv_op_vasub_vv, 0 },
227
- { "vasub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vasub_vx, rv_op_vasub_vx, 0 },
228
- { "vasubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vasubu_vv, rv_op_vasubu_vv, 0 },
229
- { "vasubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vasubu_vx, rv_op_vasubu_vx, 0 },
230
- { "vsmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vsmul_vv, rv_op_vsmul_vv, 0 },
231
- { "vsmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vsmul_vx, rv_op_vsmul_vx, 0 },
232
- { "vssrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vssrl_vv, rv_op_vssrl_vv, 0 },
233
- { "vssrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vssrl_vx, rv_op_vssrl_vx, 0 },
234
- { "vssrl.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vssrl_vi, rv_op_vssrl_vi, 0 },
235
- { "vssra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vssra_vv, rv_op_vssra_vv, 0 },
236
- { "vssra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vssra_vx, rv_op_vssra_vx, 0 },
237
- { "vssra.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vssra_vi, rv_op_vssra_vi, 0 },
238
- { "vnclipu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vnclipu_wv, rv_op_vnclipu_wv, 0 },
239
- { "vnclipu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vnclipu_wx, rv_op_vnclipu_wx, 0 },
240
- { "vnclipu.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vnclipu_wi, rv_op_vnclipu_wi, 0 },
241
- { "vnclip.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vnclip_wv, rv_op_vnclip_wv, 0 },
242
- { "vnclip.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vnclip_wx, rv_op_vnclip_wx, 0 },
243
- { "vnclip.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vnclip_wi, rv_op_vnclip_wi, 0 },
244
- { "vfadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfadd_vv, rv_op_vfadd_vv, 0 },
245
- { "vfadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfadd_vf, rv_op_vfadd_vf, 0 },
246
- { "vfsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfsub_vv, rv_op_vfsub_vv, 0 },
247
- { "vfsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfsub_vf, rv_op_vfsub_vf, 0 },
248
- { "vfrsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfrsub_vf, rv_op_vfrsub_vf, 0 },
249
- { "vfwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfwadd_vv, rv_op_vfwadd_vv, 0 },
250
- { "vfwadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfwadd_vf, rv_op_vfwadd_vf, 0 },
251
- { "vfwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfwadd_wv, rv_op_vfwadd_wv, 0 },
252
- { "vfwadd.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfwadd_wf, rv_op_vfwadd_wf, 0 },
253
- { "vfwsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfwsub_vv, rv_op_vfwsub_vv, 0 },
254
- { "vfwsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfwsub_vf, rv_op_vfwsub_vf, 0 },
255
- { "vfwsub.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfwsub_wv, rv_op_vfwsub_wv, 0 },
256
- { "vfwsub.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfwsub_wf, rv_op_vfwsub_wf, 0 },
257
- { "vfmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfmul_vv, rv_op_vfmul_vv, 0 },
258
- { "vfmul.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfmul_vf, rv_op_vfmul_vf, 0 },
259
- { "vfdiv.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfdiv_vv, rv_op_vfdiv_vv, 0 },
260
- { "vfdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfdiv_vf, rv_op_vfdiv_vf, 0 },
261
- { "vfrdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfrdiv_vf, rv_op_vfrdiv_vf, 0 },
262
- { "vfwmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfwmul_vv, rv_op_vfwmul_vv, 0 },
263
- { "vfwmul.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfwmul_vf, rv_op_vfwmul_vf, 0 },
264
- { "vfmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfmacc_vv, rv_op_vfmacc_vv, 0 },
265
- { "vfmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfmacc_vf, rv_op_vfmacc_vf, 0 },
266
- { "vfnmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfnmacc_vv, rv_op_vfnmacc_vv, 0 },
267
- { "vfnmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfnmacc_vf, rv_op_vfnmacc_vf, 0 },
268
- { "vfmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfmsac_vv, rv_op_vfmsac_vv, 0 },
269
- { "vfmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfmsac_vf, rv_op_vfmsac_vf, 0 },
270
- { "vfnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfnmsac_vv, rv_op_vfnmsac_vv, 0 },
271
- { "vfnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfnmsac_vf, rv_op_vfnmsac_vf, 0 },
272
- { "vfmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfmadd_vv, rv_op_vfmadd_vv, 0 },
273
- { "vfmadd.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfmadd_vf, rv_op_vfmadd_vf, 0 },
274
- { "vfnmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfnmadd_vv, rv_op_vfnmadd_vv, 0 },
275
- { "vfnmadd.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfnmadd_vf, rv_op_vfnmadd_vf, 0 },
276
- { "vfmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfmsub_vv, rv_op_vfmsub_vv, 0 },
277
- { "vfmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfmsub_vf, rv_op_vfmsub_vf, 0 },
278
- { "vfnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfnmsub_vv, rv_op_vfnmsub_vv, 0 },
279
- { "vfnmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfnmsub_vf, rv_op_vfnmsub_vf, 0 },
280
- { "vfwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfwmacc_vv, rv_op_vfwmacc_vv, 0 },
281
- { "vfwmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfwmacc_vf, rv_op_vfwmacc_vf, 0 },
282
- { "vfwnmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfwnmacc_vv, rv_op_vfwnmacc_vv, 0 },
283
- { "vfwnmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfwnmacc_vf, rv_op_vfwnmacc_vf, 0 },
284
- { "vfwmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfwmsac_vv, rv_op_vfwmsac_vv, 0 },
285
- { "vfwmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfwmsac_vf, rv_op_vfwmsac_vf, 0 },
286
- { "vfwnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, rv_op_vfwnmsac_vv, rv_op_vfwnmsac_vv, 0 },
287
- { "vfwnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, rv_op_vfwnmsac_vf, rv_op_vfwnmsac_vf, 0 },
288
- { "vfsqrt.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, rv_op_vfsqrt_v, rv_op_vfsqrt_v, 0 },
289
- { "vfrsqrt7.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, rv_op_vfrsqrt7_v, rv_op_vfrsqrt7_v, 0 },
290
- { "vfrec7.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, rv_op_vfrec7_v, rv_op_vfrec7_v, 0 },
291
- { "vfmin.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfmin_vv, rv_op_vfmin_vv, 0 },
292
- { "vfmin.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfmin_vf, rv_op_vfmin_vf, 0 },
293
- { "vfmax.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfmax_vv, rv_op_vfmax_vv, 0 },
294
- { "vfmax.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfmax_vf, rv_op_vfmax_vf, 0 },
295
- { "vfsgnj.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfsgnj_vv, rv_op_vfsgnj_vv, 0 },
296
- { "vfsgnj.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfsgnj_vf, rv_op_vfsgnj_vf, 0 },
297
- { "vfsgnjn.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfsgnjn_vv, rv_op_vfsgnjn_vv, 0 },
298
- { "vfsgnjn.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfsgnjn_vf, rv_op_vfsgnjn_vf, 0 },
299
- { "vfsgnjx.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfsgnjx_vv, rv_op_vfsgnjx_vv, 0 },
300
- { "vfsgnjx.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfsgnjx_vf, rv_op_vfsgnjx_vf, 0 },
301
- { "vfslide1up.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfslide1up_vf, rv_op_vfslide1up_vf, 0 },
302
- { "vfslide1down.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vfslide1down_vf, rv_op_vfslide1down_vf, 0 },
303
- { "vmfeq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmfeq_vv, rv_op_vmfeq_vv, 0 },
304
- { "vmfeq.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vmfeq_vf, rv_op_vmfeq_vf, 0 },
305
- { "vmfne.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmfne_vv, rv_op_vmfne_vv, 0 },
306
- { "vmfne.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vmfne_vf, rv_op_vmfne_vf, 0 },
307
- { "vmflt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmflt_vv, rv_op_vmflt_vv, 0 },
308
- { "vmflt.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vmflt_vf, rv_op_vmflt_vf, 0 },
309
- { "vmfle.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmfle_vv, rv_op_vmfle_vv, 0 },
310
- { "vmfle.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vmfle_vf, rv_op_vmfle_vf, 0 },
311
- { "vmfgt.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vmfgt_vf, rv_op_vmfgt_vf, 0 },
312
- { "vmfge.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, rv_op_vmfge_vf, rv_op_vmfge_vf, 0 },
313
- { "vfclass.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfclass_v, rv_op_vfclass_v, 0 },
314
- { "vfmerge.vfm", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vl, NULL, rv_op_vfmerge_vfm, rv_op_vfmerge_vfm, 0 },
315
- { "vfmv.v.f", rv_codec_v_r, rv_fmt_vd_fs1, NULL, rv_op_vfmv_v_f, rv_op_vfmv_v_f, 0 },
316
- { "vfcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfcvt_xu_f_v, rv_op_vfcvt_xu_f_v, 0 },
317
- { "vfcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfcvt_x_f_v, rv_op_vfcvt_x_f_v, 0 },
318
- { "vfcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfcvt_f_xu_v, rv_op_vfcvt_f_xu_v, 0 },
319
- { "vfcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfcvt_f_x_v, rv_op_vfcvt_f_x_v, 0 },
320
- { "vfcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfcvt_rtz_xu_f_v, rv_op_vfcvt_rtz_xu_f_v, 0 },
321
- { "vfcvt.rtz.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfcvt_rtz_x_f_v, rv_op_vfcvt_rtz_x_f_v, 0 },
322
- { "vfwcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfwcvt_xu_f_v, rv_op_vfwcvt_xu_f_v, 0 },
323
- { "vfwcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfwcvt_x_f_v, rv_op_vfwcvt_x_f_v, 0 },
324
- { "vfwcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfwcvt_f_xu_v, rv_op_vfwcvt_f_xu_v, 0 },
325
- { "vfwcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfwcvt_f_x_v, rv_op_vfwcvt_f_x_v, 0 },
326
- { "vfwcvt.f.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfwcvt_f_f_v, rv_op_vfwcvt_f_f_v, 0 },
327
- { "vfwcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfwcvt_rtz_xu_f_v, rv_op_vfwcvt_rtz_xu_f_v, 0 },
328
- { "vfwcvt.rtz.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfwcvt_rtz_x_f_v, rv_op_vfwcvt_rtz_x_f_v, 0 },
329
- { "vfncvt.xu.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfncvt_xu_f_w, rv_op_vfncvt_xu_f_w, 0 },
330
- { "vfncvt.x.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfncvt_x_f_w, rv_op_vfncvt_x_f_w, 0 },
331
- { "vfncvt.f.xu.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfncvt_f_xu_w, rv_op_vfncvt_f_xu_w, 0 },
332
- { "vfncvt.f.x.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfncvt_f_x_w, rv_op_vfncvt_f_x_w, 0 },
333
- { "vfncvt.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfncvt_f_f_w, rv_op_vfncvt_f_f_w, 0 },
334
- { "vfncvt.rod.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfncvt_rod_f_f_w, rv_op_vfncvt_rod_f_f_w, 0 },
335
- { "vfncvt.rtz.xu.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfncvt_rtz_xu_f_w, rv_op_vfncvt_rtz_xu_f_w, 0 },
336
- { "vfncvt.rtz.x.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vfncvt_rtz_x_f_w, rv_op_vfncvt_rtz_x_f_w, 0 },
337
- { "vredsum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vredsum_vs, rv_op_vredsum_vs, 0 },
338
- { "vredand.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vredand_vs, rv_op_vredand_vs, 0 },
339
- { "vredor.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vredor_vs, rv_op_vredor_vs, 0 },
340
- { "vredxor.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vredxor_vs, rv_op_vredxor_vs, 0 },
341
- { "vredminu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vredminu_vs, rv_op_vredminu_vs, 0 },
342
- { "vredmin.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vredmin_vs, rv_op_vredmin_vs, 0 },
343
- { "vredmaxu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vredmaxu_vs, rv_op_vredmaxu_vs, 0 },
344
- { "vredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vredmax_vs, rv_op_vredmax_vs, 0 },
345
- { "vwredsumu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwredsumu_vs, rv_op_vwredsumu_vs, 0 },
346
- { "vwredsum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vwredsum_vs, rv_op_vwredsum_vs, 0 },
347
- { "vfredusum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfredusum_vs, rv_op_vfredusum_vs, 0 },
348
- { "vfredosum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfredosum_vs, rv_op_vfredosum_vs, 0 },
349
- { "vfredmin.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfredmin_vs, rv_op_vfredmin_vs, 0 },
350
- { "vfredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfredmax_vs, rv_op_vfredmax_vs, 0 },
351
- { "vfwredusum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfwredusum_vs, rv_op_vfwredusum_vs, 0 },
352
- { "vfwredosum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vfwredosum_vs, rv_op_vfwredosum_vs, 0 },
353
- { "vmand.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmand_mm, rv_op_vmand_mm, 0 },
354
- { "vmnand.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmnand_mm, rv_op_vmnand_mm, 0 },
355
- { "vmandn.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmandn_mm, rv_op_vmandn_mm, 0 },
356
- { "vmxor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmxor_mm, rv_op_vmxor_mm, 0 },
357
- { "vmor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmor_mm, rv_op_vmor_mm, 0 },
358
- { "vmnor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmnor_mm, rv_op_vmnor_mm, 0 },
359
- { "vmorn.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmorn_mm, rv_op_vmorn_mm, 0 },
360
- { "vmxnor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vmxnor_mm, rv_op_vmxnor_mm, 0 },
361
- { "vcpop.m", rv_codec_v_r, rv_fmt_rd_vs2_vm, NULL, rv_op_vcpop_m, rv_op_vcpop_m, 0 },
362
- { "vfirst.m", rv_codec_v_r, rv_fmt_rd_vs2_vm, NULL, rv_op_vfirst_m, rv_op_vfirst_m, 0 },
363
- { "vmsbf.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vmsbf_m, rv_op_vmsbf_m, 0 },
364
- { "vmsif.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vmsif_m, rv_op_vmsif_m, 0 },
365
- { "vmsof.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vmsof_m, rv_op_vmsof_m, 0 },
366
- { "viota.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_viota_m, rv_op_viota_m, 0 },
367
- { "vid.v", rv_codec_v_r, rv_fmt_vd_vm, NULL, rv_op_vid_v, rv_op_vid_v, 0 },
368
- { "vmv.x.s", rv_codec_v_r, rv_fmt_rd_vs2, NULL, rv_op_vmv_x_s, rv_op_vmv_x_s, 0 },
369
- { "vmv.s.x", rv_codec_v_r, rv_fmt_vd_rs1, NULL, rv_op_vmv_s_x, rv_op_vmv_s_x, 0 },
370
- { "vfmv.f.s", rv_codec_v_r, rv_fmt_fd_vs2, NULL, rv_op_vfmv_f_s, rv_op_vfmv_f_s, 0 },
371
- { "vfmv.s.f", rv_codec_v_r, rv_fmt_vd_fs1, NULL, rv_op_vfmv_s_f, rv_op_vfmv_s_f, 0 },
372
- { "vslideup.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vslideup_vx, rv_op_vslideup_vx, 0 },
373
- { "vslideup.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vslideup_vi, rv_op_vslideup_vi, 0 },
374
- { "vslide1up.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vslide1up_vx, rv_op_vslide1up_vx, 0 },
375
- { "vslidedown.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vslidedown_vx, rv_op_vslidedown_vx, 0 },
376
- { "vslidedown.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vslidedown_vi, rv_op_vslidedown_vi, 0 },
377
- { "vslide1down.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vslide1down_vx, rv_op_vslide1down_vx, 0 },
378
- { "vrgather.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vrgather_vv, rv_op_vrgather_vv, 0 },
379
- { "vrgatherei16.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, rv_op_vrgatherei16_vv, rv_op_vrgatherei16_vv, 0 },
380
- { "vrgather.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, rv_op_vrgather_vx, rv_op_vrgather_vx, 0 },
381
- { "vrgather.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, rv_op_vrgather_vi, rv_op_vrgather_vi, 0 },
382
- { "vcompress.vm", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, rv_op_vcompress_vm, rv_op_vcompress_vm, 0 },
383
- { "vmv1r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, rv_op_vmv1r_v, rv_op_vmv1r_v, 0 },
384
- { "vmv2r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, rv_op_vmv2r_v, rv_op_vmv2r_v, 0 },
385
- { "vmv4r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, rv_op_vmv4r_v, rv_op_vmv4r_v, 0 },
386
- { "vmv8r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, rv_op_vmv8r_v, rv_op_vmv8r_v, 0 },
387
- { "vzext.vf2", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vzext_vf2, rv_op_vzext_vf2, 0 },
388
- { "vzext.vf4", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vzext_vf4, rv_op_vzext_vf4, 0 },
389
- { "vzext.vf8", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vzext_vf8, rv_op_vzext_vf8, 0 },
390
- { "vsext.vf2", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vsext_vf2, rv_op_vsext_vf2, 0 },
391
- { "vsext.vf4", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vsext_vf4, rv_op_vsext_vf4, 0 },
392
- { "vsext.vf8", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, rv_op_vsext_vf8, rv_op_vsext_vf8, 0 },
393
- { "vsetvli", rv_codec_vsetvli, rv_fmt_vsetvli, NULL, rv_op_vsetvli, rv_op_vsetvli, 0 },
394
- { "vsetivli", rv_codec_vsetivli, rv_fmt_vsetivli, NULL, rv_op_vsetivli, rv_op_vsetivli, 0 },
395
- { "vsetvl", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, rv_op_vsetvl, rv_op_vsetvl, 0 },
396
+ { "vle8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
397
+ { "vle16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
398
+ { "vle32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
399
+ { "vle64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
400
+ { "vse8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
401
+ { "vse16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
402
+ { "vse32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
403
+ { "vse64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
404
+ { "vlm.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
405
+ { "vsm.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
406
+ { "vlse8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0, 0, 0 },
407
+ { "vlse16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0, 0, 0 },
408
+ { "vlse32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0, 0, 0 },
409
+ { "vlse64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0, 0, 0 },
410
+ { "vsse8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0, 0, 0 },
411
+ { "vsse16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0, 0, 0 },
412
+ { "vsse32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0, 0, 0 },
413
+ { "vsse64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0, 0, 0 },
414
+ { "vluxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
415
+ { "vluxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
416
+ { "vluxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
417
+ { "vluxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
418
+ { "vloxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
419
+ { "vloxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
420
+ { "vloxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
421
+ { "vloxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
422
+ { "vsuxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
423
+ { "vsuxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
424
+ { "vsuxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
425
+ { "vsuxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
426
+ { "vsoxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
427
+ { "vsoxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
428
+ { "vsoxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
429
+ { "vsoxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
430
+ { "vle8ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
431
+ { "vle16ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
432
+ { "vle32ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
433
+ { "vle64ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
434
+ { "vl1re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
435
+ { "vl1re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
436
+ { "vl1re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
437
+ { "vl1re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
438
+ { "vl2re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
439
+ { "vl2re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
440
+ { "vl2re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
441
+ { "vl2re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
442
+ { "vl4re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
443
+ { "vl4re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
444
+ { "vl4re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
445
+ { "vl4re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
446
+ { "vl8re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
447
+ { "vl8re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
448
+ { "vl8re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
449
+ { "vl8re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
450
+ { "vs1r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
451
+ { "vs2r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
452
+ { "vs4r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
453
+ { "vs8r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0 },
454
+ { "vadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
455
+ { "vadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
456
+ { "vadd.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
457
+ { "vsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
458
+ { "vsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
459
+ { "vrsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
460
+ { "vrsub.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
461
+ { "vwaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
462
+ { "vwaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
463
+ { "vwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
464
+ { "vwadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
465
+ { "vwsubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
466
+ { "vwsubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
467
+ { "vwsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
468
+ { "vwsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
469
+ { "vwaddu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
470
+ { "vwaddu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
471
+ { "vwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
472
+ { "vwadd.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
473
+ { "vwsubu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
474
+ { "vwsubu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
475
+ { "vwsub.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
476
+ { "vwsub.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
477
+ { "vadc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0 },
478
+ { "vadc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0 },
479
+ { "vadc.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, 0, 0, 0 },
480
+ { "vmadc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0 },
481
+ { "vmadc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0 },
482
+ { "vmadc.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, 0, 0, 0 },
483
+ { "vsbc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0 },
484
+ { "vsbc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0 },
485
+ { "vmsbc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0 },
486
+ { "vmsbc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0 },
487
+ { "vand.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
488
+ { "vand.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
489
+ { "vand.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
490
+ { "vor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
491
+ { "vor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
492
+ { "vor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
493
+ { "vxor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
494
+ { "vxor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
495
+ { "vxor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
496
+ { "vsll.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
497
+ { "vsll.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
498
+ { "vsll.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
499
+ { "vsrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
500
+ { "vsrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
501
+ { "vsrl.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
502
+ { "vsra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
503
+ { "vsra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
504
+ { "vsra.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
505
+ { "vnsrl.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
506
+ { "vnsrl.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
507
+ { "vnsrl.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
508
+ { "vnsra.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
509
+ { "vnsra.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
510
+ { "vnsra.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
511
+ { "vmseq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
512
+ { "vmseq.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
513
+ { "vmseq.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
514
+ { "vmsne.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
515
+ { "vmsne.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
516
+ { "vmsne.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
517
+ { "vmsltu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
518
+ { "vmsltu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
519
+ { "vmslt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
520
+ { "vmslt.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
521
+ { "vmsleu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
522
+ { "vmsleu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
523
+ { "vmsleu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
524
+ { "vmsle.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
525
+ { "vmsle.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
526
+ { "vmsle.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
527
+ { "vmsgtu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
528
+ { "vmsgtu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
529
+ { "vmsgt.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
530
+ { "vmsgt.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
531
+ { "vminu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
532
+ { "vminu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
533
+ { "vmin.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
534
+ { "vmin.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
535
+ { "vmaxu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
536
+ { "vmaxu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
537
+ { "vmax.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
538
+ { "vmax.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
539
+ { "vmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
540
+ { "vmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
541
+ { "vmulh.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
542
+ { "vmulh.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
543
+ { "vmulhu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
544
+ { "vmulhu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
545
+ { "vmulhsu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
546
+ { "vmulhsu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
547
+ { "vdivu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
548
+ { "vdivu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
549
+ { "vdiv.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
550
+ { "vdiv.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
551
+ { "vremu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
552
+ { "vremu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
553
+ { "vrem.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
554
+ { "vrem.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
555
+ { "vwmulu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
556
+ { "vwmulu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
557
+ { "vwmulsu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
558
+ { "vwmulsu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
559
+ { "vwmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
560
+ { "vwmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
561
+ { "vmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
562
+ { "vmacc.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
563
+ { "vnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
564
+ { "vnmsac.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
565
+ { "vmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
566
+ { "vmadd.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
567
+ { "vnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
568
+ { "vnmsub.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
569
+ { "vwmaccu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
570
+ { "vwmaccu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
571
+ { "vwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
572
+ { "vwmacc.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
573
+ { "vwmaccsu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
574
+ { "vwmaccsu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
575
+ { "vwmaccus.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0 },
576
+ { "vmv.v.v", rv_codec_v_r, rv_fmt_vd_vs1, NULL, 0, 0, 0 },
577
+ { "vmv.v.x", rv_codec_v_r, rv_fmt_vd_rs1, NULL, 0, 0, 0 },
578
+ { "vmv.v.i", rv_codec_v_i, rv_fmt_vd_imm, NULL, 0, 0, 0 },
579
+ { "vmerge.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0 },
580
+ { "vmerge.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0 },
581
+ { "vmerge.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, 0, 0, 0 },
582
+ { "vsaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
583
+ { "vsaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
584
+ { "vsaddu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
585
+ { "vsadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
586
+ { "vsadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
587
+ { "vsadd.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
588
+ { "vssubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
589
+ { "vssubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
590
+ { "vssub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
591
+ { "vssub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
592
+ { "vaadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
593
+ { "vaadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
594
+ { "vaaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
595
+ { "vaaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
596
+ { "vasub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
597
+ { "vasub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
598
+ { "vasubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
599
+ { "vasubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
600
+ { "vsmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
601
+ { "vsmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
602
+ { "vssrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
603
+ { "vssrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
604
+ { "vssrl.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
605
+ { "vssra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
606
+ { "vssra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
607
+ { "vssra.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
608
+ { "vnclipu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
609
+ { "vnclipu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
610
+ { "vnclipu.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
611
+ { "vnclip.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
612
+ { "vnclip.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
613
+ { "vnclip.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
614
+ { "vfadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
615
+ { "vfadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
616
+ { "vfsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
617
+ { "vfsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
618
+ { "vfrsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
619
+ { "vfwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
620
+ { "vfwadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
621
+ { "vfwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
622
+ { "vfwadd.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
623
+ { "vfwsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
624
+ { "vfwsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
625
+ { "vfwsub.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
626
+ { "vfwsub.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
627
+ { "vfmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
628
+ { "vfmul.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
629
+ { "vfdiv.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
630
+ { "vfdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
631
+ { "vfrdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
632
+ { "vfwmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
633
+ { "vfwmul.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
634
+ { "vfmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
635
+ { "vfmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
636
+ { "vfnmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
637
+ { "vfnmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
638
+ { "vfmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
639
+ { "vfmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
640
+ { "vfnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
641
+ { "vfnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
642
+ { "vfmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
643
+ { "vfmadd.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
644
+ { "vfnmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
645
+ { "vfnmadd.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
646
+ { "vfmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
647
+ { "vfmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
648
+ { "vfnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
649
+ { "vfnmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
650
+ { "vfwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
651
+ { "vfwmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
652
+ { "vfwnmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
653
+ { "vfwnmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
654
+ { "vfwmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
655
+ { "vfwmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
656
+ { "vfwnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
657
+ { "vfwnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
658
+ { "vfsqrt.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
659
+ { "vfrsqrt7.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
660
+ { "vfrec7.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
661
+ { "vfmin.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
662
+ { "vfmin.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
663
+ { "vfmax.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
664
+ { "vfmax.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
665
+ { "vfsgnj.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
666
+ { "vfsgnj.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
667
+ { "vfsgnjn.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
668
+ { "vfsgnjn.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
669
+ { "vfsgnjx.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
670
+ { "vfsgnjx.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
671
+ { "vfslide1up.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
672
+ { "vfslide1down.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
673
+ { "vmfeq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
674
+ { "vmfeq.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
675
+ { "vmfne.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
676
+ { "vmfne.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
677
+ { "vmflt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
678
+ { "vmflt.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
679
+ { "vmfle.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
680
+ { "vmfle.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
681
+ { "vmfgt.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
682
+ { "vmfge.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
683
+ { "vfclass.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
684
+ { "vfmerge.vfm", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vl, NULL, 0, 0, 0 },
685
+ { "vfmv.v.f", rv_codec_v_r, rv_fmt_vd_fs1, NULL, 0, 0, 0 },
686
+ { "vfcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
687
+ { "vfcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
688
+ { "vfcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
689
+ { "vfcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
690
+ { "vfcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
691
+ { "vfcvt.rtz.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
692
+ { "vfwcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
693
+ { "vfwcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
694
+ { "vfwcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
695
+ { "vfwcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
696
+ { "vfwcvt.f.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
697
+ { "vfwcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
698
+ { "vfwcvt.rtz.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
699
+ { "vfncvt.xu.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
700
+ { "vfncvt.x.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
701
+ { "vfncvt.f.xu.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
702
+ { "vfncvt.f.x.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
703
+ { "vfncvt.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
704
+ { "vfncvt.rod.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
705
+ { "vfncvt.rtz.xu.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
706
+ { "vfncvt.rtz.x.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
707
+ { "vredsum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
708
+ { "vredand.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
709
+ { "vredor.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
710
+ { "vredxor.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
711
+ { "vredminu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
712
+ { "vredmin.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
713
+ { "vredmaxu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
714
+ { "vredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
715
+ { "vwredsumu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
716
+ { "vwredsum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
717
+ { "vfredusum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
718
+ { "vfredosum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
719
+ { "vfredmin.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
720
+ { "vfredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
721
+ { "vfwredusum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
722
+ { "vfwredosum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
723
+ { "vmand.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
724
+ { "vmnand.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
725
+ { "vmandn.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
726
+ { "vmxor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
727
+ { "vmor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
728
+ { "vmnor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
729
+ { "vmorn.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
730
+ { "vmxnor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
731
+ { "vcpop.m", rv_codec_v_r, rv_fmt_rd_vs2_vm, NULL, 0, 0, 0 },
732
+ { "vfirst.m", rv_codec_v_r, rv_fmt_rd_vs2_vm, NULL, 0, 0, 0 },
733
+ { "vmsbf.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
734
+ { "vmsif.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
735
+ { "vmsof.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
736
+ { "viota.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
737
+ { "vid.v", rv_codec_v_r, rv_fmt_vd_vm, NULL, 0, 0, 0 },
738
+ { "vmv.x.s", rv_codec_v_r, rv_fmt_rd_vs2, NULL, 0, 0, 0 },
739
+ { "vmv.s.x", rv_codec_v_r, rv_fmt_vd_rs1, NULL, 0, 0, 0 },
740
+ { "vfmv.f.s", rv_codec_v_r, rv_fmt_fd_vs2, NULL, 0, 0, 0 },
741
+ { "vfmv.s.f", rv_codec_v_r, rv_fmt_vd_fs1, NULL, 0, 0, 0 },
742
+ { "vslideup.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
743
+ { "vslideup.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
744
+ { "vslide1up.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
745
+ { "vslidedown.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
746
+ { "vslidedown.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
747
+ { "vslide1down.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
748
+ { "vrgather.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
749
+ { "vrgatherei16.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
750
+ { "vrgather.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
751
+ { "vrgather.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
752
+ { "vcompress.vm", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
753
+ { "vmv1r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
754
+ { "vmv2r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
755
+ { "vmv4r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
756
+ { "vmv8r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
757
+ { "vzext.vf2", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
758
+ { "vzext.vf4", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
759
+ { "vzext.vf8", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
760
+ { "vsext.vf2", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
761
+ { "vsext.vf4", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
762
+ { "vsext.vf8", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
763
+ { "vsetvli", rv_codec_vsetvli, rv_fmt_vsetvli, NULL, 0, 0, 0 },
764
+ { "vsetivli", rv_codec_vsetivli, rv_fmt_vsetivli, NULL, 0, 0, 0 },
765
+ { "vsetvl", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
766
{ "c.zext.b", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 },
767
{ "c.sext.b", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 },
768
{ "c.zext.h", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 },
769
--
770
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Fix lines with over 80 characters.
4
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
Acked-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <20230523093539.203909-8-liweiwei@iscas.ac.cn>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
disas/riscv.c | 201 +++++++++++++++++++++++++++++++++++---------------
13
1 file changed, 140 insertions(+), 61 deletions(-)
14
15
diff --git a/disas/riscv.c b/disas/riscv.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/disas/riscv.c
18
+++ b/disas/riscv.c
19
@@ -XXX,XX +XXX,XX @@ static const char rv_vreg_name_sym[32][4] = {
20
/* pseudo-instruction constraints */
21
22
static const rvc_constraint rvcc_jal[] = { rvc_rd_eq_ra, rvc_end };
23
-static const rvc_constraint rvcc_jalr[] = { rvc_rd_eq_ra, rvc_imm_eq_zero, rvc_end };
24
-static const rvc_constraint rvcc_nop[] = { rvc_rd_eq_x0, rvc_rs1_eq_x0, rvc_imm_eq_zero, rvc_end };
25
+static const rvc_constraint rvcc_jalr[] = { rvc_rd_eq_ra, rvc_imm_eq_zero,
26
+ rvc_end };
27
+static const rvc_constraint rvcc_nop[] = { rvc_rd_eq_x0, rvc_rs1_eq_x0,
28
+ rvc_imm_eq_zero, rvc_end };
29
static const rvc_constraint rvcc_mv[] = { rvc_imm_eq_zero, rvc_end };
30
static const rvc_constraint rvcc_not[] = { rvc_imm_eq_n1, rvc_end };
31
static const rvc_constraint rvcc_neg[] = { rvc_rs1_eq_x0, rvc_end };
32
@@ -XXX,XX +XXX,XX @@ static const rvc_constraint rvcc_bleu[] = { rvc_end };
33
static const rvc_constraint rvcc_bgt[] = { rvc_end };
34
static const rvc_constraint rvcc_bgtu[] = { rvc_end };
35
static const rvc_constraint rvcc_j[] = { rvc_rd_eq_x0, rvc_end };
36
-static const rvc_constraint rvcc_ret[] = { rvc_rd_eq_x0, rvc_rs1_eq_ra, rvc_end };
37
-static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0, rvc_imm_eq_zero, rvc_end };
38
-static const rvc_constraint rvcc_rdcycle[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc00, rvc_end };
39
-static const rvc_constraint rvcc_rdtime[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc01, rvc_end };
40
-static const rvc_constraint rvcc_rdinstret[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc02, rvc_end };
41
-static const rvc_constraint rvcc_rdcycleh[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc80, rvc_end };
42
-static const rvc_constraint rvcc_rdtimeh[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc81, rvc_end };
43
+static const rvc_constraint rvcc_ret[] = { rvc_rd_eq_x0, rvc_rs1_eq_ra,
44
+ rvc_end };
45
+static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0, rvc_imm_eq_zero,
46
+ rvc_end };
47
+static const rvc_constraint rvcc_rdcycle[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc00,
48
+ rvc_end };
49
+static const rvc_constraint rvcc_rdtime[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc01,
50
+ rvc_end };
51
+static const rvc_constraint rvcc_rdinstret[] = { rvc_rs1_eq_x0,
52
+ rvc_csr_eq_0xc02, rvc_end };
53
+static const rvc_constraint rvcc_rdcycleh[] = { rvc_rs1_eq_x0,
54
+ rvc_csr_eq_0xc80, rvc_end };
55
+static const rvc_constraint rvcc_rdtimeh[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc81,
56
+ rvc_end };
57
static const rvc_constraint rvcc_rdinstreth[] = { rvc_rs1_eq_x0,
58
rvc_csr_eq_0xc82, rvc_end };
59
-static const rvc_constraint rvcc_frcsr[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x003, rvc_end };
60
-static const rvc_constraint rvcc_frrm[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x002, rvc_end };
61
-static const rvc_constraint rvcc_frflags[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x001, rvc_end };
62
+static const rvc_constraint rvcc_frcsr[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x003,
63
+ rvc_end };
64
+static const rvc_constraint rvcc_frrm[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x002,
65
+ rvc_end };
66
+static const rvc_constraint rvcc_frflags[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x001,
67
+ rvc_end };
68
static const rvc_constraint rvcc_fscsr[] = { rvc_csr_eq_0x003, rvc_end };
69
static const rvc_constraint rvcc_fsrm[] = { rvc_csr_eq_0x002, rvc_end };
70
static const rvc_constraint rvcc_fsflags[] = { rvc_csr_eq_0x001, rvc_end };
71
@@ -XXX,XX +XXX,XX @@ const rv_opcode_data opcode_data[] = {
72
{ "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1, NULL, 0, 0, 0 },
73
{ "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,
74
rv_op_addi, rv_op_addi, rvcd_imm_nz },
75
- { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, NULL, rv_op_fld, rv_op_fld, 0 },
76
- { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, NULL, rv_op_lw, rv_op_lw, rv_op_lw },
77
+ { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, NULL, rv_op_fld,
78
+ rv_op_fld, 0 },
79
+ { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, NULL, rv_op_lw, rv_op_lw,
80
+ rv_op_lw },
81
{ "c.flw", rv_codec_cl_lw, rv_fmt_frd_offset_rs1, NULL, rv_op_flw, 0, 0 },
82
- { "c.fsd", rv_codec_cs_sd, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsd, rv_op_fsd, 0 },
83
- { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw, rv_op_sw, rv_op_sw },
84
+ { "c.fsd", rv_codec_cs_sd, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsd,
85
+ rv_op_fsd, 0 },
86
+ { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw, rv_op_sw,
87
+ rv_op_sw },
88
{ "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsw, 0, 0 },
89
- { "c.nop", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_addi, rv_op_addi, rv_op_addi },
90
+ { "c.nop", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_addi, rv_op_addi,
91
+ rv_op_addi },
92
{ "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, rv_op_addi, rv_op_addi,
93
rv_op_addi, rvcd_imm_nz },
94
{ "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, NULL, rv_op_jal, 0, 0 },
95
- { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi, rv_op_addi, rv_op_addi },
96
+ { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi, rv_op_addi,
97
+ rv_op_addi },
98
{ "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,
99
rv_op_addi, rv_op_addi, rvcd_imm_nz },
100
{ "c.lui", rv_codec_ci_lui, rv_fmt_rd_imm, NULL, rv_op_lui, rv_op_lui,
101
@@ -XXX,XX +XXX,XX @@ const rv_opcode_data opcode_data[] = {
102
rv_op_srai, rv_op_srai, rvcd_imm_nz },
103
{ "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm, NULL, rv_op_andi,
104
rv_op_andi, rv_op_andi },
105
- { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_sub, rv_op_sub, rv_op_sub },
106
- { "c.xor", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_xor, rv_op_xor, rv_op_xor },
107
- { "c.or", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_or, rv_op_or, rv_op_or },
108
- { "c.and", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_and, rv_op_and, rv_op_and },
109
- { "c.subw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_subw, rv_op_subw, rv_op_subw },
110
- { "c.addw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_addw, rv_op_addw, rv_op_addw },
111
- { "c.j", rv_codec_cj, rv_fmt_rd_offset, NULL, rv_op_jal, rv_op_jal, rv_op_jal },
112
- { "c.beqz", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_beq, rv_op_beq, rv_op_beq },
113
- { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_bne, rv_op_bne, rv_op_bne },
114
+ { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_sub, rv_op_sub,
115
+ rv_op_sub },
116
+ { "c.xor", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_xor, rv_op_xor,
117
+ rv_op_xor },
118
+ { "c.or", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_or, rv_op_or,
119
+ rv_op_or },
120
+ { "c.and", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_and, rv_op_and,
121
+ rv_op_and },
122
+ { "c.subw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_subw, rv_op_subw,
123
+ rv_op_subw },
124
+ { "c.addw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_addw, rv_op_addw,
125
+ rv_op_addw },
126
+ { "c.j", rv_codec_cj, rv_fmt_rd_offset, NULL, rv_op_jal, rv_op_jal,
127
+ rv_op_jal },
128
+ { "c.beqz", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_beq, rv_op_beq,
129
+ rv_op_beq },
130
+ { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_bne, rv_op_bne,
131
+ rv_op_bne },
132
{ "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_slli,
133
rv_op_slli, rv_op_slli, rvcd_imm_nz },
134
- { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, NULL, rv_op_fld, rv_op_fld, rv_op_fld },
135
- { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, NULL, rv_op_lw, rv_op_lw, rv_op_lw },
136
- { "c.flwsp", rv_codec_ci_lwsp, rv_fmt_frd_offset_rs1, NULL, rv_op_flw, 0, 0 },
137
- { "c.jr", rv_codec_cr_jr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr, rv_op_jalr, rv_op_jalr },
138
- { "c.mv", rv_codec_cr_mv, rv_fmt_rd_rs1_rs2, NULL, rv_op_addi, rv_op_addi, rv_op_addi },
139
- { "c.ebreak", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_ebreak, rv_op_ebreak, rv_op_ebreak },
140
- { "c.jalr", rv_codec_cr_jalr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr, rv_op_jalr, rv_op_jalr },
141
- { "c.add", rv_codec_cr, rv_fmt_rd_rs1_rs2, NULL, rv_op_add, rv_op_add, rv_op_add },
142
- { "c.fsdsp", rv_codec_css_sdsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsd, rv_op_fsd, rv_op_fsd },
143
- { "c.swsp", rv_codec_css_swsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw, rv_op_sw, rv_op_sw },
144
- { "c.fswsp", rv_codec_css_swsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsw, 0, 0 },
145
- { "c.ld", rv_codec_cl_ld, rv_fmt_rd_offset_rs1, NULL, 0, rv_op_ld, rv_op_ld },
146
- { "c.sd", rv_codec_cs_sd, rv_fmt_rs2_offset_rs1, NULL, 0, rv_op_sd, rv_op_sd },
147
- { "c.addiw", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, 0, rv_op_addiw, rv_op_addiw },
148
- { "c.ldsp", rv_codec_ci_ldsp, rv_fmt_rd_offset_rs1, NULL, 0, rv_op_ld, rv_op_ld },
149
- { "c.sdsp", rv_codec_css_sdsp, rv_fmt_rs2_offset_rs1, NULL, 0, rv_op_sd, rv_op_sd },
150
+ { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, NULL, rv_op_fld,
151
+ rv_op_fld, rv_op_fld },
152
+ { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, NULL, rv_op_lw,
153
+ rv_op_lw, rv_op_lw },
154
+ { "c.flwsp", rv_codec_ci_lwsp, rv_fmt_frd_offset_rs1, NULL, rv_op_flw, 0,
155
+ 0 },
156
+ { "c.jr", rv_codec_cr_jr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr,
157
+ rv_op_jalr, rv_op_jalr },
158
+ { "c.mv", rv_codec_cr_mv, rv_fmt_rd_rs1_rs2, NULL, rv_op_addi, rv_op_addi,
159
+ rv_op_addi },
160
+ { "c.ebreak", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_ebreak,
161
+ rv_op_ebreak, rv_op_ebreak },
162
+ { "c.jalr", rv_codec_cr_jalr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr,
163
+ rv_op_jalr, rv_op_jalr },
164
+ { "c.add", rv_codec_cr, rv_fmt_rd_rs1_rs2, NULL, rv_op_add, rv_op_add,
165
+ rv_op_add },
166
+ { "c.fsdsp", rv_codec_css_sdsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsd,
167
+ rv_op_fsd, rv_op_fsd },
168
+ { "c.swsp", rv_codec_css_swsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw,
169
+ rv_op_sw, rv_op_sw },
170
+ { "c.fswsp", rv_codec_css_swsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsw, 0,
171
+ 0 },
172
+ { "c.ld", rv_codec_cl_ld, rv_fmt_rd_offset_rs1, NULL, 0, rv_op_ld,
173
+ rv_op_ld },
174
+ { "c.sd", rv_codec_cs_sd, rv_fmt_rs2_offset_rs1, NULL, 0, rv_op_sd,
175
+ rv_op_sd },
176
+ { "c.addiw", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, 0, rv_op_addiw,
177
+ rv_op_addiw },
178
+ { "c.ldsp", rv_codec_ci_ldsp, rv_fmt_rd_offset_rs1, NULL, 0, rv_op_ld,
179
+ rv_op_ld },
180
+ { "c.sdsp", rv_codec_css_sdsp, rv_fmt_rs2_offset_rs1, NULL, 0, rv_op_sd,
181
+ rv_op_sd },
182
{ "c.lq", rv_codec_cl_lq, rv_fmt_rd_offset_rs1, NULL, 0, 0, rv_op_lq },
183
{ "c.sq", rv_codec_cs_sq, rv_fmt_rs2_offset_rs1, NULL, 0, 0, rv_op_sq },
184
{ "c.lqsp", rv_codec_ci_lqsp, rv_fmt_rd_offset_rs1, NULL, 0, 0, rv_op_lq },
185
- { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, NULL, 0, 0, rv_op_sq },
186
+ { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, NULL, 0, 0,
187
+ rv_op_sq },
188
{ "nop", rv_codec_i, rv_fmt_none, NULL, 0, 0, 0 },
189
{ "mv", rv_codec_i, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
190
{ "not", rv_codec_i, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
191
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
192
}
193
break;
194
case 11:
195
- switch (((inst >> 24) & 0b11111000) | ((inst >> 12) & 0b00000111)) {
196
+ switch (((inst >> 24) & 0b11111000) |
197
+ ((inst >> 12) & 0b00000111)) {
198
case 2: op = rv_op_amoadd_w; break;
199
case 3: op = rv_op_amoadd_d; break;
200
case 4: op = rv_op_amoadd_q; break;
201
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
202
}
203
break;
204
case 12:
205
- switch (((inst >> 22) & 0b1111111000) | ((inst >> 12) & 0b0000000111)) {
206
+ switch (((inst >> 22) & 0b1111111000) |
207
+ ((inst >> 12) & 0b0000000111)) {
208
case 0: op = rv_op_add; break;
209
case 1: op = rv_op_sll; break;
210
case 2: op = rv_op_slt; break;
211
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
212
break;
213
case 13: op = rv_op_lui; break;
214
case 14:
215
- switch (((inst >> 22) & 0b1111111000) | ((inst >> 12) & 0b0000000111)) {
216
+ switch (((inst >> 22) & 0b1111111000) |
217
+ ((inst >> 12) & 0b0000000111)) {
218
case 0: op = rv_op_addw; break;
219
case 1: op = rv_op_sllw; break;
220
case 5: op = rv_op_srlw; break;
221
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
222
}
223
break;
224
case 112:
225
- switch (((inst >> 17) & 0b11111000) | ((inst >> 12) & 0b00000111)) {
226
+ switch (((inst >> 17) & 0b11111000) |
227
+ ((inst >> 12) & 0b00000111)) {
228
case 0: op = rv_op_fmv_x_s; break;
229
case 1: op = rv_op_fclass_s; break;
230
}
231
break;
232
case 113:
233
- switch (((inst >> 17) & 0b11111000) | ((inst >> 12) & 0b00000111)) {
234
+ switch (((inst >> 17) & 0b11111000) |
235
+ ((inst >> 12) & 0b00000111)) {
236
case 0: op = rv_op_fmv_x_d; break;
237
case 1: op = rv_op_fclass_d; break;
238
}
239
break;
240
case 115:
241
- switch (((inst >> 17) & 0b11111000) | ((inst >> 12) & 0b00000111)) {
242
+ switch (((inst >> 17) & 0b11111000) |
243
+ ((inst >> 12) & 0b00000111)) {
244
case 0: op = rv_op_fmv_x_q; break;
245
case 1: op = rv_op_fclass_q; break;
246
}
247
break;
248
case 120:
249
- switch (((inst >> 17) & 0b11111000) | ((inst >> 12) & 0b00000111)) {
250
+ switch (((inst >> 17) & 0b11111000) |
251
+ ((inst >> 12) & 0b00000111)) {
252
case 0: op = rv_op_fmv_s_x; break;
253
}
254
break;
255
case 121:
256
- switch (((inst >> 17) & 0b11111000) | ((inst >> 12) & 0b00000111)) {
257
+ switch (((inst >> 17) & 0b11111000) |
258
+ ((inst >> 12) & 0b00000111)) {
259
case 0: op = rv_op_fmv_d_x; break;
260
}
261
break;
262
case 123:
263
- switch (((inst >> 17) & 0b11111000) | ((inst >> 12) & 0b00000111)) {
264
+ switch (((inst >> 17) & 0b11111000) |
265
+ ((inst >> 12) & 0b00000111)) {
266
case 0: op = rv_op_fmv_q_x; break;
267
}
268
break;
269
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
270
case 11: op = rv_op_vxor_vv; break;
271
case 12: op = rv_op_vrgather_vv; break;
272
case 14: op = rv_op_vrgatherei16_vv; break;
273
- case 16: if (((inst >> 25) & 1) == 0) op = rv_op_vadc_vvm; break;
274
+ case 16:
275
+ if (((inst >> 25) & 1) == 0) {
276
+ op = rv_op_vadc_vvm;
277
+ }
278
+ break;
279
case 17: op = rv_op_vmadc_vvm; break;
280
- case 18: if (((inst >> 25) & 1) == 0) op = rv_op_vsbc_vvm; break;
281
+ case 18:
282
+ if (((inst >> 25) & 1) == 0) {
283
+ op = rv_op_vsbc_vvm;
284
+ }
285
+ break;
286
case 19: op = rv_op_vmsbc_vvm; break;
287
case 23:
288
if (((inst >> 20) & 0b111111) == 32)
289
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
290
case 2: op = rv_op_vmsof_m; break;
291
case 3: op = rv_op_vmsif_m; break;
292
case 16: op = rv_op_viota_m; break;
293
- case 17: if (((inst >> 20) & 0b11111) == 0) op = rv_op_vid_v; break;
294
+ case 17:
295
+ if (((inst >> 20) & 0b11111) == 0) {
296
+ op = rv_op_vid_v;
297
+ }
298
+ break;
299
}
300
break;
301
case 23: if ((inst >> 25) & 1) op = rv_op_vcompress_vm; break;
302
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
303
case 12: op = rv_op_vrgather_vi; break;
304
case 14: op = rv_op_vslideup_vi; break;
305
case 15: op = rv_op_vslidedown_vi; break;
306
- case 16: if (((inst >> 25) & 1) == 0) op = rv_op_vadc_vim; break;
307
+ case 16:
308
+ if (((inst >> 25) & 1) == 0) {
309
+ op = rv_op_vadc_vim;
310
+ }
311
+ break;
312
case 17: op = rv_op_vmadc_vim; break;
313
case 23:
314
if (((inst >> 20) & 0b111111) == 32)
315
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
316
case 12: op = rv_op_vrgather_vx; break;
317
case 14: op = rv_op_vslideup_vx; break;
318
case 15: op = rv_op_vslidedown_vx; break;
319
- case 16: if (((inst >> 25) & 1) == 0) op = rv_op_vadc_vxm; break;
320
+ case 16:
321
+ if (((inst >> 25) & 1) == 0) {
322
+ op = rv_op_vadc_vxm;
323
+ }
324
+ break;
325
case 17: op = rv_op_vmadc_vxm; break;
326
- case 18: if (((inst >> 25) & 1) == 0) op = rv_op_vsbc_vxm; break;
327
+ case 18:
328
+ if (((inst >> 25) & 1) == 0) {
329
+ op = rv_op_vsbc_vxm;
330
+ }
331
+ break;
332
case 19: op = rv_op_vmsbc_vxm; break;
333
case 23:
334
if (((inst >> 20) & 0b111111) == 32)
335
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
336
case 28:
337
switch (((inst >> 12) & 0b111)) {
338
case 0:
339
- switch (((inst >> 20) & 0b111111100000) | ((inst >> 7) & 0b000000011111)) {
340
+ switch (((inst >> 20) & 0b111111100000) |
341
+ ((inst >> 7) & 0b000000011111)) {
342
case 0:
343
switch (((inst >> 15) & 0b1111111111)) {
344
case 0: op = rv_op_ecall; break;
345
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
346
}
347
break;
348
case 30:
349
- switch (((inst >> 22) & 0b1111111000) | ((inst >> 12) & 0b0000000111)) {
350
+ switch (((inst >> 22) & 0b1111111000) |
351
+ ((inst >> 12) & 0b0000000111)) {
352
case 0: op = rv_op_addd; break;
353
case 1: op = rv_op_slld; break;
354
case 5: op = rv_op_srld; break;
355
--
356
2.40.1
diff view generated by jsdifflib
Deleted patch
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
1
3
Remove redundant parenthese and fix multi-line comments.
4
5
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
6
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
7
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
8
Acked-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <20230523093539.203909-9-liweiwei@iscas.ac.cn>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
disas/riscv.c | 219 +++++++++++++++++++++++++-------------------------
13
1 file changed, 110 insertions(+), 109 deletions(-)
14
15
diff --git a/disas/riscv.c b/disas/riscv.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/disas/riscv.c
18
+++ b/disas/riscv.c
19
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
20
{
21
rv_inst inst = dec->inst;
22
rv_opcode op = rv_op_illegal;
23
- switch (((inst >> 0) & 0b11)) {
24
+ switch ((inst >> 0) & 0b11) {
25
case 0:
26
- switch (((inst >> 13) & 0b111)) {
27
+ switch ((inst >> 13) & 0b111) {
28
case 0: op = rv_op_c_addi4spn; break;
29
case 1:
30
if (isa == rv128) {
31
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
32
}
33
break;
34
case 1:
35
- switch (((inst >> 13) & 0b111)) {
36
+ switch ((inst >> 13) & 0b111) {
37
case 0:
38
- switch (((inst >> 2) & 0b11111111111)) {
39
+ switch ((inst >> 2) & 0b11111111111) {
40
case 0: op = rv_op_c_nop; break;
41
default: op = rv_op_c_addi; break;
42
}
43
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
44
break;
45
case 2: op = rv_op_c_li; break;
46
case 3:
47
- switch (((inst >> 7) & 0b11111)) {
48
+ switch ((inst >> 7) & 0b11111) {
49
case 2: op = rv_op_c_addi16sp; break;
50
default: op = rv_op_c_lui; break;
51
}
52
break;
53
case 4:
54
- switch (((inst >> 10) & 0b11)) {
55
+ switch ((inst >> 10) & 0b11) {
56
case 0:
57
op = rv_op_c_srli;
58
break;
59
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
60
}
61
break;
62
case 2:
63
- switch (((inst >> 13) & 0b111)) {
64
+ switch ((inst >> 13) & 0b111) {
65
case 0:
66
op = rv_op_c_slli;
67
break;
68
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
69
}
70
break;
71
case 4:
72
- switch (((inst >> 12) & 0b1)) {
73
+ switch ((inst >> 12) & 0b1) {
74
case 0:
75
- switch (((inst >> 2) & 0b11111)) {
76
+ switch ((inst >> 2) & 0b11111) {
77
case 0: op = rv_op_c_jr; break;
78
default: op = rv_op_c_mv; break;
79
}
80
break;
81
case 1:
82
- switch (((inst >> 2) & 0b11111)) {
83
+ switch ((inst >> 2) & 0b11111) {
84
case 0:
85
- switch (((inst >> 7) & 0b11111)) {
86
+ switch ((inst >> 7) & 0b11111) {
87
case 0: op = rv_op_c_ebreak; break;
88
default: op = rv_op_c_jalr; break;
89
}
90
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
91
}
92
break;
93
case 3:
94
- switch (((inst >> 2) & 0b11111)) {
95
+ switch ((inst >> 2) & 0b11111) {
96
case 0:
97
- switch (((inst >> 12) & 0b111)) {
98
+ switch ((inst >> 12) & 0b111) {
99
case 0: op = rv_op_lb; break;
100
case 1: op = rv_op_lh; break;
101
case 2: op = rv_op_lw; break;
102
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
103
}
104
break;
105
case 1:
106
- switch (((inst >> 12) & 0b111)) {
107
+ switch ((inst >> 12) & 0b111) {
108
case 0:
109
- switch (((inst >> 20) & 0b111111111111)) {
110
+ switch ((inst >> 20) & 0b111111111111) {
111
case 40: op = rv_op_vl1re8_v; break;
112
case 552: op = rv_op_vl2re8_v; break;
113
case 1576: op = rv_op_vl4re8_v; break;
114
case 3624: op = rv_op_vl8re8_v; break;
115
}
116
- switch (((inst >> 26) & 0b111)) {
117
+ switch ((inst >> 26) & 0b111) {
118
case 0:
119
- switch (((inst >> 20) & 0b11111)) {
120
+ switch ((inst >> 20) & 0b11111) {
121
case 0: op = rv_op_vle8_v; break;
122
case 11: op = rv_op_vlm_v; break;
123
case 16: op = rv_op_vle8ff_v; break;
124
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
125
case 3: op = rv_op_fld; break;
126
case 4: op = rv_op_flq; break;
127
case 5:
128
- switch (((inst >> 20) & 0b111111111111)) {
129
+ switch ((inst >> 20) & 0b111111111111) {
130
case 40: op = rv_op_vl1re16_v; break;
131
case 552: op = rv_op_vl2re16_v; break;
132
case 1576: op = rv_op_vl4re16_v; break;
133
case 3624: op = rv_op_vl8re16_v; break;
134
}
135
- switch (((inst >> 26) & 0b111)) {
136
+ switch ((inst >> 26) & 0b111) {
137
case 0:
138
- switch (((inst >> 20) & 0b11111)) {
139
+ switch ((inst >> 20) & 0b11111) {
140
case 0: op = rv_op_vle16_v; break;
141
case 16: op = rv_op_vle16ff_v; break;
142
}
143
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
144
}
145
break;
146
case 6:
147
- switch (((inst >> 20) & 0b111111111111)) {
148
+ switch ((inst >> 20) & 0b111111111111) {
149
case 40: op = rv_op_vl1re32_v; break;
150
case 552: op = rv_op_vl2re32_v; break;
151
case 1576: op = rv_op_vl4re32_v; break;
152
case 3624: op = rv_op_vl8re32_v; break;
153
}
154
- switch (((inst >> 26) & 0b111)) {
155
+ switch ((inst >> 26) & 0b111) {
156
case 0:
157
- switch (((inst >> 20) & 0b11111)) {
158
+ switch ((inst >> 20) & 0b11111) {
159
case 0: op = rv_op_vle32_v; break;
160
case 16: op = rv_op_vle32ff_v; break;
161
}
162
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
163
}
164
break;
165
case 7:
166
- switch (((inst >> 20) & 0b111111111111)) {
167
+ switch ((inst >> 20) & 0b111111111111) {
168
case 40: op = rv_op_vl1re64_v; break;
169
case 552: op = rv_op_vl2re64_v; break;
170
case 1576: op = rv_op_vl4re64_v; break;
171
case 3624: op = rv_op_vl8re64_v; break;
172
}
173
- switch (((inst >> 26) & 0b111)) {
174
+ switch ((inst >> 26) & 0b111) {
175
case 0:
176
- switch (((inst >> 20) & 0b11111)) {
177
+ switch ((inst >> 20) & 0b11111) {
178
case 0: op = rv_op_vle64_v; break;
179
case 16: op = rv_op_vle64ff_v; break;
180
}
181
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
182
}
183
break;
184
case 3:
185
- switch (((inst >> 12) & 0b111)) {
186
+ switch ((inst >> 12) & 0b111) {
187
case 0: op = rv_op_fence; break;
188
case 1: op = rv_op_fence_i; break;
189
case 2: op = rv_op_lq; break;
190
}
191
break;
192
case 4:
193
- switch (((inst >> 12) & 0b111)) {
194
+ switch ((inst >> 12) & 0b111) {
195
case 0: op = rv_op_addi; break;
196
case 1:
197
- switch (((inst >> 27) & 0b11111)) {
198
+ switch ((inst >> 27) & 0b11111) {
199
case 0b00000: op = rv_op_slli; break;
200
case 0b00001:
201
- switch (((inst >> 20) & 0b1111111)) {
202
+ switch ((inst >> 20) & 0b1111111) {
203
case 0b0001111: op = rv_op_zip; break;
204
}
205
break;
206
case 0b00010:
207
- switch (((inst >> 20) & 0b1111111)) {
208
+ switch ((inst >> 20) & 0b1111111) {
209
case 0b0000000: op = rv_op_sha256sum0; break;
210
case 0b0000001: op = rv_op_sha256sum1; break;
211
case 0b0000010: op = rv_op_sha256sig0; break;
212
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
213
break;
214
case 0b00101: op = rv_op_bseti; break;
215
case 0b00110:
216
- switch (((inst >> 20) & 0b1111111)) {
217
+ switch ((inst >> 20) & 0b1111111) {
218
case 0b0000000: op = rv_op_aes64im; break;
219
default:
220
if (((inst >> 24) & 0b0111) == 0b001) {
221
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
222
case 0b01001: op = rv_op_bclri; break;
223
case 0b01101: op = rv_op_binvi; break;
224
case 0b01100:
225
- switch (((inst >> 20) & 0b1111111)) {
226
+ switch ((inst >> 20) & 0b1111111) {
227
case 0b0000000: op = rv_op_clz; break;
228
case 0b0000001: op = rv_op_ctz; break;
229
case 0b0000010: op = rv_op_cpop; break;
230
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
231
case 3: op = rv_op_sltiu; break;
232
case 4: op = rv_op_xori; break;
233
case 5:
234
- switch (((inst >> 27) & 0b11111)) {
235
+ switch ((inst >> 27) & 0b11111) {
236
case 0b00000: op = rv_op_srli; break;
237
case 0b00001:
238
- switch (((inst >> 20) & 0b1111111)) {
239
+ switch ((inst >> 20) & 0b1111111) {
240
case 0b0001111: op = rv_op_unzip; break;
241
}
242
break;
243
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
244
break;
245
case 5: op = rv_op_auipc; break;
246
case 6:
247
- switch (((inst >> 12) & 0b111)) {
248
+ switch ((inst >> 12) & 0b111) {
249
case 0: op = rv_op_addiw; break;
250
case 1:
251
- switch (((inst >> 26) & 0b111111)) {
252
+ switch ((inst >> 26) & 0b111111) {
253
case 0: op = rv_op_slliw; break;
254
case 2: op = rv_op_slli_uw; break;
255
case 24:
256
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
257
}
258
break;
259
case 5:
260
- switch (((inst >> 25) & 0b1111111)) {
261
+ switch ((inst >> 25) & 0b1111111) {
262
case 0: op = rv_op_srliw; break;
263
case 32: op = rv_op_sraiw; break;
264
case 48: op = rv_op_roriw; break;
265
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
266
}
267
break;
268
case 8:
269
- switch (((inst >> 12) & 0b111)) {
270
+ switch ((inst >> 12) & 0b111) {
271
case 0: op = rv_op_sb; break;
272
case 1: op = rv_op_sh; break;
273
case 2: op = rv_op_sw; break;
274
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
275
}
276
break;
277
case 9:
278
- switch (((inst >> 12) & 0b111)) {
279
+ switch ((inst >> 12) & 0b111) {
280
case 0:
281
- switch (((inst >> 20) & 0b111111111111)) {
282
+ switch ((inst >> 20) & 0b111111111111) {
283
case 40: op = rv_op_vs1r_v; break;
284
case 552: op = rv_op_vs2r_v; break;
285
case 1576: op = rv_op_vs4r_v; break;
286
case 3624: op = rv_op_vs8r_v; break;
287
}
288
- switch (((inst >> 26) & 0b111)) {
289
+ switch ((inst >> 26) & 0b111) {
290
case 0:
291
- switch (((inst >> 20) & 0b11111)) {
292
+ switch ((inst >> 20) & 0b11111) {
293
case 0: op = rv_op_vse8_v; break;
294
case 11: op = rv_op_vsm_v; break;
295
}
296
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
297
case 3: op = rv_op_fsd; break;
298
case 4: op = rv_op_fsq; break;
299
case 5:
300
- switch (((inst >> 26) & 0b111)) {
301
+ switch ((inst >> 26) & 0b111) {
302
case 0:
303
- switch (((inst >> 20) & 0b11111)) {
304
+ switch ((inst >> 20) & 0b11111) {
305
case 0: op = rv_op_vse16_v; break;
306
}
307
break;
308
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
309
}
310
break;
311
case 6:
312
- switch (((inst >> 26) & 0b111)) {
313
+ switch ((inst >> 26) & 0b111) {
314
case 0:
315
- switch (((inst >> 20) & 0b11111)) {
316
+ switch ((inst >> 20) & 0b11111) {
317
case 0: op = rv_op_vse32_v; break;
318
}
319
break;
320
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
321
}
322
break;
323
case 7:
324
- switch (((inst >> 26) & 0b111)) {
325
+ switch ((inst >> 26) & 0b111) {
326
case 0:
327
- switch (((inst >> 20) & 0b11111)) {
328
+ switch ((inst >> 20) & 0b11111) {
329
case 0: op = rv_op_vse64_v; break;
330
}
331
break;
332
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
333
case 11: op = rv_op_amoswap_d; break;
334
case 12: op = rv_op_amoswap_q; break;
335
case 18:
336
- switch (((inst >> 20) & 0b11111)) {
337
+ switch ((inst >> 20) & 0b11111) {
338
case 0: op = rv_op_lr_w; break;
339
}
340
break;
341
case 19:
342
- switch (((inst >> 20) & 0b11111)) {
343
+ switch ((inst >> 20) & 0b11111) {
344
case 0: op = rv_op_lr_d; break;
345
}
346
break;
347
case 20:
348
- switch (((inst >> 20) & 0b11111)) {
349
+ switch ((inst >> 20) & 0b11111) {
350
case 0: op = rv_op_lr_q; break;
351
}
352
break;
353
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
354
}
355
break;
356
case 16:
357
- switch (((inst >> 25) & 0b11)) {
358
+ switch ((inst >> 25) & 0b11) {
359
case 0: op = rv_op_fmadd_s; break;
360
case 1: op = rv_op_fmadd_d; break;
361
case 3: op = rv_op_fmadd_q; break;
362
}
363
break;
364
case 17:
365
- switch (((inst >> 25) & 0b11)) {
366
+ switch ((inst >> 25) & 0b11) {
367
case 0: op = rv_op_fmsub_s; break;
368
case 1: op = rv_op_fmsub_d; break;
369
case 3: op = rv_op_fmsub_q; break;
370
}
371
break;
372
case 18:
373
- switch (((inst >> 25) & 0b11)) {
374
+ switch ((inst >> 25) & 0b11) {
375
case 0: op = rv_op_fnmsub_s; break;
376
case 1: op = rv_op_fnmsub_d; break;
377
case 3: op = rv_op_fnmsub_q; break;
378
}
379
break;
380
case 19:
381
- switch (((inst >> 25) & 0b11)) {
382
+ switch ((inst >> 25) & 0b11) {
383
case 0: op = rv_op_fnmadd_s; break;
384
case 1: op = rv_op_fnmadd_d; break;
385
case 3: op = rv_op_fnmadd_q; break;
386
}
387
break;
388
case 20:
389
- switch (((inst >> 25) & 0b1111111)) {
390
+ switch ((inst >> 25) & 0b1111111) {
391
case 0: op = rv_op_fadd_s; break;
392
case 1: op = rv_op_fadd_d; break;
393
case 3: op = rv_op_fadd_q; break;
394
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
395
case 13: op = rv_op_fdiv_d; break;
396
case 15: op = rv_op_fdiv_q; break;
397
case 16:
398
- switch (((inst >> 12) & 0b111)) {
399
+ switch ((inst >> 12) & 0b111) {
400
case 0: op = rv_op_fsgnj_s; break;
401
case 1: op = rv_op_fsgnjn_s; break;
402
case 2: op = rv_op_fsgnjx_s; break;
403
}
404
break;
405
case 17:
406
- switch (((inst >> 12) & 0b111)) {
407
+ switch ((inst >> 12) & 0b111) {
408
case 0: op = rv_op_fsgnj_d; break;
409
case 1: op = rv_op_fsgnjn_d; break;
410
case 2: op = rv_op_fsgnjx_d; break;
411
}
412
break;
413
case 19:
414
- switch (((inst >> 12) & 0b111)) {
415
+ switch ((inst >> 12) & 0b111) {
416
case 0: op = rv_op_fsgnj_q; break;
417
case 1: op = rv_op_fsgnjn_q; break;
418
case 2: op = rv_op_fsgnjx_q; break;
419
}
420
break;
421
case 20:
422
- switch (((inst >> 12) & 0b111)) {
423
+ switch ((inst >> 12) & 0b111) {
424
case 0: op = rv_op_fmin_s; break;
425
case 1: op = rv_op_fmax_s; break;
426
}
427
break;
428
case 21:
429
- switch (((inst >> 12) & 0b111)) {
430
+ switch ((inst >> 12) & 0b111) {
431
case 0: op = rv_op_fmin_d; break;
432
case 1: op = rv_op_fmax_d; break;
433
}
434
break;
435
case 23:
436
- switch (((inst >> 12) & 0b111)) {
437
+ switch ((inst >> 12) & 0b111) {
438
case 0: op = rv_op_fmin_q; break;
439
case 1: op = rv_op_fmax_q; break;
440
}
441
break;
442
case 32:
443
- switch (((inst >> 20) & 0b11111)) {
444
+ switch ((inst >> 20) & 0b11111) {
445
case 1: op = rv_op_fcvt_s_d; break;
446
case 3: op = rv_op_fcvt_s_q; break;
447
}
448
break;
449
case 33:
450
- switch (((inst >> 20) & 0b11111)) {
451
+ switch ((inst >> 20) & 0b11111) {
452
case 0: op = rv_op_fcvt_d_s; break;
453
case 3: op = rv_op_fcvt_d_q; break;
454
}
455
break;
456
case 35:
457
- switch (((inst >> 20) & 0b11111)) {
458
+ switch ((inst >> 20) & 0b11111) {
459
case 0: op = rv_op_fcvt_q_s; break;
460
case 1: op = rv_op_fcvt_q_d; break;
461
}
462
break;
463
case 44:
464
- switch (((inst >> 20) & 0b11111)) {
465
+ switch ((inst >> 20) & 0b11111) {
466
case 0: op = rv_op_fsqrt_s; break;
467
}
468
break;
469
case 45:
470
- switch (((inst >> 20) & 0b11111)) {
471
+ switch ((inst >> 20) & 0b11111) {
472
case 0: op = rv_op_fsqrt_d; break;
473
}
474
break;
475
case 47:
476
- switch (((inst >> 20) & 0b11111)) {
477
+ switch ((inst >> 20) & 0b11111) {
478
case 0: op = rv_op_fsqrt_q; break;
479
}
480
break;
481
case 80:
482
- switch (((inst >> 12) & 0b111)) {
483
+ switch ((inst >> 12) & 0b111) {
484
case 0: op = rv_op_fle_s; break;
485
case 1: op = rv_op_flt_s; break;
486
case 2: op = rv_op_feq_s; break;
487
}
488
break;
489
case 81:
490
- switch (((inst >> 12) & 0b111)) {
491
+ switch ((inst >> 12) & 0b111) {
492
case 0: op = rv_op_fle_d; break;
493
case 1: op = rv_op_flt_d; break;
494
case 2: op = rv_op_feq_d; break;
495
}
496
break;
497
case 83:
498
- switch (((inst >> 12) & 0b111)) {
499
+ switch ((inst >> 12) & 0b111) {
500
case 0: op = rv_op_fle_q; break;
501
case 1: op = rv_op_flt_q; break;
502
case 2: op = rv_op_feq_q; break;
503
}
504
break;
505
case 96:
506
- switch (((inst >> 20) & 0b11111)) {
507
+ switch ((inst >> 20) & 0b11111) {
508
case 0: op = rv_op_fcvt_w_s; break;
509
case 1: op = rv_op_fcvt_wu_s; break;
510
case 2: op = rv_op_fcvt_l_s; break;
511
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
512
}
513
break;
514
case 97:
515
- switch (((inst >> 20) & 0b11111)) {
516
+ switch ((inst >> 20) & 0b11111) {
517
case 0: op = rv_op_fcvt_w_d; break;
518
case 1: op = rv_op_fcvt_wu_d; break;
519
case 2: op = rv_op_fcvt_l_d; break;
520
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
521
}
522
break;
523
case 99:
524
- switch (((inst >> 20) & 0b11111)) {
525
+ switch ((inst >> 20) & 0b11111) {
526
case 0: op = rv_op_fcvt_w_q; break;
527
case 1: op = rv_op_fcvt_wu_q; break;
528
case 2: op = rv_op_fcvt_l_q; break;
529
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
530
}
531
break;
532
case 104:
533
- switch (((inst >> 20) & 0b11111)) {
534
+ switch ((inst >> 20) & 0b11111) {
535
case 0: op = rv_op_fcvt_s_w; break;
536
case 1: op = rv_op_fcvt_s_wu; break;
537
case 2: op = rv_op_fcvt_s_l; break;
538
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
539
}
540
break;
541
case 105:
542
- switch (((inst >> 20) & 0b11111)) {
543
+ switch ((inst >> 20) & 0b11111) {
544
case 0: op = rv_op_fcvt_d_w; break;
545
case 1: op = rv_op_fcvt_d_wu; break;
546
case 2: op = rv_op_fcvt_d_l; break;
547
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
548
}
549
break;
550
case 107:
551
- switch (((inst >> 20) & 0b11111)) {
552
+ switch ((inst >> 20) & 0b11111) {
553
case 0: op = rv_op_fcvt_q_w; break;
554
case 1: op = rv_op_fcvt_q_wu; break;
555
case 2: op = rv_op_fcvt_q_l; break;
556
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
557
}
558
break;
559
case 21:
560
- switch (((inst >> 12) & 0b111)) {
561
+ switch ((inst >> 12) & 0b111) {
562
case 0:
563
- switch (((inst >> 26) & 0b111111)) {
564
+ switch ((inst >> 26) & 0b111111) {
565
case 0: op = rv_op_vadd_vv; break;
566
case 2: op = rv_op_vsub_vv; break;
567
case 4: op = rv_op_vminu_vv; break;
568
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
569
}
570
break;
571
case 1:
572
- switch (((inst >> 26) & 0b111111)) {
573
+ switch ((inst >> 26) & 0b111111) {
574
case 0: op = rv_op_vfadd_vv; break;
575
case 1: op = rv_op_vfredusum_vs; break;
576
case 2: op = rv_op_vfsub_vv; break;
577
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
578
case 9: op = rv_op_vfsgnjn_vv; break;
579
case 10: op = rv_op_vfsgnjx_vv; break;
580
case 16:
581
- switch (((inst >> 15) & 0b11111)) {
582
+ switch ((inst >> 15) & 0b11111) {
583
case 0: if ((inst >> 25) & 1) op = rv_op_vfmv_f_s; break;
584
}
585
break;
586
case 18:
587
- switch (((inst >> 15) & 0b11111)) {
588
+ switch ((inst >> 15) & 0b11111) {
589
case 0: op = rv_op_vfcvt_xu_f_v; break;
590
case 1: op = rv_op_vfcvt_x_f_v; break;
591
case 2: op = rv_op_vfcvt_f_xu_v; break;
592
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
593
}
594
break;
595
case 19:
596
- switch (((inst >> 15) & 0b11111)) {
597
+ switch ((inst >> 15) & 0b11111) {
598
case 0: op = rv_op_vfsqrt_v; break;
599
case 4: op = rv_op_vfrsqrt7_v; break;
600
case 5: op = rv_op_vfrec7_v; break;
601
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
602
}
603
break;
604
case 2:
605
- switch (((inst >> 26) & 0b111111)) {
606
+ switch ((inst >> 26) & 0b111111) {
607
case 0: op = rv_op_vredsum_vs; break;
608
case 1: op = rv_op_vredand_vs; break;
609
case 2: op = rv_op_vredor_vs; break;
610
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
611
case 10: op = rv_op_vasubu_vv; break;
612
case 11: op = rv_op_vasub_vv; break;
613
case 16:
614
- switch (((inst >> 15) & 0b11111)) {
615
+ switch ((inst >> 15) & 0b11111) {
616
case 0: if ((inst >> 25) & 1) op = rv_op_vmv_x_s; break;
617
case 16: op = rv_op_vcpop_m; break;
618
case 17: op = rv_op_vfirst_m; break;
619
}
620
break;
621
case 18:
622
- switch (((inst >> 15) & 0b11111)) {
623
+ switch ((inst >> 15) & 0b11111) {
624
case 2: op = rv_op_vzext_vf8; break;
625
case 3: op = rv_op_vsext_vf8; break;
626
case 4: op = rv_op_vzext_vf4; break;
627
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
628
}
629
break;
630
case 20:
631
- switch (((inst >> 15) & 0b11111)) {
632
+ switch ((inst >> 15) & 0b11111) {
633
case 1: op = rv_op_vmsbf_m; break;
634
case 2: op = rv_op_vmsof_m; break;
635
case 3: op = rv_op_vmsif_m; break;
636
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
637
}
638
break;
639
case 3:
640
- switch (((inst >> 26) & 0b111111)) {
641
+ switch ((inst >> 26) & 0b111111) {
642
case 0: op = rv_op_vadd_vi; break;
643
case 3: op = rv_op_vrsub_vi; break;
644
case 9: op = rv_op_vand_vi; break;
645
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
646
case 33: op = rv_op_vsadd_vi; break;
647
case 37: op = rv_op_vsll_vi; break;
648
case 39:
649
- switch (((inst >> 15) & 0b11111)) {
650
+ switch ((inst >> 15) & 0b11111) {
651
case 0: op = rv_op_vmv1r_v; break;
652
case 1: op = rv_op_vmv2r_v; break;
653
case 3: op = rv_op_vmv4r_v; break;
654
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
655
}
656
break;
657
case 4:
658
- switch (((inst >> 26) & 0b111111)) {
659
+ switch ((inst >> 26) & 0b111111) {
660
case 0: op = rv_op_vadd_vx; break;
661
case 2: op = rv_op_vsub_vx; break;
662
case 3: op = rv_op_vrsub_vx; break;
663
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
664
}
665
break;
666
case 5:
667
- switch (((inst >> 26) & 0b111111)) {
668
+ switch ((inst >> 26) & 0b111111) {
669
case 0: op = rv_op_vfadd_vf; break;
670
case 2: op = rv_op_vfsub_vf; break;
671
case 4: op = rv_op_vfmin_vf; break;
672
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
673
case 14: op = rv_op_vfslide1up_vf; break;
674
case 15: op = rv_op_vfslide1down_vf; break;
675
case 16:
676
- switch (((inst >> 20) & 0b11111)) {
677
+ switch ((inst >> 20) & 0b11111) {
678
case 0: if ((inst >> 25) & 1) op = rv_op_vfmv_s_f; break;
679
}
680
break;
681
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
682
}
683
break;
684
case 6:
685
- switch (((inst >> 26) & 0b111111)) {
686
+ switch ((inst >> 26) & 0b111111) {
687
case 8: op = rv_op_vaaddu_vx; break;
688
case 9: op = rv_op_vaadd_vx; break;
689
case 10: op = rv_op_vasubu_vx; break;
690
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
691
case 14: op = rv_op_vslide1up_vx; break;
692
case 15: op = rv_op_vslide1down_vx; break;
693
case 16:
694
- switch (((inst >> 20) & 0b11111)) {
695
+ switch ((inst >> 20) & 0b11111) {
696
case 0: if ((inst >> 25) & 1) op = rv_op_vmv_s_x; break;
697
}
698
break;
699
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
700
}
701
break;
702
case 22:
703
- switch (((inst >> 12) & 0b111)) {
704
+ switch ((inst >> 12) & 0b111) {
705
case 0: op = rv_op_addid; break;
706
case 1:
707
- switch (((inst >> 26) & 0b111111)) {
708
+ switch ((inst >> 26) & 0b111111) {
709
case 0: op = rv_op_sllid; break;
710
}
711
break;
712
case 5:
713
- switch (((inst >> 26) & 0b111111)) {
714
+ switch ((inst >> 26) & 0b111111) {
715
case 0: op = rv_op_srlid; break;
716
case 16: op = rv_op_sraid; break;
717
}
718
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
719
}
720
break;
721
case 24:
722
- switch (((inst >> 12) & 0b111)) {
723
+ switch ((inst >> 12) & 0b111) {
724
case 0: op = rv_op_beq; break;
725
case 1: op = rv_op_bne; break;
726
case 4: op = rv_op_blt; break;
727
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
728
}
729
break;
730
case 25:
731
- switch (((inst >> 12) & 0b111)) {
732
+ switch ((inst >> 12) & 0b111) {
733
case 0: op = rv_op_jalr; break;
734
}
735
break;
736
case 27: op = rv_op_jal; break;
737
case 28:
738
- switch (((inst >> 12) & 0b111)) {
739
+ switch ((inst >> 12) & 0b111) {
740
case 0:
741
switch (((inst >> 20) & 0b111111100000) |
742
((inst >> 7) & 0b000000011111)) {
743
case 0:
744
- switch (((inst >> 15) & 0b1111111111)) {
745
+ switch ((inst >> 15) & 0b1111111111) {
746
case 0: op = rv_op_ecall; break;
747
case 32: op = rv_op_ebreak; break;
748
case 64: op = rv_op_uret; break;
749
}
750
break;
751
case 256:
752
- switch (((inst >> 20) & 0b11111)) {
753
+ switch ((inst >> 20) & 0b11111) {
754
case 2:
755
- switch (((inst >> 15) & 0b11111)) {
756
+ switch ((inst >> 15) & 0b11111) {
757
case 0: op = rv_op_sret; break;
758
}
759
break;
760
case 4: op = rv_op_sfence_vm; break;
761
case 5:
762
- switch (((inst >> 15) & 0b11111)) {
763
+ switch ((inst >> 15) & 0b11111) {
764
case 0: op = rv_op_wfi; break;
765
}
766
break;
767
@@ -XXX,XX +XXX,XX @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
768
break;
769
case 288: op = rv_op_sfence_vma; break;
770
case 512:
771
- switch (((inst >> 15) & 0b1111111111)) {
772
+ switch ((inst >> 15) & 0b1111111111) {
773
case 64: op = rv_op_hret; break;
774
}
775
break;
776
case 768:
777
- switch (((inst >> 15) & 0b1111111111)) {
778
+ switch ((inst >> 15) & 0b1111111111) {
779
case 64: op = rv_op_mret; break;
780
}
781
break;
782
case 1952:
783
- switch (((inst >> 15) & 0b1111111111)) {
784
+ switch ((inst >> 15) & 0b1111111111) {
785
case 576: op = rv_op_dret; break;
786
}
787
break;
788
@@ -XXX,XX +XXX,XX @@ static size_t inst_length(rv_inst inst)
789
{
790
/* NOTE: supports maximum instruction size of 64-bits */
791
792
- /* instruction length coding
793
+ /*
794
+ * instruction length coding
795
*
796
* aa - 16 bit aa != 11
797
* bbb11 - 32 bit bbb != 111
798
--
799
2.40.1
diff view generated by jsdifflib