From: Paolo Bonzini <pbonzini@redhat.com>
To: fred.konrad@greensocs.com, qemu-devel@nongnu.org, mttcg@greensocs.com
Cc: mark.burton@greensocs.com, peter.maydell@linaro.org,
alex.bennee@linaro.org, agraf@suse.de,
guillaume.delbergue@greensocs.com
Subject: Re: [Qemu-devel] [RFC PATCH V3] Use atomic cmpxchg to atomically check the exclusive value in a STREX
Date: Thu, 18 Jun 2015 17:46:40 +0200 [thread overview]
Message-ID: <5582E7E0.2040903@redhat.com> (raw)
In-Reply-To: <1434642290-17610-1-git-send-email-fred.konrad@greensocs.com>
On 18/06/2015 17:44, fred.konrad@greensocs.com wrote:
> + hwaddr len = 8 << size;
Should be 1 << size, and likewise below in the "if".
Paolo
> + hwaddr paddr;
> + target_ulong page_size;
> + int prot;
> +
> + arm_exclusive_lock();
> +
> + if (env->exclusive_addr != addr) {
> + arm_exclusive_unlock();
> + return 1;
> + }
> +
> + if (arm_get_phys_addr(env, addr, 1, &paddr, &prot, &page_size) != 0) {
> + tlb_fill(ENV_GET_CPU(env), addr, MMU_DATA_STORE, cpu_mmu_index(env),
> + retaddr);
> + if (arm_get_phys_addr(env, addr, 1, &paddr, &prot, &page_size) != 0) {
> + arm_exclusive_unlock();
> + return 1;
> + }
> + }
> +
> + switch (size) {
> + case 0:
> + {
> + uint8_t oldval, *p;
> + p = address_space_map(cs->as, paddr, &len, true);
> + if (len == 8 << size) {
> + oldval = (uint8_t)env->exclusive_val;
> + result = (atomic_cmpxchg(p, oldval, (uint8_t)newval) == oldval);
> + }
> + address_space_unmap(cs->as, p, len, true, result ? 8 : 0);
> + }
> + break;
> + case 1:
> + {
> + uint16_t oldval, *p;
> + p = address_space_map(cs->as, paddr, &len, true);
> + if (len == 8 << size) {
> + oldval = (uint16_t)env->exclusive_val;
> + result = (atomic_cmpxchg(p, oldval, (uint16_t)newval) == oldval);
> + }
> + address_space_unmap(cs->as, p, len, true, result ? 8 : 0);
> + }
> + break;
> + case 2:
> + {
> + uint32_t oldval, *p;
> + p = address_space_map(cs->as, paddr, &len, true);
> + if (len == 8 << size) {
> + oldval = (uint32_t)env->exclusive_val;
> + result = (atomic_cmpxchg(p, oldval, (uint32_t)newval) == oldval);
> + }
> + address_space_unmap(cs->as, p, len, true, result ? 8 : 0);
> + }
> + break;
> + case 3:
> + {
> + uint64_t oldval, *p;
> + p = address_space_map(cs->as, paddr, &len, true);
> + if (len == 8 << size) {
> + oldval = (uint64_t)env->exclusive_val;
> + result = (atomic_cmpxchg(p, oldval, (uint64_t)newval) == oldval);
> + }
> + address_space_unmap(cs->as, p, len, true, result ? 8 : 0);
> + }
> + break;
> + default:
> + abort();
> + break;
next prev parent reply other threads:[~2015-06-18 15:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-18 15:44 [Qemu-devel] [RFC PATCH V3] Use atomic cmpxchg to atomically check the exclusive value in a STREX fred.konrad
2015-06-18 15:46 ` Paolo Bonzini [this message]
2015-06-18 15:56 ` Peter Maydell
2015-06-18 18:32 ` Mark Burton
2015-06-18 19:53 ` Peter Maydell
2015-06-19 7:29 ` Mark Burton
2015-06-19 7:31 ` Paolo Bonzini
2015-06-19 7:40 ` Mark Burton
2015-06-19 7:42 ` Paolo Bonzini
2015-06-19 7:43 ` Mark Burton
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=5582E7E0.2040903@redhat.com \
--to=pbonzini@redhat.com \
--cc=agraf@suse.de \
--cc=alex.bennee@linaro.org \
--cc=fred.konrad@greensocs.com \
--cc=guillaume.delbergue@greensocs.com \
--cc=mark.burton@greensocs.com \
--cc=mttcg@greensocs.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.