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
514514 static char lastcomm[sizeof(me->comm)];
515515
516516 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",
518518 call, me->comm);
519519 strncpy(lastcomm, me->comm, sizeof(lastcomm));
520520 }
@@ -916,7 +916,7 @@ long sys32_vm86_warning(void) · 395 unmodified lines
916916 struct task_struct *me = current;
917917 static char lastcomm[sizeof(me->comm)];
918918 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",
920920 me->comm);
921921 strncpy(lastcomm, me->comm, sizeof(lastcomm));
922922 }
fs/compat.c+15−1
@@ -55,6 +55,20 @@ · 54 unmodified lines
5555
5656 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
5757
58+int compat_log = 1;
59+
60+int 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+
5872 /*
5973 * Not all architectures have sys_utime, so implement this in terms
6074 * of sys_utimes.
@@ -359,7 +373,7 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd, · 298 unmodified lines
359373 sprintf(buf,"'%c'", (cmd>>24) & 0x3f);
360374 if (!isprint(buf[1]))
361375 sprintf(buf, "%02x", buf[1]);
362− printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
376+ compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
363377 "cmd(%08x){%s} arg(%08x) on %s\n",
364378 current->comm, current->pid,
365379 (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
226226
227227 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
228228
229+extern int compat_printk(const char *fmt, ...);
230+
229231 #endif /* CONFIG_COMPAT */
230232 #endif /* _LINUX_COMPAT_H */
include/linux/sysctl.h+2−0
@@ -148,9 +148,11 @@ enum · 147 unmodified lines
148148 KERN_SPIN_RETRY=70, /* int: number of spinlock retries */
149149 KERN_ACPI_VIDEO_FLAGS=71, /* int: flags for setting up video after ACPI sleep */
150150 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */
151+ KERN_COMPAT_LOG=73, /* int: print compat layer messages */
151152 };
152153
153154
155+
154156 /* CTL_VM names: */
155157 enum
156158 {
kernel/sysctl.c+11−0
@@ -73,6 +73,7 @@ extern int printk_ratelimit_burst; · 72 unmodified lines
7373 extern int pid_max_min, pid_max_max;
7474 extern int sysctl_drop_caches;
7575 extern int percpu_pagelist_fraction;
76+extern int compat_log;
7677
7778 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
7879 int unknown_nmi_panic;
@@ -676,6 +677,16 @@ static ctl_table kern_table[] = { · 597 unmodified lines
676677 .mode = 0644,
677678 .proc_handler = &proc_dointvec,
678679 },
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+ },
679690 #endif
680691 { .ctl_name = 0 }
681692 };

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