]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/alpha/kernel/osf_sys.c
sched/headers: Prepare for new header dependencies before moving code to <linux/sched...
[mirror_ubuntu-bionic-kernel.git] / arch / alpha / kernel / osf_sys.c
1 /*
2 * linux/arch/alpha/kernel/osf_sys.c
3 *
4 * Copyright (C) 1995 Linus Torvalds
5 */
6
7 /*
8 * This file handles some of the stranger OSF/1 system call interfaces.
9 * Some of the system calls expect a non-C calling standard, others have
10 * special parameter blocks..
11 */
12
13 #include <linux/errno.h>
14 #include <linux/sched/signal.h>
15 #include <linux/sched/mm.h>
16 #include <linux/sched/task_stack.h>
17 #include <linux/kernel.h>
18 #include <linux/mm.h>
19 #include <linux/smp.h>
20 #include <linux/stddef.h>
21 #include <linux/syscalls.h>
22 #include <linux/unistd.h>
23 #include <linux/ptrace.h>
24 #include <linux/user.h>
25 #include <linux/utsname.h>
26 #include <linux/time.h>
27 #include <linux/timex.h>
28 #include <linux/major.h>
29 #include <linux/stat.h>
30 #include <linux/mman.h>
31 #include <linux/shm.h>
32 #include <linux/poll.h>
33 #include <linux/file.h>
34 #include <linux/types.h>
35 #include <linux/ipc.h>
36 #include <linux/namei.h>
37 #include <linux/uio.h>
38 #include <linux/vfs.h>
39 #include <linux/rcupdate.h>
40 #include <linux/slab.h>
41
42 #include <asm/fpu.h>
43 #include <asm/io.h>
44 #include <linux/uaccess.h>
45 #include <asm/sysinfo.h>
46 #include <asm/thread_info.h>
47 #include <asm/hwrpb.h>
48 #include <asm/processor.h>
49
50 /*
51 * Brk needs to return an error. Still support Linux's brk(0) query idiom,
52 * which OSF programs just shouldn't be doing. We're still not quite
53 * identical to OSF as we don't return 0 on success, but doing otherwise
54 * would require changes to libc. Hopefully this is good enough.
55 */
56 SYSCALL_DEFINE1(osf_brk, unsigned long, brk)
57 {
58 unsigned long retval = sys_brk(brk);
59 if (brk && brk != retval)
60 retval = -ENOMEM;
61 return retval;
62 }
63
64 /*
65 * This is pure guess-work..
66 */
67 SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
68 unsigned long, text_len, unsigned long, bss_start,
69 unsigned long, bss_len)
70 {
71 struct mm_struct *mm;
72
73 mm = current->mm;
74 mm->end_code = bss_start + bss_len;
75 mm->start_brk = bss_start + bss_len;
76 mm->brk = bss_start + bss_len;
77 #if 0
78 printk("set_program_attributes(%lx %lx %lx %lx)\n",
79 text_start, text_len, bss_start, bss_len);
80 #endif
81 return 0;
82 }
83
84 /*
85 * OSF/1 directory handling functions...
86 *
87 * The "getdents()" interface is much more sane: the "basep" stuff is
88 * braindamage (it can't really handle filesystems where the directory
89 * offset differences aren't the same as "d_reclen").
90 */
91 #define NAME_OFFSET offsetof (struct osf_dirent, d_name)
92
93 struct osf_dirent {
94 unsigned int d_ino;
95 unsigned short d_reclen;
96 unsigned short d_namlen;
97 char d_name[1];
98 };
99
100 struct osf_dirent_callback {
101 struct dir_context ctx;
102 struct osf_dirent __user *dirent;
103 long __user *basep;
104 unsigned int count;
105 int error;
106 };
107
108 static int
109 osf_filldir(struct dir_context *ctx, const char *name, int namlen,
110 loff_t offset, u64 ino, unsigned int d_type)
111 {
112 struct osf_dirent __user *dirent;
113 struct osf_dirent_callback *buf =
114 container_of(ctx, struct osf_dirent_callback, ctx);
115 unsigned int reclen = ALIGN(NAME_OFFSET + namlen + 1, sizeof(u32));
116 unsigned int d_ino;
117
118 buf->error = -EINVAL; /* only used if we fail */
119 if (reclen > buf->count)
120 return -EINVAL;
121 d_ino = ino;
122 if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) {
123 buf->error = -EOVERFLOW;
124 return -EOVERFLOW;
125 }
126 if (buf->basep) {
127 if (put_user(offset, buf->basep))
128 goto Efault;
129 buf->basep = NULL;
130 }
131 dirent = buf->dirent;
132 if (put_user(d_ino, &dirent->d_ino) ||
133 put_user(namlen, &dirent->d_namlen) ||
134 put_user(reclen, &dirent->d_reclen) ||
135 copy_to_user(dirent->d_name, name, namlen) ||
136 put_user(0, dirent->d_name + namlen))
137 goto Efault;
138 dirent = (void __user *)dirent + reclen;
139 buf->dirent = dirent;
140 buf->count -= reclen;
141 return 0;
142 Efault:
143 buf->error = -EFAULT;
144 return -EFAULT;
145 }
146
147 SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
148 struct osf_dirent __user *, dirent, unsigned int, count,
149 long __user *, basep)
150 {
151 int error;
152 struct fd arg = fdget_pos(fd);
153 struct osf_dirent_callback buf = {
154 .ctx.actor = osf_filldir,
155 .dirent = dirent,
156 .basep = basep,
157 .count = count
158 };
159
160 if (!arg.file)
161 return -EBADF;
162
163 error = iterate_dir(arg.file, &buf.ctx);
164 if (error >= 0)
165 error = buf.error;
166 if (count != buf.count)
167 error = count - buf.count;
168
169 fdput_pos(arg);
170 return error;
171 }
172
173 #undef NAME_OFFSET
174
175 SYSCALL_DEFINE6(osf_mmap, unsigned long, addr, unsigned long, len,
176 unsigned long, prot, unsigned long, flags, unsigned long, fd,
177 unsigned long, off)
178 {
179 unsigned long ret = -EINVAL;
180
181 #if 0
182 if (flags & (_MAP_HASSEMAPHORE | _MAP_INHERIT | _MAP_UNALIGNED))
183 printk("%s: unimplemented OSF mmap flags %04lx\n",
184 current->comm, flags);
185 #endif
186 if ((off + PAGE_ALIGN(len)) < off)
187 goto out;
188 if (off & ~PAGE_MASK)
189 goto out;
190 ret = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
191 out:
192 return ret;
193 }
194
195 struct osf_stat {
196 int st_dev;
197 int st_pad1;
198 unsigned st_mode;
199 unsigned short st_nlink;
200 short st_nlink_reserved;
201 unsigned st_uid;
202 unsigned st_gid;
203 int st_rdev;
204 int st_ldev;
205 long st_size;
206 int st_pad2;
207 int st_uatime;
208 int st_pad3;
209 int st_umtime;
210 int st_pad4;
211 int st_uctime;
212 int st_pad5;
213 int st_pad6;
214 unsigned st_flags;
215 unsigned st_gen;
216 long st_spare[4];
217 unsigned st_ino;
218 int st_ino_reserved;
219 int st_atime;
220 int st_atime_reserved;
221 int st_mtime;
222 int st_mtime_reserved;
223 int st_ctime;
224 int st_ctime_reserved;
225 long st_blksize;
226 long st_blocks;
227 };
228
229 /*
230 * The OSF/1 statfs structure is much larger, but this should
231 * match the beginning, at least.
232 */
233 struct osf_statfs {
234 short f_type;
235 short f_flags;
236 int f_fsize;
237 int f_bsize;
238 int f_blocks;
239 int f_bfree;
240 int f_bavail;
241 int f_files;
242 int f_ffree;
243 __kernel_fsid_t f_fsid;
244 };
245
246 struct osf_statfs64 {
247 short f_type;
248 short f_flags;
249 int f_pad1;
250 int f_pad2;
251 int f_pad3;
252 int f_pad4;
253 int f_pad5;
254 int f_pad6;
255 int f_pad7;
256 __kernel_fsid_t f_fsid;
257 u_short f_namemax;
258 short f_reserved1;
259 int f_spare[8];
260 char f_pad8[90];
261 char f_pad9[90];
262 long mount_info[10];
263 u_long f_flags2;
264 long f_spare2[14];
265 long f_fsize;
266 long f_bsize;
267 long f_blocks;
268 long f_bfree;
269 long f_bavail;
270 long f_files;
271 long f_ffree;
272 };
273
274 static int
275 linux_to_osf_stat(struct kstat *lstat, struct osf_stat __user *osf_stat)
276 {
277 struct osf_stat tmp = { 0 };
278
279 tmp.st_dev = lstat->dev;
280 tmp.st_mode = lstat->mode;
281 tmp.st_nlink = lstat->nlink;
282 tmp.st_uid = from_kuid_munged(current_user_ns(), lstat->uid);
283 tmp.st_gid = from_kgid_munged(current_user_ns(), lstat->gid);
284 tmp.st_rdev = lstat->rdev;
285 tmp.st_ldev = lstat->rdev;
286 tmp.st_size = lstat->size;
287 tmp.st_uatime = lstat->atime.tv_nsec / 1000;
288 tmp.st_umtime = lstat->mtime.tv_nsec / 1000;
289 tmp.st_uctime = lstat->ctime.tv_nsec / 1000;
290 tmp.st_ino = lstat->ino;
291 tmp.st_atime = lstat->atime.tv_sec;
292 tmp.st_mtime = lstat->mtime.tv_sec;
293 tmp.st_ctime = lstat->ctime.tv_sec;
294 tmp.st_blksize = lstat->blksize;
295 tmp.st_blocks = lstat->blocks;
296
297 return copy_to_user(osf_stat, &tmp, sizeof(tmp)) ? -EFAULT : 0;
298 }
299
300 static int
301 linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_stat,
302 unsigned long bufsiz)
303 {
304 struct osf_statfs tmp_stat;
305
306 tmp_stat.f_type = linux_stat->f_type;
307 tmp_stat.f_flags = 0; /* mount flags */
308 tmp_stat.f_fsize = linux_stat->f_frsize;
309 tmp_stat.f_bsize = linux_stat->f_bsize;
310 tmp_stat.f_blocks = linux_stat->f_blocks;
311 tmp_stat.f_bfree = linux_stat->f_bfree;
312 tmp_stat.f_bavail = linux_stat->f_bavail;
313 tmp_stat.f_files = linux_stat->f_files;
314 tmp_stat.f_ffree = linux_stat->f_ffree;
315 tmp_stat.f_fsid = linux_stat->f_fsid;
316 if (bufsiz > sizeof(tmp_stat))
317 bufsiz = sizeof(tmp_stat);
318 return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
319 }
320
321 static int
322 linux_to_osf_statfs64(struct kstatfs *linux_stat, struct osf_statfs64 __user *osf_stat,
323 unsigned long bufsiz)
324 {
325 struct osf_statfs64 tmp_stat = { 0 };
326
327 tmp_stat.f_type = linux_stat->f_type;
328 tmp_stat.f_fsize = linux_stat->f_frsize;
329 tmp_stat.f_bsize = linux_stat->f_bsize;
330 tmp_stat.f_blocks = linux_stat->f_blocks;
331 tmp_stat.f_bfree = linux_stat->f_bfree;
332 tmp_stat.f_bavail = linux_stat->f_bavail;
333 tmp_stat.f_files = linux_stat->f_files;
334 tmp_stat.f_ffree = linux_stat->f_ffree;
335 tmp_stat.f_fsid = linux_stat->f_fsid;
336 if (bufsiz > sizeof(tmp_stat))
337 bufsiz = sizeof(tmp_stat);
338 return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
339 }
340
341 SYSCALL_DEFINE3(osf_statfs, const char __user *, pathname,
342 struct osf_statfs __user *, buffer, unsigned long, bufsiz)
343 {
344 struct kstatfs linux_stat;
345 int error = user_statfs(pathname, &linux_stat);
346 if (!error)
347 error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
348 return error;
349 }
350
351 SYSCALL_DEFINE2(osf_stat, char __user *, name, struct osf_stat __user *, buf)
352 {
353 struct kstat stat;
354 int error;
355
356 error = vfs_stat(name, &stat);
357 if (error)
358 return error;
359
360 return linux_to_osf_stat(&stat, buf);
361 }
362
363 SYSCALL_DEFINE2(osf_lstat, char __user *, name, struct osf_stat __user *, buf)
364 {
365 struct kstat stat;
366 int error;
367
368 error = vfs_lstat(name, &stat);
369 if (error)
370 return error;
371
372 return linux_to_osf_stat(&stat, buf);
373 }
374
375 SYSCALL_DEFINE2(osf_fstat, int, fd, struct osf_stat __user *, buf)
376 {
377 struct kstat stat;
378 int error;
379
380 error = vfs_fstat(fd, &stat);
381 if (error)
382 return error;
383
384 return linux_to_osf_stat(&stat, buf);
385 }
386
387 SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd,
388 struct osf_statfs __user *, buffer, unsigned long, bufsiz)
389 {
390 struct kstatfs linux_stat;
391 int error = fd_statfs(fd, &linux_stat);
392 if (!error)
393 error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
394 return error;
395 }
396
397 SYSCALL_DEFINE3(osf_statfs64, char __user *, pathname,
398 struct osf_statfs64 __user *, buffer, unsigned long, bufsiz)
399 {
400 struct kstatfs linux_stat;
401 int error = user_statfs(pathname, &linux_stat);
402 if (!error)
403 error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz);
404 return error;
405 }
406
407 SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd,
408 struct osf_statfs64 __user *, buffer, unsigned long, bufsiz)
409 {
410 struct kstatfs linux_stat;
411 int error = fd_statfs(fd, &linux_stat);
412 if (!error)
413 error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz);
414 return error;
415 }
416
417 /*
418 * Uhh.. OSF/1 mount parameters aren't exactly obvious..
419 *
420 * Although to be frank, neither are the native Linux/i386 ones..
421 */
422 struct ufs_args {
423 char __user *devname;
424 int flags;
425 uid_t exroot;
426 };
427
428 struct cdfs_args {
429 char __user *devname;
430 int flags;
431 uid_t exroot;
432
433 /* This has lots more here, which Linux handles with the option block
434 but I'm too lazy to do the translation into ASCII. */
435 };
436
437 struct procfs_args {
438 char __user *devname;
439 int flags;
440 uid_t exroot;
441 };
442
443 /*
444 * We can't actually handle ufs yet, so we translate UFS mounts to
445 * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
446 * layout is so braindead it's a major headache doing it.
447 *
448 * Just how long ago was it written? OTOH our UFS driver may be still
449 * unhappy with OSF UFS. [CHECKME]
450 */
451 static int
452 osf_ufs_mount(const char __user *dirname,
453 struct ufs_args __user *args, int flags)
454 {
455 int retval;
456 struct cdfs_args tmp;
457 struct filename *devname;
458
459 retval = -EFAULT;
460 if (copy_from_user(&tmp, args, sizeof(tmp)))
461 goto out;
462 devname = getname(tmp.devname);
463 retval = PTR_ERR(devname);
464 if (IS_ERR(devname))
465 goto out;
466 retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
467 putname(devname);
468 out:
469 return retval;
470 }
471
472 static int
473 osf_cdfs_mount(const char __user *dirname,
474 struct cdfs_args __user *args, int flags)
475 {
476 int retval;
477 struct cdfs_args tmp;
478 struct filename *devname;
479
480 retval = -EFAULT;
481 if (copy_from_user(&tmp, args, sizeof(tmp)))
482 goto out;
483 devname = getname(tmp.devname);
484 retval = PTR_ERR(devname);
485 if (IS_ERR(devname))
486 goto out;
487 retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
488 putname(devname);
489 out:
490 return retval;
491 }
492
493 static int
494 osf_procfs_mount(const char __user *dirname,
495 struct procfs_args __user *args, int flags)
496 {
497 struct procfs_args tmp;
498
499 if (copy_from_user(&tmp, args, sizeof(tmp)))
500 return -EFAULT;
501
502 return do_mount("", dirname, "proc", flags, NULL);
503 }
504
505 SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
506 int, flag, void __user *, data)
507 {
508 int retval;
509
510 switch (typenr) {
511 case 1:
512 retval = osf_ufs_mount(path, data, flag);
513 break;
514 case 6:
515 retval = osf_cdfs_mount(path, data, flag);
516 break;
517 case 9:
518 retval = osf_procfs_mount(path, data, flag);
519 break;
520 default:
521 retval = -EINVAL;
522 printk("osf_mount(%ld, %x)\n", typenr, flag);
523 }
524
525 return retval;
526 }
527
528 SYSCALL_DEFINE1(osf_utsname, char __user *, name)
529 {
530 int error;
531
532 down_read(&uts_sem);
533 error = -EFAULT;
534 if (copy_to_user(name + 0, utsname()->sysname, 32))
535 goto out;
536 if (copy_to_user(name + 32, utsname()->nodename, 32))
537 goto out;
538 if (copy_to_user(name + 64, utsname()->release, 32))
539 goto out;
540 if (copy_to_user(name + 96, utsname()->version, 32))
541 goto out;
542 if (copy_to_user(name + 128, utsname()->machine, 32))
543 goto out;
544
545 error = 0;
546 out:
547 up_read(&uts_sem);
548 return error;
549 }
550
551 SYSCALL_DEFINE0(getpagesize)
552 {
553 return PAGE_SIZE;
554 }
555
556 SYSCALL_DEFINE0(getdtablesize)
557 {
558 return sysctl_nr_open;
559 }
560
561 /*
562 * For compatibility with OSF/1 only. Use utsname(2) instead.
563 */
564 SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)
565 {
566 unsigned len;
567 int i;
568
569 if (!access_ok(VERIFY_WRITE, name, namelen))
570 return -EFAULT;
571
572 len = namelen;
573 if (len > 32)
574 len = 32;
575
576 down_read(&uts_sem);
577 for (i = 0; i < len; ++i) {
578 __put_user(utsname()->domainname[i], name + i);
579 if (utsname()->domainname[i] == '\0')
580 break;
581 }
582 up_read(&uts_sem);
583
584 return 0;
585 }
586
587 /*
588 * The following stuff should move into a header file should it ever
589 * be labeled "officially supported." Right now, there is just enough
590 * support to avoid applications (such as tar) printing error
591 * messages. The attributes are not really implemented.
592 */
593
594 /*
595 * Values for Property list entry flag
596 */
597 #define PLE_PROPAGATE_ON_COPY 0x1 /* cp(1) will copy entry
598 by default */
599 #define PLE_FLAG_MASK 0x1 /* Valid flag values */
600 #define PLE_FLAG_ALL -1 /* All flag value */
601
602 struct proplistname_args {
603 unsigned int pl_mask;
604 unsigned int pl_numnames;
605 char **pl_names;
606 };
607
608 union pl_args {
609 struct setargs {
610 char __user *path;
611 long follow;
612 long nbytes;
613 char __user *buf;
614 } set;
615 struct fsetargs {
616 long fd;
617 long nbytes;
618 char __user *buf;
619 } fset;
620 struct getargs {
621 char __user *path;
622 long follow;
623 struct proplistname_args __user *name_args;
624 long nbytes;
625 char __user *buf;
626 int __user *min_buf_size;
627 } get;
628 struct fgetargs {
629 long fd;
630 struct proplistname_args __user *name_args;
631 long nbytes;
632 char __user *buf;
633 int __user *min_buf_size;
634 } fget;
635 struct delargs {
636 char __user *path;
637 long follow;
638 struct proplistname_args __user *name_args;
639 } del;
640 struct fdelargs {
641 long fd;
642 struct proplistname_args __user *name_args;
643 } fdel;
644 };
645
646 enum pl_code {
647 PL_SET = 1, PL_FSET = 2,
648 PL_GET = 3, PL_FGET = 4,
649 PL_DEL = 5, PL_FDEL = 6
650 };
651
652 SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
653 union pl_args __user *, args)
654 {
655 long error;
656 int __user *min_buf_size_ptr;
657
658 switch (code) {
659 case PL_SET:
660 if (get_user(error, &args->set.nbytes))
661 error = -EFAULT;
662 break;
663 case PL_FSET:
664 if (get_user(error, &args->fset.nbytes))
665 error = -EFAULT;
666 break;
667 case PL_GET:
668 error = get_user(min_buf_size_ptr, &args->get.min_buf_size);
669 if (error)
670 break;
671 error = put_user(0, min_buf_size_ptr);
672 break;
673 case PL_FGET:
674 error = get_user(min_buf_size_ptr, &args->fget.min_buf_size);
675 if (error)
676 break;
677 error = put_user(0, min_buf_size_ptr);
678 break;
679 case PL_DEL:
680 case PL_FDEL:
681 error = 0;
682 break;
683 default:
684 error = -EOPNOTSUPP;
685 break;
686 };
687 return error;
688 }
689
690 SYSCALL_DEFINE2(osf_sigstack, struct sigstack __user *, uss,
691 struct sigstack __user *, uoss)
692 {
693 unsigned long usp = rdusp();
694 unsigned long oss_sp = current->sas_ss_sp + current->sas_ss_size;
695 unsigned long oss_os = on_sig_stack(usp);
696 int error;
697
698 if (uss) {
699 void __user *ss_sp;
700
701 error = -EFAULT;
702 if (get_user(ss_sp, &uss->ss_sp))
703 goto out;
704
705 /* If the current stack was set with sigaltstack, don't
706 swap stacks while we are on it. */
707 error = -EPERM;
708 if (current->sas_ss_sp && on_sig_stack(usp))
709 goto out;
710
711 /* Since we don't know the extent of the stack, and we don't
712 track onstack-ness, but rather calculate it, we must
713 presume a size. Ho hum this interface is lossy. */
714 current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
715 current->sas_ss_size = SIGSTKSZ;
716 }
717
718 if (uoss) {
719 error = -EFAULT;
720 if (! access_ok(VERIFY_WRITE, uoss, sizeof(*uoss))
721 || __put_user(oss_sp, &uoss->ss_sp)
722 || __put_user(oss_os, &uoss->ss_onstack))
723 goto out;
724 }
725
726 error = 0;
727 out:
728 return error;
729 }
730
731 SYSCALL_DEFINE3(osf_sysinfo, int, command, char __user *, buf, long, count)
732 {
733 const char *sysinfo_table[] = {
734 utsname()->sysname,
735 utsname()->nodename,
736 utsname()->release,
737 utsname()->version,
738 utsname()->machine,
739 "alpha", /* instruction set architecture */
740 "dummy", /* hardware serial number */
741 "dummy", /* hardware manufacturer */
742 "dummy", /* secure RPC domain */
743 };
744 unsigned long offset;
745 const char *res;
746 long len, err = -EINVAL;
747
748 offset = command-1;
749 if (offset >= ARRAY_SIZE(sysinfo_table)) {
750 /* Digital UNIX has a few unpublished interfaces here */
751 printk("sysinfo(%d)", command);
752 goto out;
753 }
754
755 down_read(&uts_sem);
756 res = sysinfo_table[offset];
757 len = strlen(res)+1;
758 if ((unsigned long)len > (unsigned long)count)
759 len = count;
760 if (copy_to_user(buf, res, len))
761 err = -EFAULT;
762 else
763 err = 0;
764 up_read(&uts_sem);
765 out:
766 return err;
767 }
768
769 SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
770 unsigned long, nbytes, int __user *, start, void __user *, arg)
771 {
772 unsigned long w;
773 struct percpu_struct *cpu;
774
775 switch (op) {
776 case GSI_IEEE_FP_CONTROL:
777 /* Return current software fp control & status bits. */
778 /* Note that DU doesn't verify available space here. */
779
780 w = current_thread_info()->ieee_state & IEEE_SW_MASK;
781 w = swcr_update_status(w, rdfpcr());
782 if (put_user(w, (unsigned long __user *) buffer))
783 return -EFAULT;
784 return 0;
785
786 case GSI_IEEE_STATE_AT_SIGNAL:
787 /*
788 * Not sure anybody will ever use this weird stuff. These
789 * ops can be used (under OSF/1) to set the fpcr that should
790 * be used when a signal handler starts executing.
791 */
792 break;
793
794 case GSI_UACPROC:
795 if (nbytes < sizeof(unsigned int))
796 return -EINVAL;
797 w = current_thread_info()->status & UAC_BITMASK;
798 if (put_user(w, (unsigned int __user *)buffer))
799 return -EFAULT;
800 return 1;
801
802 case GSI_PROC_TYPE:
803 if (nbytes < sizeof(unsigned long))
804 return -EINVAL;
805 cpu = (struct percpu_struct*)
806 ((char*)hwrpb + hwrpb->processor_offset);
807 w = cpu->type;
808 if (put_user(w, (unsigned long __user*)buffer))
809 return -EFAULT;
810 return 1;
811
812 case GSI_GET_HWRPB:
813 if (nbytes > sizeof(*hwrpb))
814 return -EINVAL;
815 if (copy_to_user(buffer, hwrpb, nbytes) != 0)
816 return -EFAULT;
817 return 1;
818
819 default:
820 break;
821 }
822
823 return -EOPNOTSUPP;
824 }
825
826 SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
827 unsigned long, nbytes, int __user *, start, void __user *, arg)
828 {
829 switch (op) {
830 case SSI_IEEE_FP_CONTROL: {
831 unsigned long swcr, fpcr;
832 unsigned int *state;
833
834 /*
835 * Alpha Architecture Handbook 4.7.7.3:
836 * To be fully IEEE compiant, we must track the current IEEE
837 * exception state in software, because spurious bits can be
838 * set in the trap shadow of a software-complete insn.
839 */
840
841 if (get_user(swcr, (unsigned long __user *)buffer))
842 return -EFAULT;
843 state = &current_thread_info()->ieee_state;
844
845 /* Update softare trap enable bits. */
846 *state = (*state & ~IEEE_SW_MASK) | (swcr & IEEE_SW_MASK);
847
848 /* Update the real fpcr. */
849 fpcr = rdfpcr() & FPCR_DYN_MASK;
850 fpcr |= ieee_swcr_to_fpcr(swcr);
851 wrfpcr(fpcr);
852
853 return 0;
854 }
855
856 case SSI_IEEE_RAISE_EXCEPTION: {
857 unsigned long exc, swcr, fpcr, fex;
858 unsigned int *state;
859
860 if (get_user(exc, (unsigned long __user *)buffer))
861 return -EFAULT;
862 state = &current_thread_info()->ieee_state;
863 exc &= IEEE_STATUS_MASK;
864
865 /* Update softare trap enable bits. */
866 swcr = (*state & IEEE_SW_MASK) | exc;
867 *state |= exc;
868
869 /* Update the real fpcr. */
870 fpcr = rdfpcr();
871 fpcr |= ieee_swcr_to_fpcr(swcr);
872 wrfpcr(fpcr);
873
874 /* If any exceptions set by this call, and are unmasked,
875 send a signal. Old exceptions are not signaled. */
876 fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr;
877 if (fex) {
878 siginfo_t info;
879 int si_code = 0;
880
881 if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND;
882 if (fex & IEEE_TRAP_ENABLE_INE) si_code = FPE_FLTRES;
883 if (fex & IEEE_TRAP_ENABLE_UNF) si_code = FPE_FLTUND;
884 if (fex & IEEE_TRAP_ENABLE_OVF) si_code = FPE_FLTOVF;
885 if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
886 if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
887
888 info.si_signo = SIGFPE;
889 info.si_errno = 0;
890 info.si_code = si_code;
891 info.si_addr = NULL; /* FIXME */
892 send_sig_info(SIGFPE, &info, current);
893 }
894 return 0;
895 }
896
897 case SSI_IEEE_STATE_AT_SIGNAL:
898 case SSI_IEEE_IGNORE_STATE_AT_SIGNAL:
899 /*
900 * Not sure anybody will ever use this weird stuff. These
901 * ops can be used (under OSF/1) to set the fpcr that should
902 * be used when a signal handler starts executing.
903 */
904 break;
905
906 case SSI_NVPAIRS: {
907 unsigned __user *p = buffer;
908 unsigned i;
909
910 for (i = 0, p = buffer; i < nbytes; ++i, p += 2) {
911 unsigned v, w, status;
912
913 if (get_user(v, p) || get_user(w, p + 1))
914 return -EFAULT;
915 switch (v) {
916 case SSIN_UACPROC:
917 w &= UAC_BITMASK;
918 status = current_thread_info()->status;
919 status = (status & ~UAC_BITMASK) | w;
920 current_thread_info()->status = status;
921 break;
922
923 default:
924 return -EOPNOTSUPP;
925 }
926 }
927 return 0;
928 }
929
930 case SSI_LMF:
931 return 0;
932
933 default:
934 break;
935 }
936
937 return -EOPNOTSUPP;
938 }
939
940 /* Translations due to the fact that OSF's time_t is an int. Which
941 affects all sorts of things, like timeval and itimerval. */
942
943 extern struct timezone sys_tz;
944
945 struct timeval32
946 {
947 int tv_sec, tv_usec;
948 };
949
950 struct itimerval32
951 {
952 struct timeval32 it_interval;
953 struct timeval32 it_value;
954 };
955
956 static inline long
957 get_tv32(struct timeval *o, struct timeval32 __user *i)
958 {
959 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
960 (__get_user(o->tv_sec, &i->tv_sec) |
961 __get_user(o->tv_usec, &i->tv_usec)));
962 }
963
964 static inline long
965 put_tv32(struct timeval32 __user *o, struct timeval *i)
966 {
967 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
968 (__put_user(i->tv_sec, &o->tv_sec) |
969 __put_user(i->tv_usec, &o->tv_usec)));
970 }
971
972 static inline long
973 get_it32(struct itimerval *o, struct itimerval32 __user *i)
974 {
975 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
976 (__get_user(o->it_interval.tv_sec, &i->it_interval.tv_sec) |
977 __get_user(o->it_interval.tv_usec, &i->it_interval.tv_usec) |
978 __get_user(o->it_value.tv_sec, &i->it_value.tv_sec) |
979 __get_user(o->it_value.tv_usec, &i->it_value.tv_usec)));
980 }
981
982 static inline long
983 put_it32(struct itimerval32 __user *o, struct itimerval *i)
984 {
985 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
986 (__put_user(i->it_interval.tv_sec, &o->it_interval.tv_sec) |
987 __put_user(i->it_interval.tv_usec, &o->it_interval.tv_usec) |
988 __put_user(i->it_value.tv_sec, &o->it_value.tv_sec) |
989 __put_user(i->it_value.tv_usec, &o->it_value.tv_usec)));
990 }
991
992 static inline void
993 jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
994 {
995 value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
996 value->tv_sec = jiffies / HZ;
997 }
998
999 SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
1000 struct timezone __user *, tz)
1001 {
1002 if (tv) {
1003 struct timeval ktv;
1004 do_gettimeofday(&ktv);
1005 if (put_tv32(tv, &ktv))
1006 return -EFAULT;
1007 }
1008 if (tz) {
1009 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
1010 return -EFAULT;
1011 }
1012 return 0;
1013 }
1014
1015 SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
1016 struct timezone __user *, tz)
1017 {
1018 struct timespec kts;
1019 struct timezone ktz;
1020
1021 if (tv) {
1022 if (get_tv32((struct timeval *)&kts, tv))
1023 return -EFAULT;
1024 kts.tv_nsec *= 1000;
1025 }
1026 if (tz) {
1027 if (copy_from_user(&ktz, tz, sizeof(*tz)))
1028 return -EFAULT;
1029 }
1030
1031 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
1032 }
1033
1034 asmlinkage long sys_ni_posix_timers(void);
1035
1036 SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it)
1037 {
1038 struct itimerval kit;
1039 int error;
1040
1041 if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
1042 return sys_ni_posix_timers();
1043
1044 error = do_getitimer(which, &kit);
1045 if (!error && put_it32(it, &kit))
1046 error = -EFAULT;
1047
1048 return error;
1049 }
1050
1051 SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in,
1052 struct itimerval32 __user *, out)
1053 {
1054 struct itimerval kin, kout;
1055 int error;
1056
1057 if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
1058 return sys_ni_posix_timers();
1059
1060 if (in) {
1061 if (get_it32(&kin, in))
1062 return -EFAULT;
1063 } else
1064 memset(&kin, 0, sizeof(kin));
1065
1066 error = do_setitimer(which, &kin, out ? &kout : NULL);
1067 if (error || !out)
1068 return error;
1069
1070 if (put_it32(out, &kout))
1071 return -EFAULT;
1072
1073 return 0;
1074
1075 }
1076
1077 SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
1078 struct timeval32 __user *, tvs)
1079 {
1080 struct timespec tv[2];
1081
1082 if (tvs) {
1083 struct timeval ktvs[2];
1084 if (get_tv32(&ktvs[0], &tvs[0]) ||
1085 get_tv32(&ktvs[1], &tvs[1]))
1086 return -EFAULT;
1087
1088 if (ktvs[0].tv_usec < 0 || ktvs[0].tv_usec >= 1000000 ||
1089 ktvs[1].tv_usec < 0 || ktvs[1].tv_usec >= 1000000)
1090 return -EINVAL;
1091
1092 tv[0].tv_sec = ktvs[0].tv_sec;
1093 tv[0].tv_nsec = 1000 * ktvs[0].tv_usec;
1094 tv[1].tv_sec = ktvs[1].tv_sec;
1095 tv[1].tv_nsec = 1000 * ktvs[1].tv_usec;
1096 }
1097
1098 return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0);
1099 }
1100
1101 SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp,
1102 fd_set __user *, exp, struct timeval32 __user *, tvp)
1103 {
1104 struct timespec end_time, *to = NULL;
1105 if (tvp) {
1106 time_t sec, usec;
1107
1108 to = &end_time;
1109
1110 if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp))
1111 || __get_user(sec, &tvp->tv_sec)
1112 || __get_user(usec, &tvp->tv_usec)) {
1113 return -EFAULT;
1114 }
1115
1116 if (sec < 0 || usec < 0)
1117 return -EINVAL;
1118
1119 if (poll_select_set_timeout(to, sec, usec * NSEC_PER_USEC))
1120 return -EINVAL;
1121
1122 }
1123
1124 /* OSF does not copy back the remaining time. */
1125 return core_sys_select(n, inp, outp, exp, to);
1126 }
1127
1128 struct rusage32 {
1129 struct timeval32 ru_utime; /* user time used */
1130 struct timeval32 ru_stime; /* system time used */
1131 long ru_maxrss; /* maximum resident set size */
1132 long ru_ixrss; /* integral shared memory size */
1133 long ru_idrss; /* integral unshared data size */
1134 long ru_isrss; /* integral unshared stack size */
1135 long ru_minflt; /* page reclaims */
1136 long ru_majflt; /* page faults */
1137 long ru_nswap; /* swaps */
1138 long ru_inblock; /* block input operations */
1139 long ru_oublock; /* block output operations */
1140 long ru_msgsnd; /* messages sent */
1141 long ru_msgrcv; /* messages received */
1142 long ru_nsignals; /* signals received */
1143 long ru_nvcsw; /* voluntary context switches */
1144 long ru_nivcsw; /* involuntary " */
1145 };
1146
1147 SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
1148 {
1149 struct rusage32 r;
1150 u64 utime, stime;
1151 unsigned long utime_jiffies, stime_jiffies;
1152
1153 if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
1154 return -EINVAL;
1155
1156 memset(&r, 0, sizeof(r));
1157 switch (who) {
1158 case RUSAGE_SELF:
1159 task_cputime(current, &utime, &stime);
1160 utime_jiffies = nsecs_to_jiffies(utime);
1161 stime_jiffies = nsecs_to_jiffies(stime);
1162 jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
1163 jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
1164 r.ru_minflt = current->min_flt;
1165 r.ru_majflt = current->maj_flt;
1166 break;
1167 case RUSAGE_CHILDREN:
1168 utime_jiffies = nsecs_to_jiffies(current->signal->cutime);
1169 stime_jiffies = nsecs_to_jiffies(current->signal->cstime);
1170 jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
1171 jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
1172 r.ru_minflt = current->signal->cmin_flt;
1173 r.ru_majflt = current->signal->cmaj_flt;
1174 break;
1175 }
1176
1177 return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
1178 }
1179
1180 SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1181 struct rusage32 __user *, ur)
1182 {
1183 struct rusage r;
1184 long ret, err;
1185 unsigned int status = 0;
1186 mm_segment_t old_fs;
1187
1188 if (!ur)
1189 return sys_wait4(pid, ustatus, options, NULL);
1190
1191 old_fs = get_fs();
1192
1193 set_fs (KERNEL_DS);
1194 ret = sys_wait4(pid, (unsigned int __user *) &status, options,
1195 (struct rusage __user *) &r);
1196 set_fs (old_fs);
1197
1198 if (!access_ok(VERIFY_WRITE, ur, sizeof(*ur)))
1199 return -EFAULT;
1200
1201 err = 0;
1202 err |= put_user(status, ustatus);
1203 err |= __put_user(r.ru_utime.tv_sec, &ur->ru_utime.tv_sec);
1204 err |= __put_user(r.ru_utime.tv_usec, &ur->ru_utime.tv_usec);
1205 err |= __put_user(r.ru_stime.tv_sec, &ur->ru_stime.tv_sec);
1206 err |= __put_user(r.ru_stime.tv_usec, &ur->ru_stime.tv_usec);
1207 err |= __put_user(r.ru_maxrss, &ur->ru_maxrss);
1208 err |= __put_user(r.ru_ixrss, &ur->ru_ixrss);
1209 err |= __put_user(r.ru_idrss, &ur->ru_idrss);
1210 err |= __put_user(r.ru_isrss, &ur->ru_isrss);
1211 err |= __put_user(r.ru_minflt, &ur->ru_minflt);
1212 err |= __put_user(r.ru_majflt, &ur->ru_majflt);
1213 err |= __put_user(r.ru_nswap, &ur->ru_nswap);
1214 err |= __put_user(r.ru_inblock, &ur->ru_inblock);
1215 err |= __put_user(r.ru_oublock, &ur->ru_oublock);
1216 err |= __put_user(r.ru_msgsnd, &ur->ru_msgsnd);
1217 err |= __put_user(r.ru_msgrcv, &ur->ru_msgrcv);
1218 err |= __put_user(r.ru_nsignals, &ur->ru_nsignals);
1219 err |= __put_user(r.ru_nvcsw, &ur->ru_nvcsw);
1220 err |= __put_user(r.ru_nivcsw, &ur->ru_nivcsw);
1221
1222 return err ? err : ret;
1223 }
1224
1225 /*
1226 * I don't know what the parameters are: the first one
1227 * seems to be a timeval pointer, and I suspect the second
1228 * one is the time remaining.. Ho humm.. No documentation.
1229 */
1230 SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep,
1231 struct timeval32 __user *, remain)
1232 {
1233 struct timeval tmp;
1234 unsigned long ticks;
1235
1236 if (get_tv32(&tmp, sleep))
1237 goto fault;
1238
1239 ticks = timeval_to_jiffies(&tmp);
1240
1241 ticks = schedule_timeout_interruptible(ticks);
1242
1243 if (remain) {
1244 jiffies_to_timeval(ticks, &tmp);
1245 if (put_tv32(remain, &tmp))
1246 goto fault;
1247 }
1248
1249 return 0;
1250 fault:
1251 return -EFAULT;
1252 }
1253
1254
1255 struct timex32 {
1256 unsigned int modes; /* mode selector */
1257 long offset; /* time offset (usec) */
1258 long freq; /* frequency offset (scaled ppm) */
1259 long maxerror; /* maximum error (usec) */
1260 long esterror; /* estimated error (usec) */
1261 int status; /* clock command/status */
1262 long constant; /* pll time constant */
1263 long precision; /* clock precision (usec) (read only) */
1264 long tolerance; /* clock frequency tolerance (ppm)
1265 * (read only)
1266 */
1267 struct timeval32 time; /* (read only) */
1268 long tick; /* (modified) usecs between clock ticks */
1269
1270 long ppsfreq; /* pps frequency (scaled ppm) (ro) */
1271 long jitter; /* pps jitter (us) (ro) */
1272 int shift; /* interval duration (s) (shift) (ro) */
1273 long stabil; /* pps stability (scaled ppm) (ro) */
1274 long jitcnt; /* jitter limit exceeded (ro) */
1275 long calcnt; /* calibration intervals (ro) */
1276 long errcnt; /* calibration errors (ro) */
1277 long stbcnt; /* stability limit exceeded (ro) */
1278
1279 int :32; int :32; int :32; int :32;
1280 int :32; int :32; int :32; int :32;
1281 int :32; int :32; int :32; int :32;
1282 };
1283
1284 SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
1285 {
1286 struct timex txc;
1287 int ret;
1288
1289 /* copy relevant bits of struct timex. */
1290 if (copy_from_user(&txc, txc_p, offsetof(struct timex32, time)) ||
1291 copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) -
1292 offsetof(struct timex32, time)))
1293 return -EFAULT;
1294
1295 ret = do_adjtimex(&txc);
1296 if (ret < 0)
1297 return ret;
1298
1299 /* copy back to timex32 */
1300 if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
1301 (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) -
1302 offsetof(struct timex32, tick))) ||
1303 (put_tv32(&txc_p->time, &txc.time)))
1304 return -EFAULT;
1305
1306 return ret;
1307 }
1308
1309 /* Get an address range which is currently unmapped. Similar to the
1310 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
1311
1312 static unsigned long
1313 arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
1314 unsigned long limit)
1315 {
1316 struct vm_unmapped_area_info info;
1317
1318 info.flags = 0;
1319 info.length = len;
1320 info.low_limit = addr;
1321 info.high_limit = limit;
1322 info.align_mask = 0;
1323 info.align_offset = 0;
1324 return vm_unmapped_area(&info);
1325 }
1326
1327 unsigned long
1328 arch_get_unmapped_area(struct file *filp, unsigned long addr,
1329 unsigned long len, unsigned long pgoff,
1330 unsigned long flags)
1331 {
1332 unsigned long limit;
1333
1334 /* "32 bit" actually means 31 bit, since pointers sign extend. */
1335 if (current->personality & ADDR_LIMIT_32BIT)
1336 limit = 0x80000000;
1337 else
1338 limit = TASK_SIZE;
1339
1340 if (len > limit)
1341 return -ENOMEM;
1342
1343 if (flags & MAP_FIXED)
1344 return addr;
1345
1346 /* First, see if the given suggestion fits.
1347
1348 The OSF/1 loader (/sbin/loader) relies on us returning an
1349 address larger than the requested if one exists, which is
1350 a terribly broken way to program.
1351
1352 That said, I can see the use in being able to suggest not
1353 merely specific addresses, but regions of memory -- perhaps
1354 this feature should be incorporated into all ports? */
1355
1356 if (addr) {
1357 addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
1358 if (addr != (unsigned long) -ENOMEM)
1359 return addr;
1360 }
1361
1362 /* Next, try allocating at TASK_UNMAPPED_BASE. */
1363 addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
1364 len, limit);
1365 if (addr != (unsigned long) -ENOMEM)
1366 return addr;
1367
1368 /* Finally, try allocating in low memory. */
1369 addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
1370
1371 return addr;
1372 }
1373
1374 #ifdef CONFIG_OSF4_COMPAT
1375
1376 /* Clear top 32 bits of iov_len in the user's buffer for
1377 compatibility with old versions of OSF/1 where iov_len
1378 was defined as int. */
1379 static int
1380 osf_fix_iov_len(const struct iovec __user *iov, unsigned long count)
1381 {
1382 unsigned long i;
1383
1384 for (i = 0 ; i < count ; i++) {
1385 int __user *iov_len_high = (int __user *)&iov[i].iov_len + 1;
1386
1387 if (put_user(0, iov_len_high))
1388 return -EFAULT;
1389 }
1390 return 0;
1391 }
1392
1393 SYSCALL_DEFINE3(osf_readv, unsigned long, fd,
1394 const struct iovec __user *, vector, unsigned long, count)
1395 {
1396 if (unlikely(personality(current->personality) == PER_OSF4))
1397 if (osf_fix_iov_len(vector, count))
1398 return -EFAULT;
1399 return sys_readv(fd, vector, count);
1400 }
1401
1402 SYSCALL_DEFINE3(osf_writev, unsigned long, fd,
1403 const struct iovec __user *, vector, unsigned long, count)
1404 {
1405 if (unlikely(personality(current->personality) == PER_OSF4))
1406 if (osf_fix_iov_len(vector, count))
1407 return -EFAULT;
1408 return sys_writev(fd, vector, count);
1409 }
1410
1411 #endif
1412
1413 SYSCALL_DEFINE2(osf_getpriority, int, which, int, who)
1414 {
1415 int prio = sys_getpriority(which, who);
1416 if (prio >= 0) {
1417 /* Return value is the unbiased priority, i.e. 20 - prio.
1418 This does result in negative return values, so signal
1419 no error */
1420 force_successful_syscall_return();
1421 prio = 20 - prio;
1422 }
1423 return prio;
1424 }
1425
1426 SYSCALL_DEFINE0(getxuid)
1427 {
1428 current_pt_regs()->r20 = sys_geteuid();
1429 return sys_getuid();
1430 }
1431
1432 SYSCALL_DEFINE0(getxgid)
1433 {
1434 current_pt_regs()->r20 = sys_getegid();
1435 return sys_getgid();
1436 }
1437
1438 SYSCALL_DEFINE0(getxpid)
1439 {
1440 current_pt_regs()->r20 = sys_getppid();
1441 return sys_getpid();
1442 }
1443
1444 SYSCALL_DEFINE0(alpha_pipe)
1445 {
1446 int fd[2];
1447 int res = do_pipe_flags(fd, 0);
1448 if (!res) {
1449 /* The return values are in $0 and $20. */
1450 current_pt_regs()->r20 = fd[1];
1451 res = fd[0];
1452 }
1453 return res;
1454 }
1455
1456 SYSCALL_DEFINE1(sethae, unsigned long, val)
1457 {
1458 current_pt_regs()->hae = val;
1459 return 0;
1460 }