Commit b1dd1d06 authored by Halil Pasic's avatar Halil Pasic Committed by Greg Kroah-Hartman

virtio/s390: fix race on airq_areas[]

[ Upstream commit 4f419eb1 ]

The access to airq_areas was racy ever since the adapter interrupts got
introduced to virtio-ccw, but since commit 39c7dcb1 ("virtio/s390:
make airq summary indicators DMA") this became an issue in practice as
well. Namely before that commit the airq_info that got overwritten was
still functional. After that commit however the two infos share a
summary_indicator, which aggravates the situation. Which means
auto-online mechanism occasionally hangs the boot with virtio_blk.
Signed-off-by: default avatarHalil Pasic <pasic@linux.ibm.com>
Reported-by: default avatarMarc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Cc: stable@vger.kernel.org
Fixes: 96b14536 ("virtio-ccw: virtio-ccw adapter interrupt support.")
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 057cdb6f
...@@ -132,6 +132,7 @@ struct airq_info { ...@@ -132,6 +132,7 @@ struct airq_info {
struct airq_iv *aiv; struct airq_iv *aiv;
}; };
static struct airq_info *airq_areas[MAX_AIRQ_AREAS]; static struct airq_info *airq_areas[MAX_AIRQ_AREAS];
static DEFINE_MUTEX(airq_areas_lock);
#define CCW_CMD_SET_VQ 0x13 #define CCW_CMD_SET_VQ 0x13
#define CCW_CMD_VDEV_RESET 0x33 #define CCW_CMD_VDEV_RESET 0x33
...@@ -244,9 +245,11 @@ static unsigned long get_airq_indicator(struct virtqueue *vqs[], int nvqs, ...@@ -244,9 +245,11 @@ static unsigned long get_airq_indicator(struct virtqueue *vqs[], int nvqs,
unsigned long bit, flags; unsigned long bit, flags;
for (i = 0; i < MAX_AIRQ_AREAS && !indicator_addr; i++) { for (i = 0; i < MAX_AIRQ_AREAS && !indicator_addr; i++) {
mutex_lock(&airq_areas_lock);
if (!airq_areas[i]) if (!airq_areas[i])
airq_areas[i] = new_airq_info(); airq_areas[i] = new_airq_info();
info = airq_areas[i]; info = airq_areas[i];
mutex_unlock(&airq_areas_lock);
if (!info) if (!info)
return 0; return 0;
write_lock_irqsave(&info->lock, flags); write_lock_irqsave(&info->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment