qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/4] ahci: Do not ignore memory access read size
Date: Tue, 16 Jun 2015 15:03:08 -0400	[thread overview]
Message-ID: <558072EC.1080208@redhat.com> (raw)
In-Reply-To: <55804DF7.40907@redhat.com>



On 06/16/2015 12:25 PM, Eric Blake wrote:
> On 06/16/2015 10:02 AM, John Snow wrote:
>> The only guidance the AHCI specification gives on memory access
>> is: "Register accesses shall have a maximum size of 64-bits;
>> 64-bit access must not cross an 8-byte alignment boundary."
>> 
>> I interpret this to mean that aligned or unaligned 1, 2 and 4
>> byte accesses should work, as well as aligned 8 byte accesses.
>> 
>> In practice, a real Q35/ICH9 responds to 1, 2, 4 and 8 byte
>> reads regardless of alignment. Windows 7 can be observed making 1
>> byte reads to the middle of 32 bit registers to fetch error
>> codes.
>> 
>> Introduce a wrapper to support unaligned accesses to AHCI. This
>> wrapper will support aligned 8 byte reads, but will make no
>> effort to support unaligned 8 byte reads, which although they 
>> will work on real hardware, are not guaranteed to work and do not
>> appear to be used by either Windows or Linux.
>> 
>> Signed-off-by: John Snow <jsnow@redhat.com> --- hw/ide/ahci.c |
>> 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+),
>> 2 deletions(-)
>> 
> 
>> +/** + * AHCI 1.3 section 3 ("HBA Memory Registers") + * Support
>> unaligned 8/16/32 bit reads, and 64 bit aligned reads. + * Caller
>> is responsible for masking unwanted higher order bytes. + */ 
>> +static uint64_t ahci_mem_read(void *opaque, hwaddr addr,
>> unsigned size) +{ +    hwaddr aligned = addr & ~0x3;
> 
> This actually supports 4-byte aligned 8-byte reads (which is an 
> unaligned 8-byte read).  Doesn't matter; no guest should be relying
> on it.
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 

Easier to say "indeterminate" than rely on wonko behavior, even if it
sometimes accidentally works :)

Thanks.

  reply	other threads:[~2015-06-16 19:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-16 16:02 [Qemu-devel] [PATCH v2 0/4] ahci: misc fixes/tests for 2.4 John Snow
2015-06-16 16:02 ` [Qemu-devel] [PATCH v2 1/4] ahci: Do not ignore memory access read size John Snow
2015-06-16 16:25   ` Eric Blake
2015-06-16 19:03     ` John Snow [this message]
2015-06-16 16:02 ` [Qemu-devel] [PATCH v2 2/4] qtest/ahci: add test_max John Snow
2015-06-16 16:02 ` [Qemu-devel] [PATCH v2 3/4] libqos/ahci: fix memory management bugs John Snow
2015-06-16 16:02 ` [Qemu-devel] [PATCH v2 4/4] qtest/ahci: add port_reset test John Snow
2015-06-29 21:16 ` [Qemu-devel] [PATCH v2 0/4] ahci: misc fixes/tests for 2.4 John Snow
2015-07-01 17:51 ` John Snow

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=558072EC.1080208@redhat.com \
    --to=jsnow@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).