New-Syscalls

From Msim

Jump to: navigation, search

This is a preliminary page for upcoming syscall support.

Contents

OSF_SYS_mprotect

A partially supported mprotect can be implemented. We just don't change any protections. Unless benchmarks actually test these conditions we don't have to worry at this point.

       case OSF_SYS_mprotect:
               {
                       warn("partially supported mprotect (no protections changed)");
                       check_error = true;
                       regs->regs_R[MD_REG_V0] = 0;
               }
               break;


OSF_SYS_table (OSF_TBL_PROCINFO)

The OSF_SYS_table syscall on Spec2K always called OSF_TBL_SYSINFO (12) which has been supported. However, it is observed in Spec2K6 that OSF_TBL_PROCINFO (10) is also used quite heavily.

Bugs

In Spec2K, MD_REG_A0 has always been filled with 85 (OSF_SYS_table) causing the arguments to be offset by 1 (A1-A5). However, it should have always be A0-A4. Therefore, if A0 == 85 (which isn't a valid value for OSF_SYS_table anyway) we use A1-A5, otherwise, A0-A4.
These is no apparent reason for why this happens in Spec2K.
New code:

                       //Our version of Spec2K puts OSF_SYS_table in A0 (which shouldn't be...)
                       if(regs->regs_R[MD_REG_A0] == OSF_SYS_table)
                       {
                               table_id = regs->regs_R[MD_REG_A1];
                               table_index = regs->regs_R[MD_REG_A2];
                               buf_addr = regs->regs_R[MD_REG_A3];
                               num_elem = regs->regs_R[MD_REG_A4];
                               size_elem = regs->regs_R[MD_REG_A5];
                       }
                       else
                       {
                               //This is the correct handling
                               table_id = regs->regs_R[MD_REG_A0];
                               table_index = regs->regs_R[MD_REG_A1];
                               buf_addr = regs->regs_R[MD_REG_A2];
                               num_elem = regs->regs_R[MD_REG_A3];
                               size_elem = regs->regs_R[MD_REG_A4];
                       }


Definitions

We need to define the table call (OSF_TBL_PROCINFO) as well as the data structure expected by the simulator.

#define OSF_TBL_PROCINFO        10

As well as the structure (which is 120 bytes on Alpha)

       #define OSF_PI_COMLEN		19	//length of command string
       class osf_tbl_procinfo
       {
       	public:
       		uid_t		pi_uid;		//(effective) user ID
       		pid_t		pi_pid;		//proc ID
       		pid_t		pi_ppid;	//parent proc ID
       		pid_t		pi_pgrp;	//proc group ID
       		uid_t		pi_ttyd;	//controlling terminal number (dev_t is too large linux, use uid_t instead)
       		int		pi_status;	//process status:
       #define OSF_PI_EMPTY		0			//no process
       #define OSF_PI_ACTIVE		1			//active process
       #define OSF_PI_EXITING		2			//exiting
       #define OSF_PI_ZOMBIE		3			//zombie
       		int		pi_flag;	//other random flags
       		char		pi_comm[OSF_PI_COMLEN+1];
       						//short command name
       		uid_t		pi_ruid;	//(real) user ID
       		uid_t		pi_svuid;	//saved (effective) user ID
       		gid_t		pi_rgid;	//(real) group ID
       		gid_t		pi_svgid;	//saved (effective) group ID
       		pid_t		pi_session;	//session ID
       		pid_t		pi_tpgrp;	//tty pgrp
       		pid_t		pi_tsession;	//tty session id
       		u_int		pi_jobc;	//# procs qualifying pgrp for job control
       		int		pi_cursig;
                       //the following are sigset_t (which is "quad" on alpha). Doesn't match well at all on linux
       		sigset_t	pi_sig;		//signals pending
       		sigset_t	pi_sigmask;	//current signal mask
       		sigset_t	pi_sigignore;	//signals being ignored
       		sigset_t	pi_sigcatch;	//signals being caught by user
       };


OSF_SYS_fstat64

The improvisational use of osf_statbuf (as osf_statbuf64) for fstat64 does not work properly.
osf_statbuf64 has been replaced with:

class osf_statbuf64
{
       public:
               word_t                  osf_st_dev;
               word_t                  osf_st_retired1;
               word_t                  osf_st_mode;
               half_t                  osf_st_nlink;
               half_t                  osf_st_nlink_reserved;
               unsigned int            osf_st_uid;
               unsigned int            osf_st_gid;
               word_t                  osf_st_rdev;
               word_t                  osf_st_ldev;
               qword_t                 osf_st_size;

               word_t                  osf_st_retired2;
               word_t                  osf_st_uatime;
               word_t                  osf_st_retired3;
               word_t                  osf_st_umtime;
               word_t                  osf_st_retired4;
               word_t                  osf_st_uctime;

               word_t                  osf_st_retired5;
               word_t                  osf_st_retired6;

               unsigned int            osf_st_flags;
               unsigned int            osf_st_gen;

               long long               osf_st_spare[4];

               word_t                  osf_st_ino;
               word_t                  osf_st_ino_reserved;

               word_t                  osf_st_atime;
               word_t                  osf_st_atime_reserved;
               word_t                  osf_st_mtime;
               word_t                  osf_st_mtime_reserved;
               word_t                  osf_st_ctime;
               word_t                  osf_st_ctime_reserved;

               qword_t                 osf_st_blksize;
               qword_t                 osf_st_blocks;
};
Personal tools