sys_ppc32.c 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  1. /*
  2. * sys_ppc32.c: Conversion between 32bit and 64bit native syscalls.
  3. *
  4. * Copyright (C) 2001 IBM
  5. * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  6. * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  7. *
  8. * These routines maintain argument size conversion between 32bit and 64bit
  9. * environment.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version
  14. * 2 of the License, or (at your option) any later version.
  15. */
  16. #include <linux/config.h>
  17. #include <linux/kernel.h>
  18. #include <linux/sched.h>
  19. #include <linux/fs.h>
  20. #include <linux/mm.h>
  21. #include <linux/file.h>
  22. #include <linux/signal.h>
  23. #include <linux/resource.h>
  24. #include <linux/times.h>
  25. #include <linux/utsname.h>
  26. #include <linux/timex.h>
  27. #include <linux/smp.h>
  28. #include <linux/smp_lock.h>
  29. #include <linux/sem.h>
  30. #include <linux/msg.h>
  31. #include <linux/shm.h>
  32. #include <linux/poll.h>
  33. #include <linux/personality.h>
  34. #include <linux/stat.h>
  35. #include <linux/mman.h>
  36. #include <linux/in.h>
  37. #include <linux/syscalls.h>
  38. #include <linux/unistd.h>
  39. #include <linux/sysctl.h>
  40. #include <linux/binfmts.h>
  41. #include <linux/security.h>
  42. #include <linux/compat.h>
  43. #include <linux/ptrace.h>
  44. #include <linux/elf.h>
  45. #include <asm/ptrace.h>
  46. #include <asm/types.h>
  47. #include <asm/ipc.h>
  48. #include <asm/uaccess.h>
  49. #include <asm/unistd.h>
  50. #include <asm/semaphore.h>
  51. #include <asm/time.h>
  52. #include <asm/mmu_context.h>
  53. #include <asm/systemcfg.h>
  54. #include "pci.h"
  55. /* readdir & getdents */
  56. #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
  57. #define ROUND_UP(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
  58. struct old_linux_dirent32 {
  59. u32 d_ino;
  60. u32 d_offset;
  61. unsigned short d_namlen;
  62. char d_name[1];
  63. };
  64. struct readdir_callback32 {
  65. struct old_linux_dirent32 __user * dirent;
  66. int count;
  67. };
  68. static int fillonedir(void * __buf, const char * name, int namlen,
  69. off_t offset, ino_t ino, unsigned int d_type)
  70. {
  71. struct readdir_callback32 * buf = (struct readdir_callback32 *) __buf;
  72. struct old_linux_dirent32 __user * dirent;
  73. if (buf->count)
  74. return -EINVAL;
  75. buf->count++;
  76. dirent = buf->dirent;
  77. put_user(ino, &dirent->d_ino);
  78. put_user(offset, &dirent->d_offset);
  79. put_user(namlen, &dirent->d_namlen);
  80. copy_to_user(dirent->d_name, name, namlen);
  81. put_user(0, dirent->d_name + namlen);
  82. return 0;
  83. }
  84. asmlinkage int old32_readdir(unsigned int fd, struct old_linux_dirent32 __user *dirent, unsigned int count)
  85. {
  86. int error = -EBADF;
  87. struct file * file;
  88. struct readdir_callback32 buf;
  89. file = fget(fd);
  90. if (!file)
  91. goto out;
  92. buf.count = 0;
  93. buf.dirent = dirent;
  94. error = vfs_readdir(file, (filldir_t)fillonedir, &buf);
  95. if (error < 0)
  96. goto out_putf;
  97. error = buf.count;
  98. out_putf:
  99. fput(file);
  100. out:
  101. return error;
  102. }
  103. struct linux_dirent32 {
  104. u32 d_ino;
  105. u32 d_off;
  106. unsigned short d_reclen;
  107. char d_name[1];
  108. };
  109. struct getdents_callback32 {
  110. struct linux_dirent32 __user * current_dir;
  111. struct linux_dirent32 __user * previous;
  112. int count;
  113. int error;
  114. };
  115. static int filldir(void * __buf, const char * name, int namlen, off_t offset,
  116. ino_t ino, unsigned int d_type)
  117. {
  118. struct linux_dirent32 __user * dirent;
  119. struct getdents_callback32 * buf = (struct getdents_callback32 *) __buf;
  120. int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 2);
  121. buf->error = -EINVAL; /* only used if we fail.. */
  122. if (reclen > buf->count)
  123. return -EINVAL;
  124. dirent = buf->previous;
  125. if (dirent) {
  126. if (__put_user(offset, &dirent->d_off))
  127. goto efault;
  128. }
  129. dirent = buf->current_dir;
  130. if (__put_user(ino, &dirent->d_ino))
  131. goto efault;
  132. if (__put_user(reclen, &dirent->d_reclen))
  133. goto efault;
  134. if (copy_to_user(dirent->d_name, name, namlen))
  135. goto efault;
  136. if (__put_user(0, dirent->d_name + namlen))
  137. goto efault;
  138. if (__put_user(d_type, (char __user *) dirent + reclen - 1))
  139. goto efault;
  140. buf->previous = dirent;
  141. dirent = (void __user *)dirent + reclen;
  142. buf->current_dir = dirent;
  143. buf->count -= reclen;
  144. return 0;
  145. efault:
  146. buf->error = -EFAULT;
  147. return -EFAULT;
  148. }
  149. asmlinkage long sys32_getdents(unsigned int fd, struct linux_dirent32 __user *dirent,
  150. unsigned int count)
  151. {
  152. struct file * file;
  153. struct linux_dirent32 __user * lastdirent;
  154. struct getdents_callback32 buf;
  155. int error;
  156. error = -EFAULT;
  157. if (!access_ok(VERIFY_WRITE, dirent, count))
  158. goto out;
  159. error = -EBADF;
  160. file = fget(fd);
  161. if (!file)
  162. goto out;
  163. buf.current_dir = dirent;
  164. buf.previous = NULL;
  165. buf.count = count;
  166. buf.error = 0;
  167. error = vfs_readdir(file, (filldir_t)filldir, &buf);
  168. if (error < 0)
  169. goto out_putf;
  170. error = buf.error;
  171. lastdirent = buf.previous;
  172. if (lastdirent) {
  173. if (put_user(file->f_pos, &lastdirent->d_off))
  174. error = -EFAULT;
  175. else
  176. error = count - buf.count;
  177. }
  178. out_putf:
  179. fput(file);
  180. out:
  181. return error;
  182. }
  183. asmlinkage long ppc32_select(u32 n, compat_ulong_t __user *inp,
  184. compat_ulong_t __user *outp, compat_ulong_t __user *exp,
  185. compat_uptr_t tvp_x)
  186. {
  187. /* sign extend n */
  188. return compat_sys_select((int)n, inp, outp, exp, compat_ptr(tvp_x));
  189. }
  190. int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
  191. {
  192. long err;
  193. if (stat->size > MAX_NON_LFS || !new_valid_dev(stat->dev) ||
  194. !new_valid_dev(stat->rdev))
  195. return -EOVERFLOW;
  196. err = access_ok(VERIFY_WRITE, statbuf, sizeof(*statbuf)) ? 0 : -EFAULT;
  197. err |= __put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
  198. err |= __put_user(stat->ino, &statbuf->st_ino);
  199. err |= __put_user(stat->mode, &statbuf->st_mode);
  200. err |= __put_user(stat->nlink, &statbuf->st_nlink);
  201. err |= __put_user(stat->uid, &statbuf->st_uid);
  202. err |= __put_user(stat->gid, &statbuf->st_gid);
  203. err |= __put_user(new_encode_dev(stat->rdev), &statbuf->st_rdev);
  204. err |= __put_user(stat->size, &statbuf->st_size);
  205. err |= __put_user(stat->atime.tv_sec, &statbuf->st_atime);
  206. err |= __put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
  207. err |= __put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
  208. err |= __put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
  209. err |= __put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
  210. err |= __put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
  211. err |= __put_user(stat->blksize, &statbuf->st_blksize);
  212. err |= __put_user(stat->blocks, &statbuf->st_blocks);
  213. err |= __put_user(0, &statbuf->__unused4[0]);
  214. err |= __put_user(0, &statbuf->__unused4[1]);
  215. return err;
  216. }
  217. /* Note: it is necessary to treat option as an unsigned int,
  218. * with the corresponding cast to a signed int to insure that the
  219. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  220. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  221. */
  222. asmlinkage long sys32_sysfs(u32 option, u32 arg1, u32 arg2)
  223. {
  224. return sys_sysfs((int)option, arg1, arg2);
  225. }
  226. /* Handle adjtimex compatibility. */
  227. struct timex32 {
  228. u32 modes;
  229. s32 offset, freq, maxerror, esterror;
  230. s32 status, constant, precision, tolerance;
  231. struct compat_timeval time;
  232. s32 tick;
  233. s32 ppsfreq, jitter, shift, stabil;
  234. s32 jitcnt, calcnt, errcnt, stbcnt;
  235. s32 :32; s32 :32; s32 :32; s32 :32;
  236. s32 :32; s32 :32; s32 :32; s32 :32;
  237. s32 :32; s32 :32; s32 :32; s32 :32;
  238. };
  239. extern int do_adjtimex(struct timex *);
  240. extern void ppc_adjtimex(void);
  241. asmlinkage long sys32_adjtimex(struct timex32 __user *utp)
  242. {
  243. struct timex txc;
  244. int ret;
  245. memset(&txc, 0, sizeof(struct timex));
  246. if(get_user(txc.modes, &utp->modes) ||
  247. __get_user(txc.offset, &utp->offset) ||
  248. __get_user(txc.freq, &utp->freq) ||
  249. __get_user(txc.maxerror, &utp->maxerror) ||
  250. __get_user(txc.esterror, &utp->esterror) ||
  251. __get_user(txc.status, &utp->status) ||
  252. __get_user(txc.constant, &utp->constant) ||
  253. __get_user(txc.precision, &utp->precision) ||
  254. __get_user(txc.tolerance, &utp->tolerance) ||
  255. __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
  256. __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
  257. __get_user(txc.tick, &utp->tick) ||
  258. __get_user(txc.ppsfreq, &utp->ppsfreq) ||
  259. __get_user(txc.jitter, &utp->jitter) ||
  260. __get_user(txc.shift, &utp->shift) ||
  261. __get_user(txc.stabil, &utp->stabil) ||
  262. __get_user(txc.jitcnt, &utp->jitcnt) ||
  263. __get_user(txc.calcnt, &utp->calcnt) ||
  264. __get_user(txc.errcnt, &utp->errcnt) ||
  265. __get_user(txc.stbcnt, &utp->stbcnt))
  266. return -EFAULT;
  267. ret = do_adjtimex(&txc);
  268. /* adjust the conversion of TB to time of day to track adjtimex */
  269. ppc_adjtimex();
  270. if(put_user(txc.modes, &utp->modes) ||
  271. __put_user(txc.offset, &utp->offset) ||
  272. __put_user(txc.freq, &utp->freq) ||
  273. __put_user(txc.maxerror, &utp->maxerror) ||
  274. __put_user(txc.esterror, &utp->esterror) ||
  275. __put_user(txc.status, &utp->status) ||
  276. __put_user(txc.constant, &utp->constant) ||
  277. __put_user(txc.precision, &utp->precision) ||
  278. __put_user(txc.tolerance, &utp->tolerance) ||
  279. __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
  280. __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
  281. __put_user(txc.tick, &utp->tick) ||
  282. __put_user(txc.ppsfreq, &utp->ppsfreq) ||
  283. __put_user(txc.jitter, &utp->jitter) ||
  284. __put_user(txc.shift, &utp->shift) ||
  285. __put_user(txc.stabil, &utp->stabil) ||
  286. __put_user(txc.jitcnt, &utp->jitcnt) ||
  287. __put_user(txc.calcnt, &utp->calcnt) ||
  288. __put_user(txc.errcnt, &utp->errcnt) ||
  289. __put_user(txc.stbcnt, &utp->stbcnt))
  290. ret = -EFAULT;
  291. return ret;
  292. }
  293. asmlinkage long sys32_pause(void)
  294. {
  295. current->state = TASK_INTERRUPTIBLE;
  296. schedule();
  297. return -ERESTARTNOHAND;
  298. }
  299. static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i)
  300. {
  301. long usec;
  302. if (!access_ok(VERIFY_READ, i, sizeof(*i)))
  303. return -EFAULT;
  304. if (__get_user(o->tv_sec, &i->tv_sec))
  305. return -EFAULT;
  306. if (__get_user(usec, &i->tv_usec))
  307. return -EFAULT;
  308. o->tv_nsec = usec * 1000;
  309. return 0;
  310. }
  311. static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
  312. {
  313. return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
  314. (__put_user(i->tv_sec, &o->tv_sec) |
  315. __put_user(i->tv_usec, &o->tv_usec)));
  316. }
  317. struct sysinfo32 {
  318. s32 uptime;
  319. u32 loads[3];
  320. u32 totalram;
  321. u32 freeram;
  322. u32 sharedram;
  323. u32 bufferram;
  324. u32 totalswap;
  325. u32 freeswap;
  326. unsigned short procs;
  327. unsigned short pad;
  328. u32 totalhigh;
  329. u32 freehigh;
  330. u32 mem_unit;
  331. char _f[20-2*sizeof(int)-sizeof(int)];
  332. };
  333. asmlinkage long sys32_sysinfo(struct sysinfo32 __user *info)
  334. {
  335. struct sysinfo s;
  336. int ret, err;
  337. int bitcount=0;
  338. mm_segment_t old_fs = get_fs ();
  339. /* The __user cast is valid due to set_fs() */
  340. set_fs (KERNEL_DS);
  341. ret = sys_sysinfo((struct sysinfo __user *)&s);
  342. set_fs (old_fs);
  343. /* Check to see if any memory value is too large for 32-bit and
  344. * scale down if needed.
  345. */
  346. if ((s.totalram >> 32) || (s.totalswap >> 32)) {
  347. while (s.mem_unit < PAGE_SIZE) {
  348. s.mem_unit <<= 1;
  349. bitcount++;
  350. }
  351. s.totalram >>=bitcount;
  352. s.freeram >>= bitcount;
  353. s.sharedram >>= bitcount;
  354. s.bufferram >>= bitcount;
  355. s.totalswap >>= bitcount;
  356. s.freeswap >>= bitcount;
  357. s.totalhigh >>= bitcount;
  358. s.freehigh >>= bitcount;
  359. }
  360. err = put_user (s.uptime, &info->uptime);
  361. err |= __put_user (s.loads[0], &info->loads[0]);
  362. err |= __put_user (s.loads[1], &info->loads[1]);
  363. err |= __put_user (s.loads[2], &info->loads[2]);
  364. err |= __put_user (s.totalram, &info->totalram);
  365. err |= __put_user (s.freeram, &info->freeram);
  366. err |= __put_user (s.sharedram, &info->sharedram);
  367. err |= __put_user (s.bufferram, &info->bufferram);
  368. err |= __put_user (s.totalswap, &info->totalswap);
  369. err |= __put_user (s.freeswap, &info->freeswap);
  370. err |= __put_user (s.procs, &info->procs);
  371. err |= __put_user (s.totalhigh, &info->totalhigh);
  372. err |= __put_user (s.freehigh, &info->freehigh);
  373. err |= __put_user (s.mem_unit, &info->mem_unit);
  374. if (err)
  375. return -EFAULT;
  376. return ret;
  377. }
  378. /* Translations due to time_t size differences. Which affects all
  379. sorts of things, like timeval and itimerval. */
  380. extern struct timezone sys_tz;
  381. asmlinkage long sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
  382. {
  383. if (tv) {
  384. struct timeval ktv;
  385. do_gettimeofday(&ktv);
  386. if (put_tv32(tv, &ktv))
  387. return -EFAULT;
  388. }
  389. if (tz) {
  390. if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
  391. return -EFAULT;
  392. }
  393. return 0;
  394. }
  395. asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
  396. {
  397. struct timespec kts;
  398. struct timezone ktz;
  399. if (tv) {
  400. if (get_ts32(&kts, tv))
  401. return -EFAULT;
  402. }
  403. if (tz) {
  404. if (copy_from_user(&ktz, tz, sizeof(ktz)))
  405. return -EFAULT;
  406. }
  407. return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
  408. }
  409. #ifdef CONFIG_SYSVIPC
  410. long sys32_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr,
  411. u32 fifth)
  412. {
  413. int version;
  414. version = call >> 16; /* hack for backward compatibility */
  415. call &= 0xffff;
  416. switch (call) {
  417. case SEMTIMEDOP:
  418. if (fifth)
  419. /* sign extend semid */
  420. return compat_sys_semtimedop((int)first,
  421. compat_ptr(ptr), second,
  422. compat_ptr(fifth));
  423. /* else fall through for normal semop() */
  424. case SEMOP:
  425. /* struct sembuf is the same on 32 and 64bit :)) */
  426. /* sign extend semid */
  427. return sys_semtimedop((int)first, compat_ptr(ptr), second,
  428. NULL);
  429. case SEMGET:
  430. /* sign extend key, nsems */
  431. return sys_semget((int)first, (int)second, third);
  432. case SEMCTL:
  433. /* sign extend semid, semnum */
  434. return compat_sys_semctl((int)first, (int)second, third,
  435. compat_ptr(ptr));
  436. case MSGSND:
  437. /* sign extend msqid */
  438. return compat_sys_msgsnd((int)first, (int)second, third,
  439. compat_ptr(ptr));
  440. case MSGRCV:
  441. /* sign extend msqid, msgtyp */
  442. return compat_sys_msgrcv((int)first, second, (int)fifth,
  443. third, version, compat_ptr(ptr));
  444. case MSGGET:
  445. /* sign extend key */
  446. return sys_msgget((int)first, second);
  447. case MSGCTL:
  448. /* sign extend msqid */
  449. return compat_sys_msgctl((int)first, second, compat_ptr(ptr));
  450. case SHMAT:
  451. /* sign extend shmid */
  452. return compat_sys_shmat((int)first, second, third, version,
  453. compat_ptr(ptr));
  454. case SHMDT:
  455. return sys_shmdt(compat_ptr(ptr));
  456. case SHMGET:
  457. /* sign extend key_t */
  458. return sys_shmget((int)first, second, third);
  459. case SHMCTL:
  460. /* sign extend shmid */
  461. return compat_sys_shmctl((int)first, second, compat_ptr(ptr));
  462. default:
  463. return -ENOSYS;
  464. }
  465. return -ENOSYS;
  466. }
  467. #endif
  468. /* Note: it is necessary to treat out_fd and in_fd as unsigned ints,
  469. * with the corresponding cast to a signed int to insure that the
  470. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  471. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  472. */
  473. asmlinkage long sys32_sendfile(u32 out_fd, u32 in_fd, compat_off_t __user * offset, u32 count)
  474. {
  475. mm_segment_t old_fs = get_fs();
  476. int ret;
  477. off_t of;
  478. off_t __user *up;
  479. if (offset && get_user(of, offset))
  480. return -EFAULT;
  481. /* The __user pointer cast is valid because of the set_fs() */
  482. set_fs(KERNEL_DS);
  483. up = offset ? (off_t __user *) &of : NULL;
  484. ret = sys_sendfile((int)out_fd, (int)in_fd, up, count);
  485. set_fs(old_fs);
  486. if (offset && put_user(of, offset))
  487. return -EFAULT;
  488. return ret;
  489. }
  490. asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
  491. {
  492. mm_segment_t old_fs = get_fs();
  493. int ret;
  494. loff_t lof;
  495. loff_t __user *up;
  496. if (offset && get_user(lof, offset))
  497. return -EFAULT;
  498. /* The __user pointer cast is valid because of the set_fs() */
  499. set_fs(KERNEL_DS);
  500. up = offset ? (loff_t __user *) &lof : NULL;
  501. ret = sys_sendfile64(out_fd, in_fd, up, count);
  502. set_fs(old_fs);
  503. if (offset && put_user(lof, offset))
  504. return -EFAULT;
  505. return ret;
  506. }
  507. long sys32_execve(unsigned long a0, unsigned long a1, unsigned long a2,
  508. unsigned long a3, unsigned long a4, unsigned long a5,
  509. struct pt_regs *regs)
  510. {
  511. int error;
  512. char * filename;
  513. filename = getname((char __user *) a0);
  514. error = PTR_ERR(filename);
  515. if (IS_ERR(filename))
  516. goto out;
  517. flush_fp_to_thread(current);
  518. flush_altivec_to_thread(current);
  519. error = compat_do_execve(filename, compat_ptr(a1), compat_ptr(a2), regs);
  520. if (error == 0) {
  521. task_lock(current);
  522. current->ptrace &= ~PT_DTRACE;
  523. task_unlock(current);
  524. }
  525. putname(filename);
  526. out:
  527. return error;
  528. }
  529. /* Set up a thread for executing a new program. */
  530. void start_thread32(struct pt_regs* regs, unsigned long nip, unsigned long sp)
  531. {
  532. set_fs(USER_DS);
  533. /*
  534. * If we exec out of a kernel thread then thread.regs will not be
  535. * set. Do it now.
  536. */
  537. if (!current->thread.regs) {
  538. unsigned long childregs = (unsigned long)current->thread_info +
  539. THREAD_SIZE;
  540. childregs -= sizeof(struct pt_regs);
  541. current->thread.regs = (struct pt_regs *)childregs;
  542. }
  543. /*
  544. * ELF_PLAT_INIT already clears all registers but it also sets r2.
  545. * So just clear r2 here.
  546. */
  547. regs->gpr[2] = 0;
  548. regs->nip = nip;
  549. regs->gpr[1] = sp;
  550. regs->msr = MSR_USER32;
  551. #ifndef CONFIG_SMP
  552. if (last_task_used_math == current)
  553. last_task_used_math = 0;
  554. #endif /* CONFIG_SMP */
  555. current->thread.fpscr = 0;
  556. memset(current->thread.fpr, 0, sizeof(current->thread.fpr));
  557. #ifdef CONFIG_ALTIVEC
  558. #ifndef CONFIG_SMP
  559. if (last_task_used_altivec == current)
  560. last_task_used_altivec = 0;
  561. #endif /* CONFIG_SMP */
  562. memset(current->thread.vr, 0, sizeof(current->thread.vr));
  563. current->thread.vscr.u[0] = 0;
  564. current->thread.vscr.u[1] = 0;
  565. current->thread.vscr.u[2] = 0;
  566. current->thread.vscr.u[3] = 0x00010000; /* Java mode disabled */
  567. current->thread.vrsave = 0;
  568. current->thread.used_vr = 0;
  569. #endif /* CONFIG_ALTIVEC */
  570. }
  571. /* Note: it is necessary to treat option as an unsigned int,
  572. * with the corresponding cast to a signed int to insure that the
  573. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  574. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  575. */
  576. asmlinkage long sys32_prctl(u32 option, u32 arg2, u32 arg3, u32 arg4, u32 arg5)
  577. {
  578. return sys_prctl((int)option,
  579. (unsigned long) arg2,
  580. (unsigned long) arg3,
  581. (unsigned long) arg4,
  582. (unsigned long) arg5);
  583. }
  584. /* Note: it is necessary to treat pid as an unsigned int,
  585. * with the corresponding cast to a signed int to insure that the
  586. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  587. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  588. */
  589. asmlinkage long sys32_sched_rr_get_interval(u32 pid, struct compat_timespec __user *interval)
  590. {
  591. struct timespec t;
  592. int ret;
  593. mm_segment_t old_fs = get_fs ();
  594. /* The __user pointer cast is valid because of the set_fs() */
  595. set_fs (KERNEL_DS);
  596. ret = sys_sched_rr_get_interval((int)pid, (struct timespec __user *) &t);
  597. set_fs (old_fs);
  598. if (put_compat_timespec(&t, interval))
  599. return -EFAULT;
  600. return ret;
  601. }
  602. asmlinkage int sys32_pciconfig_read(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf)
  603. {
  604. return sys_pciconfig_read((unsigned long) bus,
  605. (unsigned long) dfn,
  606. (unsigned long) off,
  607. (unsigned long) len,
  608. compat_ptr(ubuf));
  609. }
  610. asmlinkage int sys32_pciconfig_write(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf)
  611. {
  612. return sys_pciconfig_write((unsigned long) bus,
  613. (unsigned long) dfn,
  614. (unsigned long) off,
  615. (unsigned long) len,
  616. compat_ptr(ubuf));
  617. }
  618. asmlinkage int sys32_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn)
  619. {
  620. return sys_pciconfig_iobase(which, in_bus, in_devfn);
  621. }
  622. /* Note: it is necessary to treat mode as an unsigned int,
  623. * with the corresponding cast to a signed int to insure that the
  624. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  625. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  626. */
  627. asmlinkage long sys32_access(const char __user * filename, u32 mode)
  628. {
  629. return sys_access(filename, (int)mode);
  630. }
  631. /* Note: it is necessary to treat mode as an unsigned int,
  632. * with the corresponding cast to a signed int to insure that the
  633. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  634. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  635. */
  636. asmlinkage long sys32_creat(const char __user * pathname, u32 mode)
  637. {
  638. return sys_creat(pathname, (int)mode);
  639. }
  640. /* Note: it is necessary to treat pid and options as unsigned ints,
  641. * with the corresponding cast to a signed int to insure that the
  642. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  643. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  644. */
  645. asmlinkage long sys32_waitpid(u32 pid, unsigned int __user * stat_addr, u32 options)
  646. {
  647. return sys_waitpid((int)pid, stat_addr, (int)options);
  648. }
  649. /* Note: it is necessary to treat gidsetsize as an unsigned int,
  650. * with the corresponding cast to a signed int to insure that the
  651. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  652. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  653. */
  654. asmlinkage long sys32_getgroups(u32 gidsetsize, gid_t __user *grouplist)
  655. {
  656. return sys_getgroups((int)gidsetsize, grouplist);
  657. }
  658. /* Note: it is necessary to treat pid as an unsigned int,
  659. * with the corresponding cast to a signed int to insure that the
  660. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  661. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  662. */
  663. asmlinkage long sys32_getpgid(u32 pid)
  664. {
  665. return sys_getpgid((int)pid);
  666. }
  667. /* Note: it is necessary to treat pid as an unsigned int,
  668. * with the corresponding cast to a signed int to insure that the
  669. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  670. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  671. */
  672. asmlinkage long sys32_getsid(u32 pid)
  673. {
  674. return sys_getsid((int)pid);
  675. }
  676. /* Note: it is necessary to treat pid and sig as unsigned ints,
  677. * with the corresponding cast to a signed int to insure that the
  678. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  679. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  680. */
  681. asmlinkage long sys32_kill(u32 pid, u32 sig)
  682. {
  683. return sys_kill((int)pid, (int)sig);
  684. }
  685. /* Note: it is necessary to treat mode as an unsigned int,
  686. * with the corresponding cast to a signed int to insure that the
  687. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  688. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  689. */
  690. asmlinkage long sys32_mkdir(const char __user * pathname, u32 mode)
  691. {
  692. return sys_mkdir(pathname, (int)mode);
  693. }
  694. long sys32_nice(u32 increment)
  695. {
  696. /* sign extend increment */
  697. return sys_nice((int)increment);
  698. }
  699. off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin)
  700. {
  701. /* sign extend n */
  702. return sys_lseek(fd, (int)offset, origin);
  703. }
  704. /* Note: it is necessary to treat bufsiz as an unsigned int,
  705. * with the corresponding cast to a signed int to insure that the
  706. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  707. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  708. */
  709. asmlinkage long sys32_readlink(const char __user * path, char __user * buf, u32 bufsiz)
  710. {
  711. return sys_readlink(path, buf, (int)bufsiz);
  712. }
  713. /* Note: it is necessary to treat option as an unsigned int,
  714. * with the corresponding cast to a signed int to insure that the
  715. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  716. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  717. */
  718. asmlinkage long sys32_sched_get_priority_max(u32 policy)
  719. {
  720. return sys_sched_get_priority_max((int)policy);
  721. }
  722. /* Note: it is necessary to treat policy as an unsigned int,
  723. * with the corresponding cast to a signed int to insure that the
  724. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  725. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  726. */
  727. asmlinkage long sys32_sched_get_priority_min(u32 policy)
  728. {
  729. return sys_sched_get_priority_min((int)policy);
  730. }
  731. /* Note: it is necessary to treat pid as an unsigned int,
  732. * with the corresponding cast to a signed int to insure that the
  733. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  734. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  735. */
  736. asmlinkage long sys32_sched_getparam(u32 pid, struct sched_param __user *param)
  737. {
  738. return sys_sched_getparam((int)pid, param);
  739. }
  740. /* Note: it is necessary to treat pid as an unsigned int,
  741. * with the corresponding cast to a signed int to insure that the
  742. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  743. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  744. */
  745. asmlinkage long sys32_sched_getscheduler(u32 pid)
  746. {
  747. return sys_sched_getscheduler((int)pid);
  748. }
  749. /* Note: it is necessary to treat pid as an unsigned int,
  750. * with the corresponding cast to a signed int to insure that the
  751. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  752. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  753. */
  754. asmlinkage long sys32_sched_setparam(u32 pid, struct sched_param __user *param)
  755. {
  756. return sys_sched_setparam((int)pid, param);
  757. }
  758. /* Note: it is necessary to treat pid and policy as unsigned ints,
  759. * with the corresponding cast to a signed int to insure that the
  760. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  761. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  762. */
  763. asmlinkage long sys32_sched_setscheduler(u32 pid, u32 policy, struct sched_param __user *param)
  764. {
  765. return sys_sched_setscheduler((int)pid, (int)policy, param);
  766. }
  767. /* Note: it is necessary to treat len as an unsigned int,
  768. * with the corresponding cast to a signed int to insure that the
  769. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  770. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  771. */
  772. asmlinkage long sys32_setdomainname(char __user *name, u32 len)
  773. {
  774. return sys_setdomainname(name, (int)len);
  775. }
  776. /* Note: it is necessary to treat gidsetsize as an unsigned int,
  777. * with the corresponding cast to a signed int to insure that the
  778. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  779. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  780. */
  781. asmlinkage long sys32_setgroups(u32 gidsetsize, gid_t __user *grouplist)
  782. {
  783. return sys_setgroups((int)gidsetsize, grouplist);
  784. }
  785. asmlinkage long sys32_sethostname(char __user *name, u32 len)
  786. {
  787. /* sign extend len */
  788. return sys_sethostname(name, (int)len);
  789. }
  790. /* Note: it is necessary to treat pid and pgid as unsigned ints,
  791. * with the corresponding cast to a signed int to insure that the
  792. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  793. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  794. */
  795. asmlinkage long sys32_setpgid(u32 pid, u32 pgid)
  796. {
  797. return sys_setpgid((int)pid, (int)pgid);
  798. }
  799. long sys32_getpriority(u32 which, u32 who)
  800. {
  801. /* sign extend which and who */
  802. return sys_getpriority((int)which, (int)who);
  803. }
  804. long sys32_setpriority(u32 which, u32 who, u32 niceval)
  805. {
  806. /* sign extend which, who and niceval */
  807. return sys_setpriority((int)which, (int)who, (int)niceval);
  808. }
  809. long sys32_ioprio_get(u32 which, u32 who)
  810. {
  811. /* sign extend which and who */
  812. return sys_ioprio_get((int)which, (int)who);
  813. }
  814. long sys32_ioprio_set(u32 which, u32 who, u32 ioprio)
  815. {
  816. /* sign extend which, who and ioprio */
  817. return sys_ioprio_set((int)which, (int)who, (int)ioprio);
  818. }
  819. /* Note: it is necessary to treat newmask as an unsigned int,
  820. * with the corresponding cast to a signed int to insure that the
  821. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  822. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  823. */
  824. asmlinkage long sys32_ssetmask(u32 newmask)
  825. {
  826. return sys_ssetmask((int) newmask);
  827. }
  828. asmlinkage long sys32_syslog(u32 type, char __user * buf, u32 len)
  829. {
  830. /* sign extend len */
  831. return sys_syslog(type, buf, (int)len);
  832. }
  833. /* Note: it is necessary to treat mask as an unsigned int,
  834. * with the corresponding cast to a signed int to insure that the
  835. * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  836. * and the register representation of a signed int (msr in 64-bit mode) is performed.
  837. */
  838. asmlinkage long sys32_umask(u32 mask)
  839. {
  840. return sys_umask((int)mask);
  841. }
  842. #ifdef CONFIG_SYSCTL
  843. struct __sysctl_args32 {
  844. u32 name;
  845. int nlen;
  846. u32 oldval;
  847. u32 oldlenp;
  848. u32 newval;
  849. u32 newlen;
  850. u32 __unused[4];
  851. };
  852. asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
  853. {
  854. struct __sysctl_args32 tmp;
  855. int error;
  856. size_t oldlen;
  857. size_t __user *oldlenp = NULL;
  858. unsigned long addr = (((unsigned long)&args->__unused[0]) + 7) & ~7;
  859. if (copy_from_user(&tmp, args, sizeof(tmp)))
  860. return -EFAULT;
  861. if (tmp.oldval && tmp.oldlenp) {
  862. /* Duh, this is ugly and might not work if sysctl_args
  863. is in read-only memory, but do_sysctl does indirectly
  864. a lot of uaccess in both directions and we'd have to
  865. basically copy the whole sysctl.c here, and
  866. glibc's __sysctl uses rw memory for the structure
  867. anyway. */
  868. oldlenp = (size_t __user *)addr;
  869. if (get_user(oldlen, (compat_size_t __user *)compat_ptr(tmp.oldlenp)) ||
  870. put_user(oldlen, oldlenp))
  871. return -EFAULT;
  872. }
  873. lock_kernel();
  874. error = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
  875. compat_ptr(tmp.oldval), oldlenp,
  876. compat_ptr(tmp.newval), tmp.newlen);
  877. unlock_kernel();
  878. if (oldlenp) {
  879. if (!error) {
  880. if (get_user(oldlen, oldlenp) ||
  881. put_user(oldlen, (compat_size_t __user *)compat_ptr(tmp.oldlenp)))
  882. error = -EFAULT;
  883. }
  884. copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused));
  885. }
  886. return error;
  887. }
  888. #endif
  889. asmlinkage int sys32_uname(struct old_utsname __user * name)
  890. {
  891. int err = 0;
  892. down_read(&uts_sem);
  893. if (copy_to_user(name, &system_utsname, sizeof(*name)))
  894. err = -EFAULT;
  895. up_read(&uts_sem);
  896. if (!err && personality(current->personality) == PER_LINUX32) {
  897. /* change "ppc64" to "ppc" */
  898. if (__put_user(0, name->machine + 3)
  899. || __put_user(0, name->machine + 4))
  900. err = -EFAULT;
  901. }
  902. return err;
  903. }
  904. asmlinkage int sys32_olduname(struct oldold_utsname __user * name)
  905. {
  906. int error;
  907. if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
  908. return -EFAULT;
  909. down_read(&uts_sem);
  910. error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
  911. error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
  912. error |= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
  913. error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
  914. error |= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
  915. error |= __put_user(0,name->release+__OLD_UTS_LEN);
  916. error |= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
  917. error |= __put_user(0,name->version+__OLD_UTS_LEN);
  918. error |= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
  919. error |= __put_user(0,name->machine+__OLD_UTS_LEN);
  920. if (personality(current->personality) == PER_LINUX32) {
  921. /* change "ppc64" to "ppc" */
  922. error |= __put_user(0, name->machine + 3);
  923. error |= __put_user(0, name->machine + 4);
  924. }
  925. up_read(&uts_sem);
  926. error = error ? -EFAULT : 0;
  927. return error;
  928. }
  929. unsigned long sys32_mmap2(unsigned long addr, size_t len,
  930. unsigned long prot, unsigned long flags,
  931. unsigned long fd, unsigned long pgoff)
  932. {
  933. /* This should remain 12 even if PAGE_SIZE changes */
  934. return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
  935. }
  936. int get_compat_timeval(struct timeval *tv, struct compat_timeval __user *ctv)
  937. {
  938. return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) ||
  939. __get_user(tv->tv_sec, &ctv->tv_sec) ||
  940. __get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
  941. }
  942. asmlinkage long sys32_utimes(char __user *filename, struct compat_timeval __user *tvs)
  943. {
  944. struct timeval ktvs[2], *ptr;
  945. ptr = NULL;
  946. if (tvs) {
  947. if (get_compat_timeval(&ktvs[0], &tvs[0]) ||
  948. get_compat_timeval(&ktvs[1], &tvs[1]))
  949. return -EFAULT;
  950. ptr = ktvs;
  951. }
  952. return do_utimes(filename, ptr);
  953. }
  954. long sys32_tgkill(u32 tgid, u32 pid, int sig)
  955. {
  956. /* sign extend tgid, pid */
  957. return sys_tgkill((int)tgid, (int)pid, sig);
  958. }
  959. /*
  960. * long long munging:
  961. * The 32 bit ABI passes long longs in an odd even register pair.
  962. */
  963. compat_ssize_t sys32_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
  964. u32 reg6, u32 poshi, u32 poslo)
  965. {
  966. return sys_pread64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
  967. }
  968. compat_ssize_t sys32_pwrite64(unsigned int fd, char __user *ubuf, compat_size_t count,
  969. u32 reg6, u32 poshi, u32 poslo)
  970. {
  971. return sys_pwrite64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
  972. }
  973. compat_ssize_t sys32_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 count)
  974. {
  975. return sys_readahead(fd, ((loff_t)offhi << 32) | offlo, count);
  976. }
  977. asmlinkage int sys32_truncate64(const char __user * path, u32 reg4,
  978. unsigned long high, unsigned long low)
  979. {
  980. return sys_truncate(path, (high << 32) | low);
  981. }
  982. asmlinkage int sys32_ftruncate64(unsigned int fd, u32 reg4, unsigned long high,
  983. unsigned long low)
  984. {
  985. return sys_ftruncate(fd, (high << 32) | low);
  986. }
  987. long ppc32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
  988. size_t len)
  989. {
  990. return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
  991. buf, len);
  992. }
  993. long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
  994. size_t len, int advice)
  995. {
  996. return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, len,
  997. advice);
  998. }
  999. long ppc32_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
  1000. u32 len_high, u32 len_low)
  1001. {
  1002. return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low,
  1003. (u64)len_high << 32 | len_low, advice);
  1004. }
  1005. long ppc32_timer_create(clockid_t clock,
  1006. struct compat_sigevent __user *ev32,
  1007. timer_t __user *timer_id)
  1008. {
  1009. sigevent_t event;
  1010. timer_t t;
  1011. long err;
  1012. mm_segment_t savefs;
  1013. if (ev32 == NULL)
  1014. return sys_timer_create(clock, NULL, timer_id);
  1015. if (get_compat_sigevent(&event, ev32))
  1016. return -EFAULT;
  1017. if (!access_ok(VERIFY_WRITE, timer_id, sizeof(timer_t)))
  1018. return -EFAULT;
  1019. savefs = get_fs();
  1020. set_fs(KERNEL_DS);
  1021. /* The __user pointer casts are valid due to the set_fs() */
  1022. err = sys_timer_create(clock,
  1023. (sigevent_t __user *) &event,
  1024. (timer_t __user *) &t);
  1025. set_fs(savefs);
  1026. if (err == 0)
  1027. err = __put_user(t, timer_id);
  1028. return err;
  1029. }
  1030. asmlinkage long sys32_add_key(const char __user *_type,
  1031. const char __user *_description,
  1032. const void __user *_payload,
  1033. u32 plen,
  1034. u32 ringid)
  1035. {
  1036. return sys_add_key(_type, _description, _payload, plen, ringid);
  1037. }
  1038. asmlinkage long sys32_request_key(const char __user *_type,
  1039. const char __user *_description,
  1040. const char __user *_callout_info,
  1041. u32 destringid)
  1042. {
  1043. return sys_request_key(_type, _description, _callout_info, destringid);
  1044. }