Am 17/01/2023 um 17:16 schrieb Warner Losh:
> 
> 
> On Tue, Jan 17, 2023 at 6:52 AM Emanuele Giuseppe Esposito
> <eespo...@redhat.com <mailto:eespo...@redhat.com>> wrote:
> 
>     QEMU does not compile when enabling clang's thread safety analysis
>     (TSA),
>     because some functions create wrappers for pthread mutexes but do
>     not use any TSA macro. Therefore the compiler fails.
> 
>     In order to make the compiler happy and avoid adding all the
>     necessary macros to all callers (lock functions should use
>     TSA_ACQUIRE, while unlock TSA_RELEASE, and this applies to allusers
>     of pthread_mutex_lock/pthread_mutex_unlock),
>     simply use TSA_NO_TSA to supppress such warnings.
> 
> 
> I'm not sure I understand this quite right. Maybe a clarifying question
> will help me understand: Why is this needed for bsd-user but not
> linux-user? How are they different here?
> 
Honestly I just went and fix the warnings that the compiler was throwing
at me. On FreeBSD it complains on bsd-user/mmap.c, but apparently the CI
or even compiling locally in linux doesn't create any issue with linux-user.

Weird. But I guess it won't hurt to add TSA_NO_TSA there too.

Emanuele

> Warner
>  
> 
>     Signed-off-by: Emanuele Giuseppe Esposito <eespo...@redhat.com
>     <mailto:eespo...@redhat.com>>
>     ---
>      bsd-user/qemu.h         | 5 +++--
>      include/exec/exec-all.h | 5 +++--
>      2 files changed, 6 insertions(+), 4 deletions(-)
> 
>     diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
>     index be6105385e..711fdd1b64 100644
>     --- a/bsd-user/qemu.h
>     +++ b/bsd-user/qemu.h
>     @@ -37,6 +37,7 @@ extern char **environ;
>      #include "target_os_signal.h"
>      #include "target.h"
>      #include "exec/gdbstub.h"
>     +#include "qemu/clang-tsa.h"
> 
>      /*
>       * This struct is used to hold certain information about the
>     image.  Basically,
>     @@ -235,8 +236,8 @@ int target_msync(abi_ulong start, abi_ulong len,
>     int flags);
>      extern unsigned long last_brk;
>      extern abi_ulong mmap_next_start;
>      abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size);
>     -void mmap_fork_start(void);
>     -void mmap_fork_end(int child);
>     +void TSA_NO_TSA mmap_fork_start(void);
>     +void TSA_NO_TSA mmap_fork_end(int child);
> 
>      /* main.c */
>      extern char qemu_proc_pathname[];
>     diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
>     index 25e11b0a8d..4f0c0559ac 100644
>     --- a/include/exec/exec-all.h
>     +++ b/include/exec/exec-all.h
>     @@ -25,6 +25,7 @@
>      #include "exec/cpu_ldst.h"
>      #endif
>      #include "qemu/interval-tree.h"
>     +#include "qemu/clang-tsa.h"
> 
>      /* allow to see translation results - the slowdown should be
>     negligible, so we leave it */
>      #define DEBUG_DISAS
>     @@ -758,8 +759,8 @@ static inline tb_page_addr_t
>     get_page_addr_code(CPUArchState *env,
>      }
> 
>      #if defined(CONFIG_USER_ONLY)
>     -void mmap_lock(void);
>     -void mmap_unlock(void);
>     +void TSA_NO_TSA mmap_lock(void);
>     +void TSA_NO_TSA mmap_unlock(void);
>      bool have_mmap_lock(void);
> 
>      /**
>     -- 
>     2.39.0
> 


Reply via email to