From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: xen-devel@lists.xenproject.org,
Jason Andryuk <jandryuk@gmail.com>,
Jan Beulich <jbeulich@suse.com>, Paul Durrant <paul@xen.org>
Subject: Re: [PATCH v2 3/3] x86/msi: clear initial MSI-X state on boot
Date: Tue, 28 Mar 2023 14:07:22 +0200 [thread overview]
Message-ID: <ZCLYe94PE3WXYnU5@mail-itl> (raw)
In-Reply-To: <ZCLRap2GJE0xwBCN@Air-de-Roger>
[-- Attachment #1: Type: text/plain, Size: 2243 bytes --]
On Tue, Mar 28, 2023 at 01:37:14PM +0200, Roger Pau Monné wrote:
> On Sat, Mar 25, 2023 at 03:49:24AM +0100, Marek Marczykowski-Górecki wrote:
> > Some firmware/devices are found to not reset MSI-X properly, leaving
> > MASKALL set. Xen relies on initial state being both disabled.
>
> The 'both' in this sentence seems out of context, as you just mention
> MASKALL in the previous sentence.
>
> > Especially, pci_reset_msix_state() assumes if MASKALL is set, it was Xen
> > setting it due to msix->host_maskall or msix->guest_maskall. Clearing
> > just MASKALL might be unsafe if ENABLE is set, so clear them both.
> >
> > Reported-by: Jason Andryuk <jandryuk@gmail.com>
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> > ---
> > v2:
> > - new patch
> > ---
> > xen/drivers/passthrough/msi.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/xen/drivers/passthrough/msi.c b/xen/drivers/passthrough/msi.c
> > index ce1a450f6f4a..60adad47e379 100644
> > --- a/xen/drivers/passthrough/msi.c
> > +++ b/xen/drivers/passthrough/msi.c
> > @@ -48,6 +48,13 @@ int pdev_msi_init(struct pci_dev *pdev)
> > ctrl = pci_conf_read16(pdev->sbdf, msix_control_reg(pos));
> > msix->nr_entries = msix_table_size(ctrl);
> >
> > + /*
> > + * Clear both ENABLE and MASKALL, pci_reset_msix_state() relies on this
> > + * initial state.
> > + */
> > + ctrl &= ~(PCI_MSIX_FLAGS_ENABLE|PCI_MSIX_FLAGS_MASKALL);
> > + pci_conf_write16(pdev->sbdf, msix_control_reg(pos), ctrl);
>
> Should you make this conditional to them being set in the first place:
>
> if ( ctrl & (PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL) )
> {
> ...
>
> We should avoid the extra access if possible (specially if it's to
> write the same value that has been read).
>
> I would even move this before the msix_table_size() call, so the
> handling of ctrl is closer together.
>
> Would it also be worth to print a debug message that the initial
> device state seems inconsistent?
That may make sense. XENLOG_WARNING? XENLOG_DEBUG?
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-03-28 12:07 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-25 2:49 [PATCH v2 1/3] x86/msi: passthrough all MSI-X vector ctrl writes to device model Marek Marczykowski-Górecki
2023-03-25 2:49 ` [PATCH v2 2/3] x86/hvm: Allow writes to registers on the same page as MSI-X table Marek Marczykowski-Górecki
2023-03-27 10:47 ` Andrew Cooper
2023-03-28 11:28 ` Roger Pau Monné
2023-03-28 12:05 ` Marek Marczykowski-Górecki
2023-03-28 12:34 ` Jan Beulich
2023-03-28 12:52 ` Marek Marczykowski-Górecki
2023-03-28 13:03 ` Jan Beulich
2023-03-28 13:22 ` Roger Pau Monné
2023-04-03 4:21 ` Marek Marczykowski-Górecki
2023-04-03 11:09 ` Jan Beulich
2023-03-28 12:52 ` Roger Pau Monné
2023-03-25 2:49 ` [PATCH v2 3/3] x86/msi: clear initial MSI-X state on boot Marek Marczykowski-Górecki
2023-03-28 11:37 ` Roger Pau Monné
2023-03-28 12:07 ` Marek Marczykowski-Górecki [this message]
2023-03-28 12:38 ` Jan Beulich
2023-03-28 12:54 ` Jan Beulich
2023-03-28 13:04 ` Marek Marczykowski-Górecki
2023-03-28 13:17 ` Jason Andryuk
2023-03-28 17:38 ` Jason Andryuk
2023-03-28 13:23 ` Jan Beulich
2023-03-28 13:27 ` Roger Pau Monné
2023-03-28 13:32 ` Jason Andryuk
2023-03-28 13:35 ` Jan Beulich
2023-03-28 13:43 ` Jason Andryuk
2023-03-28 13:54 ` Jan Beulich
2023-03-28 15:08 ` Jason Andryuk
2023-03-28 15:39 ` Jan Beulich
2023-03-27 10:12 ` [PATCH v2 1/3] x86/msi: passthrough all MSI-X vector ctrl writes to device model Roger Pau Monné
2023-03-27 10:26 ` Marek Marczykowski-Górecki
2023-03-27 10:51 ` Roger Pau Monné
2023-03-27 11:34 ` Marek Marczykowski-Górecki
2023-03-27 13:29 ` Roger Pau Monné
2023-03-27 14:20 ` Marek Marczykowski-Górecki
2023-03-27 14:37 ` Roger Pau Monné
2023-03-27 15:32 ` Jan Beulich
2023-03-27 15:42 ` Roger Pau Monné
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=ZCLYe94PE3WXYnU5@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=jandryuk@gmail.com \
--cc=jbeulich@suse.com \
--cc=paul@xen.org \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.