diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 077e1b6..6e7db51 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -245,6 +245,7 @@ ENTRY(startup_64) /* Zero EFLAGS */ pushq $0 + ud2 popfq /* diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c index 4d3ff03..f470e9a 100644 --- a/arch/x86/boot/cpucheck.c +++ b/arch/x86/boot/cpucheck.c @@ -96,9 +96,11 @@ static int has_eflag(u32 mask) "movl %0,%1 ; " "xorl %2,%1 ; " "pushl %1 ; " + "ud2; " "popfl ; " "pushfl ; " "popl %1 ; " + "ud2; " "popfl" : "=&r" (f0), "=&r" (f1) : "ri" (mask)); diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S index 581b056..391c016 100644 --- a/arch/x86/ia32/ia32entry.S +++ b/arch/x86/ia32/ia32entry.S @@ -176,6 +176,7 @@ sysexit_from_sys_call: xorq %r9,%r9 xorq %r10,%r10 xorq %r11,%r11 + ud2 popfq CFI_ADJUST_CFA_OFFSET -8 /*CFI_RESTORE rflags*/ diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h index 9e2b952..8848202 100644 --- a/arch/x86/include/asm/irqflags.h +++ b/arch/x86/include/asm/irqflags.h @@ -28,7 +28,7 @@ static inline unsigned long native_save_fl(void) static inline void native_restore_fl(unsigned long flags) { - asm volatile("push %0 ; popf" + asm volatile("push %0 ; ud2; popf" : /* no output */ :"g" (flags) :"memory", "cc"); @@ -36,7 +36,7 @@ static inline void native_restore_fl(unsigned long flags) static inline void native_irq_disable(void) { - asm volatile("cli": : :"memory"); + asm volatile("ud2; cli": : :"memory"); } static inline void native_irq_enable(void) @@ -113,7 +113,7 @@ static inline unsigned long __raw_local_irq_save(void) #else #define ENABLE_INTERRUPTS(x) sti -#define DISABLE_INTERRUPTS(x) cli +#define DISABLE_INTERRUPTS(x) ud2; cli #ifdef CONFIG_X86_64 #define SWAPGS swapgs @@ -181,7 +181,7 @@ static inline int raw_irqs_disabled(void) SAVE_REST; \ LOCKDEP_SYS_EXIT; \ RESTORE_REST; \ - cli; \ + ud2; cli; \ TRACE_IRQS_OFF; #else diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index c978648..7633adb 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -545,6 +545,7 @@ static inline void native_set_iopl_mask(unsigned mask) "andl %1, %0;" "orl %2, %0;" "pushl %0;" + "ud2; " "popfl" : "=&r" (reg) : "i" (~X86_EFLAGS_IOPL), "r" (mask)); @@ -782,7 +783,7 @@ static inline void wbinvd_halt(void) mb(); /* check for clflush to determine if wbinvd is legal */ if (cpu_has_clflush) - asm volatile("cli; wbinvd; 1: hlt; jmp 1b" : : : "memory"); + asm volatile("ud2; cli; wbinvd; 1: hlt; jmp 1b" : : : "memory"); else while (1) halt(); diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h index f08f973..99d9602 100644 --- a/arch/x86/include/asm/system.h +++ b/arch/x86/include/asm/system.h @@ -65,6 +65,7 @@ do { \ "jmp __switch_to\n" /* regparm call */ \ "1:\t" \ "popl %%ebp\n\t" /* restore EBP */ \ + "ud2\n\t" "popfl\n" /* restore flags */ \ \ /* output parameters */ \ @@ -102,7 +103,7 @@ do { \ /* frame pointer must be last for get_wchan */ #define SAVE_CONTEXT "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t" -#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t" +#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; testl $0x200,(%%rsp) ; jnz 1f ; ud2 ; 1: popf\t" #define __EXTRA_CLOBBER \ , "rcx", "rbx", "rdx", "r8", "r9", "r10", "r11", \ diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S index 8ea5164..d4180e5 100644 --- a/arch/x86/kernel/acpi/wakeup_64.S +++ b/arch/x86/kernel/acpi/wakeup_64.S @@ -90,6 +90,7 @@ resume_point: movq saved_context_cr0(%rax), %rbx movq %rbx, %cr0 pushq pt_regs_flags(%rax) + ud2 popfq movq pt_regs_sp(%rax), %rsp movq pt_regs_bp(%rax), %rbp diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 7db0d3e..98cd506 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -188,9 +188,11 @@ static inline int flag_is_changeable_p(u32 flag) "movl %0, %1 \n\t" "xorl %2, %0 \n\t" "pushl %0 \n\t" + "ud2 \n\t" "popfl \n\t" "pushfl \n\t" "popl %0 \n\t" + "ud2 \n\t" "popfl \n\t" : "=&r" (f1), "=&r" (f2) @@ -1089,6 +1091,13 @@ static void clear_all_debug_regs(void) */ #ifdef CONFIG_X86_64 +void assert_EFLAGS_IF(void) +{ + unsigned long eflags = native_save_fl(); + BUG_ON(!(eflags & X86_EFLAGS_IF)); +} + +extern int debug_save_fl; void __cpuinit cpu_init(void) { struct orig_ist *orig_ist; @@ -1187,6 +1196,8 @@ void __cpuinit cpu_init(void) if (is_uv_system()) uv_cpu_init(); + + assert_EFLAGS_IF(); } #else diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index 1db4d2e..fc5b1dd 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@ -400,6 +400,10 @@ ENTRY(ret_from_fork) push $0x0202 CFI_ADJUST_CFA_OFFSET 8 + testq $0x200,(%rsp) + jnz 1f + ud2 +1: popf # reset kernel eflags CFI_ADJUST_CFA_OFFSET -8 @@ -866,6 +870,7 @@ irq_return: #ifdef CONFIG_PARAVIRT ENTRY(native_iret) + ud2 iretq .section __ex_table,"a" @@ -1139,6 +1144,7 @@ gs_change: movl %edi,%gs 2: mfence /* workaround */ SWAPGS + ud2 popf CFI_ADJUST_CFA_OFFSET -8 ret diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 780cd92..2959fb8 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -202,6 +202,7 @@ ENTRY(secondary_startup_64) /* zero EFLAGS after setting rsp */ pushq $0 + ud2 popfq /* diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c index 7b5169d..192462e 100644 --- a/arch/x86/kernel/kprobes.c +++ b/arch/x86/kernel/kprobes.c @@ -634,6 +634,7 @@ static void __used __kprobes kretprobe_trampoline_holder(void) " popq %rdi\n" /* Skip orig_ax, ip, cs */ " addq $24, %rsp\n" + " ud2\n" " popfq\n" #else " pushf\n" diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c index 3f08f34..b6d7cb5 100644 --- a/arch/x86/kernel/paravirt_patch_64.c +++ b/arch/x86/kernel/paravirt_patch_64.c @@ -2,11 +2,11 @@ #include #include -DEF_NATIVE(pv_irq_ops, irq_disable, "cli"); +DEF_NATIVE(pv_irq_ops, irq_disable, "ud2; cli"); DEF_NATIVE(pv_irq_ops, irq_enable, "sti"); -DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; popfq"); +DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; ud2; popfq"); DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax"); -DEF_NATIVE(pv_cpu_ops, iret, "iretq"); +DEF_NATIVE(pv_cpu_ops, iret, "ud2; iretq"); DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax"); DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax"); DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3"); diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index eb62cbc..c9423f7 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -198,6 +198,7 @@ void __show_regs(struct pt_regs *regs, int all) rdmsrl(MSR_FS_BASE, fs); rdmsrl(MSR_GS_BASE, gs); rdmsrl(MSR_KERNEL_GS_BASE, shadowgs); + //shadowgs = gs = fs = 0xdeadbeef; if (!all) return; diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index 4de8f5b..0316441 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -69,6 +69,7 @@ relocate_kernel: /* zero out flags, and disable interrupts */ pushq $0 + ud2 popfq /* @@ -198,6 +199,7 @@ virtual_mapped: movq %r8, %cr0 movq %rbp, %rax + ud2 popf popq %r15 popq %r14 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 565ebc6..4cf0dca 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -266,6 +266,7 @@ static void __cpuinit smp_callin(void) /* * Activate a secondary processor. */ +extern void assert_EFLAGS_IF(void); notrace static void __cpuinit start_secondary(void *unused) { /* @@ -274,7 +275,9 @@ notrace static void __cpuinit start_secondary(void *unused) * most necessary things. */ vmi_bringup(); + assert_EFLAGS_IF(); cpu_init(); + assert_EFLAGS_IF(); preempt_disable(); smp_callin(); diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 7e37dce..ae9393b 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -897,6 +897,8 @@ dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code) } #endif +extern void assert_EFLAGS_IF(void); + void __init trap_init(void) { int i; @@ -967,7 +969,9 @@ void __init trap_init(void) /* * Should be a barrier for any external CPU state: */ + assert_EFLAGS_IF(); cpu_init(); x86_init.irqs.trap_init(); + assert_EFLAGS_IF(); } diff --git a/arch/x86/kernel/verify_cpu_64.S b/arch/x86/kernel/verify_cpu_64.S index 45b6f8a..5b139d8 100644 --- a/arch/x86/kernel/verify_cpu_64.S +++ b/arch/x86/kernel/verify_cpu_64.S @@ -35,6 +35,7 @@ verify_cpu: pushfl # Save caller passed flags pushl $0 # Kill any dangerous flags + ud2 popfl pushfl # standard way to check for cpuid @@ -42,6 +43,7 @@ verify_cpu: movl %eax,%ebx xorl $0x200000,%eax pushl %eax + ud2 popfl pushfl popl %eax @@ -96,10 +98,12 @@ verify_cpu_sse_test: jmp verify_cpu_sse_test # try again verify_cpu_no_longmode: + ud2 popfl # Restore caller passed flags movl $1,%eax ret verify_cpu_sse_ok: + ud2 popfl # Restore caller passed flags xorl %eax, %eax ret diff --git a/arch/x86/lib/cmpxchg8b_emu.S b/arch/x86/lib/cmpxchg8b_emu.S index 828cb71..04f8c29 100644 --- a/arch/x86/lib/cmpxchg8b_emu.S +++ b/arch/x86/lib/cmpxchg8b_emu.S @@ -42,6 +42,7 @@ cmpxchg8b_emu: movl %ebx, (%esi) movl %ecx, 4(%esi) + ud2 popfl ret @@ -50,6 +51,7 @@ cmpxchg8b_emu: half_same: movl 4(%esi), %edx + ud2 popfl ret diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index f4cee90..9810f6d 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -16,6 +16,8 @@ #include /* pgd_*(), ... */ #include /* kmemcheck_*(), ... */ +#include + /* * Page fault error code bits: * @@ -444,7 +446,7 @@ static int bad_address(void *p) return probe_kernel_address((unsigned long *)p, dummy); } -static void dump_pagetable(unsigned long address) +/*static*/ void dump_pagetable(unsigned long address) { pgd_t *base = __va(read_cr3() & PHYSICAL_PAGE_MASK); pgd_t *pgd = base + pgd_index(address); @@ -455,7 +457,9 @@ static void dump_pagetable(unsigned long address) if (bad_address(pgd)) goto bad; - printk("PGD %lx ", pgd_val(*pgd)); + printk("%#lx -> ", address); + printk("CR3 %p/%lx/%lx ", base, read_cr3(), pfn_to_mfn(read_cr3() >> PAGE_SHIFT)); + printk("PGD %lx/%lx ", pgd_val(*pgd), pgd->pgd); if (!pgd_present(*pgd)) goto out; @@ -464,7 +468,7 @@ static void dump_pagetable(unsigned long address) if (bad_address(pud)) goto bad; - printk("PUD %lx ", pud_val(*pud)); + printk("PUD %lx/%lx ", pud_val(*pud), pud->pud); if (!pud_present(*pud) || pud_large(*pud)) goto out; @@ -472,7 +476,7 @@ static void dump_pagetable(unsigned long address) if (bad_address(pmd)) goto bad; - printk("PMD %lx ", pmd_val(*pmd)); + printk("PMD %lx/%lx ", pmd_val(*pmd), pmd->pmd); if (!pmd_present(*pmd) || pmd_large(*pmd)) goto out; @@ -480,7 +484,7 @@ static void dump_pagetable(unsigned long address) if (bad_address(pte)) goto bad; - printk("PTE %lx", pte_val(*pte)); + printk("PTE %lx/%lx", pte_val(*pte), pte->pte); out: printk("\n"); return; @@ -683,6 +687,8 @@ static inline void show_signal_msg(struct pt_regs *regs, unsigned long error_code, unsigned long address, struct task_struct *tsk) { + extern void check_hypercall_page(void); + if (!unhandled_signal(tsk, SIGSEGV)) return; @@ -693,10 +699,18 @@ show_signal_msg(struct pt_regs *regs, unsigned long error_code, task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG, tsk->comm, task_pid_nr(tsk), address, (void *)regs->ip, (void *)regs->sp, error_code); - + printk(KERN_CONT " cs %04lx\n", regs->cs); print_vma_addr(KERN_CONT " in ", regs->ip); printk(KERN_CONT "\n"); + dump_pagetable(address); + dump_stack(); + + check_hypercall_page(); + + die("SEGFAULT", regs, error_code); + + //BUG(); } static void diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 73ffd55..dd823c7 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -14,6 +14,8 @@ #include #include +#include + DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); unsigned long __initdata e820_table_start; @@ -379,9 +381,15 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) void free_initmem(void) { + extern void check_hypercall_page(void); + + check_hypercall_page(); + free_init_pages("unused kernel memory", (unsigned long)(&__init_begin), (unsigned long)(&__init_end)); + + check_hypercall_page(); } #ifdef CONFIG_BLK_DEV_INITRD diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c index 513d8ed..6825cdc 100644 --- a/arch/x86/mm/setup_nx.c +++ b/arch/x86/mm/setup_nx.c @@ -7,7 +7,7 @@ int nx_enabled; #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) -static int disable_nx __cpuinitdata; +static int disable_nx __cpuinitdata = 1; /* * noexec = on|off diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index dfbf70e..dcda2b1 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -113,6 +113,8 @@ static void xen_vcpu_setup(int cpu) printk(KERN_DEBUG "trying to map vcpu_info %d at %p, mfn %llx, offset %d\n", cpu, vcpup, info.mfn, info.offset); + printk(KERN_CRIT "%s: time before change is %#llx\n", __func__, xen_clocksource_read()); + /* Check to see if the hypervisor will put the vcpu_info structure where we want it, which allows direct access via a percpu-variable. */ @@ -128,7 +130,12 @@ static void xen_vcpu_setup(int cpu) printk(KERN_DEBUG "cpu %d using vcpu_info at %p\n", cpu, vcpup); + printk(KERN_CRIT "time pad is 0x%02x%02x\n", + vcpup->time.pad[0], + vcpup->time.pad[1]); + } + printk(KERN_CRIT "%s: time after change is %#llx\n", __func__, xen_clocksource_read()); } /* @@ -857,6 +864,7 @@ void xen_setup_vcpu_info_placement(void) pv_irq_ops.irq_enable = __PV_IS_CALLEE_SAVE(xen_irq_enable_direct); pv_mmu_ops.read_cr2 = xen_read_cr2_direct; } + printk(KERN_CRIT "%s: time after change is %#llx\n", __func__, xen_clocksource_read()); } static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf, @@ -1189,3 +1197,15 @@ asmlinkage void __init xen_start_kernel(void) x86_64_start_reservations((char *)__pa_symbol(&boot_params)); #endif } + +void check_hypercall_page(void) +{ + extern void dump_pagetable(unsigned long address); + //extern unsigned char *hypercall_page; + int i; + printk("SUPPORTED PTE MASK %#lx\n", __supported_pte_mask); + dump_pagetable((unsigned long)&hypercall_page); + for (i=0; i<32; i++) + printk(" %02x", hypercall_page[127]._entry[i] & 0xff); + printk("\n"); +} diff --git a/arch/x86/xen/irq.c b/arch/x86/xen/irq.c index 9d30105..4f2aec5 100644 --- a/arch/x86/xen/irq.c +++ b/arch/x86/xen/irq.c @@ -11,6 +11,8 @@ #include "xen-ops.h" +#include + /* * Force a proper event-channel callback from Xen after clearing the * callback mask. We do this in a very simple manner, by making a call @@ -21,8 +23,11 @@ void xen_force_evtchn_callback(void) (void)HYPERVISOR_xen_version(0, NULL); } +int debug_save_fl = 0; + static unsigned long xen_save_fl(void) { + static int once = 10; struct vcpu_info *vcpu; unsigned long flags; @@ -35,6 +40,11 @@ static unsigned long xen_save_fl(void) -0 -> 0x00000000 -1 -> 0xffffffff */ + if (debug_save_fl && once) { + xen_raw_printk(KERN_CRIT "%s: returning %#lx\n", __func__, + (unsigned long)((-flags) & X86_EFLAGS_IF)); + once--; + } return (-flags) & X86_EFLAGS_IF; } PV_CALLEE_SAVE_REGS_THUNK(xen_save_fl); @@ -77,6 +87,23 @@ static void xen_irq_disable(void) } PV_CALLEE_SAVE_REGS_THUNK(xen_irq_disable); +struct tty_struct; +void sysrq_handle_xen(int key, struct tty_struct *tty) +{ + extern s64 xen_last_timeout; + struct vcpu_info *vcpu; + vcpu = percpu_read(xen_vcpu); + printk(KERN_CRIT "DEBUG\n"); + printk(KERN_CRIT "evtchn_upcall_mask %d\n", vcpu->evtchn_upcall_mask = 0); + printk(KERN_CRIT "last timeout %#llx now %#llx\n", xen_last_timeout, xen_clocksource_read()); + if ( xen_last_timeout < xen_clocksource_read()) + printk(KERN_CRIT "missed an event?\n"); + //printk(KERN_CRIT "tsc is %llx hypervisor says %#lx reread %#llx\n", + // native_read_tsc(), + // (unsigned long)HYPERVISOR_vcpu_op(VCPUOP_read_tsc, 0, NULL), + // native_read_tsc()); +} + static void xen_irq_enable(void) { struct vcpu_info *vcpu; @@ -128,6 +155,7 @@ static const struct pv_irq_ops xen_irq_ops __initdata = { void __init xen_init_irq_ops() { + xen_raw_printk(KERN_CRIT "Register Xen IRQ OPS\n"); pv_irq_ops = xen_irq_ops; x86_init.irqs.intr_init = xen_init_IRQ; } diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index fe03eee..a08b3c0 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c @@ -55,10 +55,12 @@ static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +extern void assert_EFLAGS_IF(void); static __cpuinit void cpu_bringup(void) { int cpu = smp_processor_id(); + assert_EFLAGS_IF(); cpu_init(); touch_softlockup_watchdog(); preempt_disable(); @@ -81,11 +83,13 @@ static __cpuinit void cpu_bringup(void) local_irq_enable(); wmb(); /* make sure everything is out */ + assert_EFLAGS_IF(); } static __cpuinit void cpu_bringup_and_idle(void) { cpu_bringup(); + assert_EFLAGS_IF(); cpu_idle(); } diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index 0a5aa44..51caf89 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -314,6 +314,8 @@ static int xen_timerop_set_next_event(unsigned long delta, { WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT); + printk(KERN_CRIT "%s\n", __func__); + if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0) BUG(); @@ -367,6 +369,8 @@ static void xen_vcpuop_set_mode(enum clock_event_mode mode, } } +s64 xen_last_timeout; + static int xen_vcpuop_set_next_event(unsigned long delta, struct clock_event_device *evt) { @@ -376,9 +380,17 @@ static int xen_vcpuop_set_next_event(unsigned long delta, WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT); - single.timeout_abs_ns = get_abs_timeout(delta); + xen_last_timeout = single.timeout_abs_ns = get_abs_timeout(delta); single.flags = VCPU_SSHOTTMR_future; + if (0) { + printk(KERN_CRIT "%s singleshot at %#llx (%#llx + %#lx)\n", __func__, + single.timeout_abs_ns, xen_clocksource_read(), delta); + printk(KERN_CRIT "%s xen_vcpu->time %#llx\n", __func__, + pvclock_clocksource_read(&per_cpu(xen_vcpu, cpu)->time)); + printk(KERN_CRIT "%s xen_vcpu_info->time %#llx\n", __func__, + pvclock_clocksource_read(&per_cpu(xen_vcpu_info, cpu).time)); + } ret = HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, cpu, &single); BUG_ON(ret != 0 && ret != -ETIME); @@ -410,6 +422,8 @@ static irqreturn_t xen_timer_interrupt(int irq, void *dev_id) struct clock_event_device *evt = &__get_cpu_var(xen_clock_events); irqreturn_t ret; + //printk(KERN_CRIT "TIMER INTERRUPT\n"); + ret = IRQ_NONE; if (evt->event_handler) { evt->event_handler(evt); @@ -480,7 +494,7 @@ __init void xen_time_init(void) clocksource_register(&xen_clocksource); - if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) { + if (/*0 && */HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) { /* Successfully turned off 100Hz tick, so we have the vcpuop-based timer interface */ printk(KERN_DEBUG "Xen: using vcpuop timer interface\n"); diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index 44203ff..fd04f0e 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c @@ -391,6 +391,14 @@ static struct sysrq_key_op sysrq_unrt_op = { .enable_mask = SYSRQ_ENABLE_RTNICE, }; +extern void sysrq_handle_xen(int key, struct tty_struct *tty); + +static struct sysrq_key_op sysrq_xen_op = { + .handler = sysrq_handle_xen, + .help_msg = "Xen(D)", + .action_msg = "Xen debug sysrq", +}; + /* Key Operations table and lock */ static DEFINE_SPINLOCK(sysrq_key_table_lock); @@ -410,7 +418,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = { * a: Don't use for system provided sysrqs, it is handled specially on * sparc and will never arrive. */ - NULL, /* a */ + &sysrq_xen_op, /* a */ &sysrq_reboot_op, /* b */ &sysrq_crash_op, /* c & ibm_emac driver debug */ &sysrq_showlocks_op, /* d */ diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 2f57276..016921e 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -438,6 +438,8 @@ static int bind_virq_to_irq(unsigned int virq, unsigned int cpu) per_cpu(virq_to_irq, cpu)[virq] = irq; bind_evtchn_to_cpu(evtchn, cpu); + if (virq == 0) + printk(KERN_CRIT "EVTCHN%d bound to VIRQ_TIMER\n", evtchn); } spin_unlock(&irq_mapping_update_lock); @@ -509,6 +511,8 @@ int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, int retval; irq = bind_virq_to_irq(virq, cpu); + if (virq == 0) + printk(KERN_CRIT "VIRQ_TIMER is IRQ%d\n", irq); retval = request_irq(irq, handler, irqflags, devname, dev_id); if (retval != 0) { unbind_from_irq(irq); @@ -621,6 +625,8 @@ void xen_evtchn_do_upcall(struct pt_regs *regs) struct vcpu_info *vcpu_info = __get_cpu_var(xen_vcpu); unsigned count; + //printk(KERN_CRIT "upcall on VCPU%d\n", cpu); + exit_idle(); irq_enter(); @@ -646,7 +652,8 @@ void xen_evtchn_do_upcall(struct pt_regs *regs) int bit_idx = __ffs(pending_bits); int port = (word_idx * BITS_PER_LONG) + bit_idx; int irq = evtchn_to_irq[port]; - + if (0 && info_for_irq(irq)->type== IRQT_VIRQ && virq_from_irq(irq) == 0) + printk(KERN_CRIT "upcall on EVTCHN%d, IRQ%d\n", port, irq); if (irq != -1) handle_irq(irq, regs); } diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index d42e25d..1706006 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -919,11 +919,14 @@ static void wait_for_devices(struct xenbus_driver *xendrv) return; while (exists_disconnected_device(drv)) { + printk(KERN_CRIT "xenbus: waiting for devices (%d / %d).\n", jiffies, timeout); if (time_after(jiffies, timeout)) break; schedule_timeout_interruptible(HZ/10); } + printk(KERN_CRIT "xenbus: done waiting\n"); + bus_for_each_dev(&xenbus_frontend.bus, NULL, drv, print_device_status); } diff --git a/include/xen/interface/vcpu.h b/include/xen/interface/vcpu.h index 87e6f8a..3e1cf84 100644 --- a/include/xen/interface/vcpu.h +++ b/include/xen/interface/vcpu.h @@ -170,4 +170,6 @@ struct vcpu_register_vcpu_info { }; DEFINE_GUEST_HANDLE_STRUCT(vcpu_register_vcpu_info); +//#define VCPUOP_read_tsc 99 + #endif /* __XEN_PUBLIC_VCPU_H__ */ diff --git a/init/main.c b/init/main.c index 4051d75..c089648 100644 --- a/init/main.c +++ b/init/main.c @@ -514,11 +514,14 @@ static void __init mm_init(void) vmalloc_init(); } +extern void assert_EFLAGS_IF(void); + asmlinkage void __init start_kernel(void) { char * command_line; extern struct kernel_param __start___param[], __stop___param[]; + assert_EFLAGS_IF(); smp_setup_processor_id(); /* @@ -543,6 +546,7 @@ asmlinkage void __init start_kernel(void) * Interrupts are still disabled. Do necessary setups, then * enable them */ + assert_EFLAGS_IF(); lock_kernel(); tick_init(); boot_cpu_init(); @@ -559,6 +563,7 @@ asmlinkage void __init start_kernel(void) page_alloc_init(); printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line); + assert_EFLAGS_IF(); parse_early_param(); parse_args("Booting kernel", static_command_line, __start___param, __stop___param - __start___param, @@ -570,7 +575,9 @@ asmlinkage void __init start_kernel(void) pidhash_init(); vfs_caches_init_early(); sort_main_extable(); + assert_EFLAGS_IF(); trap_init(); + assert_EFLAGS_IF(); mm_init(); /* * Set up the scheduler prior starting any interrupts (such as the @@ -582,7 +589,9 @@ asmlinkage void __init start_kernel(void) * Disable preemption - early bootup scheduling is extremely * fragile until we cpu_idle() for the first time. */ + assert_EFLAGS_IF(); preempt_disable(); + assert_EFLAGS_IF(); if (!irqs_disabled()) { printk(KERN_WARNING "start_kernel(): bug: interrupts were " "enabled *very* early, fixing it\n"); @@ -599,9 +608,11 @@ asmlinkage void __init start_kernel(void) timekeeping_init(); time_init(); profile_init(); + assert_EFLAGS_IF(); if (!irqs_disabled()) printk(KERN_CRIT "start_kernel(): bug: interrupts were " "enabled early\n"); + assert_EFLAGS_IF(); early_boot_irqs_on(); local_irq_enable(); @@ -609,6 +620,7 @@ asmlinkage void __init start_kernel(void) set_gfp_allowed_mask(__GFP_BITS_MASK); kmem_cache_init_late(); + assert_EFLAGS_IF(); /* * HACK ALERT! This is early. We're enabling the console before @@ -628,6 +640,7 @@ asmlinkage void __init start_kernel(void) */ locking_selftest(); + assert_EFLAGS_IF(); #ifdef CONFIG_BLK_DEV_INITRD if (initrd_start && !initrd_below_start_ok && page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) { @@ -642,6 +655,7 @@ asmlinkage void __init start_kernel(void) enable_debug_pagealloc(); kmemtrace_init(); kmemleak_init(); + assert_EFLAGS_IF(); debug_objects_mem_init(); idr_init_cache(); setup_per_cpu_pageset(); @@ -663,6 +677,7 @@ asmlinkage void __init start_kernel(void) buffer_init(); key_init(); security_init(); + assert_EFLAGS_IF(); vfs_caches_init(totalram_pages); radix_tree_init(); signals_init(); @@ -676,6 +691,7 @@ asmlinkage void __init start_kernel(void) taskstats_init_early(); delayacct_init(); + assert_EFLAGS_IF(); check_bugs(); acpi_early_init(); /* before LAPIC and SMP init */ @@ -685,6 +701,7 @@ asmlinkage void __init start_kernel(void) /* Do the rest non-__init'ed, we're now alive */ rest_init(); + assert_EFLAGS_IF(); } /* Call all constructor functions linked into the kernel. */ @@ -804,6 +821,7 @@ static noinline int init_post(void) __releases(kernel_lock) { /* need to finish all async __init code before freeing the memory */ + assert_EFLAGS_IF(); async_synchronize_full(); free_initmem(); unlock_kernel(); @@ -811,6 +829,7 @@ static noinline int init_post(void) system_state = SYSTEM_RUNNING; numa_default_policy(); + assert_EFLAGS_IF(); if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) printk(KERN_WARNING "Warning: unable to open an initial console.\n"); @@ -846,6 +865,7 @@ static noinline int init_post(void) static int __init kernel_init(void * unused) { + assert_EFLAGS_IF(); lock_kernel(); /* @@ -868,11 +888,13 @@ static int __init kernel_init(void * unused) cad_pid = task_pid(current); + assert_EFLAGS_IF(); smp_prepare_cpus(setup_max_cpus); do_pre_smp_initcalls(); start_boot_trace(); + assert_EFLAGS_IF(); smp_init(); sched_init_smp(); @@ -883,6 +905,7 @@ static int __init kernel_init(void * unused) * the work */ + assert_EFLAGS_IF(); if (!ramdisk_execute_command) ramdisk_execute_command = "/init"; @@ -897,6 +920,7 @@ static int __init kernel_init(void * unused) * initmem segments and start the user-mode stuff.. */ + assert_EFLAGS_IF(); init_post(); return 0; }