nb/intel/haswell/pcie.c: Make UBSAN not complain

UBSAN complains about "shift out of bounds", likely because integer
literals are signed by default and the result of the operation will
shift into the sign bit, yielding a negative value. However, as the
negative value is then casted to an unsigned type, it works anyway.
To make UBSAN happy, make sure the two troublesome integer literals
are unsigned so that there's no sign bit to shift into.

Tested on out-of-tree Asrock Z97 Extreme6, UBSAN now dies elsewhere.

Link: https://ticket.coreboot.org/issues/449

Change-Id: Iaf8710a5ae4e05d9f41f40f9e3617e155027800c
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/72806
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Angel Pons 2023-02-07 15:03:07 +01:00 committed by Felix Held
parent 6b7b400193
commit 08391d2f5f
1 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ static void peg_enable(struct device *dev)
uint32_t slotcap = pci_read_config32(dev, PEG_SLOTCAP); uint32_t slotcap = pci_read_config32(dev, PEG_SLOTCAP);
/* Physical slot number (zero for ports connected to onboard devices) */ /* Physical slot number (zero for ports connected to onboard devices) */
slotcap &= ~(0x1fff << 19); slotcap &= ~(0x1fffU << 19);
if (slot_implemented) { if (slot_implemented) {
uint16_t slot_number = peg_cfg->phys_slot_number & 0x1fff; uint16_t slot_number = peg_cfg->phys_slot_number & 0x1fff;
if (slot_number == 0) { if (slot_number == 0) {
@ -124,7 +124,7 @@ static void peg_enable(struct device *dev)
/* Select -3.5 dB de-emphasis */ /* Select -3.5 dB de-emphasis */
pci_or_config32(dev, PEG_LCTL2, 1 << 6); pci_or_config32(dev, PEG_LCTL2, 1 << 6);
pci_or_config32(dev, PEG_L0SLAT, 1 << 31); pci_or_config32(dev, PEG_L0SLAT, 1U << 31);
pci_update_config32(dev, 0x250, ~(7 << 20), 2 << 20); pci_update_config32(dev, 0x250, ~(7 << 20), 2 << 20);