History

[PATCH] x86_64: Add compat_printk and sysctl to turn off compat layer warnings

Sometimes e.g. with crashme the compat layer warnings can be noisy. Add a way to turn them off by gating all output through compat_printk that checks a global sysctl. The default is not changed.

Andi Kleen committed 20 years ago

Commit bebfa101 parent f2016115 files · +32 −3Browse files

Unified · Split

5 files
  1. arch/x86_64/ia32/sys_ia32.c +2 −2
  2. fs/compat.c +15 −1
  3. include/linux/compat.h +2 −0
  4. include/linux/sysctl.h +2 −0
  5. kernel/sysctl.c +11 −0
arch/x86_64/ia32/sys_ia32.c+2−2
@@ -514,7 +514,7 @@ int sys32_ni_syscall(int call) · 513 unmodified lines
514 static char lastcomm[sizeof(me->comm)];514 static char lastcomm[sizeof(me->comm)];
515 515
516 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {516 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
517 printk(KERN_INFO "IA32 syscall %d from %s not implemented\n",517 compat_printk(KERN_INFO "IA32 syscall %d from %s not implemented\n",
518 call, me->comm);518 call, me->comm);
519 strncpy(lastcomm, me->comm, sizeof(lastcomm));519 strncpy(lastcomm, me->comm, sizeof(lastcomm));
520 } 520 }
@@ -916,7 +916,7 @@ long sys32_vm86_warning(void) · 395 unmodified lines
916 struct task_struct *me = current;916 struct task_struct *me = current;
917 static char lastcomm[sizeof(me->comm)];917 static char lastcomm[sizeof(me->comm)];
918 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {918 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
919 printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",919 compat_printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
920 me->comm);920 me->comm);
921 strncpy(lastcomm, me->comm, sizeof(lastcomm));921 strncpy(lastcomm, me->comm, sizeof(lastcomm));
922 } 922 }
fs/compat.c+15−1
@@ -55,6 +55,20 @@ · 54 unmodified lines
55 55
56extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);56extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
57 57
58int compat_log = 1;
59
60int compat_printk(const char *fmt, ...)
61{
62 va_list ap;
63 int ret;
64 if (!compat_log)
65 return 0;
66 va_start(ap, fmt);
67 ret = vprintk(fmt, ap);
68 va_end(ap);
69 return ret;
70}
71
58/*72/*
59 * Not all architectures have sys_utime, so implement this in terms73 * Not all architectures have sys_utime, so implement this in terms
60 * of sys_utimes.74 * of sys_utimes.
@@ -359,7 +373,7 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd, · 298 unmodified lines
359 sprintf(buf,"'%c'", (cmd>>24) & 0x3f);373 sprintf(buf,"'%c'", (cmd>>24) & 0x3f);
360 if (!isprint(buf[1]))374 if (!isprint(buf[1]))
361 sprintf(buf, "%02x", buf[1]);375 sprintf(buf, "%02x", buf[1]);
362 printk("ioctl32(%s:%d): Unknown cmd fd(%d) "376 compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
363 "cmd(%08x){%s} arg(%08x) on %s\n",377 "cmd(%08x){%s} arg(%08x) on %s\n",
364 current->comm, current->pid,378 current->comm, current->pid,
365 (int)fd, (unsigned int)cmd, buf,379 (int)fd, (unsigned int)cmd, buf,
include/linux/compat.h+2−0
@@ -226,5 +226,7 @@ static inline int compat_timespec_compare(struct compat_timespec *lhs, · 225 unmodified lines
226 226
227asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);227asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
228 228
229extern int compat_printk(const char *fmt, ...);
230
229#endif /* CONFIG_COMPAT */231#endif /* CONFIG_COMPAT */
230#endif /* _LINUX_COMPAT_H */232#endif /* _LINUX_COMPAT_H */
include/linux/sysctl.h+2−0
@@ -148,9 +148,11 @@ enum · 147 unmodified lines
148 KERN_SPIN_RETRY=70, /* int: number of spinlock retries */148 KERN_SPIN_RETRY=70, /* int: number of spinlock retries */
149 KERN_ACPI_VIDEO_FLAGS=71, /* int: flags for setting up video after ACPI sleep */149 KERN_ACPI_VIDEO_FLAGS=71, /* int: flags for setting up video after ACPI sleep */
150 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */150 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */
151 KERN_COMPAT_LOG=73, /* int: print compat layer messages */
151};152};
152 153
153 154
155
154/* CTL_VM names: */156/* CTL_VM names: */
155enum157enum
156{158{
kernel/sysctl.c+11−0
@@ -73,6 +73,7 @@ extern int printk_ratelimit_burst; · 72 unmodified lines
73extern int pid_max_min, pid_max_max;73extern int pid_max_min, pid_max_max;
74extern int sysctl_drop_caches;74extern int sysctl_drop_caches;
75extern int percpu_pagelist_fraction;75extern int percpu_pagelist_fraction;
76extern int compat_log;
76 77
77#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)78#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
78int unknown_nmi_panic;79int unknown_nmi_panic;
@@ -676,6 +677,16 @@ static ctl_table kern_table[] = { · 597 unmodified lines
676 .mode = 0644,677 .mode = 0644,
677 .proc_handler = &proc_dointvec,678 .proc_handler = &proc_dointvec,
678 },679 },
680#endif
681#ifdef CONFIG_COMPAT
682 {
683 .ctl_name = KERN_COMPAT_LOG,
684 .procname = "compat-log",
685 .data = &compat_log,
686 .maxlen = sizeof (int),
687 .mode = 0644,
688 .proc_handler = &proc_dointvec,
689 },
679#endif690#endif
680 { .ctl_name = 0 }691 { .ctl_name = 0 }
681};692};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t