Re: [PATCH RFC 02/11] nvmet: Export nvmet_add_async_event and add definitions

Mike Christie
2025-03-13T17:51:21Z

On 3/13/25 1:36 AM, Christoph Hellwig wrote:
> On Thu, Mar 13, 2025 at 12:18:03AM -0500, Mike Christie wrote:
>> This exports nvmet_add_async_event and adds some AER definitions that
>> will be used by the nvmet_mdev_pci driver.
>
> Can you add a little explanation why mdev needs it by pci-epf not?
>

It's due to how the drivers handle NVME_REG_DBS. The mdev driver
registers a callback where when we get a write to the memory at
NVME_REG_DBS + N, the callback is run. If we get:

NVME_REG_DBS + ... some invalid queue

we were going to send a NVME_AER_ERROR_INVALID_DB_REG.

The pci-epf driver just checks the specific queues:

sq->db = NVME_REG_DBS + (sqid * 2 * sizeof(u32));
...
sq->tail = nvmet_pci_epf_bar_read32(ctrl, sq->db);
while (sq->tail ...) {

so doesn't see if the host where to do a invalid write.