diff -NaurbB linux-2.4.27/arch/i386/config.in linux-2.4.27_xm/arch/i386/config.in --- linux-2.4.27/arch/i386/config.in 2004-02-18 13:36:30.000000000 +0000 +++ linux-2.4.27_xm/arch/i386/config.in 2004-10-19 19:01:54.000000000 +0000 @@ -266,6 +266,7 @@ mainmenu_option next_comment comment 'General setup' +bool 'XtratuM support' CONFIG_XtratuM bool 'Networking support' CONFIG_NET # Visual Workstation support is utterly broken. diff -NaurbB linux-2.4.27/arch/i386/kernel/entry.S linux-2.4.27_xm/arch/i386/kernel/entry.S --- linux-2.4.27/arch/i386/kernel/entry.S 2003-06-13 14:51:29.000000000 +0000 +++ linux-2.4.27_xm/arch/i386/kernel/entry.S 2004-10-22 01:47:50.000000000 +0000 @@ -184,6 +187,9 @@ ENTRY(ret_from_fork) +#ifdef CONFIG_XtratuM + sti +#endif pushl %ebx call SYMBOL_NAME(schedule_tail) addl $4, %esp @@ -210,17 +216,28 @@ call *SYMBOL_NAME(sys_call_table)(,%eax,4) movl %eax,EAX(%esp) # save the return value ENTRY(ret_from_sys_call) +#ifndef CONFIG_XtratuM cli # need_resched and signals atomic test +#else + call *(SYMBOL_NAME(XtratuM_root_exp_func) + 0) # cli +#endif cmpl $0,need_resched(%ebx) jne reschedule cmpl $0,sigpending(%ebx) jne signal_return restore_all: +#ifdef CONFIG_XtratuM + call *(SYMBOL_NAME(XtratuM_root_exp_func) + 4) # sti +#endif RESTORE_ALL ALIGN signal_return: +#ifndef CONFIG_XtratuM sti # we can get here from an interrupt handler +#else + call *(SYMBOL_NAME(XtratuM_root_exp_func) + 4) # sti +#endif testl $(VM_MASK),EFLAGS(%esp) movl %esp,%eax jne v86_signal_return diff -NaurbB linux-2.4.27/arch/i386/kernel/i386_ksyms.c linux-2.4.27_xm/arch/i386/kernel/i386_ksyms.c --- linux-2.4.27/arch/i386/kernel/i386_ksyms.c 2004-04-14 13:05:25.000000000 +0000 +++ linux-2.4.27_xm/arch/i386/kernel/i386_ksyms.c 2004-10-22 17:00:50.000000000 +0000 @@ -191,3 +191,22 @@ EXPORT_SYMBOL(eddnr); EXPORT_SYMBOL(edd_disk80_sig); #endif + +#ifdef CONFIG_XtratuM +#include +EXPORT_SYMBOL_NOVERS(XtratuM_root_exp_func); +extern struct console *console_drivers; +EXPORT_SYMBOL(console_drivers); +#endif + +// To run RTLINUX +/* +#include +extern unsigned long (*do_gettimeoffset(void)); +EXPORT_SYMBOL_NOVERS(do_gettimeoffset); +extern int use_tsc; +EXPORT_SYMBOL_NOVERS(use_tsc); +EXPORT_SYMBOL_NOVERS(tick); +EXPORT_SYMBOL_NOVERS(kd_mksound); +*/ +// END RTLINUX diff -NaurbB linux-2.4.27/arch/i386/kernel/i8259.c linux-2.4.27_xm/arch/i386/kernel/i8259.c --- linux-2.4.27/arch/i386/kernel/i8259.c 2004-08-07 23:26:04.000000000 +0000 +++ linux-2.4.27_xm/arch/i386/kernel/i8259.c 2004-10-22 17:00:37.000000000 +0000 @@ -132,6 +132,20 @@ spinlock_t i8259A_lock = SPIN_LOCK_UNLOCKED; +#ifdef CONFIG_XtratuM + +#include + +#undef spin_lock_irqsave +#define spin_lock_irqsave(lock, flags) \ + do { actual_save_flags(&flags); actual_cli(); spin_lock(lock); } while (0) + +#undef spin_unlock_irqrestore +#define spin_unlock_irqrestore(lock, flags) \ + do { spin_unlock(lock); actual_restore_flags(flags); } while (0) + +#endif + static void end_8259A_irq (unsigned int irq) { if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) diff -NaurbB linux-2.4.27/arch/i386/kernel/Makefile linux-2.4.27_xm/arch/i386/kernel/Makefile --- linux-2.4.27/arch/i386/kernel/Makefile 2003-11-28 18:26:19.000000000 +0000 +++ linux-2.4.27_xm/arch/i386/kernel/Makefile 2004-10-22 16:58:43.000000000 +0000 @@ -30,6 +30,10 @@ endif endif +ifdef CONFIG_XtratuM +obj-y += XtratuM_root_domain.o +endif + obj-$(CONFIG_MCA) += mca.o obj-$(CONFIG_MTRR) += mtrr.o obj-$(CONFIG_X86_MSR) += msr.o diff -NaurbB linux-2.4.27/arch/i386/kernel/XtratuM_root_domain.c linux-2.4.27_xm/arch/i386/kernel/XtratuM_root_domain.c --- linux-2.4.27/arch/i386/kernel/XtratuM_root_domain.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.4.27_xm/arch/i386/kernel/XtratuM_root_domain.c 2004-10-29 00:39:02.000000000 +0000 @@ -0,0 +1,46 @@ +// XtratuM +// version: 0.1 +// +// (c) 2004, Miguel Masmano +// Released under the terms of GPL License v2 + +#include +#ifdef CONFIG_XtratuM +#include +#include +#include +#include + +void actual_sti (void) { + __asm__ __volatile__("sti": : :"memory"); +} + +void actual_cli (void) { + __asm__ __volatile__("cli": : :"memory"); +} + +void actual_save_flags (unsigned long *flags) { + __asm__ __volatile__("pushfl ; popl %0":"=g" (*flags): /* no input */); +} + +void actual_restore_flags (unsigned long flags) { + __asm__ __volatile__("pushl %0 ; popfl": /* no output */ + :"g" (flags):"memory", "cc"); +} + +extern void ret_from_intr (void); +extern irq_desc_t irq_desc[]; +extern asmlinkage unsigned int do_IRQ (struct pt_regs regs); + +XtratuM_root_exp_func_t XtratuM_root_exp_func = { + xm__cli: actual_cli, + xm__sti: actual_sti, + xm__save_flags: actual_save_flags, + xm__restore_flags: actual_restore_flags, + xm__irq_desc: (void *) irq_desc, + xm__ret_from_intr: (void *) ret_from_intr, + xm__do_IRQ: (void *) do_IRQ, + xm__exiting_from_a_root_process: 0 +}; + +#endif diff -NaurbB linux-2.4.27/arch/i386/mm/fault.c linux-2.4.27_xm/arch/i386/mm/fault.c --- linux-2.4.27/arch/i386/mm/fault.c 2004-08-07 23:26:04.000000000 +0000 +++ linux-2.4.27_xm/arch/i386/mm/fault.c 2004-10-22 17:21:35.000000000 +0000 @@ -25,6 +25,11 @@ #include #include +#include +#ifdef CONFIG_XtratuM +#include +#endif + extern void die(const char *,struct pt_regs *,long); /* @@ -153,7 +158,11 @@ /* It's safe to allow irq's after cr2 has been saved */ if (regs->eflags & X86_EFLAGS_IF) +#ifndef CONFIG_XtratuM local_irq_enable(); +#else + actual_sti(); +#endif tsk = current; diff -NaurbB linux-2.4.27/arch/i386/mm/ioremap.c linux-2.4.27_xm/arch/i386/mm/ioremap.c --- linux-2.4.27/arch/i386/mm/ioremap.c 2003-11-28 18:26:19.000000000 +0000 +++ linux-2.4.27_xm/arch/i386/mm/ioremap.c 2004-10-22 00:39:06.000000000 +0000 @@ -81,6 +81,10 @@ if (remap_area_pmd(pmd, address, end - address, phys_addr + address, flags)) break; +#ifdef CONFIG_XtratuM + set_pgdir(address, *dir); +#endif + error = 0; address = (address + PGDIR_SIZE) & PGDIR_MASK; dir++; diff -NaurbB linux-2.4.27/include/asm-i386/pgalloc.h linux-2.4.27_xm/include/asm-i386/pgalloc.h --- linux-2.4.27/include/asm-i386/pgalloc.h 2003-08-25 11:44:43.000000000 +0000 +++ linux-2.4.27_xm/include/asm-i386/pgalloc.h 2004-10-29 00:49:08.000000000 +0000 @@ -158,6 +158,39 @@ extern int do_check_pgt_cache(int, int); +#ifdef CONFIG_XtratuM + +extern inline void set_pgdir(unsigned long address, pgd_t entry) +{ + struct task_struct * p; + pgd_t *pgd; +#ifdef CONFIG_SMP + int i; +#endif + + read_lock(&tasklist_lock); + for_each_task(p) { + if (!p->mm) + continue; + *pgd_offset(p->mm,address) = entry; + } + read_unlock(&tasklist_lock); +#ifndef CONFIG_SMP + for (pgd = (pgd_t *)pgd_quicklist; pgd; pgd = (pgd_t *)*(unsigned long *)pgd) + pgd[address >> PGDIR_SHIFT] = entry; +#else + /* To pgd_alloc/pgd_free, one holds master kernel lock and so does our c +allee, so we can + modify pgd caches of other CPUs as well. -jj */ + for (i = 0; i < NR_CPUS; i++) + for (pgd = (pgd_t *)cpu_data[i].pgd_quick; pgd; pgd = (pgd_t *)* +(unsigned long *)pgd) + pgd[address >> PGDIR_SHIFT] = entry; +#endif +} + +#endif + /* * TLB flushing: * diff -NaurbB linux-2.4.27/include/asm-i386/system.h linux-2.4.27_xm/include/asm-i386/system.h --- linux-2.4.27/include/asm-i386/system.h 2004-04-14 13:05:40.000000000 +0000 +++ linux-2.4.27_xm/include/asm-i386/system.h 2004-10-29 00:49:08.000000000 +0000 @@ -313,12 +313,26 @@ #define set_wmb(var, value) do { var = value; wmb(); } while (0) /* interrupt control.. */ +#ifndef CONFIG_XtratuM #define __save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */) #define __restore_flags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc") #define __cli() __asm__ __volatile__("cli": : :"memory") #define __sti() __asm__ __volatile__("sti": : :"memory") /* used in the idle loop; sti takes one instruction cycle to complete */ #define safe_halt() __asm__ __volatile__("sti; hlt": : :"memory") +#else +#include +#define __save_flags(x) XtratuM_root_exp_func.xm__save_flags(&x) +#define __restore_flags(x) XtratuM_root_exp_func.xm__restore_flags(x) +#define __cli() XtratuM_root_exp_func.xm__cli() +#define __sti() XtratuM_root_exp_func.xm__sti() +/* used in the idle loop; sti takes one instruction cycle to complete */ +#define safe_halt() \ + do { \ + __asm__ __volatile__("cli; nop; sti; hlt": : :"memory"); \ + XtratuM_root_exp_func.xm__sti(); \ + } while (0) +#endif // CONFIG_XtratuM #define __save_and_cli(x) do { __save_flags(x); __cli(); } while(0); #define __save_and_sti(x) do { __save_flags(x); __sti(); } while(0); diff -NaurbB linux-2.4.27/include/asm-i386/XtratuM_root_domain.h linux-2.4.27_xm/include/asm-i386/XtratuM_root_domain.h --- linux-2.4.27/include/asm-i386/XtratuM_root_domain.h 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.4.27_xm/include/asm-i386/XtratuM_root_domain.h 2004-10-29 00:49:08.000000000 +0000 @@ -0,0 +1,33 @@ +// XtratuM +// version: 0.1 +// +// (c) 2004, Miguel Masmano +// Released under the terms of GPL License v2 + +#include +#ifdef CONFIG_XtratuM +#ifndef _XtratuM_ROOT_DOMAIN_H_ +#define _XtratuM_ROOT_DOMAIN_H_ + +typedef struct XtratuM_root_exp_func_struct { + /* Taking over the IRQ control */ + void (*xm__cli) (void); // Hardcoded (pos + 0) + void (*xm__sti) (void); // Hardcoded (pos + 4) + void (*xm__save_flags) (unsigned long *); // (pos + 8) + void (*xm__restore_flags) (unsigned long); // (pos + 12) + void *xm__irq_desc; // (pos + 16) + void *xm__ret_from_intr; // Hardcoded (pos + 20) + void *xm__do_IRQ; // (pos + 24) + void (*xm__exiting_from_a_root_process) (long); // (pos + 28) +} XtratuM_root_exp_func_t; + +extern XtratuM_root_exp_func_t XtratuM_root_exp_func; + +extern void actual_sti (void); +extern void actual_cli (void); +extern void actual_save_flags (unsigned long *flags); +extern void actual_restore_flags (unsigned long flags); + + +#endif +#endif diff -NaurbB linux-2.4.27/kernel/exit.c linux-2.4.27_xm/kernel/exit.c --- linux-2.4.27/kernel/exit.c 2002-11-28 23:53:15.000000000 +0000 +++ linux-2.4.27_xm/kernel/exit.c 2004-10-29 00:49:58.000000000 +0000 @@ -422,10 +422,20 @@ write_unlock_irq(&tasklist_lock); } +#ifdef CONFIG_XtratuM +#include +#endif + NORET_TYPE void do_exit(long code) { struct task_struct *tsk = current; +#ifdef CONFIG_XtratuM + if (XtratuM_root_exp_func.xm__exiting_from_a_root_process) { + (*XtratuM_root_exp_func.xm__exiting_from_a_root_process) (code); + } +#endif + if (in_interrupt()) panic("Aiee, killing interrupt handler!"); if (!tsk->pid) diff -NaurbB linux-2.4.27/Makefile linux-2.4.27_xm/Makefile --- linux-2.4.27/Makefile 2004-08-07 23:26:07.000000000 +0000 +++ linux-2.4.27_xm/Makefile 2004-10-19 19:00:45.000000000 +0000 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 27 -EXTRAVERSION = +EXTRAVERSION = -XtratuM KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) diff -NaurbB linux-2.4.27/mm/vmalloc.c linux-2.4.27_xm/mm/vmalloc.c --- linux-2.4.27/mm/vmalloc.c 2004-04-14 13:05:41.000000000 +0000 +++ linux-2.4.27_xm/mm/vmalloc.c 2004-10-22 01:03:57.000000000 +0000 @@ -165,6 +165,9 @@ dir = pgd_offset_k(address); spin_lock(&init_mm.page_table_lock); do { +#ifdef CONFIG_XtratuM + pgd_t olddir = *dir; +#endif pmd_t *pmd; pmd = pmd_alloc(&init_mm, dir, address); @@ -173,6 +176,10 @@ if (alloc_area_pmd(pmd, address, end - address, gfp_mask, prot, pages)) goto err; // The kernel NEVER reclaims pmds, so no need to undo pmd_alloc() here +#ifdef CONFIG_XtratuM + if (pgd_val(olddir) != pgd_val(*dir)) + set_pgdir(address,*dir); +#endif address = (address + PGDIR_SIZE) & PGDIR_MASK; dir++;