📄 uml-2.6.10-fc3.patch
字号:
Index: linux-2.6.10/lib/Kconfig.debug===================================================================--- linux-2.6.10.orig/lib/Kconfig.debug 2004-12-25 05:35:24.000000000 +0800+++ linux-2.6.10/lib/Kconfig.debug 2005-04-07 22:05:29.475761192 +0800@@ -23,7 +23,6 @@ config MAGIC_SYSRQ bool "Magic SysRq key" depends on DEBUG_KERNEL && (H8300 || M68KNOMMU || V850)- depends (USERMODE && MCONSOLE) help Enables console device to interpret special characters as commands to dump state information.Index: linux-2.6.10/mm/mprotect.c===================================================================--- linux-2.6.10.orig/mm/mprotect.c 2004-12-25 05:35:50.000000000 +0800+++ linux-2.6.10/mm/mprotect.c 2005-04-07 22:05:29.475761192 +0800@@ -93,19 +93,20 @@ { pgd_t *dir; unsigned long beg = start;+ struct mm_struct * mm = vma->vm_mm; - dir = pgd_offset(current->mm, start);+ dir = pgd_offset(mm, start); flush_cache_range(vma, beg, end); if (start >= end) BUG();- spin_lock(¤t->mm->page_table_lock);+ spin_lock(&mm->page_table_lock); do { change_pmd_range(dir, start, end - start, newprot); start = (start + PGDIR_SIZE) & PGDIR_MASK; dir++; } while (start && (start < end)); flush_tlb_range(vma, beg, end);- spin_unlock(¤t->mm->page_table_lock);+ spin_unlock(&mm->page_table_lock); return; } @@ -190,8 +191,9 @@ return error; } -asmlinkage long-sys_mprotect(unsigned long start, size_t len, unsigned long prot)+long+do_mprotect(struct mm_struct *mm, unsigned long start, size_t len,+ unsigned long prot) { unsigned long vm_flags, nstart, end, tmp; struct vm_area_struct *vma, *prev;@@ -220,9 +222,9 @@ vm_flags = calc_vm_prot_bits(prot); - down_write(¤t->mm->mmap_sem);+ down_write(&mm->mmap_sem); - vma = find_vma_prev(current->mm, start, &prev);+ vma = find_vma_prev(mm, start, &prev); error = -ENOMEM; if (!vma) goto out;@@ -288,6 +290,11 @@ } } out:- up_write(¤t->mm->mmap_sem);+ up_write(&mm->mmap_sem); return error; }++asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot)+{+ return(do_mprotect(current->mm, start, len, prot));+}Index: linux-2.6.10/mm/mmap.c===================================================================--- linux-2.6.10.orig/mm/mmap.c 2005-04-06 23:38:33.000000000 +0800+++ linux-2.6.10/mm/mmap.c 2005-04-07 22:05:29.476761040 +0800@@ -759,11 +759,11 @@ * The caller must hold down_write(current->mm->mmap_sem). */ -unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,- unsigned long len, unsigned long prot,- unsigned long flags, unsigned long pgoff)+unsigned long __do_mmap_pgoff(struct mm_struct *mm, struct file * file,+ unsigned long addr, unsigned long len,+ unsigned long prot, unsigned long flags,+ unsigned long pgoff) {- struct mm_struct * mm = current->mm; struct vm_area_struct * vma, * prev; struct inode *inode; unsigned int vm_flags;@@ -1037,7 +1037,7 @@ return error; } -EXPORT_SYMBOL(do_mmap_pgoff);+EXPORT_SYMBOL(__do_mmap_pgoff); /* Get an address range which is currently unmapped. * For shmat() with addr=0.Index: linux-2.6.10/mm/proc_mm.c===================================================================--- linux-2.6.10.orig/mm/proc_mm.c 2005-04-07 19:34:21.197950744 +0800+++ linux-2.6.10/mm/proc_mm.c 2005-04-07 22:05:29.476761040 +0800@@ -0,0 +1,181 @@+/*+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)+ * Licensed under the GPL+ */++#include "linux/mm.h"+#include "linux/init.h"+#include "linux/proc_fs.h"+#include "linux/proc_mm.h"+#include "linux/file.h"+#include "linux/mman.h"+#include "asm/uaccess.h"+#include "asm/mmu_context.h"++static struct file_operations proc_mm_fops;++struct mm_struct *proc_mm_get_mm(int fd)+{+ struct mm_struct *ret = ERR_PTR(-EBADF);+ struct file *file;++ file = fget(fd);+ if (!file)+ goto out;++ ret = ERR_PTR(-EINVAL);+ if(file->f_op != &proc_mm_fops)+ goto out_fput;++ ret = file->private_data;+ out_fput:+ fput(file);+ out:+ return(ret);+}++extern long do_mmap2(struct mm_struct *mm, unsigned long addr,+ unsigned long len, unsigned long prot,+ unsigned long flags, unsigned long fd,+ unsigned long pgoff);++static ssize_t write_proc_mm(struct file *file, const char *buffer,+ size_t count, loff_t *ppos)+{+ struct mm_struct *mm = file->private_data;+ struct proc_mm_op req;+ int n, ret;++ if(count > sizeof(req))+ return(-EINVAL);++ n = copy_from_user(&req, buffer, count);+ if(n != 0)+ return(-EFAULT);++ ret = count;+ switch(req.op){+ case MM_MMAP: {+ struct mm_mmap *map = &req.u.mmap;++ /* Nobody ever noticed it, but do_mmap_pgoff() calls+ * get_unmapped_area() which checks current->mm, if+ * MAP_FIXED is not set, so mmap() could replace+ * an old mapping.+ */+ if (! (map->flags & MAP_FIXED))+ return(-EINVAL);++ ret = do_mmap2(mm, map->addr, map->len, map->prot,+ map->flags, map->fd, map->offset >> PAGE_SHIFT);+ if((ret & ~PAGE_MASK) == 0)+ ret = count;++ break;+ }+ case MM_MUNMAP: {+ struct mm_munmap *unmap = &req.u.munmap;++ down_write(&mm->mmap_sem);+ ret = do_munmap(mm, unmap->addr, unmap->len);+ up_write(&mm->mmap_sem);++ if(ret == 0)+ ret = count;+ break;+ }+ case MM_MPROTECT: {+ struct mm_mprotect *protect = &req.u.mprotect;++ ret = do_mprotect(mm, protect->addr, protect->len,+ protect->prot);+ if(ret == 0)+ ret = count;+ break;+ }++ case MM_COPY_SEGMENTS: {+ struct mm_struct *from = proc_mm_get_mm(req.u.copy_segments);++ if(IS_ERR(from)){+ ret = PTR_ERR(from);+ break;+ }++ ret = copy_context(mm, from);+ if(ret == 0)+ ret = count;+ break;+ }+ default:+ ret = -EINVAL;+ break;+ }++ return(ret);+}++static int open_proc_mm(struct inode *inode, struct file *file)+{+ struct mm_struct *mm = mm_alloc();+ int ret;++ ret = -ENOMEM;+ if(mm == NULL)+ goto out_mem;++ init_new_empty_context(mm);+ arch_pick_mmap_layout(mm);++ spin_lock(&mmlist_lock);+ list_add(&mm->mmlist, ¤t->mm->mmlist);+ spin_unlock(&mmlist_lock);++ file->private_data = mm;++ return(0);++ out_mem:+ return(ret);+}++static int release_proc_mm(struct inode *inode, struct file *file)+{+ struct mm_struct *mm = file->private_data;++ mmput(mm);+ return(0);+}++static struct file_operations proc_mm_fops = {+ .open = open_proc_mm,+ .release = release_proc_mm,+ .write = write_proc_mm,+};++static int make_proc_mm(void)+{+ struct proc_dir_entry *ent;++ ent = create_proc_entry("mm", 0222, &proc_root);+ if(ent == NULL){+ printk("make_proc_mm : Failed to register /proc/mm\n");+ return(0);+ }+ ent->proc_fops = &proc_mm_fops;++ return(0);+}++__initcall(make_proc_mm);++/*+ * Overrides for Emacs so that we follow Linus's tabbing style.+ * Emacs will notice this stuff at the end of the file and automatically+ * adjust the settings for this buffer only. This must remain at the end+ * of the file.+ * ---------------------------------------------------------------------------+ * Local variables:+ * c-file-style: "linux"+ * End:+ */Index: linux-2.6.10/mm/Makefile===================================================================--- linux-2.6.10.orig/mm/Makefile 2004-12-25 05:35:00.000000000 +0800+++ linux-2.6.10/mm/Makefile 2005-04-07 22:05:29.477760888 +0800@@ -18,3 +18,4 @@ obj-$(CONFIG_SHMEM) += shmem.o obj-$(CONFIG_TINY_SHMEM) += tiny-shmem.o +obj-$(CONFIG_PROC_MM) += proc_mm.oIndex: linux-2.6.10/arch/um/drivers/mconsole_kern.c===================================================================--- linux-2.6.10.orig/arch/um/drivers/mconsole_kern.c 2004-12-25 05:33:49.000000000 +0800+++ linux-2.6.10/arch/um/drivers/mconsole_kern.c 2005-04-07 22:05:29.477760888 +0800@@ -204,6 +204,68 @@ } #endif +/* This is a more convoluted version of mconsole_proc, which has some stability+ * problems; however, we need it fixed, because it is expected that UML users+ * mount HPPFS instead of procfs on /proc. And we want mconsole_proc to still+ * show the real procfs content, not the ones from hppfs.*/+#if 0+void mconsole_proc(struct mc_request *req)+{+ char path[64];+ char *buf;+ int len;+ int fd;+ int first_chunk = 1;+ char *ptr = req->request.data;++ ptr += strlen("proc");+ while(isspace(*ptr)) ptr++;+ snprintf(path, sizeof(path), "/proc/%s", ptr);++ fd = sys_open(path, 0, 0);+ if (fd < 0) {+ mconsole_reply(req, "Failed to open file", 1, 0);+ printk("open %s: %d\n",path,fd);+ goto out;+ }++ buf = kmalloc(PAGE_SIZE, GFP_KERNEL);+ if(buf == NULL){+ mconsole_reply(req, "Failed to allocate buffer", 1, 0);+ goto out_close;+ }++ for (;;) {+ len = sys_read(fd, buf, PAGE_SIZE-1);+ if (len < 0) {+ mconsole_reply(req, "Read of file failed", 1, 0);+ goto out_free;+ }+ /*Begin the file content on his own line.*/+ if (first_chunk) {+ mconsole_reply(req, "\n", 0, 1);+ first_chunk = 0;+ }+ if (len == PAGE_SIZE-1) {+ buf[len] = '\0';+ mconsole_reply(req, buf, 0, 1);+ } else {+ buf[len] = '\0';+ mconsole_reply(req, buf, 0, 0);+ break;+ }+ }+ /*END*/++ out_free:+ kfree(buf);+ out_close:+ sys_close(fd);+ out:+ /* nothing */;+}+#endif+ void mconsole_proc(struct mc_request *req) { char path[64];Index: linux-2.6.10/arch/um/drivers/net_kern.c===================================================================--- linux-2.6.10.orig/arch/um/drivers/net_kern.c 2004-12-25 05:34:44.000000000 +0800+++ linux-2.6.10/arch/um/drivers/net_kern.c 2005-04-07 22:05:29.478760736 +0800@@ -126,10 +126,6 @@ lp->tl.data = (unsigned long) &lp->user; netif_start_queue(dev); - spin_lock(&opened_lock);- list_add(&lp->list, &opened);- spin_unlock(&opened_lock);- /* clear buffer - it can happen that the host side of the interface * is full when we get here. In this case, new data is never queued, * SIGIOs never arrive, and the net never works.@@ -152,9 +148,6 @@ free_irq(dev->irq, dev); if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user); lp->fd = -1;- spin_lock(&opened_lock);- list_del(&lp->list);- spin_unlock(&opened_lock); spin_unlock(&lp->lock); return 0;@@ -397,6 +390,11 @@ if (device->have_mac) set_ether_mac(dev, device->mac);++ spin_lock(&opened_lock);+ list_add(&lp->list, &opened);+ spin_unlock(&opened_lock);+ return(0); } @@ -705,7 +703,7 @@ static void close_devices(void) { struct list_head *ele;- struct uml_net_private *lp; + struct uml_net_private *lp; list_for_each(ele, &opened){ lp = list_entry(ele, struct uml_net_private, list);Index: linux-2.6.10/arch/um/drivers/net_user.c===================================================================--- linux-2.6.10.orig/arch/um/drivers/net_user.c 2004-12-25 05:34:26.000000000 +0800+++ linux-2.6.10/arch/um/drivers/net_user.c 2005-04-07 22:05:29.478760736 +0800@@ -173,10 +173,12 @@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -