[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/22] lockable: Do not cast function pointers
From: |
Thomas Huth |
Subject: |
[PULL 21/22] lockable: Do not cast function pointers |
Date: |
Wed, 29 May 2024 12:54:53 +0200 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
-fsanitize=undefined complains if function pointers are casted. It
also prevents enabling the strict mode of CFI which is currently
disabled with -fsanitize-cfi-icall-generalize-pointers.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2345
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240524-xkb-v4-2-2de564e5c859@daynix.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
include/qemu/lockable.h | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h
index 62110d2eb7..66713bd429 100644
--- a/include/qemu/lockable.h
+++ b/include/qemu/lockable.h
@@ -43,15 +43,30 @@ qemu_null_lockable(void *x)
return NULL;
}
+#define QML_FUNC_(name) \
+ static inline void qemu_lockable_ ## name ## _lock(void *x) \
+ { \
+ qemu_ ## name ## _lock(x); \
+ } \
+ static inline void qemu_lockable_ ## name ## _unlock(void *x) \
+ { \
+ qemu_ ## name ## _unlock(x); \
+ }
+
+QML_FUNC_(mutex)
+QML_FUNC_(rec_mutex)
+QML_FUNC_(co_mutex)
+QML_FUNC_(spin)
+
/*
* In C, compound literals have the lifetime of an automatic variable.
* In C++ it would be different, but then C++ wouldn't need QemuLockable
* either...
*/
-#define QML_OBJ_(x, name) (&(QemuLockable) { \
- .object = (x), \
- .lock = (QemuLockUnlockFunc *) qemu_ ## name ## _lock, \
- .unlock = (QemuLockUnlockFunc *) qemu_ ## name ## _unlock \
+#define QML_OBJ_(x, name) (&(QemuLockable) { \
+ .object = (x), \
+ .lock = qemu_lockable_ ## name ## _lock, \
+ .unlock = qemu_lockable_ ## name ## _unlock \
})
/**
--
2.45.1
- [PULL 11/22] target/s390x: Fix helper_per_ifetch flags, (continued)
- [PULL 11/22] target/s390x: Fix helper_per_ifetch flags, Thomas Huth, 2024/05/29
- [PULL 12/22] target/s390x: Simplify per_ifetch, per_check_exception, Thomas Huth, 2024/05/29
- [PULL 13/22] target/s390x: Adjust check of noreturn in translate_one, Thomas Huth, 2024/05/29
- [PULL 14/22] tests/tcg/s390x: Add per.S, Thomas Huth, 2024/05/29
- [PULL 15/22] fuzz: specify audiodev for usb-audio, Thomas Huth, 2024/05/29
- [PULL 16/22] fuzz: disable leak-detection for oss-fuzz builds, Thomas Huth, 2024/05/29
- [PULL 18/22] scripts/update-linux-headers.sh: Remove temporary directory inbetween, Thomas Huth, 2024/05/29
- [PULL 17/22] hw/s390x: Remove unused macro VMSTATE_ADAPTER_ROUTES, Thomas Huth, 2024/05/29
- [PULL 19/22] scripts/update-linux-headers.sh: Fix the path of setup_data.h, Thomas Huth, 2024/05/29
- [PULL 20/22] qemu-keymap: Make references to allocations static, Thomas Huth, 2024/05/29
- [PULL 21/22] lockable: Do not cast function pointers,
Thomas Huth <=
- [PULL 22/22] qapi: Do not cast function pointers, Thomas Huth, 2024/05/29
- Re: [PULL 00/22] s390x, build-oss-fuzz and Clang -fsanitize=undefined fixes, Richard Henderson, 2024/05/29