From: chengang@emindsoft.com.cn
To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com
Cc: chengang@emindsoft.com.cn, qemu-devel@nongnu.org
Subject: [PATCH] target: i386: mem_helper: Fix ldaxr instruction 64 bit alignment issue temporarily for stable-4.1
Date: Sun, 12 Jul 2020 09:47:17 +0800 [thread overview]
Message-ID: <20200712014717.10858-1-chengang@emindsoft.com.cn> (raw)
From: Chen Gang <chengang@emindsoft.com.cn>
This fix does not consider about the lock feature which may cause
another issues, but excuse me, I don't know how to fix it. At present,
the fix runs OK for my case in windows oledb32.dll in wine.
Welcome anyone to fix it, thanks.
Signed-off-by: Chen Gang <chengang@emindsoft.com.cn>
---
target/i386/mem_helper.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/target/i386/mem_helper.c b/target/i386/mem_helper.c
index d50d4b0c40..8c37b05fae 100644
--- a/target/i386/mem_helper.c
+++ b/target/i386/mem_helper.c
@@ -68,7 +68,13 @@ void helper_cmpxchg8b(CPUX86State *env, target_ulong a0)
uint64_t *haddr = g2h(a0);
cmpv = cpu_to_le64(cmpv);
newv = cpu_to_le64(newv);
- oldv = atomic_cmpxchg__nocheck(haddr, cmpv, newv);
+ if ((unsigned long)haddr % 8) {
+ volatile uint64_t tmp = *haddr; /* avoid compiler optimization */
+ oldv = atomic_cmpxchg__nocheck(&tmp, cmpv, newv);
+ *haddr = tmp;
+ } else {
+ oldv = atomic_cmpxchg__nocheck(haddr, cmpv, newv);
+ }
oldv = le64_to_cpu(oldv);
}
#else
--
2.24.0.308.g228f53135a
reply other threads:[~2020-07-12 1:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200712014717.10858-1-chengang@emindsoft.com.cn \
--to=chengang@emindsoft.com.cn \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).