1 From a67cc1b055cf09f371e2eca544884634a1ccc886 Mon Sep 17 00:00:00 2001
2 From: Andrey Semashev <andrey.semashev@gmail.com>
3 Date: Sun, 8 Jan 2017 18:09:12 +0300
4 Subject: [PATCH] Corrected register usage in x86 DCAS asm blocks.
6 In some of the asm blocks eax was modified as a result of cmpxchg8b but that
7 was not reflected in the register constraints. This could cause incorrect code
11 https://github.com/boostorg/atomic/commit/a67cc1b055cf09f371e2eca544884634a1ccc886
13 [Adjust github patch to tarball release]
14 Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
16 boost/atomic/detail/ops_gcc_x86_dcas.hpp | 14 ++++++++------
17 1 file changed, 8 insertions(+), 6 deletions(-)
19 diff --git a/boost/atomic/detail/ops_gcc_x86_dcas.hpp b/boost/atomic/detail/ops_gcc_x86_dcas.hpp
20 index 2f51182..e356e8c 100644
21 --- a/boost/atomic/detail/ops_gcc_x86_dcas.hpp
22 +++ b/boost/atomic/detail/ops_gcc_x86_dcas.hpp
23 @@ -73,6 +73,7 @@ struct gcc_dcas_x86
25 #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS)
27 + uint32_t v_lo = (uint32_t)v;
31 @@ -84,8 +85,8 @@ struct gcc_dcas_x86
32 "1: lock; cmpxchg8b %[dest]\n\t"
34 "movl %[scratch], %%ebx\n\t"
35 - : [scratch] "=m" (scratch), [dest] "=o" (storage)
36 - : [value_lo] "a" ((uint32_t)v), "c" ((uint32_t)(v >> 32))
37 + : [scratch] "=m" (scratch), [dest] "=o" (storage), [value_lo] "+a" (v_lo)
38 + : "c" ((uint32_t)(v >> 32))
39 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "edx", "memory"
41 #else // defined(__PIC__)
42 @@ -103,6 +104,7 @@ struct gcc_dcas_x86
43 #endif // defined(__PIC__)
44 #else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS)
46 + uint32_t v_lo = (uint32_t)v;
50 @@ -115,11 +117,11 @@ struct gcc_dcas_x86
52 "movl %[scratch], %%ebx\n\t"
53 #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES)
54 - : [scratch] "=m,m" (scratch)
55 - : [value_lo] "a,a" ((uint32_t)v), "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage)
56 + : [scratch] "=m,m" (scratch), [value_lo] "+a,a" (v_lo)
57 + : "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage)
59 - : [scratch] "=m" (scratch)
60 - : [value_lo] "a" ((uint32_t)v), "c" ((uint32_t)(v >> 32)), [dest] "D" (&storage)
61 + : [scratch] "=m" (scratch), [value_lo] "+a" (v_lo)
62 + : "c" ((uint32_t)(v >> 32)), [dest] "D" (&storage)
64 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "edx", "memory"