target/arm: Use correct variable for setting 'max' cpu's MIDR_EL1
PATCH v2 1/1 target/arm: Use correct variable for setting 'max' cpu's MIDR_EL1
MIDR_EL1 a 64-bit system register with the top 32-bit being RES0.
This fixes when compiling with -Werror=conversion:
target/arm/cpu64.c: In function ‘aarch64_max_initfn’:
target/arm/cpu64.c:628:21: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘uint32_t’ {aka ‘unsigned int’} may change value [-Werror=conversion]
628 | cpu->midr = t;
| ^---
I suppose cp15.c0_cpuid register in target/arm/cpu.h as uint32_t is OK.
Since v1: Follow Laurent and Peter suggestion.
--- target/arm/cpu.h | 3 ++- target/arm/cpu.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
target/arm/cpu.h +2 -1
@@ -894,7 +894,7 @@ struct ARMCPU {uint64_t id_aa64dfr0;uint64_t id_aa64dfr1; } isar; -uint32_t midr; +uint64_t midr;uint32_t revidr;uint32_t reset_fpsid;uint32_t ctr;
@@ -1685,6 +1685,7 @@ FIELD(MIDR_EL1, PARTNUM, 4, 12) FIELD(MIDR_EL1, ARCHITECTURE, 16, 4) FIELD(MIDR_EL1, VARIANT, 20, 4) FIELD(MIDR_EL1, IMPLEMENTER, 24, 8) +FIELD(MIDR_EL1, RESERVED, 32, 32) FIELD(ID_ISAR0, SWAP, 0, 4)FIELD (ID_ISAR0 ,BITCOUNT ,4 ,4 )
target/arm/cpu.c +3 -1
@@ -1182,6 +1182,8 @@ void arm_cpu_post_init(Object *obj) {ARMCPU *cpu =ARM_CPU (obj); +assert (FIELD_EX64 (cpu->midr,MIDR_EL1 ,RESERVED ) ==0 ); +/* M profile implies PMSA. We have to do this here rather than * in realize with the other feature-implication checks because * we look at the PMSA bit to see if we should add some properties.
@@ -2757,7 +2759,7 @@ static const ARMCPUInfo arm_cpus[] = {static Property arm_cpu_properties[] = {DEFINE_PROP_BOOL ("start-powered-off" ,ARMCPU , start_powered_off, false),DEFINE_PROP_UINT32 ("psci-conduit" ,ARMCPU , psci_conduit,0 ), -DEFINE_PROP_UINT32 ("midr" ,ARMCPU , midr,0 ), +DEFINE_PROP_UINT64 ("midr" ,ARMCPU , midr,0 ),DEFINE_PROP_UINT64 ("mp-affinity" ,ARMCPU , mp_affinity,ARM64_AFFINITY_INVALID ),DEFINE_PROP_INT32 ("node-id" ,ARMCPU , node_id,CPU_UNSET_NUMA_NODE_ID ),
Signature · 1 line
2.21.1
On Tue, 28 Apr 2020 at 16:50, Philippe Mathieu-Daudé <[email protected]> wrote:
Looks like you forgot to edit the commit message subject line.
Quoted 6 lines
MIDR_EL1a 64-bit system register with the top 32-bit being RES0.This fixes when compiling with -Werror=conversion:
target/arm/cpu64.c: In function ‘aarch64_max_initfn’:
target/arm/cpu64.c:628:21: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘uint32_t’ {aka ‘unsigned int’} may change value [-Werror=conversion]
Quoted 8 lines
628 | cpu->midr = t; | ^Suggested-by Laurent Desnogues <[email protected]>Suggested-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
I suppose cp15.c0_cpuid register intarget/arm/cpu.hasuint32_tis OK.
Yes, that's a 32-bit aarch32 system register.
Quoted 33 lines
Since v1: Follow Laurent and Peter suggestion.
--- target/arm/cpu.h | 3 ++- target/arm/cpu.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)target/arm/cpu.h +2
-1@@ -894,7 +894,7 @@ struct ARMCPU {uint64_t id_aa64dfr0;uint64_t id_aa64dfr1; } isar; -uint32_t midr; +uint64_t midr;uint32_t revidr;uint32_t reset_fpsid;uint32_t ctr;@@ -1685,6 +1685,7 @@ FIELD(MIDR_EL1, PARTNUM, 4, 12) FIELD(MIDR_EL1, ARCHITECTURE, 16, 4) FIELD(MIDR_EL1, VARIANT, 20, 4) FIELD(MIDR_EL1, IMPLEMENTER, 24, 8) +FIELD(MIDR_EL1, RESERVED, 32, 32) FIELD(ID_ISAR0, SWAP, 0, 4)FIELD (ID_ISAR0 ,BITCOUNT ,4 ,4 )target/arm/cpu.c +0
-0
target/arm/cpu.c void arm_cpu_post_init(Object *obj) · line 1185
Quoted 4 lines
target/arm/cpu.c +1
-0@@ -1182,6 +1182,8 @@ void arm_cpu_post_init(Object *obj) {ARMCPU *cpu =ARM_CPU (obj); +assert (FIELD_EX64 (cpu->midr,MIDR_EL1 ,RESERVED ) ==0 );
I wouldn't bother with the assert; we don't generally do that kind of check on ID register values.
Quoted 14 lines
target/arm/cpu.c +2
-2+/* M profile implies PMSA. We have to do this here rather than * in realize with the other feature-implication checks because * we look at the PMSA bit to see if we should add some properties. @@ -2757,7 +2759,7 @@ static const ARMCPUInfo arm_cpus[] = {static Property arm_cpu_properties[] = {DEFINE_PROP_BOOL ("start-powered-off" ,ARMCPU , start_powered_off, false),DEFINE_PROP_UINT32 ("psci-conduit" ,ARMCPU , psci_conduit,0 ), -DEFINE_PROP_UINT32 ("midr" ,ARMCPU , midr,0 ), +DEFINE_PROP_UINT64 ("midr" ,ARMCPU , midr,0 ),DEFINE_PROP_UINT64 ("mp-affinity" ,ARMCPU , mp_affinity,ARM64_AFFINITY_INVALID ),DEFINE_PROP_INT32 ("node-id" ,ARMCPU , node_id,CPU_UNSET_NUMA_NODE_ID ), --
Quoted 1 line
2.21.1
Otherwise looks good.
-- PMM
Quoted 36 lines · Philippe Mathieu-Daudé
MIDR_EL1a 64-bit system register with the top 32-bit being RES0.This fixes when compiling with -Werror=conversion:
target/arm/cpu64.c: In function ‘aarch64_max_initfn’:
target/arm/cpu64.c:628:21: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘uint32_t’ {aka ‘unsigned int’} may change value [-Werror=conversion]628 | cpu->midr = t; | ^Suggested-by Laurent Desnogues <[email protected]>Suggested-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
I suppose cp15.c0_cpuid register intarget/arm/cpu.hasuint32_tis OK.Since v1: Follow Laurent and Peter suggestion.
--- target/arm/cpu.h | 3 ++- target/arm/cpu.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)target/arm/cpu.h +1
-1@@ -894,7 +894,7 @@ struct ARMCPU {uint64_t id_aa64dfr0;uint64_t id_aa64dfr1; } isar; -uint32_t midr; +uint64_t midr;uint32_t revidr;uint32_t reset_fpsid;uint32_t ctr;
target/arm/cpu.h FIELD(MIDR_EL1, PARTNUM, 4, 12) · line 1688
Quoted 4 lines
target/arm/cpu.h +1
-0@@ -1685,6 +1685,7 @@ FIELD(MIDR_EL1, PARTNUM, 4, 12) FIELD(MIDR_EL1, ARCHITECTURE, 16, 4) FIELD(MIDR_EL1, VARIANT, 20, 4) FIELD(MIDR_EL1, IMPLEMENTER, 24, 8) +FIELD (MIDR_EL1 ,RESERVED ,32 ,32 )
If you follow Peter advice to not check these 32-bits, you could remove that field definition and if you keep it please rename it RES0 :-).
Thanks,
Laurent
Quoted 28 lines
target/arm/cpu.h +0
-0FIELD(ID_ISAR0, SWAP, 0, 4)FIELD (ID_ISAR0 ,BITCOUNT ,4 ,4 )target/arm/cpu.c +3
-2@@ -1182,6 +1182,8 @@ void arm_cpu_post_init(Object *obj) {ARMCPU *cpu =ARM_CPU (obj); +assert (FIELD_EX64 (cpu->midr,MIDR_EL1 ,RESERVED ) ==0 ); +/* M profile implies PMSA. We have to do this here rather than * in realize with the other feature-implication checks because * we look at the PMSA bit to see if we should add some properties. @@ -2757,7 +2759,7 @@ static const ARMCPUInfo arm_cpus[] = {static Property arm_cpu_properties[] = {DEFINE_PROP_BOOL ("start-powered-off" ,ARMCPU , start_powered_off, false),DEFINE_PROP_UINT32 ("psci-conduit" ,ARMCPU , psci_conduit,0 ), -DEFINE_PROP_UINT32 ("midr" ,ARMCPU , midr,0 ), +DEFINE_PROP_UINT64 ("midr" ,ARMCPU , midr,0 ),DEFINE_PROP_UINT64 ("mp-affinity" ,ARMCPU , mp_affinity,ARM64_AFFINITY_INVALID ),DEFINE_PROP_INT32 ("node-id" ,ARMCPU , node_id,CPU_UNSET_NUMA_NODE_ID ), --2.21.1