All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] iommu: leave IOMMU enabled by default during kexec crash transition
@ 2019-02-21 22:08 Igor Druzhinin
  2019-02-22 12:34 ` Jan Beulich
  2019-02-22 13:22 ` Jan Beulich
  0 siblings, 2 replies; 4+ messages in thread
From: Igor Druzhinin @ 2019-02-21 22:08 UTC (permalink / raw)
  To: xen-devel
  Cc: Igor Druzhinin, wei.liu2, George.Dunlap, andrew.cooper3,
	julien.grall, jbeulich, roger.pau

It's unsafe to disable IOMMU on a live system which is the case
if we're crashing since remapping hardware doesn't usually know what
to do with ongoing bus transactions and frequently raises NMI/MCE/SMI,
etc. (depends on the firmware configuration) to signal these abnormalities.
This, in turn, doesn't play well with kexec transition process as there is
no handling available at the moment for this kind of events resulting
in failures to enter the kernel.

Modern Linux kernels taught to copy all the necessary DMAR/IR tables
following kexec from the previous kernel (Xen in our case) - so it's
currently normal to keep IOMMU enabled. It might require minor changes to
kdump command line that enables IOMMU drivers (e.g. intel_iommu=on /
intremap=on) but recent kernels don't require any additional changes for
the transition to be transparent.

A fallback option is still left for compatibility with ancient crash
kernels which didn't like to have IOMMU active under their feet on boot.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
Changes in v2:
* Fixed and clarified documentation
* Renamed option to crash-disable
* Other minor suggestions taken
---
 docs/misc/xen-command-line.pandoc | 8 +++++++-
 xen/arch/x86/crash.c              | 7 +++++--
 xen/drivers/passthrough/iommu.c   | 8 ++++++++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index a03c0b4..ab853bd 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -1172,7 +1172,7 @@ detection of systems known to misbehave upon accesses to that port.
 
 ### iommu
     = List of [ <bool>, verbose, debug, force, required,
-                sharept, intremap, intpost,
+                sharept, intremap, intpost, crash-disable,
                 snoop, qinval, igfx, workaround_bios_bug,
                 amd-iommu-perdev-intremap,
                 dom0-{passthrough,strict} ]
@@ -1235,6 +1235,12 @@ boolean (e.g. `iommu=no`) can override this and leave the IOMMUs disabled.
     This option depends on `intremap`, and is disabled by default due to some
     corner cases in the implementation which have yet to be resolved.
 
+*   The `crash-disable` boolean controls disabling IOMMU functionality (DMAR/IR/QI)
+    before switching to a crash kernel. This option is inactive by default and
+    is for compatibility with older kdump kernels only. Modern kernels copy
+    all the necessary tables from the previous one following kexec which makes
+    the transition transparent for them with IOMMU functions still on.
+
 The following options are specific to Intel VT-d hardware:
 
 *   The `snoop` boolean controls the Snoop Control sub-feature, and is active
diff --git a/xen/arch/x86/crash.c b/xen/arch/x86/crash.c
index 60c98b6..01e48a1 100644
--- a/xen/arch/x86/crash.c
+++ b/xen/arch/x86/crash.c
@@ -162,8 +162,11 @@ static void nmi_shootdown_cpus(void)
         printk("Failed to shoot down CPUs {%*pbl}\n",
                nr_cpu_ids, cpumask_bits(&waiting_to_crash));
 
-    /* Crash shutdown any IOMMU functionality as the crashdump kernel is not
-     * happy when booting if interrupt/dma remapping is still enabled */
+    /*
+     * Try to crash shutdown IOMMU functionality as some old crashdump
+     * kernels are not happy when booting if interrupt/dma remapping
+     * is still enabled.
+     */
     iommu_crash_shutdown();
 
     __stop_this_cpu();
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 5ecaa10..611e857 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -35,6 +35,7 @@ bool_t __read_mostly iommu_igfx = 1;
 bool_t __read_mostly iommu_snoop = 1;
 bool_t __read_mostly iommu_qinval = 1;
 bool_t __read_mostly iommu_intremap = 1;
+bool_t __read_mostly iommu_crash_disable;
 
 static bool __hwdom_initdata iommu_hwdom_none;
 bool __hwdom_initdata iommu_hwdom_strict;
@@ -88,6 +89,10 @@ static int __init parse_iommu_param(const char *s)
             iommu_intremap = val;
         else if ( (val = parse_boolean("intpost", s, ss)) >= 0 )
             iommu_intpost = val;
