xen/pvcalls-back: fix permanently masked event channel

There is a sequence of events that can lead to a permanently masked
event channel, because xen_irq_lateeoi() is newer called. This happens
when a backend receives spurious write event from a frontend. In this
case pvcalls_conn_back_write() returns early and it does not clears the
map->write counter. As map->write > 0, pvcalls_back_ioworker() returns
without calling xen_irq_lateeoi(). This leaves the event channel in
masked state, a backend does not receive any new events from a
frontend and the whole communication stops.

Move atomic_set(&map->write, 0) to the very beginning of
pvcalls_conn_back_write() to fix this issue.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reported-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20230119211037.1234931-1-volodymyr_babchuk@epam.com
Signed-off-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
Volodymyr Babchuk 2023-01-19 21:11:15 +00:00 committed by Juergen Gross
parent 3e8cd711c3
commit c70b7741dd

View File

@ -173,6 +173,8 @@ static bool pvcalls_conn_back_write(struct sock_mapping *map)
RING_IDX cons, prod, size, array_size; RING_IDX cons, prod, size, array_size;
int ret; int ret;
atomic_set(&map->write, 0);
cons = intf->out_cons; cons = intf->out_cons;
prod = intf->out_prod; prod = intf->out_prod;
/* read the indexes before dealing with the data */ /* read the indexes before dealing with the data */
@ -197,7 +199,6 @@ static bool pvcalls_conn_back_write(struct sock_mapping *map)
iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, vec, 2, size); iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, vec, 2, size);
} }
atomic_set(&map->write, 0);
ret = inet_sendmsg(map->sock, &msg, size); ret = inet_sendmsg(map->sock, &msg, size);
if (ret == -EAGAIN) { if (ret == -EAGAIN) {
atomic_inc(&map->write); atomic_inc(&map->write);