Re: [PATCH] ata: libahci: fix panic when accessing ports beyond MMIO region

From: Damien Le Moal

Date: Thu Apr 23 2026 - 22:43:49 EST


On 4/24/26 02:19, Niklas Cassel wrote:
> Hello liyouhong,
>
> On Thu, Apr 23, 2026 at 05:48:54PM +0800, 李佑鸿 wrote:
>> However, I have already confirmed with the BIOS supplier that when the
>> BIOS disables all SATA ports, it does indeed initialize the values of
>> the HOST_CAP and HOSTPorts_IMPL registers in accordance with the specifications.
>>
>>
>> /* Register values after disabling SATA in BIOS */
>> HOST_CAP (0x00) = 0xffffffff
>> HOST_PORTS_IMPL (0x0c) = 0xffffffff
>> HOST_VERSION (0x10) = 0xffffffff
>> MMIO_SIZE = 4096
>
> I am actually very surprised to see e.g. CAP (0x00) and AHCI VERSION (0x10)
> being uninitialized.

What I am surprised of here is that we even see that device on the PCI bus at
all when it is disabled in the BIOs. If that device is disabled, why are we even
seeing it by scanning the PCI ports ? The adapter should simply not be visible
at all.

Trying to debug register values when we should not even be seeing the device in
the first place does not make sense to me. If anything, I would take a really
big hammer here and try to completely ignore that adapter if we can somehow
detect that it has been in fact disabled in the BIOS. But that detection may be
challenging to do since it seems we are dealing with a very buggy BIOS.

So maybe we should simply warn and exit probe early if we see a PCI BAR size
that is broken.

--
Damien Le Moal
Western Digital Research