From: Petr Mladek <pmladek@suse.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: boris.ostrovsky@oracle.com, jgross@suse.com,
xen-devel@lists.xenproject.org, Luca Miccio <lucmiccio@gmail.com>,
Stefano Stabellini <stefano.stabellini@xilinx.com>,
live-patching@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH LINUX v5 2/2] xen: add support for initializing xenstore later as HVM domain
Date: Fri, 21 Jul 2023 14:48:24 +0200 [thread overview]
Message-ID: <ZLp-mAc1aFEgbVgS@alley> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2307201629190.3118466@ubuntu-linux-20-04-desktop>
On Thu 2023-07-20 16:31:16, Stefano Stabellini wrote:
> On Thu, 20 Jul 2023, Petr Mladek wrote:
> > On Wed 2023-07-19 18:46:08, Stefano Stabellini wrote:
> > > On Wed, 19 Jul 2023, Petr Mladek wrote:
> > > > I see the following warning from free_irq() in 6.5-rc2 when running
> > > > livepatching selftests. It does not happen after reverting this patch.
> > > >
> > > > [ 352.168453] livepatch: signaling remaining tasks
> > > > [ 352.173228] ------------[ cut here ]------------
> > > > [ 352.175563] Trying to free already-free IRQ 0
> > > > [ 352.177355] WARNING: CPU: 1 PID: 88 at kernel/irq/manage.c:1893 free_irq+0xbf/0x350
> > > > [ 352.179942] Modules linked in: test_klp_livepatch(EK)
> > > > [ 352.181621] CPU: 1 PID: 88 Comm: xenbus_probe Kdump: loaded Tainted: G E K 6.5.0-rc2-default+ #535
> > > > [ 352.184754] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014
> > > > [ 352.188214] RIP: 0010:free_irq+0xbf/0x350
[...]
> > > > [ 352.213951] Call Trace:
> > > > [ 352.214390] <TASK>
> > > > [ 352.214717] ? __warn+0x81/0x170
> > > > [ 352.215436] ? free_irq+0xbf/0x350
> > > > [ 352.215906] ? report_bug+0x10b/0x200
> > > > [ 352.216408] ? prb_read_valid+0x17/0x20
> > > > [ 352.216926] ? handle_bug+0x44/0x80
> > > > [ 352.217409] ? exc_invalid_op+0x13/0x60
> > > > [ 352.217932] ? asm_exc_invalid_op+0x16/0x20
> > > > [ 352.218497] ? free_irq+0xbf/0x350
> > > > [ 352.218979] ? __pfx_xenbus_probe_thread+0x10/0x10
> > > > [ 352.219600] xenbus_probe+0x7a/0x80
> > > > [ 352.221030] xenbus_probe_thread+0x76/0xc0
> > > > [ 352.221416] ? __pfx_autoremove_wake_function+0x10/0x10
> > > > [ 352.221882] kthread+0xfd/0x130
> > > > [ 352.222191] ? __pfx_kthread+0x10/0x10
> > > > [ 352.222544] ret_from_fork+0x2d/0x50
> > > > [ 352.222893] ? __pfx_kthread+0x10/0x10
> > > > [ 352.223260] ret_from_fork_asm+0x1b/0x30
> >
> > I do not know where exactly it triggers the XEN code.
> >
> > > but it would seem
> > > that either:
> > > 1) free_irq is called twice
> > > 2) free_irq is called but xs_init_irq wasn't initialized before
> > >
> > > For 2) I can see that xenbus_probe() is called in a few cases where
> > > xs_init_irq wasn't set. Something like the below would make the warning
> > > go away but it would be nice to figure out which one is the code path
> > > taken that originally triggered the warning.
> >
> > I added some debugging messages and:
> >
> > + xenbus_probe() was called in xenbus_probe_thread().
> >
> > + xenbus_init() returned early after xen_domain() check so that
> > xs_init_irq was never initialized.
> >
> > Note that I use KVM and not XEN:
> >
> > [ 0.000000] Hypervisor detected: KVM
> > [...]
> > [ 0.072150] Booting paravirtualized kernel on KVM
>
> Ah! So the issue is that xenbus_init() returns early but
> xenbus_probe_initcall() doesn't. So maybe we just need a xen_domain
> check in xenbus_probe_initcall too.
>
> diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
> index 58b732dcbfb8..e9bd3ed70108 100644
> --- a/drivers/xen/xenbus/xenbus_probe.c
> +++ b/drivers/xen/xenbus/xenbus_probe.c
> @@ -811,6 +812,9 @@ static int xenbus_probe_thread(void *unused)
>
> static int __init xenbus_probe_initcall(void)
> {
> + if (!xen_domain())
> + return -ENODEV;
> +
> /*
> * Probe XenBus here in the XS_PV case, and also XS_HVM unless we
> * need to wait for the platform PCI device to come up or
I confirm that this change cures the problem as well. Feel free
to add:
Tested-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
prev parent reply other threads:[~2023-07-21 12:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <alpine.DEB.2.22.394.2205131417320.3842@ubuntu-linux-20-04-desktop>
[not found] ` <20220513211938.719341-2-sstabellini@kernel.org>
2023-07-19 15:47 ` [PATCH LINUX v5 2/2] xen: add support for initializing xenstore later as HVM domain Petr Mladek
2023-07-20 1:46 ` Stefano Stabellini
2023-07-20 10:18 ` Petr Mladek
2023-07-20 23:31 ` Stefano Stabellini
2023-07-21 12:48 ` Petr Mladek [this message]
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=ZLp-mAc1aFEgbVgS@alley \
--to=pmladek@suse.com \
--cc=axboe@kernel.dk \
--cc=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=live-patching@vger.kernel.org \
--cc=lucmiccio@gmail.com \
--cc=peterz@infradead.org \
--cc=sstabellini@kernel.org \
--cc=stefano.stabellini@xilinx.com \
--cc=tglx@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox