Page MenuHomeFreeBSD

Allow byte reads of AHCI registers.
AcceptedPublic

Authored by neel on May 7 2015, 1:30 AM.

Details

Reviewers
mav
rgrimes
Group Reviewers
bhyve
Summary

This is needed to support Windows guests that use byte reads to access certain
AHCI registers (e.g. PxTFD.Status and PxTFD.Error).

Test Plan

Verified with the following guests:
FreeBSD 11.0 amd64 ahci-hd
FreeBSD 10.1 i386 ahci-hd
FreeBSD 10.1 amd64 ahci-cd
Centos 7 amd64 ahci-hd
Ubuntu 13.10 amd64 ahci-cd
OpenBSD 5.6 amd64 ahci-cd
OpenBSD 5.6 i386 ahci-hd ahci-cd
Windows 7 amd64 ahci-hd

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage

Event Timeline

neel updated this revision to Diff 5245.May 7 2015, 1:30 AM
neel retitled this revision from to Allow byte reads of AHCI registers..
neel updated this object.
neel added reviewers: grehan, mav.
neel edited the test plan for this revision. (Show Details)
mav edited edge metadata.May 7 2015, 8:09 AM

As I see, reading single byte at offset multiple to 4 this function still return 32-bit value, at next -- 24-bit, etc. Is this expected/acceptable behavior?

grehan accepted this revision.May 7 2015, 9:34 AM
grehan edited edge metadata.

The PCI common code could probably enforce some of this (and others, such as unaligned or natural boundary crossings in accesses), but this is fine for now.

This revision is now accepted and ready to land.May 7 2015, 9:34 AM
neel added a comment.EditedMay 7 2015, 5:49 PM
In D2469#45441, @mav wrote:

As I see, reading single byte at offset multiple to 4 this function still return 32-bit value, at next -- 24-bit, etc. Is this expected/acceptable behavior?

I am not sure that I understand the comment but here is an explanation of how it behaves after the patch:

Assuming that the AHCI register at offset 0x20 contains the value 0xDEADBEEF.

regoff size return pci_ahci_read()
0x20 1 0x00000000DEADBEEF
0x21 1 0x0000000000DEADBE
0x22 1 0x000000000000DEAD
0x23 1 0x00000000000000DE

  • least significant 8-bits used by instruction emulation

0x20 2 0x00000000DEADBEEF
0x22 2 0x000000000000DEAD

  • least significant 16-bits used by instruction emulation

0x20 4 0x00000000DEADBEEF

  • least significant 32-bits used by instruction emulation
neel updated this revision to Diff 5261.May 7 2015, 6:01 PM
neel edited edge metadata.

Assert that AHCI reads are naturally aligned and do not straddle a 32-bit
boundary.

This revision now requires review to proceed.May 7 2015, 6:01 PM
mav added a comment.May 7 2015, 6:29 PM
In D2469#45544, @neel wrote:

I am not sure that I understand the comment but here is an explanation of how it behaves after the patch:

I understand the behavior. Just was not sure what will trim extra bits. If all the consumers (instruction emulation code) do it correctly, then OK.

mav accepted this revision.May 7 2015, 6:29 PM
mav edited edge metadata.
This revision is now accepted and ready to land.May 7 2015, 6:29 PM
emaste added a subscriber: jhb.Nov 15 2018, 9:17 PM
rgrimes removed a reviewer: grehan.Feb 20 2019, 6:14 PM