From nobody Sat Feb 7 21:15:27 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1285A24503B; Sat, 15 Nov 2025 09:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763197204; cv=none; b=Pfb1sWB0u1S6shIxQ6irvN/bhPBc1WgwId/yYFygJxf094dJ0zS9L/riPPS2o5pziu2p3VhgcBZHNwzIT7buLs4yQCN78AhExeEZDGmYnMnwiXMSx+LRbGbNG05EzSs6jL9sm7KexmcxVcXmkHuzZ81ILGP38Y8kM5awg+s4Oso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763197204; c=relaxed/simple; bh=Fn+54cM7t339sKRQ7gF+ZAKVKdk0zzg/V/yrB2Vdu3c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=uZHgBzz+srfUOmuiLXfWxIGLGn8OK6DZNG2UszacQ8tJbjunnNkewgCmmCilRxWH78XJxhAVVJEV521AJGUrO5NFOBbkBpe+chjUQ4uG4z99F36g0TwwNvguUD2A6n7YQ3u/0L32tSdX0yT3GCycOKXpZrSendkQiJnw3xLYvNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=LcRFXnqO; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="LcRFXnqO" Received: from namjain-Virtual-Machine.mshome.net (unknown [4.213.232.40]) by linux.microsoft.com (Postfix) with ESMTPSA id 8CB88201AE70; Sat, 15 Nov 2025 00:59:58 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8CB88201AE70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1763197202; bh=lLZx9JvSQA3blQF6VXFyrcFYBitj0xT3LfhpPh4FTEM=; h=From:To:Cc:Subject:Date:From; b=LcRFXnqO5ibP9hc7bW+pRudkmNlnGzJatSQxSw+TW6ZMOYRxC5SHHbxjVEQgelcEc sIVOb3NLI53K6uW0iHZC+bHDJXkyIC5cH/F98eCR7I1ADTkrsFCLbJfZsaNCobg9Uc QGi78s9zlIHHMdNE4RSukMMIyuyvNtddXE/Ze0dY= From: Naman Jain To: Wei Liu , Dexuan Cui , Greg Kroah-Hartman , Michael Kelley , Long Li , Saurabh Sengar Cc: "K . Y . Srinivasan" , Haiyang Zhang , Tianyu Lan , Naman Jain , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Salvatore Bonaccorso , Peter Morrow Subject: [PATCH 6.6 and older] uio_hv_generic: Enable user space to manage interrupt_mask for subchannels Date: Sat, 15 Nov 2025 14:29:37 +0530 Message-Id: <20251115085937.2237-1-namjain@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Long Li Enable the user space to manage interrupt_mask for subchannels through irqcontrol interface for uio device. Also remove the memory barrier when monitor bit is enabled as it is not necessary. This is a backport of the upstream commit d062463edf17 ("uio_hv_generic: Set event for all channels on the device") with some modifications to resolve merge conflicts and take care of missing support for slow devices on older kernels. Original change was not a fix, but it needs to be backported to fix a NULL pointer crash resulting from missing interrupt mask setting. Commit 37bd91f22794 ("uio_hv_generic: Let userspace take care of interrupt = mask") removed the default setting of interrupt_mask for channels (including subchannels) in the uio_hv_generic driver, as it relies on the user space to take care of managing it. This approach works fine when user space can control this setting using the irqcontrol interface provided for uio devices. Support for setting the interrupt mask through this interface for subchannels came only after commit d062463edf17 ("uio_hv_generic: Set event for all channels on the device"). On older kernels, this change is not present. With uio_hv_generic no longer setting the interrupt_mask, and userspace not having the capability to set it, it remains unset, and interrupts can come for the subchannels, which can result in a crash in hv_uio_channel_cb. Backport the change to older kernels, where this change was not present, to allow userspace to set the interrupt mask properly for subchannels. Additionally, this patch also adds certain checks for primary vs subchannels in the hv_uio_channel_cb, which can gracefully handle these two cases and prevent the NULL pointer crashes. Signed-off-by: Long Li Fixes: 37bd91f22794 ("uio_hv_generic: Let userspace take care of interrupt = mask") Closes: https://bugs.debian.org/1120602 Cc: # 6.6.x and older Signed-off-by: Naman Jain --- Remove reviewed-by tags since the original code has changed quite a bit while backporting. Backported change for 6.12 kernel is sent separately. --- drivers/uio/uio_hv_generic.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c index 2724656bf634..69e5016ebd46 100644 --- a/drivers/uio/uio_hv_generic.c +++ b/drivers/uio/uio_hv_generic.c @@ -80,9 +80,15 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state) { struct hv_uio_private_data *pdata =3D info->priv; struct hv_device *dev =3D pdata->device; + struct vmbus_channel *primary, *sc; =20 - dev->channel->inbound.ring_buffer->interrupt_mask =3D !irq_state; - virt_mb(); + primary =3D dev->channel; + primary->inbound.ring_buffer->interrupt_mask =3D !irq_state; + + mutex_lock(&vmbus_connection.channel_mutex); + list_for_each_entry(sc, &primary->sc_list, sc_list) + sc->inbound.ring_buffer->interrupt_mask =3D !irq_state; + mutex_unlock(&vmbus_connection.channel_mutex); =20 return 0; } @@ -93,11 +99,18 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state) static void hv_uio_channel_cb(void *context) { struct vmbus_channel *chan =3D context; - struct hv_device *hv_dev =3D chan->device_obj; - struct hv_uio_private_data *pdata =3D hv_get_drvdata(hv_dev); + struct hv_device *hv_dev; + struct hv_uio_private_data *pdata; =20 virt_mb(); =20 + /* + * The callback may come from a subchannel, in which case look + * for the hv device in the primary channel + */ + hv_dev =3D chan->primary_channel ? + chan->primary_channel->device_obj : chan->device_obj; + pdata =3D hv_get_drvdata(hv_dev); uio_event_notify(&pdata->info); } =20 --=20 2.34.1