diff mbox series

[v2,16/17] cpu: Restrict cpu_paging_enabled / cpu_get_memory_mapping to sysemu

Message ID 20210301215110.772346-17-f4bug@amsat.org
State New
Headers show
Series cpu: Introduce SysemuCPUOps structure | expand

Commit Message

Philippe Mathieu-Daudé March 1, 2021, 9:51 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Claudio Fontana March 2, 2021, 12:34 p.m. UTC | #1
On 3/1/21 10:51 PM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/hw/core/cpu.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> index 960846d2b64..d99d3c830dc 100644
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -427,6 +427,8 @@ static inline void cpu_tb_jmp_cache_clear(CPUState *cpu)
>  extern bool mttcg_enabled;
>  #define qemu_tcg_mttcg_enabled() (mttcg_enabled)
>  
> +#if !defined(CONFIG_USER_ONLY)
> +
>  /**
>   * cpu_paging_enabled:
>   * @cpu: The CPU whose state is to be inspected.
> @@ -444,8 +446,6 @@ bool cpu_paging_enabled(const CPUState *cpu);
>  void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
>                              Error **errp);
>  
> -#if !defined(CONFIG_USER_ONLY)
> -
>  /**
>   * cpu_write_elf64_note:
>   * @f: pointer to a function that writes memory to a file
> 

Hi Philippe,

this is the only patch where I was able to find an issue.

Adding any #ifdef CONFIG_USER_ONLY in include/hw/core/cpu.h as far as I experienced, is basically wrong.

Your use is not causing direct damage, but could be used as a precedent to introduce serious bugs.
It was the case for me.

Is there some other header, only included by target-specific code, that you could place these?

Ciao,

Claudio
Philippe Mathieu-Daudé March 2, 2021, 12:39 p.m. UTC | #2
On 3/2/21 1:34 PM, Claudio Fontana wrote:
> On 3/1/21 10:51 PM, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  include/hw/core/cpu.h | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
>> index 960846d2b64..d99d3c830dc 100644
>> --- a/include/hw/core/cpu.h
>> +++ b/include/hw/core/cpu.h
>> @@ -427,6 +427,8 @@ static inline void cpu_tb_jmp_cache_clear(CPUState *cpu)
>>  extern bool mttcg_enabled;
>>  #define qemu_tcg_mttcg_enabled() (mttcg_enabled)
>>  
>> +#if !defined(CONFIG_USER_ONLY)
>> +
>>  /**
>>   * cpu_paging_enabled:
>>   * @cpu: The CPU whose state is to be inspected.
>> @@ -444,8 +446,6 @@ bool cpu_paging_enabled(const CPUState *cpu);
>>  void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
>>                              Error **errp);
>>  
>> -#if !defined(CONFIG_USER_ONLY)
>> -
>>  /**
>>   * cpu_write_elf64_note:
>>   * @f: pointer to a function that writes memory to a file
>>
> 
> Hi Philippe,
> 
> this is the only patch where I was able to find an issue.
> 
> Adding any #ifdef CONFIG_USER_ONLY in include/hw/core/cpu.h as far as I experienced, is basically wrong.

Note I'm not strictly "adding" it but moving it.

I agree CONFIG_USER_ONLY shouldn't be used in hw/ (and sent 3 series
to clean this the last days).

> Your use is not causing direct damage, but could be used as a precedent to introduce serious bugs.
> It was the case for me.
> 
> Is there some other header, only included by target-specific code, that you could place these?

I'll think about it, meanwhile we can also drop this patch, it is not
a requisite.

Thanks for your review,

Phil.
diff mbox series

Patch

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 960846d2b64..d99d3c830dc 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -427,6 +427,8 @@  static inline void cpu_tb_jmp_cache_clear(CPUState *cpu)
 extern bool mttcg_enabled;
 #define qemu_tcg_mttcg_enabled() (mttcg_enabled)
 
+#if !defined(CONFIG_USER_ONLY)
+
 /**
  * cpu_paging_enabled:
  * @cpu: The CPU whose state is to be inspected.
@@ -444,8 +446,6 @@  bool cpu_paging_enabled(const CPUState *cpu);
 void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
                             Error **errp);
 
-#if !defined(CONFIG_USER_ONLY)
-
 /**
  * cpu_write_elf64_note:
  * @f: pointer to a function that writes memory to a file