On Sun, Jan 12, 2025 at 09:37:41PM -0800, Nicolin Chen wrote: > > > > I supposed we will need a way to indicate lost events to userspace on > > > > top of this? > > > > > > Perhaps another u32 flag in the arm_smmuv3_vevent struct to report > > > an overflow. That said, what userspace/VMM will need to do with it? > > > > Trigger the above code in the VM somehow? > > I found two ways of forwarding an overflow flag: > > 1. Return -EOVERFLOW to read(). But it cannot return the read bytes > any more: You could not return any bytes, it would have to be 0 bytes read, ie immediately return EOVERFLOW and do nothing else. Returning EOVERFLOW from read would have to also clear the overflow indicator. The other approach would be to add a sequence number to each event and let userspace detect the non-montonicity. It would require adding a header to the native ARM evt. > 2. Return EPOLLERR via pollfd.revents. But it cannot use POLLERR > for other errors any more: > -------------------------------------------------- > @@ -420,2 +421,4 @@ static __poll_t iommufd_eventq_fops_poll(struct file *filep, > poll_wait(filep, &eventq->wait_queue, wait); > + if (test_bit(IOMMUFD_VEVENTQ_ERROR_OVERFLOW, veventq->errors)) > + return EPOLLERR; > mutex_lock(&eventq->mutex); But then how do you clear the error? I've only seen POLLERR used for fatal conditions so there is no recovery, it is permanent. Jason