From: Andrew Jeffery <andrew@aj.id.au>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, joel@jms.id.au, clg@kaod.org, f4bug@amsat.org
Subject: Re: [Qemu-devel] [RFC PATCH 1/1] memory: Support unaligned accesses on aligned-only models
Date: Fri, 14 Jul 2017 15:50:22 +0930 [thread overview]
Message-ID: <1500013222.7221.1.camel@aj.id.au> (raw)
In-Reply-To: <cd1aba90-176f-9ec6-3e2b-d1135156a96d@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2516 bytes --]
Hi Paolo,
Thanks for taking a look!
On Thu, 2017-07-13 at 14:05 +0200, Paolo Bonzini wrote:
> On 30/06/2017 05:00, Andrew Jeffery wrote:
> > This RFC patch stems from a discussion on a patch for an ADC model[1] where it
> > was pointed out that I should be able to use the .impl member of
> > MemoryRegionOps to constrain how my read() and write() callbacks where invoked.
> >
> > I tried Phil's suggested approach and found I got reads of size 4, but with an
> > address that was not 4-byte aligned.
> >
> > Looking at the source for access_with_adjusted_size() lead to the comment
> >
> > /* FIXME: support unaligned access? */
> >
> > which at least suggests that the implementation isn't complete.
> >
> > So, this patch is a quick and incomplete attempt at resolving the issue to see
> > whether I'm on the right track or way off in the weeds.
> >
> > I've lightly tested it with the ADC model mentioned above, and it appears to do
> > the right thing (I changed the values generated by the ADC to distinguish
> > between the lower and upper 16 bits).
>
> I think the idea is okay.
>
> > + access_addr[0] = align_down(addr, access_size);
> > + access_addr[1] = align_up(addr + size, access_size);
> > +
> > + for (cur = access_addr[0]; cur < access_addr[1]; cur += access_size) {
> > + uint64_t mask_bounds[2];
> > + mask_bounds[0] = MAX(addr, cur) - cur;
> > + mask_bounds[1] =
> > + MIN(addr + size, align_up(cur + 1, access_size)) - cur;
> > +
> > + access_mask = (-1ULL << mask_bounds[0] * 8) &
> > + (-1ULL >> (64 - mask_bounds[1] * 8));
>
> Please use MAKE_64BIT_MASK.
Okay.
>
> > + r |= access(mr, cur, &access_value, access_size,
> > + (MAX(addr, cur) - addr), access_mask, attrs);
> > +
> > + /* XXX: Can't do this hack for writes */
> > + access_value >>= mask_bounds[0] * 8;
> > + }
>
> Can you subtract access_addr[0] from mask_bounds[0] and mask_bounds[1]
> (instead of cur) to remove the need for this right shift?
I haven't looked at the patch since I sent it. Given you think the idea
of the patch is okay I'll get back to working on it and think about
this.
Cheers,
Andrew
>
> Thanks,
>
> Paolo
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
prev parent reply other threads:[~2017-07-14 6:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 3:00 [Qemu-devel] [RFC PATCH 1/1] memory: Support unaligned accesses on aligned-only models Andrew Jeffery
2017-07-13 12:05 ` Paolo Bonzini
2017-07-14 6:20 ` Andrew Jeffery [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=1500013222.7221.1.camel@aj.id.au \
--to=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=f4bug@amsat.org \
--cc=joel@jms.id.au \
--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).