Skip to content

Commit 86e5876

Browse files
vsyrjalaIngo Molnar
authored andcommitted
x86/gpu: Fix sign extension issue in Intel graphics stolen memory quirks
Have the KB(),MB(),GB() macros produce unsigned longs to avoid unintended sign extension issues with the gen2 memory size detection. What happens is first the uint8_t returned by read_pci_config_byte() gets promoted to an int which gets multiplied by another int from the MB() macro, and finally the result gets sign extended to size_t. Although this shouldn't be a problem in practice as all affected gen2 platforms are 32bit AFAIK, so size_t will be 32 bits. Reported-by: Bjorn Helgaas <[email protected]> Suggested-by: H. Peter Anvin <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent f963640 commit 86e5876

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/early-quirks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static u32 __init intel_stolen_base(int num, int slot, int func, size_t stolen_s
240240
return base;
241241
}
242242

243-
#define KB(x) ((x) * 1024)
243+
#define KB(x) ((x) * 1024UL)
244244
#define MB(x) (KB (KB (x)))
245245
#define GB(x) (MB (KB (x)))
246246

0 commit comments

Comments
 (0)