From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Mykyta Poturai <Mykyta_Poturai@epam.com>
Cc: Jan Beulich <jbeulich@suse.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [XEN PATCH] xen/vpci: Fix UB in mask_write
Date: Wed, 6 Nov 2024 15:57:06 +0100 [thread overview]
Message-ID: <ZyuDwnYj5-uCWrMy@macbook> (raw)
In-Reply-To: <7c57371b-803a-418b-97cb-55e79516eed4@epam.com>
On Wed, Nov 06, 2024 at 02:32:13PM +0000, Mykyta Poturai wrote:
> On 06.11.24 14:42, Roger Pau Monné wrote:
> > On Wed, Nov 06, 2024 at 12:26:55PM +0000, Mykyta Poturai wrote:
> >> On 06.11.2024 10:07, Roger Pau Monné wrote:
> >>> Wait - how can msi->vectors ever be 0? AFAICT there's no way in the
> >>> MSI logic to configure 0 vectors, there will always be at least 1 vector
> >>> enabled.
> >>>
> >>> Maybe what you want, if this fix is for compliance reasons, is an
> >>> assert unreachable that msi->vectors > 0?
> >>
> >> I did some investigation and figured out that the value of 0 is being
> >> set by guest writing to msi_control_reg. As far as I understand, the
> >> control_write() function only checks that vectors are not greater than
> >> the maximum allowed value, but does not check for 0.
> >
> > control_write() will set vectors to (1UL << val), so even if user
> > provides val == 0, vectors will be 1.
> >
> > Can you provide an example input value of control_write() that will
> > lead to msi->vectors == 0?
> >
> > Is maybe msi_maxvec not set correctly in your use case if you indeed
> > see vectors == 0?
> >
> > Thanks, Roger.
>
> Indeed, I have checked and msi_maxvec is set to 0. Thanks for pointing
> this out. I will investigate further why this is happening. It is quite
> strange that it somehow worked on 4.18 with the same problem.
Check whether pdev_msi_init() is called during device addition, as
that's what initializes msi_maxvec. Another cause could be memory
corruption.
> I will change the check to an assert then, so if something similar
> happens again it can be caught earlier.
Let's try to figure out what causes msi_maxvec to be 0 in your case
and then we can see how to better detect this. If msi_maxvec needs to
be checked it should likely be done in init_msi().
Regards, Roger.
next prev parent reply other threads:[~2024-11-06 14:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 8:05 [XEN PATCH] xen/vpci: Fix UB in mask_write Mykyta Poturai
2024-11-06 9:00 ` Roger Pau Monné
2024-11-06 9:07 ` Roger Pau Monné
2024-11-06 11:31 ` Jan Beulich
2024-11-06 12:26 ` Mykyta Poturai
2024-11-06 12:42 ` Roger Pau Monné
2024-11-06 14:32 ` Mykyta Poturai
2024-11-06 14:57 ` Roger Pau Monné [this message]
2024-11-11 12:21 ` Mykyta Poturai
2024-11-12 11:26 ` Roger Pau Monné
2024-11-07 9:25 ` Jan Beulich
2024-11-07 9:36 ` Roger Pau Monné
2024-11-06 11:35 ` Jan Beulich
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=ZyuDwnYj5-uCWrMy@macbook \
--to=roger.pau@citrix.com \
--cc=Mykyta_Poturai@epam.com \
--cc=jbeulich@suse.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.