x86_64 patch for OpenSSI - 4 of 6 - x86_64 arch files for OpenSSI
John Hughes <[email protected]> Fri, 12 Feb 2010 16:13:41 +0100
| Newsgroups | gmane.linux.cluster.ssic.devel |
|---|---|
| Message-ID | <[email protected]> |
This patch creates the x86_64 architecture files for OpenSSI.
(cluster/arch/x86_64).
To apply:
1. get the current (12/2/2010) OpenSSI cvs to ./openssi
2. save the patch as ./openssi-x86_64.patch
3. cd ./openssi/kernel
4. Apply the patch:
patch -p0 <../../openssi-x86_64.patch
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
ssic-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ssic-linux-devel
openssi-x86_64.patch
(text/x-patch, 9.5 KB)
Index: cluster/arch/x86_64/vproc/Makefile =================================================================== RCS file: cluster/arch/x86_64/vproc/Makefile diff -N cluster/arch/x86_64/vproc/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ cluster/arch/x86_64/vproc/Makefile 22 Jan 2010 16:12:16 -0000 1.1.3.1.2.2 @@ -0,0 +1,8 @@ +# +# This exists solely to provide the "clean" target. Given the generated +# dependencies, it is simpler to just include the files rather than +# try to build them separately. +# + +include $(CLUSTERDIR)/Rules.make + Index: cluster/arch/x86_64/vproc/rproc_arch.c =================================================================== RCS file: cluster/arch/x86_64/vproc/rproc_arch.c diff -N cluster/arch/x86_64/vproc/rproc_arch.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ cluster/arch/x86_64/vproc/rproc_arch.c 25 Jan 2010 19:23:11 -0000 1.1.3.1.2.4 @@ -0,0 +1,262 @@ +/* + * rproc_arch.c + * Copyright 2001 Compaq Computer Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE + * or NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to [email protected] + * + * x86_64 + */ + +#include <asm/i387.h> +#include <asm/ldt.h> +#include <asm/desc.h> +#include <asm/elf.h> +#include <linux/dpvproc.h> +#include <linux/vmalloc.h> + +/* + * This is included by rproc_cli_pproc.c; it is just easier that way. + */ + +/* + * This special macro can be used to load a debugging register + */ +#define loaddebug(thread,register) \ + __asm__("movq %0,%%db" #register \ + : /* no output */ \ + :"r" ((thread)->debugreg##register)) + +int +rproc_arch_data_load_msg(rvp_full_data *fp, unsigned long stack_start, + unsigned long stack_size, int optype) +{ + struct task_struct *t = current; + rvp_arch_data *ap = &fp->full_arch_data; + + (void)optype; + (void)stack_size; + if (stack_start != 0) { + SSI_ASSERT(RVP_ISRFORK(optype)); + fp->full_regs.arch_pt_regs.rsp = stack_start; + } + unlazy_fpu(t); + savesegment(es, t->thread.es); + savesegment(ds, t->thread.ds); + savesegment(fs, t->thread.fs); + savesegment(gs, t->thread.gs); + ap->arch_thread = t->thread; + if (optype != RVP_MIGRATE_THREAD) + ap->arch_context = t->mm->context; + + return 0; +} + +int +rproc_arch_data_unload_msg(rvp_full_data *fp, + struct arch_regs_stack *regs, + int optype) +{ + struct task_struct *t = current; + rvp_arch_data *ap = &fp->full_arch_data; + int error; + + (void)optype; + *regs = fp->full_regs; + if (optype != RVP_MIGRATE_THREAD && ap->arch_context.size != 0) { + error = copy_ldt(&t->mm->context, &ap->arch_context); + if (error < 0) + return error; + } + load_LDT(&t->mm->context); + array_cpy(t->thread.tls_array, ap->arch_thread.tls_array); + load_TLS(&t->thread, smp_processor_id()); + if (ap->arch_thread.fs) + loadsegment(fs, ap->arch_thread.fs); + if (ap->arch_thread.gs) + loadsegment(gs, ap->arch_thread.gs); + if (tsk_used_math(t)) + t->thread.i387 = ap->arch_thread.i387; + if (ap->arch_thread.debugreg7) { + /* Load current threads debugreg */ + t->thread.debugreg0 = ap->arch_thread.debugreg0; + t->thread.debugreg1 = ap->arch_thread.debugreg0; + t->thread.debugreg2 = ap->arch_thread.debugreg0; + t->thread.debugreg3 = ap->arch_thread.debugreg0; + /* no 4 and 5 */ + t->thread.debugreg6 = ap->arch_thread.debugreg0; + t->thread.debugreg7 = ap->arch_thread.debugreg0; + /* Processor debugreg */ + loaddebug(&t->thread, 0); + loaddebug(&t->thread, 1); + loaddebug(&t->thread, 2); + loaddebug(&t->thread, 3); + /* no 4 and 5 */ + loaddebug(&t->thread, 6); + loaddebug(&t->thread, 7); + } + + return 0; +} + +void +rproc_arch_data_remove_msg(rvp_full_data *fp, + int optype) +{ + (void)fp; + (void)optype; +} + +int +rproc_arch_pproc_cangoremote(int optype) +{ + (void)optype; + /* + * Arch specific things we don't deal with, yet. (And maybe never will.) + * Not sure how this applies to X86_64. Commented out i386 specifics. + * Need to fined out what is needed here for x86_64. + */ + + /* Virtual 8086 */ +// if (current->thread.vm86_info != NULL) +// return -EBUSY; + + /* Direct I/O port access */ +// if (current->thread.io_bitmap_ptr) +// return -EBUSY; + + return 0; +} + +/* Architecture specific glue for syscalls. */ + +asmlinkage long +sys_migrate(clusternode_t node, struct pt_regs *regs) +{ + return dvp_migrate(node, (struct arch_regs_stack *)regs, 0); +} + +asmlinkage long +sys_rfork(clusternode_t node, struct pt_regs *regs) +{ + return dvp_rfork(node, SIGCHLD, regs->rsp, + (struct arch_regs_stack *)regs, 0); +} + +asmlinkage long +sys_rexecve(char __user *filename, char __user * __user *argp, + char __user * __user *envp, clusternode_t node, + struct pt_regs *regs) +{ + int error; + + filename = getname(filename); + error = PTR_ERR(filename); + + if (IS_ERR(filename)) + goto out; + + error = dvp_rexecve(node, filename, argp, envp, regs); + putname(filename); +out: + return error; +} + +long do_ssi_ptrace(long request, long pid, long addr, long data, + int *arch_flags) +{ + (void)arch_flags; + return sys_ptrace(request, pid, addr, data); +} + +bool_t +xdr_mm_context_t(XDR *xdrs, mm_context_t *cp) +{ + int allocsize; + + if (!xdr_arch_int(xdrs, &cp->size)) + return FALSE; + if (!xdr_opaque(xdrs, (void *)&cp->ldt, sizeof(cp->ldt))) + return FALSE; + allocsize = cp->size * LDT_ENTRY_SIZE; + switch (xdrs->x_op) { + case XDR_DECODE: + if (allocsize > 0) { + cp->ldt = kmalloc_nofail(allocsize); + if (!xdr_opaque(xdrs, cp->ldt, allocsize)) + return FALSE; + } else + cp->ldt = NULL; + break; + case XDR_FREE: + kfree(cp->ldt); + cp->ldt = NULL; + break; + case XDR_ENCODE: + if (!xdr_opaque(xdrs, cp->ldt, allocsize)) + return FALSE; + break; + } + + return TRUE; +} + +asmlinkage unsigned long +rproc_get_newsp(void) +{ + /* + * Doing this here is inelegant, but on i386 there is no way to + * easily get this information while writing assembly. + */ + + return current->thread.rsp0 - sizeof(struct pt_regs); +} + +void +ret_from_rexec(struct pt_regs *rp) +{ + /* + * This is simple on i386 because a struct pt_regs and + * struct arch_reg_stack are the same. + */ + ret_from_rproc((struct arch_regs_stack *)rp, 0); +} + +static int +thread_info_load_msg(rvp_thread_info_t *tip, int optype) +{ + struct task_struct *t = current; + + tip->rvp_ti_flags = t->thread_info->flags; + + return 0; +} + +int +thread_info_unload_msg(rvp_thread_info_t *tip, int optype) +{ + struct task_struct *t = current; + + t->thread_info->flags = tip->rvp_ti_flags & + (TIF_SYSCALL_TRACE | TIF_SINGLESTEP | TIF_SYSCALL_AUDIT); + + return 0; +} + +void thread_info_remove_msg(rvp_thread_info_t *tip) +{ +} Index: include/cluster/gen/rproc_arch_x86_64.x =================================================================== RCS file: include/cluster/gen/rproc_arch_x86_64.x diff -N include/cluster/gen/rproc_arch_x86_64.x --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/cluster/gen/rproc_arch_x86_64.x 22 Jan 2010 16:01:19 -0000 1.1.3.1.2.2 @@ -0,0 +1,59 @@ +%/* +% * rproc_arch.x +% * Copyright 2001 Compaq Computer Corporation +% * +% * This program is free software; you can redistribute it and/or +% * modify it under the terms of the GNU General Public License as +% * published by the Free Software Foundation; either version 2 of +% * the License, or (at your option) any later version. +% * +% * This program is distributed in the hope that it will be useful, +% * but WITHOUT ANY WARRANTY; without even the implied warranty of +% * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE +% * or NON INFRINGEMENT. See the GNU General Public License for more +% * details. +% * +% * You should have received a copy of the GNU General Public License +% * along with this program; if not, write to the Free Software +% * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +% * +% * Questions/Comments/Bugfixes to [email protected] +% * +% * x86_64 +% */ + +struct rvp_arch_data { + struct thread_struct arch_thread; + mm_context_t arch_context; +}; + +struct rvp_thread_info_t { + /* task: local only */ + /* exec_domain: setting personality should handle this */ + arch_ulong rvp_ti_flags; + /* status cpu preempt_count: local only */ + /* addr_limit: can only be USER_DS */ + /* restart_block, previous_esp, supervisor_stack: local only */ +}; + +#ifdef RPC_HDR +%extern int thread_info_unload_msg(rvp_thread_info_t *, int); +%extern void thread_info_remove_msg(rvp_thread_info_t *); +%extern bool_t xdr_thread_struct(XDR *, struct thread_struct *); +%extern bool_t xdr_mm_context_t(XDR *, mm_context_t *); +#endif /* RPC_HDR */ + +#ifdef RPC_XDR +%bool_t +%xdr_arch_regs_stack(XDR *xdrs, struct arch_regs_stack *objp) +%{ +% return xdr_opaque(xdrs, (void *)objp, sizeof(*objp)); +%} +% +%bool_t +%xdr_thread_struct(XDR *xdrs, struct thread_struct *objp) +%{ +% return xdr_opaque(xdrs, (void *)objp, sizeof(*objp)); +%} +#endif /* RPC_XDR */ +