diff options
Diffstat (limited to 'xenolinux-2.4.21-pre4-sparse')
4 files changed, 39 insertions, 6 deletions
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/ioport.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/ioport.c index 798c5c5c1f..c43daee3fd 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/ioport.c +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/ioport.c @@ -7,13 +7,30 @@ asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on) { - /* No IO permission! */ - return -EPERM; + /* No IO permission! Selective IO perms aren't virtualised yet. */ + return -EPERM; } asmlinkage int sys_iopl(unsigned long unused) { - /* The hypervisor won't allow it! */ - return -EPERM; + struct pt_regs *regs = (struct pt_regs *)&unused; + unsigned int level = regs->ebx; + unsigned int old = (regs->eflags >> 12) & 3; + + if ( !(start_info.flags & SIF_PRIVILEGED) ) + return -EPERM; + + if ( level > 3 ) + return -EINVAL; + if ( (level > old) && !capable(CAP_SYS_RAWIO) ) + return -EPERM; + + /* Change the one on our stack for sanity's sake. */ + regs->eflags = (regs->eflags & 0xffffcfff) | (level << 12); + + /* Force the change at ring 0. */ + HYPERVISOR_iopl(level); + + return 0; } diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/process.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/process.c index d4db667474..a7c0755d38 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/process.c +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/process.c @@ -363,7 +363,12 @@ void __switch_to(struct task_struct *prev_p, struct task_struct *next_p) } if ( next->esp0 != 0 ) + { queue_multicall2(__HYPERVISOR_stack_switch, __KERNEL_DS, next->esp0); + /* Next call will silently fail if we are a non-privileged guest OS. */ + queue_multicall1(__HYPERVISOR_iopl, + ((((struct pt_regs *)next->esp0)-1)->eflags>>12)&3); + } /* EXECUTE ALL TASK SWITCH XEN SYSCALLS AT THIS POINT. */ execute_multicall_list(); diff --git a/xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor.h b/xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor.h index 935ea3a6ef..887a01b231 100644 --- a/xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor.h +++ b/xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor.h @@ -11,7 +11,7 @@ #include <asm/hypervisor-ifs/hypervisor-if.h> #include <asm/ptrace.h> -#include <asm/page.h> +//#include <asm/page.h> /* arch/xeno/kernel/setup.c */ union start_info_union @@ -353,7 +353,6 @@ static inline int HYPERVISOR_multicall(void *call_list, int nr_calls) return ret; } - static inline long HYPERVISOR_kbd_op(unsigned char op, unsigned char val) { int ret; @@ -365,4 +364,15 @@ static inline long HYPERVISOR_kbd_op(unsigned char op, unsigned char val) return ret; } +static inline long HYPERVISOR_iopl(unsigned int new_iopl) +{ + int ret; + __asm__ __volatile__ ( + TRAP_INSTR + : "=a" (ret) : "0" (__HYPERVISOR_iopl), + "b" (new_iopl) ); + + return ret; +} + #endif /* __HYPERVISOR_H__ */ diff --git a/xenolinux-2.4.21-pre4-sparse/mkbuildtree b/xenolinux-2.4.21-pre4-sparse/mkbuildtree index 8749150889..38f76d7e2b 100755 --- a/xenolinux-2.4.21-pre4-sparse/mkbuildtree +++ b/xenolinux-2.4.21-pre4-sparse/mkbuildtree @@ -23,6 +23,7 @@ rm -f ${D}/mkbuildtree ## subdirectories. # This first symlink is special: it links to shared files in Xen's source tree +rm -f ${D}/include/asm-xeno/hypervisor-ifs ln -sf `pwd`/../xen/include/hypervisor-ifs ${D}/include/asm-xeno/hypervisor-ifs # The remainder are the i386 -> xeno-i386 links |