target/riscv/cpu.c: fix machine IDs getters
PATCH 1/1 target/riscv/cpu.c: fix machine IDs getters
mvendorid is an uint32 property, mimpid/marchid are uint64 properties. But their getters are returning bools. The reason this went under the radar for this long is because we have no code using the getters.
The problem can be seem via the 'qom-get' API though. Launching QEMU with the 'veyron-v1' CPU, a model with:
VEYRON_V1_MVENDORID: 0x61f (1567)VEYRON_V1_MIMPID: 0x111 (273)VEYRON_V1_MARCHID: 0x8000000000010000 (9223372036854841344)
This is what the API returns when retrieving these properties:
(qemu) qom-get /machine/soc0/harts[0] mvendorid
true
(qemu) qom-get /machine/soc0/harts[0] mimpid
true
(qemu) qom-get /machine/soc0/harts[0] marchid
true
After this patch:
(qemu) qom-get /machine/soc0/harts[0] mvendorid
1567
(qemu) qom-get /machine/soc0/harts[0] mimpid
273
(qemu) qom-get /machine/soc0/harts[0] marchid
9223372036854841344
--- target/riscv/cpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target/riscv/cpu.c +6 -6
@@ -1573,9 +1573,9 @@ static void cpu_set_mvendorid(Object *obj, Visitor *v, const char *name,static void cpu_get_mvendorid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.mvendorid; +uint32_t value =RISCV_CPU (obj)->cfg.mvendorid; -visit_type_bool (v, name, &value, errp); +visit_type_uint32 (v, name, &value, errp); } static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,
@@ -1602,9 +1602,9 @@ static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,static void cpu_get_mimpid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.mimpid; +uint64_t value =RISCV_CPU (obj)->cfg.mimpid; -visit_type_bool (v, name, &value, errp); +visit_type_uint64 (v, name, &value, errp); } static void cpu_set_marchid(Object *obj, Visitor *v, const char *name,
@@ -1652,9 +1652,9 @@ static void cpu_set_marchid(Object *obj, Visitor *v, const char *name,static void cpu_get_marchid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.marchid; +uint64_t value =RISCV_CPU (obj)->cfg.marchid; -visit_type_bool (v, name, &value, errp); +visit_type_uint64 (v, name, &value, errp); }static void riscv_cpu_class_init (ObjectClass *c,void *data)
Signature · 1 line
2.41.0
Quoted 29 lines · Daniel Henrique Barboza
mvendorid is an uint32 property, mimpid/marchid are uint64 properties. But their getters are returning bools. The reason this went under the radar for this long is because we have no code using the getters.
The problem can be seem via the 'qom-get' API though. Launching QEMU with the 'veyron-v1' CPU, a model with:
VEYRON_V1_MVENDORID:0x61f(1567)VEYRON_V1_MIMPID:0x111(273)VEYRON_V1_MARCHID:0x8000000000010000(9223372036854841344)This is what the API returns when retrieving these properties:
(qemu) qom-get /machine/soc0/harts[0] mvendorid
true
(qemu) qom-get /machine/soc0/harts[0] mimpid
true
(qemu) qom-get /machine/soc0/harts[0] marchid
trueAfter this patch:
(qemu) qom-get /machine/soc0/harts[0] mvendorid
1567
(qemu) qom-get /machine/soc0/harts[0] mimpid
273
(qemu) qom-get /machine/soc0/harts[0] marchid
9223372036854841344
Quoted 4 lines
Fixes 1e34150045 ("target/riscv/cpu.c: restrict 'mvendorid' value")Fixes a1863ad368 ("target/riscv/cpu.c: restrict 'mimpid' value")Fixes d6a427e2c0 ("target/riscv/cpu.c: restrict 'marchid' value")Signed-off-by Daniel Henrique Barboza <[email protected]>
Quoted 44 lines
--- target/riscv/cpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)target/riscv/cpu.c +6
-6@@ -1573,9 +1573,9 @@ static void cpu_set_mvendorid(Object *obj, Visitor *v, const char *name,static void cpu_get_mvendorid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.mvendorid; +uint32_t value =RISCV_CPU (obj)->cfg.mvendorid; -visit_type_bool (v, name, &value, errp); +visit_type_uint32 (v, name, &value, errp); } static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,@@ -1602,9 +1602,9 @@ static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,static void cpu_get_mimpid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.mimpid; +uint64_t value =RISCV_CPU (obj)->cfg.mimpid; -visit_type_bool (v, name, &value, errp); +visit_type_uint64 (v, name, &value, errp); } static void cpu_set_marchid(Object *obj, Visitor *v, const char *name,@@ -1652,9 +1652,9 @@ static void cpu_set_marchid(Object *obj, Visitor *v, const char *name,static void cpu_get_marchid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.marchid; +uint64_t value =RISCV_CPU (obj)->cfg.marchid; -visit_type_bool (v, name, &value, errp); +visit_type_uint64 (v, name, &value, errp); }static void riscv_cpu_class_init (ObjectClass *c,void *data)
Quoted 30 lines · Daniel Henrique Barboza
mvendorid is an uint32 property, mimpid/marchid are uint64 properties. But their getters are returning bools. The reason this went under the radar for this long is because we have no code using the getters.
The problem can be seem via the 'qom-get' API though. Launching QEMU with the 'veyron-v1' CPU, a model with:
VEYRON_V1_MVENDORID:0x61f(1567)VEYRON_V1_MIMPID:0x111(273)VEYRON_V1_MARCHID:0x8000000000010000(9223372036854841344)This is what the API returns when retrieving these properties:
(qemu) qom-get /machine/soc0/harts[0] mvendorid
true
(qemu) qom-get /machine/soc0/harts[0] mimpid
true
(qemu) qom-get /machine/soc0/harts[0] marchid
trueAfter this patch:
(qemu) qom-get /machine/soc0/harts[0] mvendorid
1567
(qemu) qom-get /machine/soc0/harts[0] mimpid
273
(qemu) qom-get /machine/soc0/harts[0] marchid
9223372036854841344
Quoted 4 lines
Fixes 1e34150045 ("target/riscv/cpu.c: restrict 'mvendorid' value")Fixes a1863ad368 ("target/riscv/cpu.c: restrict 'mimpid' value")Fixes d6a427e2c0 ("target/riscv/cpu.c: restrict 'marchid' value")Signed-off-by Daniel Henrique Barboza <[email protected]>
Alistair
Quoted 48 lines
--- target/riscv/cpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)target/riscv/cpu.c +6
-7@@ -1573,9 +1573,9 @@ static void cpu_set_mvendorid(Object *obj, Visitor *v, const char *name,static void cpu_get_mvendorid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.mvendorid; +uint32_t value =RISCV_CPU (obj)->cfg.mvendorid; -visit_type_bool (v, name, &value, errp); +visit_type_uint32 (v, name, &value, errp); } static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,@@ -1602,9 +1602,9 @@ static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,static void cpu_get_mimpid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.mimpid; +uint64_t value =RISCV_CPU (obj)->cfg.mimpid; -visit_type_bool (v, name, &value, errp); +visit_type_uint64 (v, name, &value, errp); } static void cpu_set_marchid(Object *obj, Visitor *v, const char *name,@@ -1652,9 +1652,9 @@ static void cpu_set_marchid(Object *obj, Visitor *v, const char *name,static void cpu_get_marchid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.marchid; +uint64_t value =RISCV_CPU (obj)->cfg.marchid; -visit_type_bool (v, name, &value, errp); +visit_type_uint64 (v, name, &value, errp); }static void riscv_cpu_class_init (ObjectClass *c,void *data) --2.41.0
Alistair Francis
AppliedQuoted 30 lines · Daniel Henrique Barboza
mvendorid is an uint32 property, mimpid/marchid are uint64 properties. But their getters are returning bools. The reason this went under the radar for this long is because we have no code using the getters.
The problem can be seem via the 'qom-get' API though. Launching QEMU with the 'veyron-v1' CPU, a model with:
VEYRON_V1_MVENDORID:0x61f(1567)VEYRON_V1_MIMPID:0x111(273)VEYRON_V1_MARCHID:0x8000000000010000(9223372036854841344)This is what the API returns when retrieving these properties:
(qemu) qom-get /machine/soc0/harts[0] mvendorid
true
(qemu) qom-get /machine/soc0/harts[0] mimpid
true
(qemu) qom-get /machine/soc0/harts[0] marchid
trueAfter this patch:
(qemu) qom-get /machine/soc0/harts[0] mvendorid
1567
(qemu) qom-get /machine/soc0/harts[0] mimpid
273
(qemu) qom-get /machine/soc0/harts[0] marchid
9223372036854841344
Quoted 4 lines
Fixes 1e34150045 ("target/riscv/cpu.c: restrict 'mvendorid' value")Fixes a1863ad368 ("target/riscv/cpu.c: restrict 'mimpid' value")Fixes d6a427e2c0 ("target/riscv/cpu.c: restrict 'marchid' value")Signed-off-by Daniel Henrique Barboza <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 48 lines
--- target/riscv/cpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)target/riscv/cpu.c +6
-7@@ -1573,9 +1573,9 @@ static void cpu_set_mvendorid(Object *obj, Visitor *v, const char *name,static void cpu_get_mvendorid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.mvendorid; +uint32_t value =RISCV_CPU (obj)->cfg.mvendorid; -visit_type_bool (v, name, &value, errp); +visit_type_uint32 (v, name, &value, errp); } static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,@@ -1602,9 +1602,9 @@ static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,static void cpu_get_mimpid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.mimpid; +uint64_t value =RISCV_CPU (obj)->cfg.mimpid; -visit_type_bool (v, name, &value, errp); +visit_type_uint64 (v, name, &value, errp); } static void cpu_set_marchid(Object *obj, Visitor *v, const char *name,@@ -1652,9 +1652,9 @@ static void cpu_set_marchid(Object *obj, Visitor *v, const char *name,static void cpu_get_marchid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -bool value =RISCV_CPU (obj)->cfg.marchid; +uint64_t value =RISCV_CPU (obj)->cfg.marchid; -visit_type_bool (v, name, &value, errp); +visit_type_uint64 (v, name, &value, errp); }static void riscv_cpu_class_init (ObjectClass *c,void *data) --2.41.0