Re: [PATCH] watchdog: aspeed: fix 64-bit division

From: Arnd Bergmann
Date: Fri Mar 14 2025 - 13:40:00 EST


On Fri, Mar 14, 2025, at 18:37, Guenter Roeck wrote:
> On 3/14/25 09:02, Arnd Bergmann wrote:
>>
>> if (!of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2400-wdt")) {
>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> - idx = ((intptr_t)wdt->base & 0x00000fff) / resource_size(res);
>> + idx = ((intptr_t)wdt->base & 0x00000fff) / (uintptr_t)resource_size(res);
>> }
>>
>> scu_base = syscon_regmap_lookup_by_compatible(scu.compatible);
> Does that help if the pointers are 64-bit on a 32-bit platform
> (multi_v7_lpae_defconfig) ?

Yes, that is the problem: resource_size() returns a resource_size_t,
so this is a 32-bit by 64-bit division.

Pointers are always 32-bit, CONFIG_LPAE only changes phys_addr_t
and resource_size_t.

Arnd