aboutsummaryrefslogtreecommitdiffstats
path: root/main/qemu/atomic-bswap.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/qemu/atomic-bswap.patch')
-rw-r--r--main/qemu/atomic-bswap.patch61
1 files changed, 61 insertions, 0 deletions
diff --git a/main/qemu/atomic-bswap.patch b/main/qemu/atomic-bswap.patch
new file mode 100644
index 0000000000..2c7bc41ff4
--- /dev/null
+++ b/main/qemu/atomic-bswap.patch
@@ -0,0 +1,61 @@
+workaround fortify-headers, due to some callers to those function depends
+on compiler to optimize away the memcpy call for atomicity.
+
+https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg06183.html
+
+diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
+index a684c1a..f298653 100644
+--- a/include/qemu/bswap.h
++++ b/include/qemu/bswap.h
+@@ -323,44 +323,44 @@ static inline void stb_p(void *ptr, uint8_t v)
+ static inline int lduw_he_p(const void *ptr)
+ {
+ uint16_t r;
+- memcpy(&r, ptr, sizeof(r));
++ __builtin_memcpy(&r, ptr, sizeof(r));
+ return r;
+ }
+
+ static inline int ldsw_he_p(const void *ptr)
+ {
+ int16_t r;
+- memcpy(&r, ptr, sizeof(r));
++ __builtin_memcpy(&r, ptr, sizeof(r));
+ return r;
+ }
+
+ static inline void stw_he_p(void *ptr, uint16_t v)
+ {
+- memcpy(ptr, &v, sizeof(v));
++ __builtin_memcpy(ptr, &v, sizeof(v));
+ }
+
+ static inline int ldl_he_p(const void *ptr)
+ {
+ int32_t r;
+- memcpy(&r, ptr, sizeof(r));
++ __builtin_memcpy(&r, ptr, sizeof(r));
+ return r;
+ }
+
+ static inline void stl_he_p(void *ptr, uint32_t v)
+ {
+- memcpy(ptr, &v, sizeof(v));
++ __builtin_memcpy(ptr, &v, sizeof(v));
+ }
+
+ static inline uint64_t ldq_he_p(const void *ptr)
+ {
+ uint64_t r;
+- memcpy(&r, ptr, sizeof(r));
++ __builtin_memcpy(&r, ptr, sizeof(r));
+ return r;
+ }
+
+ static inline void stq_he_p(void *ptr, uint64_t v)
+ {
+- memcpy(ptr, &v, sizeof(v));
++ __builtin_memcpy(ptr, &v, sizeof(v));
+ }
+
+ static inline int lduw_le_p(const void *ptr)