aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2019-02-25 12:23:39 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2019-02-25 12:28:57 +0000
commit228579f6c7663dc4107b1b418367e968513277f9 (patch)
tree5c92a8f92de5e5c242e0746e787b0dde9590ca32
parent52e70f912af535cecaccc74f2ff45af487cf7101 (diff)
downloadaports-228579f6c7663dc4107b1b418367e968513277f9.tar.bz2
aports-228579f6c7663dc4107b1b418367e968513277f9.tar.xz
main/qemu: workaround bug in qemu due to memcpy assumed to be atomic
Some functions using include/qemu/bswap.h assumes that the inline functions using memcpy are atomic. Qemu assumes that compiler will optimize away the memcpy call. Our fortify-headers seems to get in the way for this, so we work around it by explicitly use __builtin_memcpy. https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg06183.html
-rw-r--r--main/qemu/APKBUILD4
-rw-r--r--main/qemu/atomic-bswap.patch61
2 files changed, 64 insertions, 1 deletions
diff --git a/main/qemu/APKBUILD b/main/qemu/APKBUILD
index f3579fe4ae..d1ccb114aa 100644
--- a/main/qemu/APKBUILD
+++ b/main/qemu/APKBUILD
@@ -4,7 +4,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=qemu
pkgver=3.1.0
-pkgrel=2
+pkgrel=3
pkgdesc="QEMU is a generic machine emulator and virtualizer"
url="http://qemu.org/"
arch="all"
@@ -158,6 +158,7 @@ source="http://wiki.qemu-project.org/download/$pkgname-$pkgver.tar.xz
fix-sockios-header.patch
test-crypto-ivgen-skip-essiv.patch
guest-agent-shutdown.patch
+ atomic-bswap.patch
$pkgname-guest-agent.confd
$pkgname-guest-agent.initd
@@ -397,6 +398,7 @@ d8933df9484158c2b4888254e62117d78f8ed7c18527b249419f39c2b2ab1afa148010884b40661f
39590476a4ebd7c1e79a4f0451b24c75b1817a2a83abaa1f71bb60b225d772152f0af8f3e51ff65645e378c536ffa6ff551dade52884d03a14b7c6a19c5c97d4 fix-sockios-header.patch
8b8db136f78bd26b5da171effa9e11016ec2bc3e2fc8107228b5543b47aa370978ed883794aa4f917f334e284a5b49e82070e1da2d31d49301195b6713a48eff test-crypto-ivgen-skip-essiv.patch
b8e58bcc409f25cc6ff59967ed68f4de0a8656ec4db71ab663cc77761f8210b3f85c475fceb32dec934dc02a5c4f679a8313edbcf84e149692a81764c8904f67 guest-agent-shutdown.patch
+9b7a3fd7878bf339cf54f824e3eb6bb5bd19d8108c3647d2022edb3c013db3fca7846437bee51326cd12fc054535d9b6ea425b5c7c4ca7ec310b6564f22f2c4d atomic-bswap.patch
d90c034cae3f9097466854ed1a9f32ab4b02089fcdf7320e8f4da13b2b1ff65067233f48809911485e4431d7ec1a22448b934121bc9522a2dc489009e87e2b1f qemu-guest-agent.confd
1cd24c2444c5935a763c501af2b0da31635aad9cf62e55416d6477fcec153cddbe7de205d99616def11b085e0dd366ba22463d2270f831d884edbc307c7864a6 qemu-guest-agent.initd
9b7a89b20fcf737832cb7b4d5dc7d8301dd88169cbe5339eda69fbb51c2e537d8cb9ec7cf37600899e734209e63410d50d0821bce97e401421db39c294d97be2 80-kvm.rules
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)