Message ID | 20250313034524.3069690-14-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | accel/tcg, codebase: Build once patches | expand |
On 13/3/25 04:44, Richard Henderson wrote: > Split out mmap_lock, et al from page-protection.h > to a new header. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > accel/tcg/internal-target.h | 1 + > include/exec/mmap-lock.h | 33 +++++++++++++++++++++++++++++++++ What about include/accel/tcg/mmap-lock.h? > include/exec/page-protection.h | 22 ---------------------- > accel/tcg/cpu-exec.c | 1 + > accel/tcg/tb-maint.c | 1 + > accel/tcg/translate-all.c | 1 + > linux-user/arm/cpu_loop.c | 1 + > linux-user/elfload.c | 1 + > linux-user/flatload.c | 1 + > linux-user/mmap.c | 1 + > linux-user/syscall.c | 1 + > target/arm/helper.c | 1 + > 12 files changed, 43 insertions(+), 22 deletions(-) > create mode 100644 include/exec/mmap-lock.h
On 3/12/25 20:44, Richard Henderson wrote: > Split out mmap_lock, et al from page-protection.h > to a new header. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > accel/tcg/internal-target.h | 1 + > include/exec/mmap-lock.h | 33 +++++++++++++++++++++++++++++++++ > include/exec/page-protection.h | 22 ---------------------- > accel/tcg/cpu-exec.c | 1 + > accel/tcg/tb-maint.c | 1 + > accel/tcg/translate-all.c | 1 + > linux-user/arm/cpu_loop.c | 1 + > linux-user/elfload.c | 1 + > linux-user/flatload.c | 1 + > linux-user/mmap.c | 1 + > linux-user/syscall.c | 1 + > target/arm/helper.c | 1 + > 12 files changed, 43 insertions(+), 22 deletions(-) > create mode 100644 include/exec/mmap-lock.h > > diff --git a/accel/tcg/internal-target.h b/accel/tcg/internal-target.h > index 2cdf11c905..c88f007ffb 100644 > --- a/accel/tcg/internal-target.h > +++ b/accel/tcg/internal-target.h > @@ -13,6 +13,7 @@ > #include "exec/translation-block.h" > #include "tb-internal.h" > #include "tcg-target-mo.h" > +#include "exec/mmap-lock.h" > > /* > * Access to the various translations structures need to be serialised > diff --git a/include/exec/mmap-lock.h b/include/exec/mmap-lock.h > new file mode 100644 > index 0000000000..eb02dd409c > --- /dev/null > +++ b/include/exec/mmap-lock.h > @@ -0,0 +1,33 @@ > +/* > + * QEMU user-only mmap lock, with stubs for system mode > + * > + * Copyright (c) 2003 Fabrice Bellard > + * > + * SPDX-License-Identifier: LGPL-2.1+ > + */ > +#ifndef EXEC_MMAP_LOCK_H > +#define EXEC_MMAP_LOCK_H > + > +#ifdef CONFIG_USER_ONLY > + > +void TSA_NO_TSA mmap_lock(void); > +void TSA_NO_TSA mmap_unlock(void); > +bool have_mmap_lock(void); > + > +static inline void mmap_unlock_guard(void *unused) > +{ > + mmap_unlock(); > +} > + > +#define WITH_MMAP_LOCK_GUARD() \ > + for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \ > + = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1) > + > +#else > + > +static inline void mmap_lock(void) {} > +static inline void mmap_unlock(void) {} > +#define WITH_MMAP_LOCK_GUARD() > + > +#endif /* CONFIG_USER_ONLY */ > +#endif /* EXEC_MMAP_LOCK_H */ > diff --git a/include/exec/page-protection.h b/include/exec/page-protection.h > index 3e0a8a0333..c43231af8b 100644 > --- a/include/exec/page-protection.h > +++ b/include/exec/page-protection.h > @@ -38,26 +38,4 @@ > */ > #define PAGE_PASSTHROUGH 0x0800 > > -#ifdef CONFIG_USER_ONLY > - > -void TSA_NO_TSA mmap_lock(void); > -void TSA_NO_TSA mmap_unlock(void); > -bool have_mmap_lock(void); > - > -static inline void mmap_unlock_guard(void *unused) > -{ > - mmap_unlock(); > -} > - > -#define WITH_MMAP_LOCK_GUARD() \ > - for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \ > - = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1) > -#else > - > -static inline void mmap_lock(void) {} > -static inline void mmap_unlock(void) {} > -#define WITH_MMAP_LOCK_GUARD() > - > -#endif /* !CONFIG_USER_ONLY */ > - > #endif > diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c > index ef3d967e3a..372b876604 100644 > --- a/accel/tcg/cpu-exec.c > +++ b/accel/tcg/cpu-exec.c > @@ -27,6 +27,7 @@ > #include "disas/disas.h" > #include "exec/cpu-common.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "exec/translation-block.h" > #include "tcg/tcg.h" > #include "qemu/atomic.h" > diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c > index 3f1bebf6ab..d5899ad047 100644 > --- a/accel/tcg/tb-maint.c > +++ b/accel/tcg/tb-maint.c > @@ -24,6 +24,7 @@ > #include "exec/log.h" > #include "exec/exec-all.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "exec/tb-flush.h" > #include "tb-internal.h" > #include "system/tcg.h" > diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c > index 82bc16bd53..16e5043597 100644 > --- a/accel/tcg/translate-all.c > +++ b/accel/tcg/translate-all.c > @@ -45,6 +45,7 @@ > > #include "exec/cputlb.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "tb-internal.h" > #include "exec/translator.h" > #include "exec/tb-flush.h" > diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c > index 10d8561f9b..cb6e17e50c 100644 > --- a/linux-user/arm/cpu_loop.c > +++ b/linux-user/arm/cpu_loop.c > @@ -25,6 +25,7 @@ > #include "signal-common.h" > #include "semihosting/common-semi.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "user/page-protection.h" > #include "target/arm/syndrome.h" > > diff --git a/linux-user/elfload.c b/linux-user/elfload.c > index 8799e4ea27..f54054dce3 100644 > --- a/linux-user/elfload.c > +++ b/linux-user/elfload.c > @@ -10,6 +10,7 @@ > #include "user/tswap-target.h" > #include "user/page-protection.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "exec/translation-block.h" > #include "user/guest-base.h" > #include "user-internals.h" > diff --git a/linux-user/flatload.c b/linux-user/flatload.c > index d5cb1830dd..4beb3ed1b9 100644 > --- a/linux-user/flatload.c > +++ b/linux-user/flatload.c > @@ -35,6 +35,7 @@ > > #include "qemu.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "user-internals.h" > #include "loader.h" > #include "user-mmap.h" > diff --git a/linux-user/mmap.c b/linux-user/mmap.c > index d1f36e6f16..f88a80c31e 100644 > --- a/linux-user/mmap.c > +++ b/linux-user/mmap.c > @@ -21,6 +21,7 @@ > #include "trace.h" > #include "exec/log.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "exec/tb-flush.h" > #include "exec/translation-block.h" > #include "qemu.h" > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index b32de763f7..4928f0b080 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -26,6 +26,7 @@ > #include "tcg/startup.h" > #include "target_mman.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "exec/tb-flush.h" > #include "exec/translation-block.h" > #include <elf.h> > diff --git a/target/arm/helper.c b/target/arm/helper.c > index f0ead22937..8316beead3 100644 > --- a/target/arm/helper.c > +++ b/target/arm/helper.c > @@ -14,6 +14,7 @@ > #include "cpu-features.h" > #include "exec/helper-proto.h" > #include "exec/page-protection.h" > +#include "exec/mmap-lock.h" > #include "qemu/main-loop.h" > #include "qemu/timer.h" > #include "qemu/bitops.h" Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff --git a/accel/tcg/internal-target.h b/accel/tcg/internal-target.h index 2cdf11c905..c88f007ffb 100644 --- a/accel/tcg/internal-target.h +++ b/accel/tcg/internal-target.h @@ -13,6 +13,7 @@ #include "exec/translation-block.h" #include "tb-internal.h" #include "tcg-target-mo.h" +#include "exec/mmap-lock.h" /* * Access to the various translations structures need to be serialised diff --git a/include/exec/mmap-lock.h b/include/exec/mmap-lock.h new file mode 100644 index 0000000000..eb02dd409c --- /dev/null +++ b/include/exec/mmap-lock.h @@ -0,0 +1,33 @@ +/* + * QEMU user-only mmap lock, with stubs for system mode + * + * Copyright (c) 2003 Fabrice Bellard + * + * SPDX-License-Identifier: LGPL-2.1+ + */ +#ifndef EXEC_MMAP_LOCK_H +#define EXEC_MMAP_LOCK_H + +#ifdef CONFIG_USER_ONLY + +void TSA_NO_TSA mmap_lock(void); +void TSA_NO_TSA mmap_unlock(void); +bool have_mmap_lock(void); + +static inline void mmap_unlock_guard(void *unused) +{ + mmap_unlock(); +} + +#define WITH_MMAP_LOCK_GUARD() \ + for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \ + = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1) + +#else + +static inline void mmap_lock(void) {} +static inline void mmap_unlock(void) {} +#define WITH_MMAP_LOCK_GUARD() + +#endif /* CONFIG_USER_ONLY */ +#endif /* EXEC_MMAP_LOCK_H */ diff --git a/include/exec/page-protection.h b/include/exec/page-protection.h index 3e0a8a0333..c43231af8b 100644 --- a/include/exec/page-protection.h +++ b/include/exec/page-protection.h @@ -38,26 +38,4 @@ */ #define PAGE_PASSTHROUGH 0x0800 -#ifdef CONFIG_USER_ONLY - -void TSA_NO_TSA mmap_lock(void); -void TSA_NO_TSA mmap_unlock(void); -bool have_mmap_lock(void); - -static inline void mmap_unlock_guard(void *unused) -{ - mmap_unlock(); -} - -#define WITH_MMAP_LOCK_GUARD() \ - for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \ - = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1) -#else - -static inline void mmap_lock(void) {} -static inline void mmap_unlock(void) {} -#define WITH_MMAP_LOCK_GUARD() - -#endif /* !CONFIG_USER_ONLY */ - #endif diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index ef3d967e3a..372b876604 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -27,6 +27,7 @@ #include "disas/disas.h" #include "exec/cpu-common.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "exec/translation-block.h" #include "tcg/tcg.h" #include "qemu/atomic.h" diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 3f1bebf6ab..d5899ad047 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -24,6 +24,7 @@ #include "exec/log.h" #include "exec/exec-all.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "exec/tb-flush.h" #include "tb-internal.h" #include "system/tcg.h" diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 82bc16bd53..16e5043597 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -45,6 +45,7 @@ #include "exec/cputlb.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "tb-internal.h" #include "exec/translator.h" #include "exec/tb-flush.h" diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 10d8561f9b..cb6e17e50c 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -25,6 +25,7 @@ #include "signal-common.h" #include "semihosting/common-semi.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "user/page-protection.h" #include "target/arm/syndrome.h" diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 8799e4ea27..f54054dce3 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -10,6 +10,7 @@ #include "user/tswap-target.h" #include "user/page-protection.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "exec/translation-block.h" #include "user/guest-base.h" #include "user-internals.h" diff --git a/linux-user/flatload.c b/linux-user/flatload.c index d5cb1830dd..4beb3ed1b9 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -35,6 +35,7 @@ #include "qemu.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "user-internals.h" #include "loader.h" #include "user-mmap.h" diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d1f36e6f16..f88a80c31e 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -21,6 +21,7 @@ #include "trace.h" #include "exec/log.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "exec/tb-flush.h" #include "exec/translation-block.h" #include "qemu.h" diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b32de763f7..4928f0b080 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -26,6 +26,7 @@ #include "tcg/startup.h" #include "target_mman.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "exec/tb-flush.h" #include "exec/translation-block.h" #include <elf.h> diff --git a/target/arm/helper.c b/target/arm/helper.c index f0ead22937..8316beead3 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -14,6 +14,7 @@ #include "cpu-features.h" #include "exec/helper-proto.h" #include "exec/page-protection.h" +#include "exec/mmap-lock.h" #include "qemu/main-loop.h" #include "qemu/timer.h" #include "qemu/bitops.h"
Split out mmap_lock, et al from page-protection.h to a new header. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- accel/tcg/internal-target.h | 1 + include/exec/mmap-lock.h | 33 +++++++++++++++++++++++++++++++++ include/exec/page-protection.h | 22 ---------------------- accel/tcg/cpu-exec.c | 1 + accel/tcg/tb-maint.c | 1 + accel/tcg/translate-all.c | 1 + linux-user/arm/cpu_loop.c | 1 + linux-user/elfload.c | 1 + linux-user/flatload.c | 1 + linux-user/mmap.c | 1 + linux-user/syscall.c | 1 + target/arm/helper.c | 1 + 12 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 include/exec/mmap-lock.h