linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/hyper-v: Fix panic on a host without the 15-bit APIC ID support
@ 2020-12-02  0:45 Dexuan Cui
  2020-12-02  1:28 ` Woodhouse, David
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dexuan Cui @ 2020-12-02  0:45 UTC (permalink / raw)
  To: tglx, dwmw, x86, decui, mikelley, linux-hyperv
  Cc: linux-kernel, Tianyu.Lan, vkuznets, kys, haiyangz, sthemmin, wei.liu

The commit f36a74b9345a itself is good, but it causes a panic in a
Linux VM that runs on a Hyper-V host that doesn't have the 15-bit
Extended APIC ID support:
    kernel BUG at arch/x86/kernel/apic/io_apic.c:2408!

This happens because the Hyper-V ioapic_ir_domain (which is defined in
drivers/iommu/hyperv-iommu.c) can not be found. Fix the panic by
properly claiming the only I/O APIC emulated by Hyper-V.

Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Fixes: f36a74b9345a ("x86/ioapic: Use I/O-APIC ID for finding irqdomain, not index")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
 drivers/iommu/hyperv-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


This patch is for the tip.git tree's x86/apic branch.

diff --git a/drivers/iommu/hyperv-iommu.c b/drivers/iommu/hyperv-iommu.c
index 9438daa24fdb..1d21a0b5f724 100644
--- a/drivers/iommu/hyperv-iommu.c
+++ b/drivers/iommu/hyperv-iommu.c
@@ -105,8 +105,8 @@ static int hyperv_irq_remapping_select(struct irq_domain *d,
 				       struct irq_fwspec *fwspec,
 				       enum irq_domain_bus_token bus_token)
 {
-	/* Claim only the first (and only) I/OAPIC */
-	return x86_fwspec_is_ioapic(fwspec) && fwspec->param[0] == 0;
+	/* Claim the only I/O APIC emulated by Hyper-V */
+	return x86_fwspec_is_ioapic(fwspec);
 }
 
 static const struct irq_domain_ops hyperv_ir_domain_ops = {

base-commit: d1adcfbb520c43c10fc22fcdccdd4204e014fb53
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/hyper-v: Fix panic on a host without the 15-bit APIC ID support
  2020-12-02  0:45 [PATCH] iommu/hyper-v: Fix panic on a host without the 15-bit APIC ID support Dexuan Cui
@ 2020-12-02  1:28 ` Woodhouse, David
  2020-12-02  9:56 ` Thomas Gleixner
  2020-12-02 10:28 ` [tip: x86/apic] iommu/hyper-v: Remove I/O-APIC ID check from hyperv_irq_remapping_select() tip-bot2 for Dexuan Cui
  2 siblings, 0 replies; 5+ messages in thread
From: Woodhouse, David @ 2020-12-02  1:28 UTC (permalink / raw)
  To: tglx, decui, x86, mikelley, linux-hyperv
  Cc: sthemmin, linux-kernel, Tianyu.Lan, vkuznets, kys, haiyangz, wei.liu

On Tue, 2020-12-01 at 16:45 -0800, Dexuan Cui wrote:
> The commit f36a74b9345a itself is good, but it causes a panic in a
> Linux VM that runs on a Hyper-V host that doesn't have the 15-bit
> Extended APIC ID support:
>     kernel BUG at arch/x86/kernel/apic/io_apic.c:2408!
> 
> This happens because the Hyper-V ioapic_ir_domain (which is defined in
> drivers/iommu/hyperv-iommu.c) can not be found. Fix the panic by
> properly claiming the only I/O APIC emulated by Hyper-V.
> 
> Cc: David Woodhouse <dwmw@amazon.co.uk>
> Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> Fixes: f36a74b9345a ("x86/ioapic: Use I/O-APIC ID for finding irqdomain, not index")
> Signed-off-by: Dexuan Cui <decui@microsoft.com>

Oops, apologies for missing that.

Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>



Amazon Development Centre (London) Ltd. Registered in England and Wales with registration number 04543232 with its registered office at 1 Principal Place, Worship Street, London EC2A 2FA, United Kingdom.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/hyper-v: Fix panic on a host without the 15-bit APIC ID support
  2020-12-02  0:45 [PATCH] iommu/hyper-v: Fix panic on a host without the 15-bit APIC ID support Dexuan Cui
  2020-12-02  1:28 ` Woodhouse, David
@ 2020-12-02  9:56 ` Thomas Gleixner
  2020-12-02 19:53   ` Dexuan Cui
  2020-12-02 10:28 ` [tip: x86/apic] iommu/hyper-v: Remove I/O-APIC ID check from hyperv_irq_remapping_select() tip-bot2 for Dexuan Cui
  2 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2020-12-02  9:56 UTC (permalink / raw)
  To: Dexuan Cui, dwmw, x86, decui, mikelley, linux-hyperv
  Cc: linux-kernel, Tianyu.Lan, vkuznets, kys, haiyangz, sthemmin, wei.liu

On Tue, Dec 01 2020 at 16:45, Dexuan Cui wrote:
> The commit f36a74b9345a itself is good, but it causes a panic in a
> Linux VM that runs on a Hyper-V host that doesn't have the 15-bit
> Extended APIC ID support:
>     kernel BUG at arch/x86/kernel/apic/io_apic.c:2408!

This has nothing to do with the 15bit APIC ID support, really.

The point is that the select() function only matches when I/O APIC ID is
0, which is not guaranteed. That's independent of the 15bit extended
APIC ID feature. But the I/O-APIC ID is irrelevant on hyperv because
there is only one.

