From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: alex.bennee@linaro.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v4 5/5] tcg/sparc: Support unaligned access for user-only
Date: Sat, 5 Feb 2022 07:55:54 +1100 [thread overview]
Message-ID: <ab4a94d6-7d29-10f8-e7a6-c3d9c22cf567@linaro.org> (raw)
In-Reply-To: <CAFEAcA97K-rXBJP9zo1nLFMdA5Rt1hjh1tqUyigcNV+ydSfZgQ@mail.gmail.com>
On 2/5/22 06:07, Peter Maydell wrote:
>> + /*
>> + * Overalignment: When we're asking for really large alignment,
>> + * the actual access is always done above and all we need to do
>> + * here is invoke the handler for SIGBUS.
>> + */
>
> I thought the access was in an annulled delay slot and so won't
> be "done above" ?
Bad wording, I suppose. If the alignment check succeeds, then access is done above. If
the alignment check fails, there is no access to be performed, only to report failure.
>> + switch ((unsigned)memop) {
>> + case MO_BEUW | MO_UNALN:
>> + case MO_BESW | MO_UNALN:
>> + case MO_BEUL | MO_ALIGN_2:
>> + case MO_BESL | MO_ALIGN_2:
>> + case MO_BEUQ | MO_ALIGN_4:
>> + /* Two loads: shift and combine. */
>> + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, 0,
>> + qemu_ld_opc[a_bits | MO_BE | (memop & MO_SIGN)]);
>> + tcg_out_ldst(s, data, TCG_REG_T1, 1 << a_bits,
>> + qemu_ld_opc[a_bits | MO_BE]);
>> + tcg_out_arithi(s, TCG_REG_T2, TCG_REG_T2, 8 << a_bits, SHIFT_SLLX);
>
> Why are we calculating the offset in memory of the second half of
> the data and the amount to shift it by using the alignment-bits
> rather than the size-bits ? Because of the cases we know that
> here a_bits == s_bits - 1, but I think it would be clearer to
> work in terms of the size.
Ok.
>> + tcg_out_arithi(s, TCG_REG_T1, TCG_REG_T1, 3, ARITH_ANDN);
>> + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, 0, LDUW);
>
> Doesn't this give the wrong fault-address value to the guest
> (ie not the address it used for the load, but a rounded-down one)
> if we take a SIGSEGV? Or do we fix that up elsewhere?
Oops, no. Perhaps a single byte load to the zero register would fix that, without having
to go to full load-by-parts.
>> + case MO_BEUQ | MO_ALIGN_2:
>> + /*
>> + * An extra test to verify alignment 2 is 5 insns, which
>> + * is more than we would save by using the slightly smaller
>> + * unaligned sequence above.
>> + */
>> + tcg_out_ldst(s, data, TCG_REG_T1, 0, LDUH);
>> + for (int i = 2; i < 8; i += 2) {
>> + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, LDUW);
>
> Isn't this loading 2 + 3 * 4 == 14 bytes?
Oops. Got confused with the qemu vs sparc "word" there for a moment.
r~
prev parent reply other threads:[~2022-02-04 21:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 7:00 [PATCH v4 0/5] tcg/sparc: Unaligned access for user-only Richard Henderson
2022-02-04 7:00 ` [PATCH v4 1/5] tcg/sparc: Add scratch argument to tcg_out_movi_int Richard Henderson
2022-02-04 17:35 ` Peter Maydell
2022-02-04 20:42 ` Richard Henderson
2022-02-04 7:00 ` [PATCH v4 2/5] tcg/sparc: Improve code gen for shifted 32-bit constants Richard Henderson
2022-02-04 7:56 ` Philippe Mathieu-Daudé via
2022-02-04 17:39 ` Peter Maydell
2022-02-04 7:00 ` [PATCH v4 3/5] tcg/sparc: Use the constant pool for 64-bit constants Richard Henderson
2022-02-04 18:18 ` Peter Maydell
2022-02-04 20:41 ` Richard Henderson
2022-02-04 22:20 ` Peter Maydell
2022-02-04 7:00 ` [PATCH v4 4/5] tcg/sparc: Add tcg_out_jmpl_const for better tail calls Richard Henderson
2022-02-04 18:34 ` Peter Maydell
2022-02-04 20:44 ` Richard Henderson
2022-02-04 7:00 ` [PATCH v4 5/5] tcg/sparc: Support unaligned access for user-only Richard Henderson
2022-02-04 19:07 ` Peter Maydell
2022-02-04 20:55 ` 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=ab4a94d6-7d29-10f8-e7a6-c3d9c22cf567@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--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 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).