* RE: [uml-devel] SKAS on AMD 64-Bit
2004-08-15 21:44 ` Anthony Brock
@ 2004-08-15 23:13 ` Anthony Brock
2004-08-23 15:58 ` BlaisorBlade
2004-08-31 23:08 ` [uml-devel] UML " Qinghua(Kevin) Ye
0 siblings, 2 replies; 5+ messages in thread
From: Anthony Brock @ 2004-08-15 23:13 UTC (permalink / raw)
To: user-mode-linux-devel
[-- Attachment #1: Type: text/plain, Size: 2148 bytes --]
It would probably help if I included the patch! :)
Tony
> -----Original Message-----
> From: user-mode-linux-devel-admin@lists.sourceforge.net
> [mailto:user-mode-linux-devel-admin@lists.sourceforge.net]On Behalf Of
> Anthony Brock
> Sent: Sunday, August 15, 2004 2:44 PM
> To: user-mode-linux-devel@lists.sourceforge.net
> Subject: RE: [uml-devel] SKAS on AMD 64-Bit
>
>
> Given a lack of responses to my inquiry, I've attempted to migrate the
> existing patches to the "arch/i386" and "include/asm-i386" directories to
> the corresponding "arch/x86_64" and "include/asm-x86_64" directories.
>
> However, I am experiencing the following issue during boot of a previously
> functional guest UML when I use the new Host Kernel:
>
> Checking for the skas3 patch in the host...found
> Checking for /proc/mm...found
> Linux version 2.6.7-1um (root@vs1) (gcc version 3.3.3 (SuSE Linux)) #2 Thu
> Jul 29 08:57:53 PDT 2004
> On node 0 totalpages: 122880
> DMA zone: 122880 pages, LIFO batch:16
> Normal zone: 0 pages, LIFO batch:1
> HighMem zone: 0 pages, LIFO batch:1
> Built 1 zonelists
>
> *** OUTPUT TRIMMED ***
>
> kjournald starting. Commit interval 5 seconds
> EXT3-fs: mounted filesystem with ordered data mode.
> VFS: Mounted root (ext3 filesystem) readonly.
> Kernel panic: kernel BUG at mm/mmap.c:700!
>
>
> Any ideas? How would I generate a backtrace for this issue?
>
> I am attaching a copy of the non-functional patch. This patch applies
> against a vanilla 2.6.7 kernel with host-skas3-2.6.7-v1.patch pre-applied
> (in other words, it's a patch to the SKAS3 patch). Thanks in advance!
>
> Tony
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> User-mode-linux-devel mailing list
> User-mode-linux-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
>
[-- Attachment #2: x86_64-host-skas3-2.6.7-v1.patch --]
[-- Type: application/octet-stream, Size: 7878 bytes --]
diff -ur arch/x86_64/Kconfig.skas arch/x86_64/Kconfig
--- arch/x86_64/Kconfig.skas 2004-06-15 22:19:44.000000000 -0700
+++ arch/x86_64/Kconfig 2004-08-06 14:29:12.447093965 -0700
@@ -249,6 +249,10 @@
cost of slightly increased overhead in some places. If unsure say
N here.
+config PROC_MM
+ bool "/proc/mm support"
+ default y
+
config K8_NUMA
bool "K8 NUMA support"
depends on SMP
diff -ur arch/x86_64/kernel/ldt.c.skas arch/x86_64/kernel/ldt.c
--- arch/x86_64/kernel/ldt.c.skas 2004-06-15 22:20:03.000000000 -0700
+++ arch/x86_64/kernel/ldt.c 2004-08-06 14:25:55.828722076 -0700
@@ -58,7 +58,7 @@
wmb();
pc->size = mincount;
wmb();
- if (reload) {
+ if (reload && (¤t->active_mm->context == pc)) {
#ifdef CONFIG_SMP
cpumask_t mask;
@@ -94,14 +94,12 @@
* we do not have to muck with descriptors here, that is
* done in switch_mm() as needed.
*/
-int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
+int __init_new_context(struct mm_struct *mm, struct mm_struct *old_mm)
{
- struct mm_struct * old_mm;
int retval = 0;
init_MUTEX(&mm->context.sem);
mm->context.size = 0;
- old_mm = current->mm;
if (old_mm && old_mm->context.size > 0) {
down(&old_mm->context.sem);
retval = copy_ldt(&mm->context, &old_mm->context);
@@ -110,6 +108,11 @@
return retval;
}
+int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
+{
+ return __init_new_context(mm, current->mm);
+}
+
/*
*
* Don't touch the LDT register - we're already in the next thread.
@@ -125,11 +128,11 @@
}
}
-static int read_ldt(void __user * ptr, unsigned long bytecount)
+static int read_ldt(struct mm_struct * mm, void __user * ptr,
+ unsigned long bytecount)
{
int err;
unsigned long size;
- struct mm_struct * mm = current->mm;
if (!mm->context.size)
return 0;
@@ -164,10 +167,9 @@
return bytecount;
}
-static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
+static int write_ldt(struct mm_struct * mm, void __user * ptr,
+ unsigned long bytecount, int oldmode)
{
- struct task_struct *me = current;
- struct mm_struct * mm = me->mm;
__u32 entry_1, entry_2, *lp;
int error;
struct user_desc ldt_info;
@@ -192,7 +194,7 @@
down(&mm->context.sem);
if (ldt_info.entry_number >= (unsigned)mm->context.size) {
- error = alloc_ldt(¤t->mm->context, ldt_info.entry_number+1, 1);
+ error = alloc_ldt(&mm->context, ldt_info.entry_number+1, 1);
if (error < 0)
goto out_unlock;
}
@@ -225,23 +227,29 @@
return error;
}
-asmlinkage int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
+int modify_ldt(struct mm_struct * mm, int func, void __user *ptr,
+ unsigned long bytecount)
{
int ret = -ENOSYS;
switch (func) {
case 0:
- ret = read_ldt(ptr, bytecount);
+ ret = read_ldt(mm, ptr, bytecount);
break;
case 1:
- ret = write_ldt(ptr, bytecount, 1);
+ ret = write_ldt(mm, ptr, bytecount, 1);
break;
case 2:
ret = read_default_ldt(ptr, bytecount);
break;
case 0x11:
- ret = write_ldt(ptr, bytecount, 0);
+ ret = write_ldt(mm, ptr, bytecount, 0);
break;
}
return ret;
}
+
+asmlinkage int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
+{
+ return modify_ldt(current->mm, func, ptr, bytecount);
+}
diff -ur arch/x86_64/kernel/ptrace.c.skas arch/x86_64/kernel/ptrace.c
--- arch/x86_64/kernel/ptrace.c.skas 2004-06-15 22:19:09.000000000 -0700
+++ arch/x86_64/kernel/ptrace.c 2004-08-06 14:13:50.589224916 -0700
@@ -17,6 +17,7 @@
#include <linux/user.h>
#include <linux/security.h>
#include <linux/audit.h>
+#include <linux/proc_mm.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
@@ -477,6 +478,56 @@
break;
}
+#ifdef CONFIG_PROC_MM
+ case PTRACE_FAULTINFO: {
+ struct ptrace_faultinfo fault;
+
+ fault = ((struct ptrace_faultinfo)
+ { .is_write = child->thread.error_code,
+ .addr = child->thread.cr2 });
+ ret = copy_to_user((unsigned long *) data, &fault,
+ sizeof(fault));
+ if(ret)
+ break;
+ break;
+ }
+
+ case PTRACE_SIGPENDING:
+ ret = copy_to_user((unsigned long *) data,
+ &child->pending.signal,
+ sizeof(child->pending.signal));
+ break;
+
+ case PTRACE_LDT: {
+ struct ptrace_ldt ldt;
+
+ if(copy_from_user(&ldt, (unsigned long *) data,
+ sizeof(ldt))){
+ ret = -EIO;
+ break;
+ }
+ ret = modify_ldt(child->mm, ldt.func, ldt.ptr, ldt.bytecount);
+ break;
+ }
+
+ case PTRACE_SWITCH_MM: {
+ struct mm_struct *old = child->mm;
+ struct mm_struct *new = proc_mm_get_mm(data);
+
+ if(IS_ERR(new)){
+ ret = PTR_ERR(new);
+ break;
+ }
+
+ atomic_inc(&new->mm_users);
+ child->mm = new;
+ child->active_mm = new;
+ mmput(old);
+ ret = 0;
+ break;
+ }
+#endif
+
default:
ret = ptrace_request(child, request, addr, data);
break;
diff -ur arch/x86_64/kernel/sys_x86_64.c.skas arch/x86_64/kernel/sys_x86_64.c
--- arch/x86_64/kernel/sys_x86_64.c.skas 2004-06-15 22:19:37.000000000 -0700
+++ arch/x86_64/kernel/sys_x86_64.c 2004-08-06 13:51:08.308766765 -0700
@@ -38,7 +38,9 @@
return error;
}
-long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
+long do_mmap2(struct mm_struct *mm,
+ unsigned long addr, unsigned long len,
+ unsigned long prot, unsigned long flags,
unsigned long fd, unsigned long off)
{
long error;
@@ -56,9 +58,9 @@
if (!file)
goto out;
}
- down_write(¤t->mm->mmap_sem);
- error = do_mmap_pgoff(file, addr, len, prot, flags, off >> PAGE_SHIFT);
- up_write(¤t->mm->mmap_sem);
+ down_write(&mm->mmap_sem);
+ error = __do_mmap_pgoff(mm, file, addr, len, prot, flags, off >> PAGE_SHIFT);
+ up_write(&mm->mmap_sem);
if (file)
fput(file);
@@ -66,6 +68,12 @@
return error;
}
+long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
+ unsigned long fd, unsigned long off)
+{
+ return do_mmap2(current->mm, addr, len, prot, flags, fd, off);
+}
+
static void find_start_end(unsigned long flags, unsigned long *begin,
unsigned long *end)
{
diff -ur include/asm-x86_64/desc.h.skas include/asm-x86_64/desc.h
--- include/asm-x86_64/desc.h.skas 2004-06-15 22:20:26.000000000 -0700
+++ include/asm-x86_64/desc.h 2004-08-06 14:32:39.968349277 -0700
@@ -210,6 +210,9 @@
put_cpu();
}
+extern int modify_ldt(struct mm_struct * mm, int func, void __user *ptr,
+ unsigned long bytecount);
+
#endif /* !__ASSEMBLY__ */
#endif
diff -ur include/asm-x86_64/processor.h.skas include/asm-x86_64/processor.h
--- include/asm-x86_64/processor.h.skas 2004-06-15 22:20:18.000000000 -0700
+++ include/asm-x86_64/processor.h 2004-08-06 14:34:56.998875865 -0700
@@ -454,6 +454,8 @@
ti->task; \
})
+extern int __init_new_context(struct mm_struct *mm, struct mm_struct *old_mm);
+
#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
#ifdef CONFIG_SCHED_SMT
diff -ur include/asm-x86_64/ptrace.h.skas include/asm-x86_64/ptrace.h
--- include/asm-x86_64/ptrace.h.skas 2004-06-15 22:19:03.000000000 -0700
+++ include/asm-x86_64/ptrace.h 2004-08-06 14:38:35.353933414 -0700
@@ -110,4 +110,26 @@
#endif
+/*For SKAS3 support.*/
+#ifndef _LINUX_PTRACE_STRUCT_DEF
+#define _LINUX_PTRACE_STRUCT_DEF
+
+#define PTRACE_FAULTINFO 52
+#define PTRACE_SIGPENDING 53
+#define PTRACE_LDT 54
+#define PTRACE_SWITCH_MM 55
+
+struct ptrace_faultinfo {
+ int is_write;
+ unsigned long addr;
+};
+
+struct ptrace_ldt {
+ int func;
+ void *ptr;
+ unsigned long bytecount;
+};
+
+#endif /*ifndef _LINUX_PTRACE_STRUCT_DEF*/
+
#endif
^ permalink raw reply [flat|nested] 5+ messages in thread