linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: linux-hyperv@vger.kernel.org, Haiyang Zhang <haiyangz@microsoft.com>
Cc: linux-pci@vger.kernel.org, Dexuan Cui <decui@microsoft.com>
Subject: unlocked access to struct irq_data->chip_data in pci_hyperv
Date: Wed, 25 Jan 2023 18:04:11 +0100	[thread overview]
Message-ID: <20230125180411.4742f159.olaf@aepfle.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]

Hello,

there are several crash reports due to struct irq_data->chip_data being NULL.

I was under the impression all the "recent changes" to pci-hyperv.c
would fix them. But apparently this specific issue is still there.

What does serialize read and write access to struct irq_data->chip_data?
It seems hv_msi_free can run while other code paths still access at least
->chip_data.

The change below may reduce the window, but I'm not confident this would
actually resolve the concurrency issues.


Olaf

--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1760,8 +1760,9 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
 		    msi_desc->nvec_used > 1;
 
 	/* Reuse the previous allocation */
-	if (data->chip_data && multi_msi) {
-		int_desc = data->chip_data;
+	virt_rmb();
+	int_desc = READ_ONCE(data->chip_data);
+	if (int_desc && multi_msi) {
 		msg->address_hi = int_desc->address >> 32;
 		msg->address_lo = int_desc->address & 0xffffffff;
 		msg->data = int_desc->data;
@@ -1778,8 +1779,9 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
 		goto return_null_message;
 
 	/* Free any previous message that might have already been composed. */
-	if (data->chip_data && !multi_msi) {
-		int_desc = data->chip_data;
+	virt_rmb();
+	int_desc = READ_ONCE(data->chip_data);
+	if (int_desc && !multi_msi) {
 		data->chip_data = NULL;
 		hv_int_desc_free(hpdev, int_desc);
 	}

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2023-01-25 17:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25 17:04 Olaf Hering [this message]
2023-01-30  9:47 ` unlocked access to struct irq_data->chip_data in pci_hyperv Dexuan Cui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230125180411.4742f159.olaf@aepfle.de \
    --to=olaf@aepfle.de \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).