From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 2/2] DO NOT APPLY - debugging code to lock a pcpu in an NMI loop Date: Tue, 24 Sep 2013 20:56:53 +0100 Message-ID: <1380052613-3837-2-git-send-email-andrew.cooper3@citrix.com> References: <1380052613-3837-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1380052613-3837-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper List-Id: xen-devel@lists.xenproject.org Should be used in combination with the regular NMI watchdog --- xen/arch/x86/crash.c | 32 ++++++++++++++++++++++++++++++++ xen/arch/x86/x86_64/entry.S | 8 ++++++++ 2 files changed, 40 insertions(+) diff --git a/xen/arch/x86/crash.c b/xen/arch/x86/crash.c index 5f0f07c..724fc17 100644 --- a/xen/arch/x86/crash.c +++ b/xen/arch/x86/crash.c @@ -207,6 +207,38 @@ void machine_crash_shutdown(void) arch_get_pfn_to_mfn_frame_list_list(dom0); } +void __attribute__((noreturn)) do_nmi_loop(struct cpu_user_regs *regs) +{ + unsigned int cpu = smp_processor_id(); + printk("In NMI wedge on cpu%d\n Spinning forever...", cpu); + for ( ; ; ) + halt(); +} + +void nmi_loop(void); +static void nmi_wedge(unsigned char key) +{ + unsigned int cpu = smp_processor_id(); + + printk("'%c' pressed -> Wedging cpu%d in NMI loop\n", key, cpu); + + _update_gate_addr_lower(&idt_tables[cpu][TRAP_nmi], &nmi_loop); +} + +static struct keyhandler nmi_wedge_keyhandler = { + .diagnostic = 1, + .u.fn = nmi_wedge, + .desc = "Wedge cpu in NMI loop" +}; + +static int __init nmi_wedge_key_init(void) +{ + printk("Installing NMI wedge keyhandler\n"); + register_keyhandler('1', &nmi_wedge_keyhandler); + return 0; +} +__initcall(nmi_wedge_key_init); + /* * Local variables: * mode: C diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S index f64e871..18b77f4 100644 --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -666,6 +666,14 @@ ENTRY(nmi_crash) callq do_nmi_crash /* Does not return */ ud2 +ENTRY(nmi_loop) + pushq $0 + movl $TRAP_nmi,4(%rsp) + SAVE_ALL + movq %rsp,%rdi + callq do_nmi_loop /* Does not return */ + ud2 + ENTRY(machine_check) pushq $0 movl $TRAP_machine_check,4(%rsp) -- 1.7.10.4