From: Richard Henderson <richard.henderson@linaro.org>
To: Nicholas Piggin <npiggin@gmail.com>, qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org
Subject: Re: [RFC PATCH 3/3] target/ppc: Implement reservation protection for larx/stcx
Date: Tue, 20 Feb 2024 09:03:27 -1000 [thread overview]
Message-ID: <0aa2515e-55ef-4472-a567-1545c7e5f1ed@linaro.org> (raw)
In-Reply-To: <20240220041922.373029-4-npiggin@gmail.com>
On 2/19/24 18:19, Nicholas Piggin wrote:
> + env->access_type = ACCESS_RES;
> + host = probe_access(env, addr, size, MMU_DATA_LOAD, mmu_idx, raddr);
> + if (host) {
> + cpu_set_llsc_prot(cs, qemu_ram_addr_from_host_nofail(host));
> + } else {
> + /* XXX: fault? */
> + g_assert_not_reached();
> + }
probe_access will not return a host address for lots of reasons, including watchpoints,
plugins, etc.
> +
> + if (unlikely(size == 16)) {
> + Int128 val16;
> + val16 = cpu_ld16_mmu(env, addr,
> + make_memop_idx(DEF_MEMOP(env, MO_128 | MO_ALIGN), mmu_idx),
> + raddr);
> + env->gpr[reg] = int128_gethi(val16);
> + env->gpr[reg + 1] = int128_getlo(val16);
> + return;
> + }
> +
> + switch (size) {
> + case 1:
> + val = ldub_p(host);
> + break;
> + case 2:
> + val = FIELD_EX64(env->msr, MSR, LE) ? lduw_le_p(host) : lduw_be_p(host);
> + break;
> + case 4:
> + val = FIELD_EX64(env->msr, MSR, LE) ? ldl_le_p(host) : ldl_be_p(host);
> + break;
> + case 8:
> + val = FIELD_EX64(env->msr, MSR, LE) ? ldq_le_p(host) : ldq_be_p(host);
> + break;
> + default:
> + g_assert_not_reached();
> + }
> + env->gpr[reg] = val;
Passing in size and performing a switch on it is not the best organization.
You should use multiple helper functions with a common subroutine to handle the llsc
setup. You should pass in the whole MemOpIdx.
> +#define MEMOP_GET_SIZE(x) (1 << ((x) & MO_SIZE))
This is memop_size().
r~
prev parent reply other threads:[~2024-02-20 19:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 4:19 [RFC PATCH 0/3] real ll/sc emulation Nicholas Piggin
2024-02-20 4:19 ` [RFC PATCH 1/3] accel/tcg: Fix TCG TLB coherency race with physical dirty bit clearing Nicholas Piggin
2024-02-20 4:19 ` [RFC PATCH 2/3] tcg: add a ll/sc protection facility Nicholas Piggin
2024-02-20 18:53 ` Richard Henderson
2024-02-20 4:19 ` [RFC PATCH 3/3] target/ppc: Implement reservation protection for larx/stcx Nicholas Piggin
2024-02-20 19:03 ` Richard Henderson [this message]
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=0aa2515e-55ef-4472-a567-1545c7e5f1ed@linaro.org \
--to=richard.henderson@linaro.org \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 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).