[PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'

Philippe Mathieu-Daudé posted 24 patches 1 week, 2 days ago
[PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
Posted by Philippe Mathieu-Daudé 1 week, 2 days ago
Move CPU TLB related methods to "exec/cputlb.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/cputlb.h   | 7 +++++++
 include/exec/exec-all.h | 3 ---
 include/exec/ram_addr.h | 1 +
 system/physmem.c        | 1 +
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h
index ef18642a32..6cac7d530f 100644
--- a/include/exec/cputlb.h
+++ b/include/exec/cputlb.h
@@ -32,4 +32,11 @@ void tlb_unprotect_code(ram_addr_t ram_addr);
 
 #endif /* CONFIG_TCG */
 
+#ifndef CONFIG_USER_ONLY
+
+void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
+void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
+
+#endif
+
 #endif
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 2e4c4cc4b4..2c06e54387 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -589,9 +589,6 @@ static inline void mmap_lock(void) {}
 static inline void mmap_unlock(void) {}
 #define WITH_MMAP_LOCK_GUARD()
 
-void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
-void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
-
 MemoryRegionSection *
 address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
                                   hwaddr *xlat, hwaddr *plen,
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 891c44cf2d..b6d5551549 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -23,6 +23,7 @@
 #include "cpu.h"
 #include "sysemu/xen.h"
 #include "sysemu/tcg.h"
+#include "exec/cputlb.h"
 #include "exec/ramlist.h"
 #include "exec/ramblock.h"
 #include "exec/exec-all.h"
diff --git a/system/physmem.c b/system/physmem.c
index dc1db3a384..3f937a5e58 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -32,6 +32,7 @@
 #endif /* CONFIG_TCG */
 
 #include "exec/exec-all.h"
+#include "exec/cputlb.h"
 #include "exec/page-protection.h"
 #include "exec/target_page.h"
 #include "hw/qdev-core.h"
-- 
2.45.2


Re: [PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
Posted by Richard Henderson 1 week, 1 day ago
On 11/13/24 17:12, Philippe Mathieu-Daudé wrote:
> Move CPU TLB related methods to "exec/cputlb.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/exec/cputlb.h   | 7 +++++++
>   include/exec/exec-all.h | 3 ---
>   include/exec/ram_addr.h | 1 +
>   system/physmem.c        | 1 +
>   4 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h
> index ef18642a32..6cac7d530f 100644
> --- a/include/exec/cputlb.h
> +++ b/include/exec/cputlb.h
> @@ -32,4 +32,11 @@ void tlb_unprotect_code(ram_addr_t ram_addr);
>   
>   #endif /* CONFIG_TCG */
>   
> +#ifndef CONFIG_USER_ONLY
> +
> +void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
> +void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
> +
> +#endif
> +
>   #endif

This can join the existing CONFIG_TCG, !CONFIG_USER_ONLY block above.


r~

Re: [PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
Posted by Philippe Mathieu-Daudé 1 week, 1 day ago
On 14/11/24 19:19, Richard Henderson wrote:
> On 11/13/24 17:12, Philippe Mathieu-Daudé wrote:
>> Move CPU TLB related methods to "exec/cputlb.h".
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/exec/cputlb.h   | 7 +++++++
>>   include/exec/exec-all.h | 3 ---
>>   include/exec/ram_addr.h | 1 +
>>   system/physmem.c        | 1 +
>>   4 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h
>> index ef18642a32..6cac7d530f 100644
>> --- a/include/exec/cputlb.h
>> +++ b/include/exec/cputlb.h
>> @@ -32,4 +32,11 @@ void tlb_unprotect_code(ram_addr_t ram_addr);
>>   #endif /* CONFIG_TCG */
>> +#ifndef CONFIG_USER_ONLY
>> +
>> +void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t 
>> length);
>> +void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
>> +
>> +#endif
>> +
>>   #endif
> 
> This can join the existing CONFIG_TCG, !CONFIG_USER_ONLY block above.

Actually they are used by all accelerators (thus prototype required),
but elided at build time:

static inline
void cpu_physical_memory_dirty_bits_cleared(ram_addr_t start,
                                             ram_addr_t length)
{
     if (tcg_enabled()) {
         tlb_reset_dirty_range_all(start, length);
     }

}

That said, we can probably to smth to improve that. I'll have
a look.

Re: [PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
Posted by Pierrick Bouvier 1 week, 2 days ago
On 11/13/24 17:12, Philippe Mathieu-Daudé wrote:
> Move CPU TLB related methods to "exec/cputlb.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/exec/cputlb.h   | 7 +++++++
>   include/exec/exec-all.h | 3 ---
>   include/exec/ram_addr.h | 1 +
>   system/physmem.c        | 1 +
>   4 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h
> index ef18642a32..6cac7d530f 100644
> --- a/include/exec/cputlb.h
> +++ b/include/exec/cputlb.h
> @@ -32,4 +32,11 @@ void tlb_unprotect_code(ram_addr_t ram_addr);
>   
>   #endif /* CONFIG_TCG */
>   
> +#ifndef CONFIG_USER_ONLY
> +
> +void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
> +void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
> +
> +#endif
> +
>   #endif
> diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
> index 2e4c4cc4b4..2c06e54387 100644
> --- a/include/exec/exec-all.h
> +++ b/include/exec/exec-all.h
> @@ -589,9 +589,6 @@ static inline void mmap_lock(void) {}
>   static inline void mmap_unlock(void) {}
>   #define WITH_MMAP_LOCK_GUARD()
>   
> -void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
> -void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
> -
>   MemoryRegionSection *
>   address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
>                                     hwaddr *xlat, hwaddr *plen,
> diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
> index 891c44cf2d..b6d5551549 100644
> --- a/include/exec/ram_addr.h
> +++ b/include/exec/ram_addr.h
> @@ -23,6 +23,7 @@
>   #include "cpu.h"
>   #include "sysemu/xen.h"
>   #include "sysemu/tcg.h"
> +#include "exec/cputlb.h"
>   #include "exec/ramlist.h"
>   #include "exec/ramblock.h"
>   #include "exec/exec-all.h"
> diff --git a/system/physmem.c b/system/physmem.c
> index dc1db3a384..3f937a5e58 100644
> --- a/system/physmem.c
> +++ b/system/physmem.c
> @@ -32,6 +32,7 @@
>   #endif /* CONFIG_TCG */
>   
>   #include "exec/exec-all.h"
> +#include "exec/cputlb.h"
>   #include "exec/page-protection.h"
>   #include "exec/target_page.h"
>   #include "hw/qdev-core.h"

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>