aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/ia32
diff options
context:
space:
mode:
authorKyle McMartin <kyle@parisc-linux.org>2007-02-10 04:46:00 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 13:51:32 -0500
commitd4d23add3abcd18d8021b99f230df608ccb2f007 (patch)
tree756c5a7d21a9f5a25f10bfcec40c01aecc596c2f /arch/x86_64/ia32
parent72fd4a35a824331d7a0f4168d7576502d95d34b3 (diff)
[PATCH] Common compat_sys_sysinfo
I noticed that almost all architectures implemented exactly the same sys32_sysinfo... except parisc, where a bug was to be found in handling of the uptime. So let's remove a whole whack of code for fun and profit. Cribbed compat_sys_sysinfo from x86_64's implementation, since I figured it would be the best tested. This patch incorporates Arnd's suggestion of not using set_fs/get_fs, but instead extracting out the common code from sys_sysinfo. Cc: Christoph Hellwig <hch@infradead.org> Cc: <linux-arch@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86_64/ia32')
-rw-r--r--arch/x86_64/ia32/ia32entry.S2
-rw-r--r--arch/x86_64/ia32/sys_ia32.c66
2 files changed, 1 insertions, 67 deletions
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index b4aa875e175..5f32cf4de5f 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -515,7 +515,7 @@ ia32_sys_call_table:
515 .quad sys32_vm86_warning /* vm86old */ 515 .quad sys32_vm86_warning /* vm86old */
516 .quad compat_sys_wait4 516 .quad compat_sys_wait4
517 .quad sys_swapoff /* 115 */ 517 .quad sys_swapoff /* 115 */
518 .quad sys32_sysinfo 518 .quad compat_sys_sysinfo
519 .quad sys32_ipc 519 .quad sys32_ipc
520 .quad sys_fsync 520 .quad sys_fsync
521 .quad stub32_sigreturn 521 .quad stub32_sigreturn
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
index c9bac3af29d..200fdde18d9 100644
--- a/arch/x86_64/ia32/sys_ia32.c
+++ b/arch/x86_64/ia32/sys_ia32.c
@@ -523,72 +523,6 @@ sys32_sysfs(int option, u32 arg1, u32 arg2)
523 return sys_sysfs(option, arg1, arg2); 523 return sys_sysfs(option, arg1, arg2);
524} 524}
525 525
526struct sysinfo32 {
527 s32 uptime;
528 u32 loads[3];
529 u32 totalram;
530 u32 freeram;
531 u32 sharedram;
532 u32 bufferram;
533 u32 totalswap;
534 u32 freeswap;
535 unsigned short procs;
536 unsigned short pad;
537 u32 totalhigh;
538 u32 freehigh;
539 u32 mem_unit;
540 char _f[20-2*sizeof(u32)-sizeof(int)];
541};
542
543asmlinkage long
544sys32_sysinfo(struct sysinfo32 __user *info)
545{
546 struct sysinfo s;
547 int ret;
548 mm_segment_t old_fs = get_fs ();
549 int bitcount = 0;
550
551 set_fs (KERNEL_DS);
552 ret = sys_sysinfo((struct sysinfo __user *)&s);
553 set_fs (old_fs);
554
555 /* Check to see if any memory value is too large for 32-bit and scale
556 * down if needed
557 */
558 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
559 while (s.mem_unit < PAGE_SIZE) {
560 s.mem_unit <<= 1;
561 bitcount++;
562 }
563 s.totalram >>= bitcount;
564 s.freeram >>= bitcount;
565 s.sharedram >>= bitcount;
566 s.bufferram >>= bitcount;
567 s.totalswap >>= bitcount;
568 s.freeswap >>= bitcount;
569 s.totalhigh >>= bitcount;
570 s.freehigh >>= bitcount;
571 }
572
573 if (!access_ok(VERIFY_WRITE, info, sizeof(struct sysinfo32)) ||
574 __put_user (s.uptime, &info->uptime) ||
575 __put_user (s.loads[0], &info->loads[0]) ||
576 __put_user (s.loads[1], &info->loads[1]) ||
577 __put_user (s.loads[2], &info->loads[2]) ||
578 __put_user (s.totalram, &info->totalram) ||
579 __put_user (s.freeram, &info->freeram) ||
580 __put_user (s.sharedram, &info->sharedram) ||
581 __put_user (s.bufferram, &info->bufferram) ||
582 __put_user (s.totalswap, &info->totalswap) ||
583 __put_user (s.freeswap, &info->freeswap) ||
584 __put_user (s.procs, &info->procs) ||
585 __put_user (s.totalhigh, &info->totalhigh) ||
586 __put_user (s.freehigh, &info->freehigh) ||
587 __put_user (s.mem_unit, &info->mem_unit))
588 return -EFAULT;
589 return 0;
590}
591
592asmlinkage long 526asmlinkage long
593sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval) 527sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
594{ 528{