From: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: Richard Henderson <rth@twiddle.net>,
qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/1] tci: eliminate UB due to unaligned reads
Date: Sat, 3 Mar 2018 19:01:42 +0300 [thread overview]
Message-ID: <CAE5jQCcKo_4iWaNd-+iFNjTCrhnU++GaWfkC+RmouYNufJh0eQ@mail.gmail.com> (raw)
In-Reply-To: <57abe9de-1258-3624-2f8a-882f1de1d19d@weilnetz.de>
2018-03-03 18:41 GMT+03:00 Stefan Weil <sw@weilnetz.de>:
> Am 03.03.2018 um 15:07 schrieb Anatoly Trosinenko:
> > Can rewriting TCI in such a way that every operation is aligned at 4- or
> > even 8-byte boundary fix the situation or are there some more serious
> > problems?
>
> That's my preferred solution. Are there cases which would require 8-byte
> alignment?
>
And what if create some function like
uint8_t *align_and_increment(uint8_t **ptr, int pow2) {
size_t size = 1 << pow2;
uint8_t *result = (uint8_t*)((((uintptr)*ptr) + size - 1) & ~(size - 1));
*ptr = result + size;
return result;
}
and rewrite get / put functions like this:
static uint32_t tci_read_i32(uint8_t **tb_ptr)
{
uint32_t value = *(uint32_t *)align_and_increment(tb_ptr, 2);
return value;
}
On one hand, it involves some slightly obscure pointer calculations
(just in one place), on the other hand, no modifications will probably
be required for TCI TCG backend or interpreter loop code (they can
still be useful for **optimizations** of bytecode size, but it should
just work as is).
--
Best regards,
Anatoly
next prev parent reply other threads:[~2018-03-03 16:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-27 13:49 [Qemu-devel] [PATCH 0/1] Fix unaligned reads in the tcg/tci.c Anatoly Trosinenko
2018-01-27 13:49 ` [Qemu-devel] [PATCH 1/1] tci: eliminate UB due to unaligned reads Anatoly Trosinenko
2018-01-27 16:38 ` Stefan Weil
2018-01-28 6:42 ` Anatoly Trosinenko
2018-02-19 14:26 ` Anatoly Trosinenko
2018-03-03 8:54 ` Anatoly Trosinenko
2018-03-03 13:57 ` Richard Henderson
2018-03-03 14:07 ` Anatoly Trosinenko
2018-03-03 14:13 ` Richard Henderson
2018-03-03 14:59 ` Anatoly Trosinenko
2018-03-03 15:41 ` Stefan Weil
2018-03-03 16:01 ` Anatoly Trosinenko [this message]
2018-03-12 13:45 ` Richard Henderson
2018-02-05 13:52 ` [Qemu-devel] [PATCH 0/1] Fix unaligned reads in the tcg/tci.c Anatoly Trosinenko
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=CAE5jQCcKo_4iWaNd-+iFNjTCrhnU++GaWfkC+RmouYNufJh0eQ@mail.gmail.com \
--to=anatoly.trosinenko@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=rth@twiddle.net \
--cc=sw@weilnetz.de \
/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).