From: Richard Henderson <rth@twiddle.net>
To: Sergey Sorokin <afarallax@yandex.ru>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Alexander Graf <agraf@suse.de>,
qemu-arm@nongnu.org, Claudio Fontana <claudio.fontana@huawei.com>,
Vassili Karpov <av1474@comtv.ru>
Subject: Re: [Qemu-devel] [PATCH v4] Improve the alignment check infrastructure
Date: Thu, 23 Jun 2016 12:18:32 -0700 [thread overview]
Message-ID: <2e0293e6-987c-43ec-e9c1-3a63aa593fb4@twiddle.net> (raw)
In-Reply-To: <1466705806-679898-1-git-send-email-afarallax@yandex.ru>
On 06/23/2016 11:16 AM, Sergey Sorokin wrote:
> +#if defined(CONFIG_SOFTMMU)
> +/**
> + * get_alignment_bits
> + * @memop: TCGMemOp value
> + *
> + * Extract the alignment size from the memop.
> + *
> + * Returns: 0 in case of byte access (which is always aligned);
> + * positive value - number of alignment bits;
> + * negative value if unaligned access enabled
> + * and this is not a byte access.
> + */
> +static inline int get_alignment_bits(TCGMemOp memop)
> +{
> + int a = memop & MO_AMASK;
> + int s = memop & MO_SIZE;
> +
> + if (a == MO_UNALN) {
> + /* Negative value if unaligned access enabled,
> + * or zero value in case of byte access.
> + */
> + return -s;
> + } else if (a == MO_ALIGN) {
> + tcg_debug_assert((TLB_FLAGS_MASK & ((1 << s) - 1)) == 0);
> + /* A natural alignment: return a number of access size bits */
> + return s;
> + } else {
> + /* Specific alignment size. It must be equal or greater
> + * than the access size.
> + */
> + a >>= MO_ASHIFT;
> + tcg_debug_assert(a >= s);
> + tcg_debug_assert((TLB_FLAGS_MASK & ((1 << a) - 1)) == 0);
> + return a;
> + }
> +}
> +#endif /* CONFIG_SOFTMMU */
While it's true that usermode doesn't support alignment checks at all (either
direction, I'd prefer to leave the function available and isolate the one
assert that caused your build problem. E.g.
static inline int get_alignment_bits(TCGMemOp memop)
{
int a = memop & MO_AMASK;
int s = memop & MO_SIZE;
int r;
...
} else if (a == MO_ALIGN) {
/* A natural alignment: return a number of access size bits */
r = s;
} else {
/* Specific alignment size. It must be equal or greater
* than the access size.
*/
r = a >> MO_ASHIFT;
tcg_debug_assert(r >= s);
}
#ifdef CONFIG_SOFTMMU
/* Make sure requested alignment doesn't overlap TLB flags. */
tcg_debug_assert((TLB_FLAGS_MASK & ((1 << r) - 1)) == 0);
#endif
return r;
}
I'll give this a test with some target-sparc changes where this will be useful.
r~
next prev parent reply other threads:[~2016-06-23 19:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-23 18:16 [Qemu-devel] [PATCH v4] Improve the alignment check infrastructure Sergey Sorokin
2016-06-23 19:18 ` Richard Henderson [this message]
2016-06-24 4:48 ` Richard Henderson
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=2e0293e6-987c-43ec-e9c1-3a63aa593fb4@twiddle.net \
--to=rth@twiddle.net \
--cc=afarallax@yandex.ru \
--cc=agraf@suse.de \
--cc=av1474@comtv.ru \
--cc=claudio.fontana@huawei.com \
--cc=crosthwaite.peter@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-arm@nongnu.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).