+#ifdef CONFIG_KEXEC
+        else if ( (val = parse_boolean("crash-disable", s, ss)) >= 0 )
+            iommu_crash_disable = val;
+#endif
         else if ( (val = parse_boolean("debug", s, ss)) >= 0 )
         {
             iommu_debug = val;
@@ -579,6 +584,9 @@ void iommu_share_p2m_table(struct domain* d)
 
 void iommu_crash_shutdown(void)
 {
+    if ( !iommu_crash_disable )
+        return;
+
     if ( iommu_enabled )
         iommu_get_ops()->crash_shutdown();
     iommu_enabled = iommu_intremap = iommu_intpost = 0;
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] iommu: leave IOMMU enabled by default during kexec crash transition
  2019-02-21 22:08 [PATCH v2] iommu: leave IOMMU enabled by default during kexec crash transition Igor Druzhinin
@ 2019-02-22 12:34 ` Jan Beulich
  2019-02-22 12:43   ` Igor Druzhinin
  2019-02-22 13:22 ` Jan Beulich
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2019-02-22 12:34 UTC (permalink / raw)
  To: Igor Druzhinin
  Cc: Wei Liu, George Dunlap, Andrew Cooper, Julien Grall, xen-devel,
	Roger Pau Monne

>>> On 21.02.19 at 23:08, <igor.druzhinin@citrix.com> wrote:
> Modern Linux kernels taught to copy all the necessary DMAR/IR tables
> following kexec from the previous kernel (Xen in our case) - so it's
> currently normal to keep IOMMU enabled. It might require minor changes to
> kdump command line that enables IOMMU drivers (e.g. intel_iommu=on /
> intremap=on) but recent kernels don't require any additional changes for
> the transition to be transparent.

In your reply on the v1 thread didn't you say Linux disables translation?

> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -35,6 +35,7 @@ bool_t __read_mostly iommu_igfx = 1;
>  bool_t __read_mostly iommu_snoop = 1;
>  bool_t __read_mostly iommu_qinval = 1;
>  bool_t __read_mostly iommu_intremap = 1;
> +bool_t __read_mostly iommu_crash_disable;
>  
>  static bool __hwdom_initdata iommu_hwdom_none;
>  bool __hwdom_initdata iommu_hwdom_strict;

While I can see that all upper context still uses bool_t, lower context
already suggests to better use bool. An easy to make adjustment
while committing if no other need arises for a v3.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] iommu: leave IOMMU enabled by default during kexec crash transition
  2019-02-22 12:34 ` Jan Beulich
@ 2019-02-22 12:43   ` Igor Druzhinin
  0 siblings, 0 replies; 4+ messages in thread
From: Igor Druzhinin @ 2019-02-22 12:43 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Wei Liu, George Dunlap, Andrew Cooper, Julien Grall, xen-devel,
	Roger Pau Monne

On 22/02/2019 12:34, Jan Beulich wrote:
>>>> On 21.02.19 at 23:08, <igor.druzhinin@citrix.com> wrote:
>> Modern Linux kernels taught to copy all the necessary DMAR/IR tables
>> following kexec from the previous kernel (Xen in our case) - so it's
>> currently normal to keep IOMMU enabled. It might require minor changes to
>> kdump command line that enables IOMMU drivers (e.g. intel_iommu=on /
>> intremap=on) but recent kernels don't require any additional changes for
>> the transition to be transparent.
> 
> In your reply on the v1 thread didn't you say Linux disables translation?

I didn't rule out a possibility that there were versions of Linux that
did it in a wrong order or didn't do it at all as current versions do.

Igor

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] iommu: leave IOMMU enabled by default during kexec crash transition
  2019-02-21 22:08 [PATCH v2] iommu: leave IOMMU enabled by default during kexec crash transition Igor Druzhinin
  2019-02-22 12:34 ` Jan Beulich
@ 2019-02-22 13:22 ` Jan Beulich
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2019-02-22 13:22 UTC (permalink / raw)
  To: Igor Druzhinin
  Cc: Wei Liu, George Dunlap, Andrew Cooper, Julien Grall, xen-devel,
	Roger Pau Monne

>>> On 21.02.19 at 23:08, <igor.druzhinin@citrix.com> wrote:
> It's unsafe to disable IOMMU on a live system which is the case
> if we're crashing since remapping hardware doesn't usually know what
> to do with ongoing bus transactions and frequently raises NMI/MCE/SMI,
> etc. (depends on the firmware configuration) to signal these abnormalities.
> This, in turn, doesn't play well with kexec transition process as there is
> no handling available at the moment for this kind of events resulting
> in failures to enter the kernel.
> 
> Modern Linux kernels taught to copy all the necessary DMAR/IR tables
> following kexec from the previous kernel (Xen in our case) - so it's
> currently normal to keep IOMMU enabled. It might require minor changes to
> kdump command line that enables IOMMU drivers (e.g. intel_iommu=on /
> intremap=on) but recent kernels don't require any additional changes for
> the transition to be transparent.
> 
> A fallback option is still left for compatibility with ancient crash
> kernels which didn't like to have IOMMU active under their feet on boot.
> 
> Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>

Based on the subsequent discussion
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2019-02-22 13:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 22:08 [PATCH v2] iommu: leave IOMMU enabled by default during kexec crash transition Igor Druzhinin
2019-02-22 12:34 ` Jan Beulich
2019-02-22 12:43   ` Igor Druzhinin
2019-02-22 13:22 ` Jan Beulich

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.