HomeFreeBSD

bhyve: Avoid using a packed struct for xhci port registers

Description

bhyve: Avoid using a packed struct for xhci port registers

I believe the __packed annotation is there only because
pci_xhci_portregs_read() is treating the register set as an array of
uint32_t. clang warns about taking the address of portregs->portsc
because it is a packed member and thus might not have expected
alignment.

Fix the problem by simply selecting the field to read with a switch
statement. This mimics pci_xhci_portregs_write(). While here, switch
to using some symbolic constants.

There is a small semantic change here in that pci_xhci_portregs_read()
would silently truncate unaligned offsets. For consistency with
pci_xhci_portregs_write(), which does not do that, return all ones for
unaligned reads instead.

MFC after: 2 weeks
Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37408

Details

Provenance
markjAuthored on Nov 18 2022, 7:07 PM
Reviewer
corvink
Differential Revision
D37408: bhyve: Avoid using a packed struct for xhci port registers
Parents
rGc127c61efa4d: bhyve: Let BASL compile with raised warnings
Branches
Unknown
Tags
Unknown