Re: [PATCH v5] ata: ahci: fail probe if BAR too small for claimed ports

From: Niklas Cassel

Date: Tue Apr 28 2026 - 03:11:19 EST


On Tue, 28 Apr 2026 10:09:35 +0800, dayou5941@xxxxxxx wrote:
> When an AHCI controller is disabled in BIOS, its HOST_CAP register may
> contain invalid values (e.g., 0xFFFFFFFF) indicating an impossibly large
> number of ports.

Indicating an impossibly large number of ports is simply not correct.

The CAP.NP field is a zeroes based 5-bit register field, so it can represent
values in the range 1-32.

Values in the range 1-32 is not impossibly large, it it simply the possible
number of ports defined by the standard.


> If CAP.NP claims more ports than can physically fit
> within the mapped BAR region, accessing port registers beyond the BAR
> boundary causes a kernel panic.
>
> Add validation in ahci_init_one() to check that the BAR size is
> sufficient for the number of ports claimed in CAP.NP. The check
> calculates the required MMIO size as:
>
> [...]

Applied to libata/linux.git (for-7.2), thanks!

I rephrased the "impossible number of ports" sentence while applying.

[1/1] ata: ahci: fail probe if BAR too small for claimed ports
https://git.kernel.org/libata/linux/c/eb9c9a3a

Kind regards,
Niklas