include/device: Fix IO resource handling covering 0xFFFF
IO resource creation utils taking 'from' and 'to' as parameters use uint16_t for them, where 'to' equals the resource limit plus 1. When a resource is with a limit of 0xFFFF, the value of 'to' will be clipped to 0x0000 by uint16_t. Fix this problem by use uint32_t and checks the effective range to make sure it no larger than UINT16_MAX + 1. TEST=Build and boot on intel/archercity CRB TEST=Build on intel/avenuecity CRB Change-Id: Ie83045683094d6330c1676809f83acf30175cc90 Signed-off-by: Shuo Liu <shuo.liu@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/82192 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
parent
6c708d8a46
commit
bd33b6ab9f
@ -369,10 +369,12 @@ const struct resource *fixed_io_range_flags(struct device *dev, unsigned long in
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
const struct resource *fixed_io_from_to_flags(struct device *dev, unsigned long index,
|
const struct resource *fixed_io_from_to_flags(struct device *dev, unsigned long index,
|
||||||
uint16_t base, uint16_t end, unsigned long flags)
|
uint16_t base, uint32_t end, unsigned long flags)
|
||||||
{
|
{
|
||||||
if (end <= base)
|
if (end <= base)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (end > UINT16_MAX + 1)
|
||||||
|
return NULL;
|
||||||
return fixed_io_range_flags(dev, index, base, end - base, flags);
|
return fixed_io_range_flags(dev, index, base, end - base, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,10 +395,12 @@ const struct resource *domain_io_window_range(struct device *dev, unsigned long
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
const struct resource *domain_io_window_from_to(struct device *dev, unsigned long index,
|
const struct resource *domain_io_window_from_to(struct device *dev, unsigned long index,
|
||||||
uint16_t base, uint16_t end)
|
uint16_t base, uint32_t end)
|
||||||
{
|
{
|
||||||
if (end <= base)
|
if (end <= base)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (end > UINT16_MAX + 1)
|
||||||
|
return NULL;
|
||||||
return domain_io_window_range(dev, index, base, end - base);
|
return domain_io_window_range(dev, index, base, end - base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user