bhyve: Appease warning about a potentially unaligned pointer.
When initializing the device model for a PCI pass through device that uses MSI-X, bhyve reads the MSI-X capability from the real device to save a copy in the emulated PCI config space. It also saves a copy in a local struct msixcap on the stack. Since struct msixcap is packed, GCC complains that casting a pointer to the struct to a uint32_t pointer may result in an unaligned pointer. This path is not performance critical, so to appease the compiler, simply change the pointer to a char * and use memcpy to copy the 4 bytes read in each iteration of the loop. Reviewed by: corvink, bz, markj Differential Revision: https://reviews.freebsd.org/D37490
This commit is contained in:
parent
15cebe3d63
commit
32b21dd271
@ -212,7 +212,7 @@ cfginitmsi(struct passthru_softc *sc)
|
||||
struct pcisel sel;
|
||||
struct pci_devinst *pi;
|
||||
struct msixcap msixcap;
|
||||
uint32_t *msixcap_ptr;
|
||||
char *msixcap_ptr;
|
||||
|
||||
pi = sc->psc_pi;
|
||||
sel = sc->psc_sel;
|
||||
@ -249,15 +249,15 @@ cfginitmsi(struct passthru_softc *sc)
|
||||
*/
|
||||
sc->psc_msix.capoff = ptr;
|
||||
caplen = 12;
|
||||
msixcap_ptr = (uint32_t*) &msixcap;
|
||||
msixcap_ptr = (char *)&msixcap;
|
||||
capptr = ptr;
|
||||
while (caplen > 0) {
|
||||
u32 = read_config(&sel, capptr, 4);
|
||||
*msixcap_ptr = u32;
|
||||
memcpy(msixcap_ptr, &u32, 4);
|
||||
pci_set_cfgdata32(pi, capptr, u32);
|
||||
caplen -= 4;
|
||||
capptr += 4;
|
||||
msixcap_ptr++;
|
||||
msixcap_ptr += 4;
|
||||
}
|
||||
}
|
||||
ptr = read_config(&sel, ptr + PCICAP_NEXTPTR, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user