[SSI] openssi/kernel/cluster/arch/x86_64/vproc Makefile, NONE, 1.1.4.2 rproc_arch.c, NONE, 1.1.4.2

John Hughes <[email protected]> Sat, 13 Feb 2010 14:36:16 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/arch/x86_64/vproc
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv27428/cluster/arch/x86_64/vproc

Added Files:
      Tag: OPENSSI-FC
	Makefile rproc_arch.c 
Log Message:
Add files needed for x86_64

--- NEW FILE: rproc_arch.c ---
/*
 * 	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)
{
}

--- NEW FILE: Makefile ---
#
# 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



------------------------------------------------------------------------------
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