2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
|
2008-02-05 06:31:29 +00:00
|
|
|
* Copyright (C) 2001 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-16 22:20:36 +00:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
2008-02-05 06:31:29 +00:00
|
|
|
#include <linux/console.h>
|
|
|
|
#include <linux/ctype.h>
|
2009-12-15 02:01:06 +00:00
|
|
|
#include <linux/string.h>
|
2008-02-05 06:31:29 +00:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/notifier.h>
|
|
|
|
#include <linux/reboot.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <linux/utsname.h>
|
2008-12-09 21:14:07 +00:00
|
|
|
#include <linux/socket.h>
|
|
|
|
#include <linux/un.h>
|
2008-02-05 06:31:29 +00:00
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/mutex.h>
|
2012-08-19 17:00:49 +00:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/mount.h>
|
|
|
|
#include <linux/file.h>
|
2008-02-05 06:31:29 +00:00
|
|
|
#include <asm/uaccess.h>
|
2012-03-29 16:47:46 +00:00
|
|
|
#include <asm/switch_to.h>
|
2008-02-05 06:31:29 +00:00
|
|
|
|
2012-10-08 02:27:32 +00:00
|
|
|
#include <init.h>
|
|
|
|
#include <irq_kern.h>
|
|
|
|
#include <irq_user.h>
|
|
|
|
#include <kern_util.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "mconsole.h"
|
|
|
|
#include "mconsole_kern.h"
|
2012-10-08 02:27:32 +00:00
|
|
|
#include <os.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-06 08:18:50 +00:00
|
|
|
static int do_unlink_socket(struct notifier_block *notifier,
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long what, void *data)
|
|
|
|
{
|
2007-10-16 08:26:57 +00:00
|
|
|
return mconsole_unlink_socket();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct notifier_block reboot_notifier = {
|
|
|
|
.notifier_call = do_unlink_socket,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2006-01-06 08:18:50 +00:00
|
|
|
/* Safe without explicit locking for now. Tasklets provide their own
|
2005-04-16 22:20:36 +00:00
|
|
|
* locking, and the interrupt handler is safe because it can't interrupt
|
|
|
|
* itself and it can only happen on CPU 0.
|
|
|
|
*/
|
|
|
|
|
2006-01-06 08:18:54 +00:00
|
|
|
static LIST_HEAD(mc_requests);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-12-05 19:36:26 +00:00
|
|
|
static void mc_work_proc(struct work_struct *unused)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct mconsole_entry *req;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
while (!list_empty(&mc_requests)) {
|
2006-04-11 05:53:39 +00:00
|
|
|
local_irq_save(flags);
|
2007-10-16 08:26:57 +00:00
|
|
|
req = list_entry(mc_requests.next, struct mconsole_entry, list);
|
2005-04-16 22:20:36 +00:00
|
|
|
list_del(&req->list);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
req->request.cmd->handler(&req->request);
|
|
|
|
kfree(req);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-05 19:36:26 +00:00
|
|
|
static DECLARE_WORK(mconsole_work, mc_work_proc);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-10-08 21:49:34 +00:00
|
|
|
static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
/* long to avoid size mismatch warnings from gcc */
|
|
|
|
long fd;
|
|
|
|
struct mconsole_entry *new;
|
2006-10-24 10:15:29 +00:00
|
|
|
static struct mc_request req; /* that's OK */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
fd = (long) dev_id;
|
2007-10-16 08:26:57 +00:00
|
|
|
while (mconsole_get_request(fd, &req)) {
|
|
|
|
if (req.cmd->context == MCONSOLE_INTR)
|
2005-04-16 22:20:36 +00:00
|
|
|
(*req.cmd->handler)(&req);
|
|
|
|
else {
|
2006-04-11 05:53:28 +00:00
|
|
|
new = kmalloc(sizeof(*new), GFP_NOWAIT);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (new == NULL)
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(&req, "Out of memory", 1, 0);
|
|
|
|
else {
|
|
|
|
new->request = req;
|
2006-10-24 10:15:29 +00:00
|
|
|
new->request.regs = get_irq_regs()->regs;
|
2005-04-16 22:20:36 +00:00
|
|
|
list_add(&new->list, &mc_requests);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-16 08:26:57 +00:00
|
|
|
if (!list_empty(&mc_requests))
|
2005-04-16 22:20:36 +00:00
|
|
|
schedule_work(&mconsole_work);
|
|
|
|
reactivate_fd(fd, MCONSOLE_IRQ);
|
2007-10-16 08:26:57 +00:00
|
|
|
return IRQ_HANDLED;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_version(struct mc_request *req)
|
|
|
|
{
|
|
|
|
char version[256];
|
|
|
|
|
2006-10-02 09:18:11 +00:00
|
|
|
sprintf(version, "%s %s %s %s %s", utsname()->sysname,
|
2007-10-16 08:26:57 +00:00
|
|
|
utsname()->nodename, utsname()->release, utsname()->version,
|
|
|
|
utsname()->machine);
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, version, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_log(struct mc_request *req)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *ptr = req->request.data;
|
|
|
|
|
|
|
|
ptr += strlen("log ");
|
|
|
|
|
|
|
|
len = req->len - (ptr - req->request.data);
|
2007-10-16 08:26:57 +00:00
|
|
|
printk(KERN_WARNING "%.*s", len, ptr);
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, "", 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_proc(struct mc_request *req)
|
|
|
|
{
|
2010-03-02 22:51:53 +00:00
|
|
|
struct vfsmount *mnt = task_active_pid_ns(current)->proc_mnt;
|
2005-04-16 22:20:36 +00:00
|
|
|
char *buf;
|
|
|
|
int len;
|
2012-08-19 17:00:49 +00:00
|
|
|
struct file *file;
|
2005-04-16 22:20:36 +00:00
|
|
|
int first_chunk = 1;
|
|
|
|
char *ptr = req->request.data;
|
|
|
|
|
|
|
|
ptr += strlen("proc");
|
2009-12-15 02:01:06 +00:00
|
|
|
ptr = skip_spaces(ptr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-08-19 17:00:49 +00:00
|
|
|
file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY);
|
|
|
|
if (IS_ERR(file)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, "Failed to open file", 1, 0);
|
2012-08-19 17:00:49 +00:00
|
|
|
printk(KERN_ERR "open /proc/%s: %ld\n", ptr, PTR_ERR(file));
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (buf == NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, "Failed to allocate buffer", 1, 0);
|
2012-08-19 17:00:49 +00:00
|
|
|
goto out_fput;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-08-19 17:00:49 +00:00
|
|
|
do {
|
2013-06-19 08:35:42 +00:00
|
|
|
loff_t pos = file->f_pos;
|
2012-08-19 17:00:49 +00:00
|
|
|
mm_segment_t old_fs = get_fs();
|
|
|
|
set_fs(KERNEL_DS);
|
|
|
|
len = vfs_read(file, buf, PAGE_SIZE - 1, &pos);
|
|
|
|
set_fs(old_fs);
|
|
|
|
file->f_pos = pos;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (len < 0) {
|
|
|
|
mconsole_reply(req, "Read of file failed", 1, 0);
|
|
|
|
goto out_free;
|
|
|
|
}
|
2007-10-16 08:26:57 +00:00
|
|
|
/* Begin the file content on his own line. */
|
2005-04-16 22:20:36 +00:00
|
|
|
if (first_chunk) {
|
|
|
|
mconsole_reply(req, "\n", 0, 1);
|
|
|
|
first_chunk = 0;
|
|
|
|
}
|
2012-08-19 17:00:49 +00:00
|
|
|
buf[len] = '\0';
|
|
|
|
mconsole_reply(req, buf, 0, (len > 0));
|
|
|
|
} while (len > 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
out_free:
|
|
|
|
kfree(buf);
|
2012-08-19 17:00:49 +00:00
|
|
|
out_fput:
|
|
|
|
fput(file);
|
|
|
|
out: ;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define UML_MCONSOLE_HELPTEXT \
|
|
|
|
"Commands: \n\
|
|
|
|
version - Get kernel version \n\
|
|
|
|
help - Print this message \n\
|
|
|
|
halt - Halt UML \n\
|
|
|
|
reboot - Reboot UML \n\
|
|
|
|
config <dev>=<config> - Add a new device to UML; \n\
|
|
|
|
same syntax as command line \n\
|
|
|
|
config <dev> - Query the configuration of a device \n\
|
|
|
|
remove <dev> - Remove a device from UML \n\
|
|
|
|
sysrq <letter> - Performs the SysRq action controlled by the letter \n\
|
2006-02-01 11:06:23 +00:00
|
|
|
cad - invoke the Ctrl-Alt-Del handler \n\
|
2005-04-16 22:20:36 +00:00
|
|
|
stop - pause the UML; it will do nothing until it receives a 'go' \n\
|
|
|
|
go - continue the UML after a 'stop' \n\
|
|
|
|
log <string> - make UML enter <string> into the kernel log\n\
|
|
|
|
proc <file> - returns the contents of the UML's /proc/<file>\n\
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 02:27:46 +00:00
|
|
|
stack <pid> - returns the stack of the specified pid\n\
|
2005-04-16 22:20:36 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
void mconsole_help(struct mc_request *req)
|
|
|
|
{
|
|
|
|
mconsole_reply(req, UML_MCONSOLE_HELPTEXT, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_halt(struct mc_request *req)
|
|
|
|
{
|
|
|
|
mconsole_reply(req, "", 0, 0);
|
|
|
|
machine_halt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_reboot(struct mc_request *req)
|
|
|
|
{
|
|
|
|
mconsole_reply(req, "", 0, 0);
|
|
|
|
machine_restart(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_cad(struct mc_request *req)
|
|
|
|
{
|
|
|
|
mconsole_reply(req, "", 0, 0);
|
|
|
|
ctrl_alt_del();
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_go(struct mc_request *req)
|
|
|
|
{
|
|
|
|
mconsole_reply(req, "Not stopped", 1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_stop(struct mc_request *req)
|
|
|
|
{
|
|
|
|
deactivate_fd(req->originating_fd, MCONSOLE_IRQ);
|
|
|
|
os_set_fd_block(req->originating_fd, 1);
|
2006-10-24 10:15:29 +00:00
|
|
|
mconsole_reply(req, "stopped", 0, 0);
|
2008-02-05 06:31:25 +00:00
|
|
|
for (;;) {
|
|
|
|
if (!mconsole_get_request(req->originating_fd, req))
|
|
|
|
continue;
|
2006-10-24 10:15:29 +00:00
|
|
|
if (req->cmd->handler == mconsole_go)
|
|
|
|
break;
|
|
|
|
if (req->cmd->handler == mconsole_stop) {
|
|
|
|
mconsole_reply(req, "Already stopped", 1, 0);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (req->cmd->handler == mconsole_sysrq) {
|
|
|
|
struct pt_regs *old_regs;
|
|
|
|
old_regs = set_irq_regs((struct pt_regs *)&req->regs);
|
|
|
|
mconsole_sysrq(req);
|
|
|
|
set_irq_regs(old_regs);
|
|
|
|
continue;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
(*req->cmd->handler)(req);
|
|
|
|
}
|
|
|
|
os_set_fd_block(req->originating_fd, 0);
|
|
|
|
reactivate_fd(req->originating_fd, MCONSOLE_IRQ);
|
|
|
|
mconsole_reply(req, "", 0, 0);
|
|
|
|
}
|
|
|
|
|
2007-02-10 09:44:01 +00:00
|
|
|
static DEFINE_SPINLOCK(mc_devices_lock);
|
2006-02-01 11:06:29 +00:00
|
|
|
static LIST_HEAD(mconsole_devices);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
void mconsole_register_dev(struct mc_device *new)
|
|
|
|
{
|
2007-02-10 09:44:01 +00:00
|
|
|
spin_lock(&mc_devices_lock);
|
|
|
|
BUG_ON(!list_empty(&new->list));
|
2005-04-16 22:20:36 +00:00
|
|
|
list_add(&new->list, &mconsole_devices);
|
2007-02-10 09:44:01 +00:00
|
|
|
spin_unlock(&mc_devices_lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct mc_device *mconsole_find_dev(char *name)
|
|
|
|
{
|
|
|
|
struct list_head *ele;
|
|
|
|
struct mc_device *dev;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
list_for_each(ele, &mconsole_devices) {
|
2005-04-16 22:20:36 +00:00
|
|
|
dev = list_entry(ele, struct mc_device, list);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (!strncmp(name, dev->name, strlen(dev->name)))
|
|
|
|
return dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-10-16 08:26:57 +00:00
|
|
|
return NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-31 10:30:08 +00:00
|
|
|
#define UNPLUGGED_PER_PAGE \
|
|
|
|
((PAGE_SIZE - sizeof(struct list_head)) / sizeof(unsigned long))
|
|
|
|
|
|
|
|
struct unplugged_pages {
|
|
|
|
struct list_head list;
|
|
|
|
void *pages[UNPLUGGED_PER_PAGE];
|
|
|
|
};
|
|
|
|
|
2008-02-05 06:31:27 +00:00
|
|
|
static DEFINE_MUTEX(plug_mem_mutex);
|
2006-03-31 10:30:08 +00:00
|
|
|
static unsigned long long unplugged_pages_count = 0;
|
2007-02-10 09:44:04 +00:00
|
|
|
static LIST_HEAD(unplugged_pages);
|
2006-03-31 10:30:08 +00:00
|
|
|
static int unplug_index = UNPLUGGED_PER_PAGE;
|
|
|
|
|
2007-02-10 09:43:53 +00:00
|
|
|
static int mem_config(char *str, char **error_out)
|
2006-03-31 10:30:08 +00:00
|
|
|
{
|
|
|
|
unsigned long long diff;
|
|
|
|
int err = -EINVAL, i, add;
|
|
|
|
char *ret;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (str[0] != '=') {
|
2007-02-10 09:43:53 +00:00
|
|
|
*error_out = "Expected '=' after 'mem'";
|
2006-03-31 10:30:08 +00:00
|
|
|
goto out;
|
2007-02-10 09:43:53 +00:00
|
|
|
}
|
2006-03-31 10:30:08 +00:00
|
|
|
|
|
|
|
str++;
|
2007-10-16 08:26:57 +00:00
|
|
|
if (str[0] == '-')
|
2006-03-31 10:30:08 +00:00
|
|
|
add = 0;
|
2007-10-16 08:26:57 +00:00
|
|
|
else if (str[0] == '+') {
|
2006-03-31 10:30:08 +00:00
|
|
|
add = 1;
|
|
|
|
}
|
2007-02-10 09:43:53 +00:00
|
|
|
else {
|
|
|
|
*error_out = "Expected increment to start with '-' or '+'";
|
|
|
|
goto out;
|
|
|
|
}
|
2006-03-31 10:30:08 +00:00
|
|
|
|
|
|
|
str++;
|
|
|
|
diff = memparse(str, &ret);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (*ret != '\0') {
|
2007-02-10 09:43:53 +00:00
|
|
|
*error_out = "Failed to parse memory increment";
|
2006-03-31 10:30:08 +00:00
|
|
|
goto out;
|
2007-02-10 09:43:53 +00:00
|
|
|
}
|
2006-03-31 10:30:08 +00:00
|
|
|
|
|
|
|
diff /= PAGE_SIZE;
|
|
|
|
|
2008-02-05 06:31:27 +00:00
|
|
|
mutex_lock(&plug_mem_mutex);
|
2007-10-16 08:26:57 +00:00
|
|
|
for (i = 0; i < diff; i++) {
|
2006-03-31 10:30:08 +00:00
|
|
|
struct unplugged_pages *unplugged;
|
|
|
|
void *addr;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (add) {
|
|
|
|
if (list_empty(&unplugged_pages))
|
2006-03-31 10:30:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
unplugged = list_entry(unplugged_pages.next,
|
|
|
|
struct unplugged_pages, list);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (unplug_index > 0)
|
2006-03-31 10:30:08 +00:00
|
|
|
addr = unplugged->pages[--unplug_index];
|
|
|
|
else {
|
|
|
|
list_del(&unplugged->list);
|
|
|
|
addr = unplugged;
|
|
|
|
unplug_index = UNPLUGGED_PER_PAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
free_page((unsigned long) addr);
|
|
|
|
unplugged_pages_count--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct page *page;
|
|
|
|
|
|
|
|
page = alloc_page(GFP_ATOMIC);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (page == NULL)
|
2006-03-31 10:30:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
unplugged = page_address(page);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (unplug_index == UNPLUGGED_PER_PAGE) {
|
2006-03-31 10:30:08 +00:00
|
|
|
list_add(&unplugged->list, &unplugged_pages);
|
|
|
|
unplug_index = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct list_head *entry = unplugged_pages.next;
|
|
|
|
addr = unplugged;
|
|
|
|
|
|
|
|
unplugged = list_entry(entry,
|
|
|
|
struct unplugged_pages,
|
|
|
|
list);
|
|
|
|
err = os_drop_memory(addr, PAGE_SIZE);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR "Failed to release "
|
|
|
|
"memory - errno = %d\n", err);
|
2007-02-10 09:43:53 +00:00
|
|
|
*error_out = "Failed to release memory";
|
2007-02-10 09:44:01 +00:00
|
|
|
goto out_unlock;
|
2007-02-10 09:43:53 +00:00
|
|
|
}
|
|
|
|
unplugged->pages[unplug_index++] = addr;
|
2006-03-31 10:30:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unplugged_pages_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err = 0;
|
2007-02-10 09:44:01 +00:00
|
|
|
out_unlock:
|
2008-02-05 06:31:27 +00:00
|
|
|
mutex_unlock(&plug_mem_mutex);
|
2006-03-31 10:30:08 +00:00
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mem_get_config(char *name, char *str, int size, char **error_out)
|
|
|
|
{
|
|
|
|
char buf[sizeof("18446744073709551615")];
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
sprintf(buf, "%ld", uml_physmem);
|
|
|
|
CONFIG_CHUNK(str, size, len, buf, 1);
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mem_id(char **str, int *start_out, int *end_out)
|
|
|
|
{
|
|
|
|
*start_out = 0;
|
|
|
|
*end_out = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-10 09:43:53 +00:00
|
|
|
static int mem_remove(int n, char **error_out)
|
2006-03-31 10:30:08 +00:00
|
|
|
{
|
2007-02-10 09:43:53 +00:00
|
|
|
*error_out = "Memory doesn't support the remove operation";
|
2006-03-31 10:30:08 +00:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct mc_device mem_mc = {
|
2007-02-10 09:44:01 +00:00
|
|
|
.list = LIST_HEAD_INIT(mem_mc.list),
|
2006-03-31 10:30:08 +00:00
|
|
|
.name = "mem",
|
|
|
|
.config = mem_config,
|
|
|
|
.get_config = mem_get_config,
|
|
|
|
.id = mem_id,
|
|
|
|
.remove = mem_remove,
|
|
|
|
};
|
|
|
|
|
2007-07-24 01:43:48 +00:00
|
|
|
static int __init mem_mc_init(void)
|
2006-03-31 10:30:08 +00:00
|
|
|
{
|
2007-10-16 08:26:57 +00:00
|
|
|
if (can_drop_memory())
|
2006-03-31 10:30:08 +00:00
|
|
|
mconsole_register_dev(&mem_mc);
|
2007-10-16 08:26:57 +00:00
|
|
|
else printk(KERN_ERR "Can't release memory to the host - memory "
|
|
|
|
"hotplug won't be supported\n");
|
2006-03-31 10:30:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
__initcall(mem_mc_init);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define CONFIG_BUF_SIZE 64
|
|
|
|
|
2006-01-06 08:18:50 +00:00
|
|
|
static void mconsole_get_config(int (*get_config)(char *, char *, int,
|
2005-04-16 22:20:36 +00:00
|
|
|
char **),
|
|
|
|
struct mc_request *req, char *name)
|
|
|
|
{
|
|
|
|
char default_buf[CONFIG_BUF_SIZE], *error, *buf;
|
|
|
|
int n, size;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (get_config == NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, "No get_config routine defined", 1, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = NULL;
|
2006-09-26 06:33:00 +00:00
|
|
|
size = ARRAY_SIZE(default_buf);
|
2005-04-16 22:20:36 +00:00
|
|
|
buf = default_buf;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
while (1) {
|
2005-04-16 22:20:36 +00:00
|
|
|
n = (*get_config)(name, buf, size, &error);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (error != NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, error, 1, 0);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (n <= size) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, buf, 0, 0);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (buf != default_buf)
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree(buf);
|
|
|
|
|
|
|
|
size = n;
|
|
|
|
buf = kmalloc(size, GFP_KERNEL);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (buf == NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, "Failed to allocate buffer", 1, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
2007-10-16 08:26:57 +00:00
|
|
|
if (buf != default_buf)
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_config(struct mc_request *req)
|
|
|
|
{
|
|
|
|
struct mc_device *dev;
|
2007-02-10 09:43:53 +00:00
|
|
|
char *ptr = req->request.data, *name, *error_string = "";
|
2005-04-16 22:20:36 +00:00
|
|
|
int err;
|
|
|
|
|
|
|
|
ptr += strlen("config");
|
2009-12-15 02:01:06 +00:00
|
|
|
ptr = skip_spaces(ptr);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev = mconsole_find_dev(ptr);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (dev == NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, "Bad configuration option", 1, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
name = &ptr[strlen(dev->name)];
|
|
|
|
ptr = name;
|
2007-10-16 08:26:57 +00:00
|
|
|
while ((*ptr != '=') && (*ptr != '\0'))
|
2005-04-16 22:20:36 +00:00
|
|
|
ptr++;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (*ptr == '=') {
|
2007-02-10 09:43:53 +00:00
|
|
|
err = (*dev->config)(name, &error_string);
|
|
|
|
mconsole_reply(req, error_string, err, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
else mconsole_get_config(dev->get_config, req, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_remove(struct mc_request *req)
|
|
|
|
{
|
2006-01-06 08:18:50 +00:00
|
|
|
struct mc_device *dev;
|
2005-06-25 21:55:25 +00:00
|
|
|
char *ptr = req->request.data, *err_msg = "";
|
2006-01-06 08:19:05 +00:00
|
|
|
char error[256];
|
2005-06-25 21:55:25 +00:00
|
|
|
int err, start, end, n;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
ptr += strlen("remove");
|
2009-12-15 02:01:06 +00:00
|
|
|
ptr = skip_spaces(ptr);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev = mconsole_find_dev(ptr);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (dev == NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_reply(req, "Bad remove option", 1, 0);
|
|
|
|
return;
|
|
|
|
}
|
2005-06-25 21:55:25 +00:00
|
|
|
|
2006-01-06 08:19:05 +00:00
|
|
|
ptr = &ptr[strlen(dev->name)];
|
|
|
|
|
|
|
|
err = 1;
|
|
|
|
n = (*dev->id)(&ptr, &start, &end);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (n < 0) {
|
2006-01-06 08:19:05 +00:00
|
|
|
err_msg = "Couldn't parse device number";
|
|
|
|
goto out;
|
|
|
|
}
|
2007-10-16 08:26:57 +00:00
|
|
|
else if ((n < start) || (n > end)) {
|
2006-01-06 08:19:05 +00:00
|
|
|
sprintf(error, "Invalid device number - must be between "
|
|
|
|
"%d and %d", start, end);
|
|
|
|
err_msg = error;
|
|
|
|
goto out;
|
|
|
|
}
|
2005-06-25 21:55:25 +00:00
|
|
|
|
2007-02-10 09:43:53 +00:00
|
|
|
err_msg = NULL;
|
|
|
|
err = (*dev->remove)(n, &err_msg);
|
2007-10-16 08:26:57 +00:00
|
|
|
switch(err) {
|
2007-03-29 08:20:28 +00:00
|
|
|
case 0:
|
|
|
|
err_msg = "";
|
|
|
|
break;
|
2006-01-06 08:19:05 +00:00
|
|
|
case -ENODEV:
|
2007-10-16 08:26:57 +00:00
|
|
|
if (err_msg == NULL)
|
2007-02-10 09:43:53 +00:00
|
|
|
err_msg = "Device doesn't exist";
|
2006-01-06 08:19:05 +00:00
|
|
|
break;
|
|
|
|
case -EBUSY:
|
2007-10-16 08:26:57 +00:00
|
|
|
if (err_msg == NULL)
|
2007-02-10 09:43:53 +00:00
|
|
|
err_msg = "Device is currently open";
|
2006-01-06 08:19:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
out:
|
2005-06-25 21:55:25 +00:00
|
|
|
mconsole_reply(req, err_msg, err, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-09-29 08:58:52 +00:00
|
|
|
struct mconsole_output {
|
|
|
|
struct list_head list;
|
|
|
|
struct mc_request *req;
|
|
|
|
};
|
|
|
|
|
2007-02-10 09:44:01 +00:00
|
|
|
static DEFINE_SPINLOCK(client_lock);
|
2006-01-06 08:19:04 +00:00
|
|
|
static LIST_HEAD(clients);
|
|
|
|
static char console_buf[MCONSOLE_MAX_DATA];
|
|
|
|
|
|
|
|
static void console_write(struct console *console, const char *string,
|
2007-10-16 08:27:17 +00:00
|
|
|
unsigned int len)
|
2006-01-06 08:19:04 +00:00
|
|
|
{
|
|
|
|
struct list_head *ele;
|
|
|
|
int n;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (list_empty(&clients))
|
2006-01-06 08:19:04 +00:00
|
|
|
return;
|
|
|
|
|
2007-10-16 08:27:17 +00:00
|
|
|
while (len > 0) {
|
|
|
|
n = min((size_t) len, ARRAY_SIZE(console_buf));
|
|
|
|
strncpy(console_buf, string, n);
|
2006-01-06 08:19:04 +00:00
|
|
|
string += n;
|
|
|
|
len -= n;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
list_for_each(ele, &clients) {
|
2006-09-29 08:58:52 +00:00
|
|
|
struct mconsole_output *entry;
|
2006-01-06 08:19:04 +00:00
|
|
|
|
2006-09-29 08:58:52 +00:00
|
|
|
entry = list_entry(ele, struct mconsole_output, list);
|
2007-10-16 08:27:17 +00:00
|
|
|
mconsole_reply_len(entry->req, console_buf, n, 0, 1);
|
2006-01-06 08:19:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct console mc_console = { .name = "mc",
|
|
|
|
.write = console_write,
|
2006-01-11 20:17:28 +00:00
|
|
|
.flags = CON_ENABLED,
|
2006-01-06 08:19:04 +00:00
|
|
|
.index = -1 };
|
|
|
|
|
|
|
|
static int mc_add_console(void)
|
|
|
|
{
|
|
|
|
register_console(&mc_console);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
late_initcall(mc_add_console);
|
|
|
|
|
|
|
|
static void with_console(struct mc_request *req, void (*proc)(void *),
|
|
|
|
void *arg)
|
|
|
|
{
|
2006-09-29 08:58:52 +00:00
|
|
|
struct mconsole_output entry;
|
2006-01-06 08:19:04 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
2006-09-29 08:58:52 +00:00
|
|
|
entry.req = req;
|
2007-02-10 09:44:01 +00:00
|
|
|
spin_lock_irqsave(&client_lock, flags);
|
2006-01-06 08:19:04 +00:00
|
|
|
list_add(&entry.list, &clients);
|
2007-02-10 09:44:01 +00:00
|
|
|
spin_unlock_irqrestore(&client_lock, flags);
|
2006-01-06 08:19:04 +00:00
|
|
|
|
|
|
|
(*proc)(arg);
|
|
|
|
|
2007-10-16 08:27:17 +00:00
|
|
|
mconsole_reply_len(req, "", 0, 0, 0);
|
2006-01-06 08:19:04 +00:00
|
|
|
|
2007-02-10 09:44:01 +00:00
|
|
|
spin_lock_irqsave(&client_lock, flags);
|
2006-01-06 08:19:04 +00:00
|
|
|
list_del(&entry.list);
|
2007-02-10 09:44:01 +00:00
|
|
|
spin_unlock_irqrestore(&client_lock, flags);
|
2006-01-06 08:19:04 +00:00
|
|
|
}
|
|
|
|
|
2006-01-06 08:19:05 +00:00
|
|
|
#ifdef CONFIG_MAGIC_SYSRQ
|
2007-10-16 08:27:17 +00:00
|
|
|
|
|
|
|
#include <linux/sysrq.h>
|
|
|
|
|
2006-01-06 08:19:05 +00:00
|
|
|
static void sysrq_proc(void *arg)
|
|
|
|
{
|
|
|
|
char *op = arg;
|
2010-08-18 04:15:47 +00:00
|
|
|
handle_sysrq(*op);
|
2006-01-06 08:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mconsole_sysrq(struct mc_request *req)
|
|
|
|
{
|
|
|
|
char *ptr = req->request.data;
|
|
|
|
|
|
|
|
ptr += strlen("sysrq");
|
2009-12-15 02:01:06 +00:00
|
|
|
ptr = skip_spaces(ptr);
|
2006-01-06 08:19:05 +00:00
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
/*
|
|
|
|
* With 'b', the system will shut down without a chance to reply,
|
2006-01-06 08:19:05 +00:00
|
|
|
* so in this case, we reply first.
|
|
|
|
*/
|
2007-10-16 08:26:57 +00:00
|
|
|
if (*ptr == 'b')
|
2006-01-06 08:19:05 +00:00
|
|
|
mconsole_reply(req, "", 0, 0);
|
|
|
|
|
|
|
|
with_console(req, sysrq_proc, ptr);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void mconsole_sysrq(struct mc_request *req)
|
|
|
|
{
|
|
|
|
mconsole_reply(req, "Sysrq not compiled in", 1, 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-06 08:19:04 +00:00
|
|
|
static void stack_proc(void *arg)
|
|
|
|
{
|
|
|
|
struct task_struct *from = current, *to = arg;
|
|
|
|
|
|
|
|
to->thread.saved_task = from;
|
2012-10-10 23:47:16 +00:00
|
|
|
rcu_user_hooks_switch(from, to);
|
2006-01-06 08:19:04 +00:00
|
|
|
switch_to(from, to, from);
|
|
|
|
}
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
/*
|
|
|
|
* Mconsole stack trace
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 02:27:46 +00:00
|
|
|
* Added by Allan Graves, Jeff Dike
|
|
|
|
* Dumps a stacks registers to the linux console.
|
|
|
|
* Usage stack <pid>.
|
|
|
|
*/
|
uml: throw out CONFIG_MODE_TT
This patchset throws out tt mode, which has been non-functional for a while.
This is done in phases, interspersed with code cleanups on the affected files.
The removal is done as follows:
remove all code, config options, and files which depend on
CONFIG_MODE_TT
get rid of the CHOOSE_MODE macro, which decided whether to
call tt-mode or skas-mode code, and replace invocations with their
skas portions
replace all now-trivial procedures with their skas equivalents
There are now a bunch of now-redundant pieces of data structures, including
mode-specific pieces of the thread structure, pt_regs, and mm_context. These
are all replaced with their skas-specific contents.
As part of the ongoing style compliance project, I made a style pass over all
files that were changed. There are three such patches, one for each phase,
covering the files affected by that phase but no later ones.
I noticed that we weren't freeing the LDT state associated with a process when
it exited, so that's fixed in one of the later patches.
The last patch is a tidying patch which I've had for a while, but which caused
inexplicable crashes under tt mode. Since that is no longer a problem, this
can now go in.
This patch:
Start getting rid of tt mode support.
This patch throws out CONFIG_MODE_TT and all config options, code, and files
which depend on it.
CONFIG_MODE_SKAS is gone and everything that depends on it is included
unconditionally.
The few changed lines are in re-written Kconfig help, lines which needed
something skas-related removed from them, and a few more which weren't
strictly deletions.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-16 08:26:50 +00:00
|
|
|
void mconsole_stack(struct mc_request *req)
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 02:27:46 +00:00
|
|
|
{
|
2006-01-06 08:19:05 +00:00
|
|
|
char *ptr = req->request.data;
|
|
|
|
int pid_requested= -1;
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 02:27:46 +00:00
|
|
|
struct task_struct *to = NULL;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
/*
|
|
|
|
* Would be nice:
|
2006-01-06 08:19:05 +00:00
|
|
|
* 1) Send showregs output to mconsole.
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 02:27:46 +00:00
|
|
|
* 2) Add a way to stack dump all pids.
|
|
|
|
*/
|
|
|
|
|
2006-01-06 08:19:05 +00:00
|
|
|
ptr += strlen("stack");
|
2009-12-15 02:01:06 +00:00
|
|
|
ptr = skip_spaces(ptr);
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 02:27:46 +00:00
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
/*
|
|
|
|
* Should really check for multiple pids or reject bad args here
|
|
|
|
*/
|
2006-01-06 08:19:05 +00:00
|
|
|
/* What do the arguments in mconsole_reply mean? */
|
2007-10-16 08:26:57 +00:00
|
|
|
if (sscanf(ptr, "%d", &pid_requested) == 0) {
|
2006-01-06 08:19:05 +00:00
|
|
|
mconsole_reply(req, "Please specify a pid", 1, 0);
|
|
|
|
return;
|
|
|
|
}
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 02:27:46 +00:00
|
|
|
|
2008-02-05 06:31:29 +00:00
|
|
|
to = find_task_by_pid_ns(pid_requested, &init_pid_ns);
|
2007-10-16 08:26:57 +00:00
|
|
|
if ((to == NULL) || (pid_requested == 0)) {
|
2006-01-06 08:19:05 +00:00
|
|
|
mconsole_reply(req, "Couldn't find that pid", 1, 0);
|
|
|
|
return;
|
|
|
|
}
|
2006-01-06 08:19:04 +00:00
|
|
|
with_console(req, stack_proc, to);
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 02:27:46 +00:00
|
|
|
}
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
/*
|
|
|
|
* Changed by mconsole_setup, which is __setup, and called before SMP is
|
2005-04-16 22:20:36 +00:00
|
|
|
* active.
|
|
|
|
*/
|
2006-01-06 08:18:50 +00:00
|
|
|
static char *notify_socket = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-07-24 01:43:48 +00:00
|
|
|
static int __init mconsole_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
/* long to avoid size mismatch warnings from gcc */
|
|
|
|
long sock;
|
|
|
|
int err;
|
2008-12-09 21:14:07 +00:00
|
|
|
char file[UNIX_PATH_MAX];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (umid_file_name("mconsole", file, sizeof(file)))
|
|
|
|
return -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
snprintf(mconsole_socket_name, sizeof(file), "%s", file);
|
|
|
|
|
|
|
|
sock = os_create_unix_socket(file, sizeof(file), 1);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (sock < 0) {
|
|
|
|
printk(KERN_ERR "Failed to initialize management console\n");
|
|
|
|
return 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-02-05 06:31:19 +00:00
|
|
|
if (os_set_fd_block(sock, 0))
|
|
|
|
goto out;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
register_reboot_notifier(&reboot_notifier);
|
|
|
|
|
|
|
|
err = um_request_irq(MCONSOLE_IRQ, sock, IRQ_READ, mconsole_interrupt,
|
2012-07-17 18:18:23 +00:00
|
|
|
IRQF_SHARED, "mconsole", (void *)sock);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR "Failed to get IRQ for management console\n");
|
2008-02-05 06:31:19 +00:00
|
|
|
goto out;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (notify_socket != NULL) {
|
2006-01-06 08:18:48 +00:00
|
|
|
notify_socket = kstrdup(notify_socket, GFP_KERNEL);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (notify_socket != NULL)
|
2005-04-16 22:20:36 +00:00
|
|
|
mconsole_notify(notify_socket, MCONSOLE_SOCKET,
|
2006-01-06 08:18:50 +00:00
|
|
|
mconsole_socket_name,
|
2005-04-16 22:20:36 +00:00
|
|
|
strlen(mconsole_socket_name) + 1);
|
|
|
|
else printk(KERN_ERR "mconsole_setup failed to strdup "
|
|
|
|
"string\n");
|
|
|
|
}
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
printk(KERN_INFO "mconsole (version %d) initialized on %s\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
MCONSOLE_VERSION, mconsole_socket_name);
|
2007-10-16 08:26:57 +00:00
|
|
|
return 0;
|
2008-02-05 06:31:19 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
os_close_file(sock);
|
|
|
|
return 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__initcall(mconsole_init);
|
|
|
|
|
2009-12-15 02:00:11 +00:00
|
|
|
static ssize_t mconsole_proc_write(struct file *file,
|
|
|
|
const char __user *buffer, size_t count, loff_t *pos)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
|
|
|
|
buf = kmalloc(count + 1, GFP_KERNEL);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (buf == NULL)
|
|
|
|
return -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (copy_from_user(buf, buffer, count)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
count = -EFAULT;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf[count] = '\0';
|
|
|
|
|
|
|
|
mconsole_notify(notify_socket, MCONSOLE_USER_NOTIFY, buf, count);
|
|
|
|
out:
|
|
|
|
kfree(buf);
|
2007-10-16 08:26:57 +00:00
|
|
|
return count;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 02:00:11 +00:00
|
|
|
static const struct file_operations mconsole_proc_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.write = mconsole_proc_write,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 16:52:59 +00:00
|
|
|
.llseek = noop_llseek,
|
2009-12-15 02:00:11 +00:00
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int create_proc_mconsole(void)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *ent;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (notify_socket == NULL)
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-12-15 02:00:11 +00:00
|
|
|
ent = proc_create("mconsole", 0200, NULL, &mconsole_proc_fops);
|
2007-10-16 08:26:57 +00:00
|
|
|
if (ent == NULL) {
|
2013-04-04 15:58:25 +00:00
|
|
|
printk(KERN_INFO "create_proc_mconsole : proc_create failed\n");
|
2007-10-16 08:26:57 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-10-16 08:26:57 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(notify_spinlock);
|
|
|
|
|
|
|
|
void lock_notify(void)
|
|
|
|
{
|
|
|
|
spin_lock(¬ify_spinlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void unlock_notify(void)
|
|
|
|
{
|
|
|
|
spin_unlock(¬ify_spinlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
__initcall(create_proc_mconsole);
|
|
|
|
|
2007-10-16 08:27:20 +00:00
|
|
|
#define NOTIFY "notify:"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static int mconsole_setup(char *str)
|
|
|
|
{
|
2007-10-16 08:26:57 +00:00
|
|
|
if (!strncmp(str, NOTIFY, strlen(NOTIFY))) {
|
2005-04-16 22:20:36 +00:00
|
|
|
str += strlen(NOTIFY);
|
|
|
|
notify_socket = str;
|
|
|
|
}
|
|
|
|
else printk(KERN_ERR "mconsole_setup : Unknown option - '%s'\n", str);
|
2007-10-16 08:26:57 +00:00
|
|
|
return 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-16 08:27:20 +00:00
|
|
|
__setup("mconsole=", mconsole_setup);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
__uml_help(mconsole_setup,
|
|
|
|
"mconsole=notify:<socket>\n"
|
|
|
|
" Requests that the mconsole driver send a message to the named Unix\n"
|
|
|
|
" socket containing the name of the mconsole socket. This also serves\n"
|
|
|
|
" to notify outside processes when UML has booted far enough to respond\n"
|
|
|
|
" to mconsole requests.\n\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
static int notify_panic(struct notifier_block *self, unsigned long unused1,
|
|
|
|
void *ptr)
|
|
|
|
{
|
|
|
|
char *message = ptr;
|
|
|
|
|
2007-10-16 08:26:57 +00:00
|
|
|
if (notify_socket == NULL)
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-06 08:18:50 +00:00
|
|
|
mconsole_notify(notify_socket, MCONSOLE_PANIC, message,
|
2005-04-16 22:20:36 +00:00
|
|
|
strlen(message) + 1);
|
2007-10-16 08:26:57 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block panic_exit_notifier = {
|
|
|
|
.notifier_call = notify_panic,
|
|
|
|
.next = NULL,
|
|
|
|
.priority = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
static int add_notifier(void)
|
|
|
|
{
|
[PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
We noticed that notifier chains in the kernel fall into two basic usage
classes:
"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;
"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.
We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.
With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)
There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)
Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.
Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.
ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain
BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain
It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)
The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.
[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-27 09:16:30 +00:00
|
|
|
atomic_notifier_chain_register(&panic_notifier_list,
|
|
|
|
&panic_exit_notifier);
|
2007-10-16 08:26:57 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__initcall(add_notifier);
|
|
|
|
|
|
|
|
char *mconsole_notify_socket(void)
|
|
|
|
{
|
2007-10-16 08:26:57 +00:00
|
|
|
return notify_socket;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(mconsole_notify_socket);
|