From: Andrew Cooper <andrew.cooper3@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 6 of 6] KEXEC: disable iommu jumping into the kdump kernel
Date: Wed, 25 May 2011 15:32:08 +0100 [thread overview]
Message-ID: <cb005f9078d34b052da9.1306333928@andrewcoop> (raw)
In-Reply-To: <patchbomb.1306333922@andrewcoop>
kdump kernels are unable to boot with IOMMU enabled.
this patch disabled IOMMU mode and removes some of the generic
code from the shutdown path which doesnt work after other
CPUs have been shot down.
Because we need to replace the calls to disable_local_APIC,
we remove the calls to __stop_this_cpu and replace them inline,
with suitable modification regarding interrupts and local APICs.
At the bottom of nmi_shootdown_cpus, remove the call to
local_irq_enable as this causes us to jump into purgatory with
the interrupt flag enabled. From a quick qrep through the current
kexec-tools source, there is a fair amount of time before the
interrupt flag is touched, meaning that we could possibly be
servicing interrupts in the Xen context even though we have really
crashed and left.
hpet_disable_legacy_broadcast has been split sideways into a crash
version which forgoes the locks (as only 1 cpu is still running by
this point), and forgoes the IPI to all other processors.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff -r d3026545e9a0 -r cb005f9078d3 xen/arch/x86/crash.c
--- a/xen/arch/x86/crash.c Wed May 25 15:12:37 2011 +0100
+++ b/xen/arch/x86/crash.c Wed May 25 15:30:43 2011 +0100
@@ -27,6 +27,7 @@
#include <asm/hvm/support.h>
#include <asm/apic.h>
#include <asm/io_apic.h>
+#include <xen/iommu.h>
static atomic_t waiting_for_crash_ipi;
static unsigned int crashing_cpu;
@@ -43,7 +44,10 @@ static int crash_nmi_callback(struct cpu
kexec_crash_save_cpu();
- __stop_this_cpu();
+ crash_disable_local_APIC(FALSE);
+ hvm_cpu_down();
+ clts();
+ asm volatile ( "fninit" );
atomic_dec(&waiting_for_crash_ipi);
@@ -77,10 +81,20 @@ static void nmi_shootdown_cpus(void)
msecs--;
}
- __stop_this_cpu();
+ crash_disable_local_APIC(TRUE);
+ hvm_cpu_down();
+ clts();
+ asm volatile ( "fninit" );
+
+ /* This is a bit of a hack due to the problems with the x2apic_enabled
+ * variable, but we can't do any better without a significant refactoring
+ * of the APIC code */
+ if ( current_local_apic_mode() == APIC_MODE_X2APIC )
+ x2apic_enabled = 1;
+ else
+ x2apic_enabled = 0;
+
disable_IO_APIC();
-
- local_irq_enable();
}
void machine_crash_shutdown(void)
@@ -89,6 +103,10 @@ void machine_crash_shutdown(void)
nmi_shootdown_cpus();
+ /* Crash shutdown any IOMMU functionality as the crashdump kernel is not
+ * happy when booting if interrupt/dma remapping is still enabled */
+ iommu_crash_shutdown();
+
info = kexec_crash_save_info();
info->xen_phys_start = xen_phys_start;
info->dom0_pfn_to_mfn_frame_list_list =
diff -r d3026545e9a0 -r cb005f9078d3 xen/arch/x86/hpet.c
--- a/xen/arch/x86/hpet.c Wed May 25 15:12:37 2011 +0100
+++ b/xen/arch/x86/hpet.c Wed May 25 15:30:43 2011 +0100
@@ -670,6 +670,32 @@ void hpet_disable_legacy_broadcast(void)
smp_send_event_check_mask(&cpu_online_map);
}
+/* This function is similar to the regular
+ * hpet_disable_legacy_broadcast function, except it is called
+ * on the crash path with only the current processor up, so we
+ * can forget the locks and really cant send an event check IPI
+ * to the other processors */
+void crash_hpet_disable_legacy_broadcast(void)
+{
+ u32 cfg;
+
+ if ( !hpet_events || !(hpet_events->flags & HPET_EVT_LEGACY) )
+ return;
+
+ hpet_events->flags |= HPET_EVT_DISABLE;
+
+ /* disable HPET T0 */
+ cfg = hpet_read32(HPET_Tn_CFG(0));
+ cfg &= ~HPET_TN_ENABLE;
+ hpet_write32(cfg, HPET_Tn_CFG(0));
+
+ /* Stop HPET legacy interrupts */
+ cfg = hpet_read32(HPET_CFG);
+ cfg &= ~HPET_CFG_LEGACY;
+ hpet_write32(cfg, HPET_CFG);
+
+}
+
void hpet_broadcast_enter(void)
{
unsigned int cpu = smp_processor_id();
diff -r d3026545e9a0 -r cb005f9078d3 xen/arch/x86/machine_kexec.c
--- a/xen/arch/x86/machine_kexec.c Wed May 25 15:12:37 2011 +0100
+++ b/xen/arch/x86/machine_kexec.c Wed May 25 15:30:43 2011 +0100
@@ -89,7 +89,7 @@ void machine_kexec(xen_kexec_image_t *im
};
if ( hpet_broadcast_is_available() )
- hpet_disable_legacy_broadcast();
+ crash_hpet_disable_legacy_broadcast();
/*
* compat_machine_kexec() returns to idle pagetables, which requires us
diff -r d3026545e9a0 -r cb005f9078d3 xen/include/asm-x86/hpet.h
--- a/xen/include/asm-x86/hpet.h Wed May 25 15:12:37 2011 +0100
+++ b/xen/include/asm-x86/hpet.h Wed May 25 15:30:43 2011 +0100
@@ -73,5 +73,6 @@ void hpet_broadcast_enter(void);
void hpet_broadcast_exit(void);
int hpet_broadcast_is_available(void);
void hpet_disable_legacy_broadcast(void);
+void crash_hpet_disable_legacy_broadcast(void);
#endif /* __X86_HPET_H__ */
next prev parent reply other threads:[~2011-05-25 14:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-25 14:32 [PATCH 0 of 6] Fix kexec in Xen (take 3) Andrew Cooper
2011-05-25 14:32 ` [PATCH 1 of 6] APIC: record local APIC state on boot Andrew Cooper
2011-05-25 14:32 ` [PATCH 2 of 6] APIC: remove 'enabled_via_apicbase' variable Andrew Cooper
2011-05-25 14:32 ` [PATCH 3 of 6] APIC: add crash_disable_local_APIC Andrew Cooper
2011-05-25 14:32 ` [PATCH 4 of 6] IOMMU: Sanitise some of our pointer work Andrew Cooper
2011-05-25 17:28 ` Konrad Rzeszutek Wilk
2011-05-25 14:32 ` [PATCH 5 of 6] IOMMU: add crash_shutdown iommu_op Andrew Cooper
2011-05-25 14:32 ` Andrew Cooper [this message]
2011-05-25 15:01 ` [PATCH 0 of 6] Fix kexec in Xen (take 3) Wei Wang2
2011-05-25 16:14 ` Jan Beulich
2011-05-25 16:30 ` Andrew Cooper
2011-05-25 21:35 ` Keir Fraser
2011-05-26 9:12 ` Andrew Cooper
2011-05-26 9:19 ` Keir Fraser
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=cb005f9078d34b052da9.1306333928@andrewcoop \
--to=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xensource.com \
/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;
as well as URLs for NNTP newsgroup(s).