* [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12
@ 2018-03-28 20:40 Michael Clark
2018-03-28 20:40 ` [Qemu-devel] [PULL 1/2] RISC-V: Convert cpu definition to future model Michael Clark
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Clark @ 2018-03-28 20:40 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: patches, Michael Clark
The following changes since commit 043289bef4d9c0d277c45695c676a6cc9fca48a0:
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180328' into staging (2018-03-28 13:30:10 +0100)
are available in the git repository at:
https://github.com/riscv/riscv-qemu.git tags/riscv-qemu-2.12-important-fixes
for you to fetch changes up to 33b4f859f1e1ea6722d10c3e9c0e3d85afb44ff4:
RISC-V: Fix incorrect disassembly for addiw (2018-03-28 11:12:02 -0700)
----------------------------------------------------------------
RISC-V: Important fixes for QEMU 2.12
This series includes changes that are considered important.
i.e. correct user-visible bugs that are exercised by common
operations such as -cpu list (CPU model changes) or -d in_asm
(fix for disassembly of addiw)
----------------------------------------------------------------
Michael Clark (2):
RISC-V: Convert cpu definition to future model
RISC-V: Fix incorrect disassembly for addiw
disas/riscv.c | 2 +-
target/riscv/cpu.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------
2 files changed, 70 insertions(+), 55 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL 1/2] RISC-V: Convert cpu definition to future model
2018-03-28 20:40 [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12 Michael Clark
@ 2018-03-28 20:40 ` Michael Clark
2018-03-28 20:40 ` [Qemu-devel] [PULL 2/2] RISC-V: Fix incorrect disassembly for addiw Michael Clark
2018-03-29 10:21 ` [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12 Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Michael Clark @ 2018-03-28 20:40 UTC (permalink / raw)
To: qemu-devel
Cc: patches, Michael Clark, Igor Mammedov, Sagar Karandikar,
Bastian Koppelmann, Palmer Dabbelt
- Model borrowed from target/sh4/cpu.c
- Rewrote riscv_cpu_list to use object_class_get_list
- Dropped 'struct RISCVCPUInfo' and used TypeInfo array
- Replaced riscv_cpu_register_types with DEFINE_TYPES
- Marked base class as abstract
- Fixes -cpu list
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Palmer Dabbelt <palmer@sifive.com>
Signed-off-by: Michael Clark <mjc@sifive.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
target/riscv/cpu.c | 123 ++++++++++++++++++++++++++++++-----------------------
1 file changed, 69 insertions(+), 54 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 9de34d7..5a527fb 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -115,6 +115,8 @@ static void riscv_any_cpu_init(Object *obj)
set_resetvec(env, DEFAULT_RSTVEC);
}
+#if defined(TARGET_RISCV32)
+
static void rv32gcsu_priv1_09_1_cpu_init(Object *obj)
{
CPURISCVState *env = &RISCV_CPU(obj)->env;
@@ -141,6 +143,8 @@ static void rv32imacu_nommu_cpu_init(Object *obj)
set_resetvec(env, DEFAULT_RSTVEC);
}
+#elif defined(TARGET_RISCV64)
+
static void rv64gcsu_priv1_09_1_cpu_init(Object *obj)
{
CPURISCVState *env = &RISCV_CPU(obj)->env;
@@ -167,20 +171,7 @@ static void rv64imacu_nommu_cpu_init(Object *obj)
set_resetvec(env, DEFAULT_RSTVEC);
}
-static const RISCVCPUInfo riscv_cpus[] = {
- { 96, TYPE_RISCV_CPU_ANY, riscv_any_cpu_init },
- { 32, TYPE_RISCV_CPU_RV32GCSU_V1_09_1, rv32gcsu_priv1_09_1_cpu_init },
- { 32, TYPE_RISCV_CPU_RV32GCSU_V1_10_0, rv32gcsu_priv1_10_0_cpu_init },
- { 32, TYPE_RISCV_CPU_RV32IMACU_NOMMU, rv32imacu_nommu_cpu_init },
- { 32, TYPE_RISCV_CPU_SIFIVE_E31, rv32imacu_nommu_cpu_init },
- { 32, TYPE_RISCV_CPU_SIFIVE_U34, rv32gcsu_priv1_10_0_cpu_init },
- { 64, TYPE_RISCV_CPU_RV64GCSU_V1_09_1, rv64gcsu_priv1_09_1_cpu_init },
- { 64, TYPE_RISCV_CPU_RV64GCSU_V1_10_0, rv64gcsu_priv1_10_0_cpu_init },
- { 64, TYPE_RISCV_CPU_RV64IMACU_NOMMU, rv64imacu_nommu_cpu_init },
- { 64, TYPE_RISCV_CPU_SIFIVE_E51, rv64imacu_nommu_cpu_init },
- { 64, TYPE_RISCV_CPU_SIFIVE_U54, rv64gcsu_priv1_10_0_cpu_init },
- { 0, NULL, NULL }
-};
+#endif
static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model)
{
@@ -366,28 +357,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)
cc->vmsd = &vmstate_riscv_cpu;
}
-static void cpu_register(const RISCVCPUInfo *info)
-{
- TypeInfo type_info = {
- .name = info->name,
- .parent = TYPE_RISCV_CPU,
- .instance_size = sizeof(RISCVCPU),
- .instance_init = info->initfn,
- };
-
- type_register(&type_info);
-}
-
-static const TypeInfo riscv_cpu_type_info = {
- .name = TYPE_RISCV_CPU,
- .parent = TYPE_CPU,
- .instance_size = sizeof(RISCVCPU),
- .instance_init = riscv_cpu_init,
- .abstract = false,
- .class_size = sizeof(RISCVCPUClass),
- .class_init = riscv_cpu_class_init,
-};
-
char *riscv_isa_string(RISCVCPU *cpu)
{
int i;
@@ -403,30 +372,76 @@ char *riscv_isa_string(RISCVCPU *cpu)
return isa_str;
}
-void riscv_cpu_list(FILE *f, fprintf_function cpu_fprintf)
+typedef struct RISCVCPUListState {
+ fprintf_function cpu_fprintf;
+ FILE *file;
+} RISCVCPUListState;
+
+static gint riscv_cpu_list_compare(gconstpointer a, gconstpointer b)
{
- const RISCVCPUInfo *info = riscv_cpus;
+ ObjectClass *class_a = (ObjectClass *)a;
+ ObjectClass *class_b = (ObjectClass *)b;
+ const char *name_a, *name_b;
- while (info->name) {
- if (info->bit_widths & TARGET_LONG_BITS) {
- (*cpu_fprintf)(f, "%s\n", info->name);
- }
- info++;
- }
+ name_a = object_class_get_name(class_a);
+ name_b = object_class_get_name(class_b);
+ return strcmp(name_a, name_b);
}
-static void riscv_cpu_register_types(void)
+static void riscv_cpu_list_entry(gpointer data, gpointer user_data)
{
- const RISCVCPUInfo *info = riscv_cpus;
+ RISCVCPUListState *s = user_data;
+ const char *typename = object_class_get_name(OBJECT_CLASS(data));
+ int len = strlen(typename) - strlen(RISCV_CPU_TYPE_SUFFIX);
- type_register_static(&riscv_cpu_type_info);
+ (*s->cpu_fprintf)(s->file, "%.*s\n", len, typename);
+}
- while (info->name) {
- if (info->bit_widths & TARGET_LONG_BITS) {
- cpu_register(info);
- }
- info++;
- }
+void riscv_cpu_list(FILE *f, fprintf_function cpu_fprintf)
+{
+ RISCVCPUListState s = {
+ .cpu_fprintf = cpu_fprintf,
+ .file = f,
+ };
+ GSList *list;
+
+ list = object_class_get_list(TYPE_RISCV_CPU, false);
+ list = g_slist_sort(list, riscv_cpu_list_compare);
+ g_slist_foreach(list, riscv_cpu_list_entry, &s);
+ g_slist_free(list);
}
-type_init(riscv_cpu_register_types)
+#define DEFINE_CPU(type_name, initfn) \
+ { \
+ .name = type_name, \
+ .parent = TYPE_RISCV_CPU, \
+ .instance_init = initfn \
+ }
+
+static const TypeInfo riscv_cpu_type_infos[] = {
+ {
+ .name = TYPE_RISCV_CPU,
+ .parent = TYPE_CPU,
+ .instance_size = sizeof(RISCVCPU),
+ .instance_init = riscv_cpu_init,
+ .abstract = true,
+ .class_size = sizeof(RISCVCPUClass),
+ .class_init = riscv_cpu_class_init,
+ },
+ DEFINE_CPU(TYPE_RISCV_CPU_ANY, riscv_any_cpu_init),
+#if defined(TARGET_RISCV32)
+ DEFINE_CPU(TYPE_RISCV_CPU_RV32GCSU_V1_09_1, rv32gcsu_priv1_09_1_cpu_init),
+ DEFINE_CPU(TYPE_RISCV_CPU_RV32GCSU_V1_10_0, rv32gcsu_priv1_10_0_cpu_init),
+ DEFINE_CPU(TYPE_RISCV_CPU_RV32IMACU_NOMMU, rv32imacu_nommu_cpu_init),
+ DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rv32imacu_nommu_cpu_init),
+ DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rv32gcsu_priv1_10_0_cpu_init)
+#elif defined(TARGET_RISCV64)
+ DEFINE_CPU(TYPE_RISCV_CPU_RV64GCSU_V1_09_1, rv64gcsu_priv1_09_1_cpu_init),
+ DEFINE_CPU(TYPE_RISCV_CPU_RV64GCSU_V1_10_0, rv64gcsu_priv1_10_0_cpu_init),
+ DEFINE_CPU(TYPE_RISCV_CPU_RV64IMACU_NOMMU, rv64imacu_nommu_cpu_init),
+ DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rv64imacu_nommu_cpu_init),
+ DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rv64gcsu_priv1_10_0_cpu_init)
+#endif
+};
+
+DEFINE_TYPES(riscv_cpu_type_infos)
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL 2/2] RISC-V: Fix incorrect disassembly for addiw
2018-03-28 20:40 [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12 Michael Clark
2018-03-28 20:40 ` [Qemu-devel] [PULL 1/2] RISC-V: Convert cpu definition to future model Michael Clark
@ 2018-03-28 20:40 ` Michael Clark
2018-03-29 10:21 ` [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12 Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Michael Clark @ 2018-03-28 20:40 UTC (permalink / raw)
To: qemu-devel
Cc: patches, Michael Clark, Sagar Karandikar, Bastian Koppelmann,
Palmer Dabbelt, Peter Maydell
This fixes a bug in the disassembler constraints used
to lift instructions into pseudo-instructions, whereby
addiw instructions are always lifted to sext.w instead
of just lifting addiw with a zero immediate.
An associated fix has been made to the metadata used to
machine generate the disseasembler:
https://github.com/michaeljclark/riscv-meta/
commit/4a6b2f3898430768acfe201405224d2ea31e1477
Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Clark <mjc@sifive.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
disas/riscv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/disas/riscv.c b/disas/riscv.c
index 3c17501..74ad16e 100644
--- a/disas/riscv.c
+++ b/disas/riscv.c
@@ -600,7 +600,7 @@ static const rvc_constraint rvcc_mv[] = { rvc_imm_eq_zero, rvc_end };
static const rvc_constraint rvcc_not[] = { rvc_imm_eq_n1, rvc_end };
static const rvc_constraint rvcc_neg[] = { rvc_rs1_eq_x0, rvc_end };
static const rvc_constraint rvcc_negw[] = { rvc_rs1_eq_x0, rvc_end };
-static const rvc_constraint rvcc_sext_w[] = { rvc_rs2_eq_x0, rvc_end };
+static const rvc_constraint rvcc_sext_w[] = { rvc_imm_eq_zero, rvc_end };
static const rvc_constraint rvcc_seqz[] = { rvc_imm_eq_p1, rvc_end };
static const rvc_constraint rvcc_snez[] = { rvc_rs1_eq_x0, rvc_end };
static const rvc_constraint rvcc_sltz[] = { rvc_rs2_eq_x0, rvc_end };
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12
2018-03-28 20:40 [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12 Michael Clark
2018-03-28 20:40 ` [Qemu-devel] [PULL 1/2] RISC-V: Convert cpu definition to future model Michael Clark
2018-03-28 20:40 ` [Qemu-devel] [PULL 2/2] RISC-V: Fix incorrect disassembly for addiw Michael Clark
@ 2018-03-29 10:21 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-03-29 10:21 UTC (permalink / raw)
To: Michael Clark; +Cc: QEMU Developers, RISC-V Patches
On 28 March 2018 at 21:40, Michael Clark <mjc@sifive.com> wrote:
> The following changes since commit 043289bef4d9c0d277c45695c676a6cc9fca48a0:
>
> Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180328' into staging (2018-03-28 13:30:10 +0100)
>
> are available in the git repository at:
>
> https://github.com/riscv/riscv-qemu.git tags/riscv-qemu-2.12-important-fixes
>
> for you to fetch changes up to 33b4f859f1e1ea6722d10c3e9c0e3d85afb44ff4:
>
> RISC-V: Fix incorrect disassembly for addiw (2018-03-28 11:12:02 -0700)
>
> ----------------------------------------------------------------
> RISC-V: Important fixes for QEMU 2.12
>
> This series includes changes that are considered important.
> i.e. correct user-visible bugs that are exercised by common
> operations such as -cpu list (CPU model changes) or -d in_asm
> (fix for disassembly of addiw)
>
> ----------------------------------------------------------------
> Michael Clark (2):
> RISC-V: Convert cpu definition to future model
> RISC-V: Fix incorrect disassembly for addiw
>
> disas/riscv.c | 2 +-
> target/riscv/cpu.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------
> 2 files changed, 70 insertions(+), 55 deletions(-)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-29 10:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-28 20:40 [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12 Michael Clark
2018-03-28 20:40 ` [Qemu-devel] [PULL 1/2] RISC-V: Convert cpu definition to future model Michael Clark
2018-03-28 20:40 ` [Qemu-devel] [PULL 2/2] RISC-V: Fix incorrect disassembly for addiw Michael Clark
2018-03-29 10:21 ` [Qemu-devel] [PULL 0/2] RISC-V: Important fixes for QEMU 2.12 Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).