> This happens because the Hyper-V ioapic_ir_domain (which is defined in
> drivers/iommu/hyperv-iommu.c) can not be found. Fix the panic by
> properly claiming the only I/O APIC emulated by Hyper-V.

We don't fix a panic. We fix a bug in the code :)

I'll amend the changelog.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip: x86/apic] iommu/hyper-v: Remove I/O-APIC ID check from hyperv_irq_remapping_select()
  2020-12-02  0:45 [PATCH] iommu/hyper-v: Fix panic on a host without the 15-bit APIC ID support Dexuan Cui
  2020-12-02  1:28 ` Woodhouse, David
  2020-12-02  9:56 ` Thomas Gleixner
@ 2020-12-02 10:28 ` tip-bot2 for Dexuan Cui
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Dexuan Cui @ 2020-12-02 10:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Dexuan Cui, Thomas Gleixner, David Woodhouse, x86, linux-kernel

The following commit has been merged into the x86/apic branch of tip:

Commit-ID:     26ab12bb9d96133b7880141d68b5e01a8783de9d
Gitweb:        https://git.kernel.org/tip/26ab12bb9d96133b7880141d68b5e01a8783de9d
Author:        Dexuan Cui <decui@microsoft.com>
AuthorDate:    Tue, 01 Dec 2020 16:45:10 -08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 11:22:55 +01:00

iommu/hyper-v: Remove I/O-APIC ID check from hyperv_irq_remapping_select()

commit a491bb19f728 ("iommu/hyper-v: Implement select() method on remapping
irqdomain") restricted the irq_domain_ops::select() callback to match on
I/O-APIC index 0, which was correct until the parameter was changed to
carry the I/O APIC ID in commit f36a74b9345a.

If the ID is not 0 then the match fails. Therefore I/O-APIC init fails to
retrieve the parent irqdomain for the I/O-APIC resulting in a boot panic:

    kernel BUG at arch/x86/kernel/apic/io_apic.c:2408!

Fix it by matching the I/O-APIC independent of the ID as there is only one
I/O APIC emulated by Hyper-V.

[ tglx: Amended changelog ]

Fixes: f36a74b9345a ("x86/ioapic: Use I/O-APIC ID for finding irqdomain, not index")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Link: https://lore.kernel.org/r/20201202004510.1818-1-decui@microsoft.com
---
 drivers/iommu/hyperv-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/hyperv-iommu.c b/drivers/iommu/hyperv-iommu.c
index 9438daa..1d21a0b 100644
--- a/drivers/iommu/hyperv-iommu.c
+++ b/drivers/iommu/hyperv-iommu.c
@@ -105,8 +105,8 @@ static int hyperv_irq_remapping_select(struct irq_domain *d,
 				       struct irq_fwspec *fwspec,
 				       enum irq_domain_bus_token bus_token)
 {
-	/* Claim only the first (and only) I/OAPIC */
-	return x86_fwspec_is_ioapic(fwspec) && fwspec->param[0] == 0;
+	/* Claim the only I/O APIC emulated by Hyper-V */
+	return x86_fwspec_is_ioapic(fwspec);
 }
 
 static const struct irq_domain_ops hyperv_ir_domain_ops = {

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH] iommu/hyper-v: Fix panic on a host without the 15-bit APIC ID support
  2020-12-02  9:56 ` Thomas Gleixner
@ 2020-12-02 19:53   ` Dexuan Cui
  0 siblings, 0 replies; 5+ messages in thread
From: Dexuan Cui @ 2020-12-02 19:53 UTC (permalink / raw)
  To: Thomas Gleixner, dwmw, x86, Michael Kelley, linux-hyperv
  Cc: linux-kernel, Tianyu Lan, vkuznets, KY Srinivasan, Haiyang Zhang,
	Stephen Hemminger, wei.liu

> From: Thomas Gleixner <tglx@linutronix.de>
> Sent: Wednesday, December 2, 2020 1:56 AM
> 
> On Tue, Dec 01 2020 at 16:45, Dexuan Cui wrote:
> > The commit f36a74b9345a itself is good, but it causes a panic in a
> > Linux VM that runs on a Hyper-V host that doesn't have the 15-bit
> > Extended APIC ID support:
> >     kernel BUG at arch/x86/kernel/apic/io_apic.c:2408!
> 
> This has nothing to do with the 15bit APIC ID support, really.
> 
> The point is that the select() function only matches when I/O APIC ID is
> 0, which is not guaranteed. That's independent of the 15bit extended
> APIC ID feature. But the I/O-APIC ID is irrelevant on hyperv because
> there is only one.
> 
> > This happens because the Hyper-V ioapic_ir_domain (which is defined in
> > drivers/iommu/hyperv-iommu.c) can not be found. Fix the panic by
> > properly claiming the only I/O APIC emulated by Hyper-V.
> 
> We don't fix a panic. We fix a bug in the code :)
> 
> I'll amend the changelog.
> 
> Thanks,
> 
>         tglx

Thank you for reworking the commit log, tglx!

Dexuan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-02 19:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02  0:45 [PATCH] iommu/hyper-v: Fix panic on a host without the 15-bit APIC ID support Dexuan Cui
2020-12-02  1:28 ` Woodhouse, David
2020-12-02  9:56 ` Thomas Gleixner
2020-12-02 19:53   ` Dexuan Cui
2020-12-02 10:28 ` [tip: x86/apic] iommu/hyper-v: Remove I/O-APIC ID check from hyperv_irq_remapping_select() tip-bot2 for Dexuan Cui

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).