smmu_xfer_notify()

Updated: April 19, 2023

Register to be notified of DMA device memory access transgressions

Synopsis:

#include <smmu.h>

int smmu_xfer_notify(const struct sigevent *evp);

Arguments:

evp
A pointer to the sigevent data structure.

Library:

libsmmu.a

Description:

Clients of the smmuman service can use the smmu_xfer_notify() function to register to have the service inform them when a DMA device without the appropriate permissions attempts to access memory.

When the smmuman service learns that an IOMMU/SMMU has refused a DMA device's memory access attempt, the service delivers a sigevent to the client that registered with smmu_xfer_notify() to inform it that a transgression record is available. The client can then call smmu_xfer_status() to retrieve the record with the information about the DMA device transgression.

The smmuman client registering for and receiving updates doesn't have to be the client that owns the SMMU objects and has added devices and mapped memory regions to it. You could have some clients (e.g., device drivers) create objects, add devices and map memory regions, and another client (i.e., some other process in your system) monitor transgressions.

Ensuring that your client receives notifications

The smmuman service doesn't internally queue up notifications from hardware of memory access transgressions by DMA devices; it doesn't save notifications and deliver them later to clients when they register for notifications.

This means that if a client isn't attached to the smmuman service and registered for notifications when a DMA device attempts an illegal memory access, the client will never know about the attempted transgression.

Note also that when the smmuman service informs a client that an IOMMU/SMMU has refused a DMA device's memory access attempt, it clears that client's registration for notification of DMA device memory access transgressions. The client must call smmu_xfer_notify() to re-register for notification.

Returns:

-1
Failure: errno is set.
>0
Success.