diff mbox series

[RFC,11/40] target/arm: Copy features from ARMCPUClass

Message ID 20230103181646.55711-12-richard.henderson@linaro.org
State New
Headers show
Series Toward class init of cpu features | expand

Commit Message

Richard Henderson Jan. 3, 2023, 6:16 p.m. UTC
Create a features member in ARMCPUClass and copy to the instance in
arm_cpu_init.  Settings of this value will come in a future patch.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/cpu-qom.h | 18 ++++++++++++++++++
 target/arm/cpu.c     |  1 +
 2 files changed, 19 insertions(+)

Comments

Philippe Mathieu-Daudé Jan. 5, 2023, 10:04 p.m. UTC | #1
On 3/1/23 19:16, Richard Henderson wrote:
> Create a features member in ARMCPUClass and copy to the instance in
> arm_cpu_init.  Settings of this value will come in a future patch.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/arm/cpu-qom.h | 18 ++++++++++++++++++
>   target/arm/cpu.c     |  1 +
>   2 files changed, 19 insertions(+)
> 
> diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
> index 5509ef9d85..ac58cc3a87 100644
> --- a/target/arm/cpu-qom.h
> +++ b/target/arm/cpu-qom.h
> @@ -74,8 +74,26 @@ struct ARMCPUClass {
>   
>       /* 'compatible' string for this CPU for Linux device trees */
>       const char *dtb_compatible;
> +
> +    /* Internal CPU feature flags.  */
> +    uint64_t features;
>   };
>   
> +static inline int arm_class_feature(ARMCPUClass *acc, int feature)
> +{
> +    return (acc->features & (1ULL << feature)) != 0;
> +}
> +
> +static inline void set_class_feature(ARMCPUClass *acc, int feature)
> +{
> +    acc->features |= 1ULL << feature;
> +}
> +
> +static inline void unset_class_feature(ARMCPUClass *acc, int feature)
> +{
> +    acc->features &= ~(1ULL << feature);
> +}

These helpers are not used until patch #19 "target/arm: Move most cpu
initialization to the class".

>   void register_cp_regs_for_features(ARMCPU *cpu);
>   void init_cpreg_list(ARMCPU *cpu);
>   
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index 1bc45b2b25..d64b86b6a5 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -1191,6 +1191,7 @@ static void arm_cpu_initfn(Object *obj)
>       QLIST_INIT(&cpu->el_change_hooks);
>   
>       cpu->dtb_compatible = acc->dtb_compatible;
> +    cpu->env.features = acc->features;
>   
>   #ifdef CONFIG_USER_ONLY
>   # ifdef TARGET_AARCH64
Richard Henderson Jan. 6, 2023, 2:19 a.m. UTC | #2
On 1/5/23 14:04, Philippe Mathieu-Daudé wrote:
> On 3/1/23 19:16, Richard Henderson wrote:
>> Create a features member in ARMCPUClass and copy to the instance in
>> arm_cpu_init.  Settings of this value will come in a future patch.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   target/arm/cpu-qom.h | 18 ++++++++++++++++++
>>   target/arm/cpu.c     |  1 +
>>   2 files changed, 19 insertions(+)
>>
>> diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
>> index 5509ef9d85..ac58cc3a87 100644
>> --- a/target/arm/cpu-qom.h
>> +++ b/target/arm/cpu-qom.h
>> @@ -74,8 +74,26 @@ struct ARMCPUClass {
>>       /* 'compatible' string for this CPU for Linux device trees */
>>       const char *dtb_compatible;
>> +
>> +    /* Internal CPU feature flags.  */
>> +    uint64_t features;
>>   };
>> +static inline int arm_class_feature(ARMCPUClass *acc, int feature)
>> +{
>> +    return (acc->features & (1ULL << feature)) != 0;
>> +}
>> +
>> +static inline void set_class_feature(ARMCPUClass *acc, int feature)
>> +{
>> +    acc->features |= 1ULL << feature;
>> +}
>> +
>> +static inline void unset_class_feature(ARMCPUClass *acc, int feature)
>> +{
>> +    acc->features &= ~(1ULL << feature);
>> +}
> 
> These helpers are not used until patch #19 "target/arm: Move most cpu
> initialization to the class".

I know, but I thought it clearer to introduce them with the field.


r~

> 
>>   void register_cp_regs_for_features(ARMCPU *cpu);
>>   void init_cpreg_list(ARMCPU *cpu);
>> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
>> index 1bc45b2b25..d64b86b6a5 100644
>> --- a/target/arm/cpu.c
>> +++ b/target/arm/cpu.c
>> @@ -1191,6 +1191,7 @@ static void arm_cpu_initfn(Object *obj)
>>       QLIST_INIT(&cpu->el_change_hooks);
>>       cpu->dtb_compatible = acc->dtb_compatible;
>> +    cpu->env.features = acc->features;
>>   #ifdef CONFIG_USER_ONLY
>>   # ifdef TARGET_AARCH64
>
Philippe Mathieu-Daudé Jan. 6, 2023, 7:14 a.m. UTC | #3
On 6/1/23 03:19, Richard Henderson wrote:
> On 1/5/23 14:04, Philippe Mathieu-Daudé wrote:
>> On 3/1/23 19:16, Richard Henderson wrote:
>>> Create a features member in ARMCPUClass and copy to the instance in
>>> arm_cpu_init.  Settings of this value will come in a future patch.
>>>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>>>   target/arm/cpu-qom.h | 18 ++++++++++++++++++
>>>   target/arm/cpu.c     |  1 +
>>>   2 files changed, 19 insertions(+)


>>> +static inline void unset_class_feature(ARMCPUClass *acc, int feature)
>>> +{
>>> +    acc->features &= ~(1ULL << feature);
>>> +}
>>
>> These helpers are not used until patch #19 "target/arm: Move most cpu
>> initialization to the class".
> 
> I know, but I thought it clearer to introduce them with the field.

Fine.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
index 5509ef9d85..ac58cc3a87 100644
--- a/target/arm/cpu-qom.h
+++ b/target/arm/cpu-qom.h
@@ -74,8 +74,26 @@  struct ARMCPUClass {
 
     /* 'compatible' string for this CPU for Linux device trees */
     const char *dtb_compatible;
+
+    /* Internal CPU feature flags.  */
+    uint64_t features;
 };
 
+static inline int arm_class_feature(ARMCPUClass *acc, int feature)
+{
+    return (acc->features & (1ULL << feature)) != 0;
+}
+
+static inline void set_class_feature(ARMCPUClass *acc, int feature)
+{
+    acc->features |= 1ULL << feature;
+}
+
+static inline void unset_class_feature(ARMCPUClass *acc, int feature)
+{
+    acc->features &= ~(1ULL << feature);
+}
+
 void register_cp_regs_for_features(ARMCPU *cpu);
 void init_cpreg_list(ARMCPU *cpu);
 
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 1bc45b2b25..d64b86b6a5 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1191,6 +1191,7 @@  static void arm_cpu_initfn(Object *obj)
     QLIST_INIT(&cpu->el_change_hooks);
 
     cpu->dtb_compatible = acc->dtb_compatible;
+    cpu->env.features = acc->features;
 
 #ifdef CONFIG_USER_ONLY
 # ifdef TARGET_AARCH64