ia64/xen-unstable
changeset 3073:2befcd58b59b
bitkeeper revision 1.1159.1.439 (419e8535rE43ZEqB5g-cVo09BFHZwQ)
sync w/ head.
sync w/ head.
author | cl349@arcadians.cl.cam.ac.uk |
---|---|
date | Fri Nov 19 23:43:49 2004 +0000 (2004-11-19) |
parents | 32610e557901 296c38890427 |
children | 5c5d3fca4e9b |
files | .rootkeys linux-2.6.9-xen-sparse/arch/xen/i386/kernel/irq.c linux-2.6.9-xen-sparse/arch/xen/kernel/Makefile linux-2.6.9-xen-sparse/arch/xen/kernel/empty.c linux-2.6.9-xen-sparse/arch/xen/kernel/evtchn.c xen/arch/x86/domain.c xen/arch/x86/memory.c xen/arch/x86/setup.c xen/arch/x86/shadow.c xen/arch/x86/traps.c xen/common/physdev.c xen/include/asm-x86/debugger.h xen/include/asm-x86/processor.h xen/include/xen/sched.h |
line diff
1.1 --- a/.rootkeys Thu Nov 18 18:37:24 2004 +0000 1.2 +++ b/.rootkeys Fri Nov 19 23:43:49 2004 +0000 1.3 @@ -171,7 +171,6 @@ 4107adf1WcCgkhsdLTRGX52cOG1vJg linux-2.6 1.4 4107adf1s5u6249DNPUViX1YNagbUQ linux-2.6.9-xen-sparse/arch/xen/i386/pci/irq.c 1.5 40f56239zOksGg_H4XD4ye6iZNtoZA linux-2.6.9-xen-sparse/arch/xen/kernel/Makefile 1.6 40f56239bvOjuuuViZ0XMlNiREFC0A linux-2.6.9-xen-sparse/arch/xen/kernel/ctrl_if.c 1.7 -40f56239pYRq5yshPTkv3ujXKc8K6g linux-2.6.9-xen-sparse/arch/xen/kernel/empty.c 1.8 40f56238xFQe9T7M_U_FItM-bZIpLw linux-2.6.9-xen-sparse/arch/xen/kernel/evtchn.c 1.9 4110f478aeQWllIN7J4kouAHiAqrPw linux-2.6.9-xen-sparse/arch/xen/kernel/fixup.c 1.10 412dfae9eA3_6e6bCGUtg1mj8b56fQ linux-2.6.9-xen-sparse/arch/xen/kernel/gnttab.c
2.1 --- a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/irq.c Thu Nov 18 18:37:24 2004 +0000 2.2 +++ b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/irq.c Fri Nov 19 23:43:49 2004 +0000 2.3 @@ -695,7 +695,6 @@ void free_irq(unsigned int irq, void *de 2.4 p = &desc->action; 2.5 for (;;) { 2.6 struct irqaction * action = *p; 2.7 - 2.8 if (action) { 2.9 struct irqaction **pp = p; 2.10 p = &action->next; 2.11 @@ -757,7 +756,7 @@ unsigned long probe_irq_on(void) 2.12 * something may have generated an irq long ago and we want to 2.13 * flush such a longstanding irq before considering it as spurious. 2.14 */ 2.15 - for (i = NR_PIRQS-1; i > 0; i--) { 2.16 + for (i = NR_IRQS-1; i > 0; i--) { 2.17 desc = irq_desc + i; 2.18 2.19 spin_lock_irq(&desc->lock); 2.20 @@ -775,7 +774,7 @@ unsigned long probe_irq_on(void) 2.21 * (we must startup again here because if a longstanding irq 2.22 * happened in the previous stage, it may have masked itself) 2.23 */ 2.24 - for (i = NR_PIRQS-1; i > 0; i--) { 2.25 + for (i = NR_IRQS-1; i > 0; i--) { 2.26 desc = irq_desc + i; 2.27 2.28 spin_lock_irq(&desc->lock); 2.29 @@ -797,7 +796,7 @@ unsigned long probe_irq_on(void) 2.30 * Now filter out any obviously spurious interrupts 2.31 */ 2.32 val = 0; 2.33 - for (i = 0; i < NR_PIRQS; i++) { 2.34 + for (i = 0; i < NR_IRQS; i++) { 2.35 irq_desc_t *desc = irq_desc + i; 2.36 unsigned int status; 2.37 2.38 @@ -844,7 +843,7 @@ unsigned int probe_irq_mask(unsigned lon 2.39 unsigned int mask; 2.40 2.41 mask = 0; 2.42 - for (i = 0; i < NR_PIRQS; i++) { 2.43 + for (i = 0; i < NR_IRQS; i++) { 2.44 irq_desc_t *desc = irq_desc + i; 2.45 unsigned int status; 2.46 2.47 @@ -894,7 +893,7 @@ int probe_irq_off(unsigned long val) 2.48 2.49 nr_irqs = 0; 2.50 irq_found = 0; 2.51 - for (i = 0; i < NR_PIRQS; i++) { 2.52 + for (i = 0; i < NR_IRQS; i++) { 2.53 irq_desc_t *desc = irq_desc + i; 2.54 unsigned int status; 2.55
3.1 --- a/linux-2.6.9-xen-sparse/arch/xen/kernel/Makefile Thu Nov 18 18:37:24 2004 +0000 3.2 +++ b/linux-2.6.9-xen-sparse/arch/xen/kernel/Makefile Fri Nov 19 23:43:49 2004 +0000 3.3 @@ -9,5 +9,5 @@ XENARCH := $(subst ",,$(CONFIG_XENARCH)) 3.4 3.5 extra-y += vmlinux.lds 3.6 3.7 -obj-y := ctrl_if.o evtchn.o fixup.o reboot.o xen_proc.o empty.o \ 3.8 +obj-y := ctrl_if.o evtchn.o fixup.o reboot.o xen_proc.o \ 3.9 gnttab.o skbuff.o smp.o
4.1 --- a/linux-2.6.9-xen-sparse/arch/xen/kernel/empty.c Thu Nov 18 18:37:24 2004 +0000 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,44 +0,0 @@ 4.4 - 4.5 -#include <linux/string.h> 4.6 -#include <asm-xen/hypervisor.h> 4.7 - 4.8 -#if 0 4.9 -static __inline__ int HYPERVISOR_console_write(const char *str, int count) 4.10 -{ 4.11 - int ret; 4.12 - __asm__ __volatile__ ( 4.13 - TRAP_INSTR 4.14 - : "=a" (ret) : "0" (__HYPERVISOR_console_write), 4.15 - "b" (str), "c" (count) : "memory" ); 4.16 - 4.17 - 4.18 - return ret; 4.19 -} 4.20 -#endif 4.21 - 4.22 -#if 01 4.23 -void 4.24 -xen_puts(const char *str) 4.25 -{ 4.26 - 4.27 - (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(str), (char *)str); 4.28 -} 4.29 - 4.30 -asmlinkage int CLPRINTK(const char *fmt, ...) 4.31 -{ 4.32 - va_list args; 4.33 - int printk_len; 4.34 - static char printk_buf[1024+1]; 4.35 - 4.36 - /* Emit the output into the temporary buffer */ 4.37 - va_start(args, fmt); 4.38 - printk_len = vsnprintf(printk_buf, sizeof(printk_buf)-1, fmt, args); 4.39 - va_end(args); 4.40 - 4.41 - printk_buf[printk_len] = 0; 4.42 - /* Send the processed output directly to Xen. */ 4.43 - (void)HYPERVISOR_console_io(CONSOLEIO_write, printk_len, printk_buf); 4.44 - 4.45 - return 0; 4.46 -} 4.47 -#endif
5.1 --- a/linux-2.6.9-xen-sparse/arch/xen/kernel/evtchn.c Thu Nov 18 18:37:24 2004 +0000 5.2 +++ b/linux-2.6.9-xen-sparse/arch/xen/kernel/evtchn.c Fri Nov 19 23:43:49 2004 +0000 5.3 @@ -75,7 +75,7 @@ static unsigned long pirq_needs_unmask_n 5.4 /* Upcall to generic IRQ layer. */ 5.5 extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs); 5.6 5.7 -#define VALID_EVTCHN(_chn) ((_chn) != -1) 5.8 +#define VALID_EVTCHN(_chn) ((_chn) >= 0) 5.9 5.10 /* 5.11 * Force a proper event-channel callback from Xen after clearing the 5.12 @@ -291,35 +291,51 @@ void unbind_evtchn_from_irq(int evtchn) 5.13 5.14 static unsigned int startup_dynirq(unsigned int irq) 5.15 { 5.16 - unmask_evtchn(irq_to_evtchn[irq]); 5.17 + int evtchn = irq_to_evtchn[irq]; 5.18 + 5.19 + if ( !VALID_EVTCHN(evtchn) ) 5.20 + return 0; 5.21 + unmask_evtchn(evtchn); 5.22 return 0; 5.23 } 5.24 5.25 static void shutdown_dynirq(unsigned int irq) 5.26 { 5.27 - mask_evtchn(irq_to_evtchn[irq]); 5.28 + int evtchn = irq_to_evtchn[irq]; 5.29 + 5.30 + if ( !VALID_EVTCHN(evtchn) ) 5.31 + return; 5.32 + mask_evtchn(evtchn); 5.33 } 5.34 5.35 static void enable_dynirq(unsigned int irq) 5.36 { 5.37 - unmask_evtchn(irq_to_evtchn[irq]); 5.38 + int evtchn = irq_to_evtchn[irq]; 5.39 + 5.40 + unmask_evtchn(evtchn); 5.41 } 5.42 5.43 static void disable_dynirq(unsigned int irq) 5.44 { 5.45 - mask_evtchn(irq_to_evtchn[irq]); 5.46 + int evtchn = irq_to_evtchn[irq]; 5.47 + 5.48 + mask_evtchn(evtchn); 5.49 } 5.50 5.51 static void ack_dynirq(unsigned int irq) 5.52 { 5.53 - mask_evtchn(irq_to_evtchn[irq]); 5.54 - clear_evtchn(irq_to_evtchn[irq]); 5.55 + int evtchn = irq_to_evtchn[irq]; 5.56 + 5.57 + mask_evtchn(evtchn); 5.58 + clear_evtchn(evtchn); 5.59 } 5.60 5.61 static void end_dynirq(unsigned int irq) 5.62 { 5.63 + int evtchn = irq_to_evtchn[irq]; 5.64 + 5.65 if ( !(irq_desc[irq].status & IRQ_DISABLED) ) 5.66 - unmask_evtchn(irq_to_evtchn[irq]); 5.67 + unmask_evtchn(evtchn); 5.68 } 5.69 5.70 static struct hw_interrupt_type dynirq_type = {
6.1 --- a/xen/arch/x86/domain.c Thu Nov 18 18:37:24 2004 +0000 6.2 +++ b/xen/arch/x86/domain.c Fri Nov 19 23:43:49 2004 +0000 6.3 @@ -392,60 +392,23 @@ void switch_to(struct exec_domain *prev_ 6.4 write_ptbase(&next_p->mm); 6.5 } 6.6 6.7 - if ( unlikely(prev_p->domain->io_bitmap != NULL) || 6.8 - unlikely(next_p->domain->io_bitmap != NULL) ) 6.9 + if ( unlikely(prev_p->thread.io_bitmap != NULL) ) 6.10 { 6.11 - if ( next_p->domain->io_bitmap != NULL ) 6.12 - { 6.13 - /* Copy in the appropriate parts of the IO bitmap. We use the 6.14 - * selector to copy only the interesting parts of the bitmap. */ 6.15 - 6.16 - u64 old_sel = ~0ULL; /* IO bitmap selector for previous task. */ 6.17 - 6.18 - if ( prev_p->domain->io_bitmap != NULL) 6.19 - { 6.20 - old_sel = prev_p->domain->io_bitmap_sel; 6.21 - 6.22 - /* Replace any areas of the IO bitmap that had bits cleared. */ 6.23 - for ( i = 0; i < sizeof(prev_p->domain->io_bitmap_sel) * 8; i++ ) 6.24 - if ( !test_bit(i, &prev_p->domain->io_bitmap_sel) ) 6.25 - memcpy(&tss->io_bitmap[i * IOBMP_SELBIT_LWORDS], 6.26 - &next_p->domain->io_bitmap[i * IOBMP_SELBIT_LWORDS], 6.27 - IOBMP_SELBIT_LWORDS * sizeof(unsigned long)); 6.28 - } 6.29 + for ( i = 0; i < sizeof(prev_p->thread.io_bitmap_sel) * 8; i++ ) 6.30 + if ( !test_bit(i, &prev_p->thread.io_bitmap_sel) ) 6.31 + memset(&tss->io_bitmap[i * IOBMP_BYTES_PER_SELBIT], 6.32 + ~0U, IOBMP_BYTES_PER_SELBIT); 6.33 + tss->bitmap = IOBMP_INVALID_OFFSET; 6.34 + } 6.35 6.36 - /* Copy in any regions of the new task's bitmap that have bits 6.37 - * clear and we haven't already dealt with. */ 6.38 - for ( i = 0; i < sizeof(prev_p->domain->io_bitmap_sel) * 8; i++ ) 6.39 - { 6.40 - if ( test_bit(i, &old_sel) 6.41 - && !test_bit(i, &next_p->domain->io_bitmap_sel) ) 6.42 - memcpy(&tss->io_bitmap[i * IOBMP_SELBIT_LWORDS], 6.43 - &next_p->domain->io_bitmap[i * IOBMP_SELBIT_LWORDS], 6.44 - IOBMP_SELBIT_LWORDS * sizeof(unsigned long)); 6.45 - } 6.46 - 6.47 - tss->bitmap = IO_BITMAP_OFFSET; 6.48 - 6.49 - } 6.50 - else 6.51 - { 6.52 - /* In this case, we're switching FROM a task with IO port access, 6.53 - * to a task that doesn't use the IO bitmap. We set any TSS bits 6.54 - * that might have been cleared, ready for future use. */ 6.55 - for ( i = 0; i < sizeof(prev_p->domain->io_bitmap_sel) * 8; i++ ) 6.56 - if ( !test_bit(i, &prev_p->domain->io_bitmap_sel) ) 6.57 - memset(&tss->io_bitmap[i * IOBMP_SELBIT_LWORDS], 6.58 - 0xFF, IOBMP_SELBIT_LWORDS * sizeof(unsigned long)); 6.59 - 6.60 - /* 6.61 - * a bitmap offset pointing outside of the TSS limit 6.62 - * causes a nicely controllable SIGSEGV if a process 6.63 - * tries to use a port IO instruction. The first 6.64 - * sys_ioperm() call sets up the bitmap properly. 6.65 - */ 6.66 - tss->bitmap = INVALID_IO_BITMAP_OFFSET; 6.67 - } 6.68 + if ( unlikely(next_p->thread.io_bitmap != NULL) ) 6.69 + { 6.70 + for ( i = 0; i < sizeof(next_p->thread.io_bitmap_sel) * 8; i++ ) 6.71 + if ( !test_bit(i, &next_p->thread.io_bitmap_sel) ) 6.72 + memcpy(&tss->io_bitmap[i * IOBMP_BYTES_PER_SELBIT], 6.73 + &next_p->thread.io_bitmap[i * IOBMP_BYTES_PER_SELBIT], 6.74 + IOBMP_BYTES_PER_SELBIT); 6.75 + tss->bitmap = IOBMP_OFFSET; 6.76 } 6.77 6.78 set_current(next_p);
7.1 --- a/xen/arch/x86/memory.c Thu Nov 18 18:37:24 2004 +0000 7.2 +++ b/xen/arch/x86/memory.c Fri Nov 19 23:43:49 2004 +0000 7.3 @@ -1846,8 +1846,7 @@ int ptwr_do_page_fault(unsigned long add 7.4 7.5 UNLOCK_BIGLOCK(d); 7.6 7.7 - /* Maybe fall through to shadow mode to propagate writable L1. */ 7.8 - return !current->mm.shadow_mode; 7.9 + return EXCRET_fault_fixed; 7.10 } 7.11 7.12 static __init int ptwr_init(void)
8.1 --- a/xen/arch/x86/setup.c Thu Nov 18 18:37:24 2004 +0000 8.2 +++ b/xen/arch/x86/setup.c Fri Nov 19 23:43:49 2004 +0000 8.3 @@ -268,7 +268,7 @@ void __init cpu_init(void) 8.4 panic("CPU#%d already initialized!!!\n", nr); 8.5 printk("Initializing CPU#%d\n", nr); 8.6 8.7 - t->bitmap = INVALID_IO_BITMAP_OFFSET; 8.8 + t->bitmap = IOBMP_INVALID_OFFSET; 8.9 memset(t->io_bitmap, ~0, sizeof(t->io_bitmap)); 8.10 8.11 /* Set up GDT and IDT. */
9.1 --- a/xen/arch/x86/shadow.c Thu Nov 18 18:37:24 2004 +0000 9.2 +++ b/xen/arch/x86/shadow.c Fri Nov 19 23:43:49 2004 +0000 9.3 @@ -636,7 +636,7 @@ int shadow_fault(unsigned long va, long 9.4 shadow_unlock(m); 9.5 9.6 check_pagetable(m, current->mm.pagetable, "post-sf"); 9.7 - return 1; 9.8 + return EXCRET_fault_fixed; 9.9 } 9.10 9.11
10.1 --- a/xen/arch/x86/traps.c Thu Nov 18 18:37:24 2004 +0000 10.2 +++ b/xen/arch/x86/traps.c Fri Nov 19 23:43:49 2004 +0000 10.3 @@ -228,7 +228,7 @@ asmlinkage void fatal_trap(int trapnr, s 10.4 __asm__ __volatile__ ( "hlt" ); 10.5 } 10.6 10.7 -static inline void do_trap(int trapnr, char *str, 10.8 +static inline int do_trap(int trapnr, char *str, 10.9 struct xen_regs *regs, 10.10 long error_code, int use_error_code) 10.11 { 10.12 @@ -249,7 +249,7 @@ static inline void do_trap(int trapnr, c 10.13 tb->eip = ti->address; 10.14 if ( TI_GET_IF(ti) ) 10.15 ed->vcpu_info->evtchn_upcall_mask = 1; 10.16 - return; 10.17 + return 0; 10.18 10.19 xen_fault: 10.20 10.21 @@ -257,7 +257,7 @@ static inline void do_trap(int trapnr, c 10.22 { 10.23 DPRINTK("Trap %d: %08lx -> %08lx\n", trapnr, regs->eip, fixup); 10.24 regs->eip = fixup; 10.25 - return; 10.26 + return 0; 10.27 } 10.28 10.29 DEBUGGER_trap_fatal(trapnr, regs, error_code); 10.30 @@ -266,18 +266,19 @@ static inline void do_trap(int trapnr, c 10.31 panic("CPU%d FATAL TRAP: vector = %d (%s)\n" 10.32 "[error_code=%08x]\n", 10.33 smp_processor_id(), trapnr, str, error_code); 10.34 + return 0; 10.35 } 10.36 10.37 #define DO_ERROR_NOCODE(trapnr, str, name) \ 10.38 -asmlinkage void do_##name(struct xen_regs * regs, long error_code) \ 10.39 +asmlinkage int do_##name(struct xen_regs * regs, long error_code) \ 10.40 { \ 10.41 - do_trap(trapnr, str, regs, error_code, 0); \ 10.42 + return do_trap(trapnr, str, regs, error_code, 0); \ 10.43 } 10.44 10.45 #define DO_ERROR(trapnr, str, name) \ 10.46 -asmlinkage void do_##name(struct xen_regs * regs, long error_code) \ 10.47 +asmlinkage int do_##name(struct xen_regs * regs, long error_code) \ 10.48 { \ 10.49 - do_trap(trapnr, str, regs, error_code, 1); \ 10.50 + return do_trap(trapnr, str, regs, error_code, 1); \ 10.51 } 10.52 10.53 DO_ERROR_NOCODE( 0, "divide error", divide_error) 10.54 @@ -292,7 +293,7 @@ DO_ERROR_NOCODE(16, "fpu error", coproce 10.55 DO_ERROR(17, "alignment check", alignment_check) 10.56 DO_ERROR_NOCODE(19, "simd error", simd_coprocessor_error) 10.57 10.58 -asmlinkage void do_int3(struct xen_regs *regs, long error_code) 10.59 +asmlinkage int do_int3(struct xen_regs *regs, long error_code) 10.60 { 10.61 struct exec_domain *ed = current; 10.62 struct trap_bounce *tb = &ed->thread.trap_bounce; 10.63 @@ -316,6 +317,8 @@ asmlinkage void do_int3(struct xen_regs 10.64 tb->eip = ti->address; 10.65 if ( TI_GET_IF(ti) ) 10.66 ed->vcpu_info->evtchn_upcall_mask = 1; 10.67 + 10.68 + return 0; 10.69 } 10.70 10.71 asmlinkage void do_double_fault(void) 10.72 @@ -355,7 +358,7 @@ asmlinkage void do_machine_check(struct 10.73 fatal_trap(TRAP_machine_check, regs, error_code); 10.74 } 10.75 10.76 -asmlinkage void do_page_fault(struct xen_regs *regs, long error_code) 10.77 +asmlinkage int do_page_fault(struct xen_regs *regs, long error_code) 10.78 { 10.79 trap_info_t *ti; 10.80 unsigned long off, addr, fixup; 10.81 @@ -381,18 +384,22 @@ asmlinkage void do_page_fault(struct xen 10.82 LOCK_BIGLOCK(d); 10.83 ptwr_flush(PTWR_PT_ACTIVE); 10.84 UNLOCK_BIGLOCK(d); 10.85 - return; 10.86 + return EXCRET_fault_fixed; 10.87 } 10.88 10.89 if ( (addr < PAGE_OFFSET) && 10.90 ((error_code & 3) == 3) && /* write-protection fault */ 10.91 ptwr_do_page_fault(addr) ) 10.92 - return; 10.93 + { 10.94 + if ( unlikely(d->mm.shadow_mode) ) 10.95 + (void)shadow_fault(addr, error_code); 10.96 + return EXCRET_fault_fixed; 10.97 + } 10.98 } 10.99 10.100 if ( unlikely(ed->mm.shadow_mode) && 10.101 (addr < PAGE_OFFSET) && shadow_fault(addr, error_code) ) 10.102 - return; /* Returns TRUE if fault was handled. */ 10.103 + return EXCRET_fault_fixed; 10.104 10.105 if ( unlikely(addr >= LDT_VIRT_START(ed)) && 10.106 (addr < (LDT_VIRT_START(ed) + (ed->mm.ldt_ents*LDT_ENTRY_SIZE))) ) 10.107 @@ -407,7 +414,7 @@ asmlinkage void do_page_fault(struct xen 10.108 ret = map_ldt_shadow_page(off >> PAGE_SHIFT); 10.109 UNLOCK_BIGLOCK(d); 10.110 if ( likely(ret) ) 10.111 - return; /* successfully copied the mapping */ 10.112 + return EXCRET_fault_fixed; /* successfully copied the mapping */ 10.113 } 10.114 10.115 if ( unlikely(!(regs->cs & 3)) ) 10.116 @@ -421,7 +428,7 @@ asmlinkage void do_page_fault(struct xen 10.117 tb->eip = ti->address; 10.118 if ( TI_GET_IF(ti) ) 10.119 ed->vcpu_info->evtchn_upcall_mask = 1; 10.120 - return; 10.121 + return 0; 10.122 10.123 xen_fault: 10.124 10.125 @@ -431,7 +438,7 @@ asmlinkage void do_page_fault(struct xen 10.126 if ( !ed->mm.shadow_mode ) 10.127 DPRINTK("Page fault: %08lx -> %08lx\n", regs->eip, fixup); 10.128 regs->eip = fixup; 10.129 - return; 10.130 + return 0; 10.131 } 10.132 10.133 DEBUGGER_trap_fatal(TRAP_page_fault, regs, error_code); 10.134 @@ -458,9 +465,10 @@ asmlinkage void do_page_fault(struct xen 10.135 "[error_code=%08x]\n" 10.136 "Faulting linear address might be %08lx\n", 10.137 smp_processor_id(), error_code, addr); 10.138 + return 0; 10.139 } 10.140 10.141 -asmlinkage void do_general_protection(struct xen_regs *regs, long error_code) 10.142 +asmlinkage int do_general_protection(struct xen_regs *regs, long error_code) 10.143 { 10.144 struct exec_domain *ed = current; 10.145 struct domain *d = ed->domain; 10.146 @@ -510,7 +518,7 @@ asmlinkage void do_general_protection(st 10.147 if ( VM_ASSIST(d, VMASST_TYPE_4gb_segments) && 10.148 (error_code == 0) && 10.149 gpf_emulate_4gb(regs) ) 10.150 - return; 10.151 + return 0; 10.152 #endif 10.153 10.154 /* Pass on GPF as is. */ 10.155 @@ -522,7 +530,7 @@ asmlinkage void do_general_protection(st 10.156 tb->eip = ti->address; 10.157 if ( TI_GET_IF(ti) ) 10.158 ed->vcpu_info->evtchn_upcall_mask = 1; 10.159 - return; 10.160 + return 0; 10.161 10.162 gp_in_kernel: 10.163 10.164 @@ -530,7 +538,7 @@ asmlinkage void do_general_protection(st 10.165 { 10.166 DPRINTK("GPF (%04lx): %08lx -> %08lx\n", error_code, regs->eip, fixup); 10.167 regs->eip = fixup; 10.168 - return; 10.169 + return 0; 10.170 } 10.171 10.172 DEBUGGER_trap_fatal(TRAP_gp_fault, regs, error_code); 10.173 @@ -538,6 +546,7 @@ asmlinkage void do_general_protection(st 10.174 show_registers(regs); 10.175 panic("CPU%d GENERAL PROTECTION FAULT\n" 10.176 "[error_code=%08x]\n", smp_processor_id(), error_code); 10.177 + return 0; 10.178 } 10.179 10.180 asmlinkage void mem_parity_error(struct xen_regs *regs) 10.181 @@ -557,8 +566,6 @@ asmlinkage void io_check_error(struct xe 10.182 10.183 static void unknown_nmi_error(unsigned char reason, struct xen_regs * regs) 10.184 { 10.185 - DEBUGGER_trap_entry(TRAP_nmi, regs, 0); 10.186 - 10.187 printk("Uhhuh. NMI received for unknown reason %02x.\n", reason); 10.188 printk("Dazed and confused, but trying to continue\n"); 10.189 printk("Do you have a strange power saving mode enabled?\n"); 10.190 @@ -589,7 +596,7 @@ static void nmi_softirq(void) 10.191 send_guest_virq(dom0->exec_domain[0], VIRQ_IO_ERR); 10.192 } 10.193 10.194 -asmlinkage void math_state_restore(struct xen_regs *regs, long error_code) 10.195 +asmlinkage int math_state_restore(struct xen_regs *regs, long error_code) 10.196 { 10.197 /* Prevent recursion. */ 10.198 clts(); 10.199 @@ -610,9 +617,11 @@ asmlinkage void math_state_restore(struc 10.200 tb->cs = current->thread.traps[7].cs; 10.201 tb->eip = current->thread.traps[7].address; 10.202 } 10.203 + 10.204 + return EXCRET_fault_fixed; 10.205 } 10.206 10.207 -asmlinkage void do_debug(struct xen_regs *regs, long error_code) 10.208 +asmlinkage int do_debug(struct xen_regs *regs, long error_code) 10.209 { 10.210 unsigned int condition; 10.211 struct exec_domain *d = current; 10.212 @@ -627,7 +636,7 @@ asmlinkage void do_debug(struct xen_regs 10.213 (d->thread.debugreg[7] == 0) ) 10.214 { 10.215 __asm__("movl %0,%%db7" : : "r" (0)); 10.216 - return; 10.217 + goto out; 10.218 } 10.219 10.220 if ( (regs->cs & 3) == 0 ) 10.221 @@ -640,7 +649,7 @@ asmlinkage void do_debug(struct xen_regs 10.222 * on it. No need to bump EIP; the only faulting trap is an instruction 10.223 * breakpoint, which can't happen to us. 10.224 */ 10.225 - return; 10.226 + goto out; 10.227 } 10.228 10.229 /* Save debug status register where guest OS can peek at it */ 10.230 @@ -649,13 +658,16 @@ asmlinkage void do_debug(struct xen_regs 10.231 tb->flags = TBF_TRAP_NOCODE; 10.232 tb->cs = d->thread.traps[1].cs; 10.233 tb->eip = d->thread.traps[1].address; 10.234 + 10.235 + out: 10.236 + return EXCRET_not_a_fault; 10.237 } 10.238 10.239 - 10.240 -asmlinkage void do_spurious_interrupt_bug(struct xen_regs * regs, 10.241 - long error_code) 10.242 -{ /* nothing */ } 10.243 - 10.244 +asmlinkage int do_spurious_interrupt_bug( 10.245 + struct xen_regs * regs, long error_code) 10.246 +{ 10.247 + return EXCRET_not_a_fault; 10.248 +} 10.249 10.250 #define _set_gate(gate_addr,type,dpl,addr) \ 10.251 do { \ 10.252 @@ -729,7 +741,7 @@ void __init trap_init(void) 10.253 tss->cs = __HYPERVISOR_CS; 10.254 tss->eip = (unsigned long)do_double_fault; 10.255 tss->eflags = 2; 10.256 - tss->bitmap = INVALID_IO_BITMAP_OFFSET; 10.257 + tss->bitmap = IOBMP_INVALID_OFFSET; 10.258 _set_tssldt_desc(gdt_table+__DOUBLEFAULT_TSS_ENTRY, 10.259 (int)tss, 235, 0x89); 10.260
11.1 --- a/xen/common/physdev.c Thu Nov 18 18:37:24 2004 +0000 11.2 +++ b/xen/common/physdev.c Fri Nov 19 23:43:49 2004 +0000 11.3 @@ -169,16 +169,16 @@ int physdev_pci_access_modify( 11.4 11.5 /* Now, setup access to the IO ports and memory regions for the device. */ 11.6 11.7 - if ( p->io_bitmap == NULL ) 11.8 + if ( p->thread.io_bitmap == NULL ) 11.9 { 11.10 - if ( (p->io_bitmap = xmalloc(IO_BITMAP_BYTES)) == NULL ) 11.11 + if ( (p->thread.io_bitmap = xmalloc(IOBMP_BYTES)) == NULL ) 11.12 { 11.13 rc = -ENOMEM; 11.14 goto out; 11.15 } 11.16 - memset(p->io_bitmap, 0xFF, IO_BITMAP_BYTES); 11.17 + memset(p->thread.io_bitmap, 0xFF, IOBMP_BYTES); 11.18 11.19 - p->io_bitmap_sel = ~0ULL; 11.20 + p->thread.io_bitmap_sel = ~0ULL; 11.21 } 11.22 11.23 for ( i = 0; i < DEVICE_COUNT_RESOURCE; i++ ) 11.24 @@ -195,13 +195,8 @@ int physdev_pci_access_modify( 11.25 "for device %s\n", dom, r->start, r->end, pdev->slot_name); 11.26 for ( j = r->start; j < r->end + 1; j++ ) 11.27 { 11.28 - clear_bit(j, p->io_bitmap); 11.29 - /* Record that we cleared a bit using bit n of the selector: 11.30 - * n = (j / (4 bytes in a word * 8 bits in a byte)) 11.31 - * / number of words per selector bit 11.32 - */ 11.33 - clear_bit((j / (8 * 4)) / IOBMP_SELBIT_LWORDS, 11.34 - &p->io_bitmap_sel); 11.35 + clear_bit(j, p->thread.io_bitmap); 11.36 + clear_bit(j / IOBMP_BITS_PER_SELBIT, &p->thread.io_bitmap_sel); 11.37 } 11.38 } 11.39
12.1 --- a/xen/include/asm-x86/debugger.h Thu Nov 18 18:37:24 2004 +0000 12.2 +++ b/xen/include/asm-x86/debugger.h Fri Nov 19 23:43:49 2004 +0000 12.3 @@ -22,33 +22,13 @@ 12.4 #ifndef __X86_DEBUGGER_H__ 12.5 #define __X86_DEBUGGER_H__ 12.6 12.7 -/* Avoid magic vector numbers by using these semi-sensical names. */ 12.8 -#define TRAP_divide_error 0 12.9 -#define TRAP_debug 1 12.10 -#define TRAP_nmi 2 12.11 -#define TRAP_int3 3 12.12 -#define TRAP_overflow 4 12.13 -#define TRAP_bounds 5 12.14 -#define TRAP_invalid_op 6 12.15 -#define TRAP_no_device 7 12.16 -#define TRAP_double_fault 8 12.17 -#define TRAP_copro_seg 9 12.18 -#define TRAP_invalid_tss 10 12.19 -#define TRAP_no_segment 11 12.20 -#define TRAP_stack_error 12 12.21 -#define TRAP_gp_fault 13 12.22 -#define TRAP_page_fault 14 12.23 -#define TRAP_spurious_int 15 12.24 -#define TRAP_copro_error 16 12.25 -#define TRAP_alignment_check 17 12.26 -#define TRAP_machine_check 18 12.27 -#define TRAP_simd_error 19 12.28 +#include <asm/processor.h> 12.29 12.30 /* The main trap handlers use these helper macros which include early bail. */ 12.31 #define DEBUGGER_trap_entry(_v, _r, _e) \ 12.32 - if ( debugger_trap_entry(_v, _r, _e) ) return; 12.33 + if ( debugger_trap_entry(_v, _r, _e) ) return EXCRET_fault_fixed; 12.34 #define DEBUGGER_trap_fatal(_v, _r, _e) \ 12.35 - if ( debugger_trap_fatal(_v, _r, _e) ) return; 12.36 + if ( debugger_trap_fatal(_v, _r, _e) ) return EXCRET_fault_fixed; 12.37 12.38 #ifdef XEN_DEBUGGER 12.39
13.1 --- a/xen/include/asm-x86/processor.h Thu Nov 18 18:37:24 2004 +0000 13.2 +++ b/xen/include/asm-x86/processor.h Fri Nov 19 23:43:49 2004 +0000 13.3 @@ -85,6 +85,39 @@ 13.4 #define X86_CR4_OSXMMEXCPT 0x0400 /* enable unmasked SSE exceptions */ 13.5 13.6 /* 13.7 + * Trap/fault mnemonics. 13.8 + */ 13.9 +#define TRAP_divide_error 0 13.10 +#define TRAP_debug 1 13.11 +#define TRAP_nmi 2 13.12 +#define TRAP_int3 3 13.13 +#define TRAP_overflow 4 13.14 +#define TRAP_bounds 5 13.15 +#define TRAP_invalid_op 6 13.16 +#define TRAP_no_device 7 13.17 +#define TRAP_double_fault 8 13.18 +#define TRAP_copro_seg 9 13.19 +#define TRAP_invalid_tss 10 13.20 +#define TRAP_no_segment 11 13.21 +#define TRAP_stack_error 12 13.22 +#define TRAP_gp_fault 13 13.23 +#define TRAP_page_fault 14 13.24 +#define TRAP_spurious_int 15 13.25 +#define TRAP_copro_error 16 13.26 +#define TRAP_alignment_check 17 13.27 +#define TRAP_machine_check 18 13.28 +#define TRAP_simd_error 19 13.29 + 13.30 +/* 13.31 + * Non-fatal fault/trap handlers return an error code to the caller. If the 13.32 + * code is non-zero, it means that either the exception was not due to a fault 13.33 + * (i.e., it was a trap) or that the fault has been fixed up so the instruction 13.34 + * replay ought to succeed. 13.35 + */ 13.36 +#define EXCRET_not_a_fault 1 /* It was a trap. No instruction replay needed. */ 13.37 +#define EXCRET_fault_fixed 1 /* It was fault that we fixed: try a replay. */ 13.38 + 13.39 +/* 13.40 * 'trap_bounce' flags values. 13.41 */ 13.42 #define TBF_TRAP 1 13.43 @@ -245,15 +278,11 @@ static inline void clear_in_cr4 (unsigne 13.44 :"ax"); 13.45 } 13.46 13.47 -/* 13.48 - * Size of io_bitmap in longwords: 13.49 - * For Xen we support the full 8kbyte IO bitmap but use the io_bitmap_sel field 13.50 - * to avoid a full 8kbyte copy when switching to domains with bits cleared. 13.51 - */ 13.52 -#define IO_BITMAP_SIZE 2048 13.53 -#define IO_BITMAP_BYTES (IO_BITMAP_SIZE * 4) 13.54 -#define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap) 13.55 -#define INVALID_IO_BITMAP_OFFSET 0x8000 13.56 +#define IOBMP_BYTES 8192 13.57 +#define IOBMP_BYTES_PER_SELBIT (IOBMP_BYTES / 64) 13.58 +#define IOBMP_BITS_PER_SELBIT (IOBMP_BYTES_PER_SELBIT * 8) 13.59 +#define IOBMP_OFFSET offsetof(struct tss_struct,io_bitmap) 13.60 +#define IOBMP_INVALID_OFFSET 0x8000 13.61 13.62 struct i387_state { 13.63 u8 state[512]; /* big enough for FXSAVE */ 13.64 @@ -294,9 +323,9 @@ struct tss_struct { 13.65 u16 trace; 13.66 #endif 13.67 u16 bitmap; 13.68 - u32 io_bitmap[IO_BITMAP_SIZE+1]; 13.69 + u8 io_bitmap[IOBMP_BYTES]; 13.70 /* Pads the TSS to be cacheline-aligned (total size is 0x2080). */ 13.71 - u32 __cacheline_filler[5]; 13.72 + u32 __cacheline_filler[6]; 13.73 }; 13.74 13.75 struct trap_bounce { 13.76 @@ -336,6 +365,11 @@ struct thread_struct { 13.77 /* Bounce information for propagating an exception to guest OS. */ 13.78 struct trap_bounce trap_bounce; 13.79 13.80 + /* I/O-port access bitmap. */ 13.81 + u64 io_bitmap_sel; /* Selector to tell us which part of the IO bitmap are 13.82 + * "interesting" (i.e. have clear bits) */ 13.83 + u8 *io_bitmap; /* Pointer to task's IO bitmap or NULL */ 13.84 + 13.85 /* Trap info. */ 13.86 #ifdef __i386__ 13.87 int fast_trap_idx;
14.1 --- a/xen/include/xen/sched.h Thu Nov 18 18:37:24 2004 +0000 14.2 +++ b/xen/include/xen/sched.h Fri Nov 19 23:43:49 2004 +0000 14.3 @@ -137,14 +137,6 @@ struct domain { 14.4 spinlock_t pcidev_lock; 14.5 struct list_head pcidev_list; 14.6 14.7 - /* The following IO bitmap stuff is x86-dependent. */ 14.8 - u64 io_bitmap_sel; /* Selector to tell us which part of the IO bitmap are 14.9 - * "interesting" (i.e. have clear bits) */ 14.10 - 14.11 - /* Handy macro - number of bytes of the IO bitmap, per selector bit. */ 14.12 -#define IOBMP_SELBIT_LWORDS (IO_BITMAP_SIZE / 64) 14.13 - unsigned long *io_bitmap; /* Pointer to task's IO bitmap or NULL */ 14.14 - 14.15 unsigned long d_flags; 14.16 unsigned long vm_assist; 14.17