uml-fixes-2.6.1-mm5-A1
Subsystems (2)
PATCH 1/1 uml-fixes-2.6.1-mm5-A1
Jeff, Andrew,
the attached patch is needed to make UML work on 2.6.1-mm5. It does the following things:
- update UML to the extable changes
- remove __i386__ kgdb dependency from config.h. The config.h kgdb.h thing is a kludge by itself i think - but this change doesnt make it any better. It might break amd64 which has CONFIG_X86 too iirc - but this unbreaks UML compilation.
- move i386 TASK_SIZE definition from page.h back to processor.h. This was moved to page.h by the 4G/4G patch and there's no reason why we couldnt leave it in processor.h. This unbreaks UML compilation.
- a top Makefile change broke UML compilation. I'm not sure why, but it makes the difference.
with this patch applied, UML compiles & works fine.
Ingo
arch/um/sys-i386/extable.c renamed from arch/um/sys-i386/extable.c.orig +0 -30
@@ -1,30 +0,0 @@ -/* -* linux/arch/i386/mm/extable.c -*/ - -#include <linux/config.h> -#include <linux/module.h> -#include <linux/spinlock.h> -#include <asm/uaccess.h> - -/* Simple binary search */ -const struct exception_table_entry * -search_extable (const struct exception_table_entry *first, -const struct exception_table_entry *last, -unsigned long value) -{ -while (first <= last) { -const struct exception_table_entry *mid; -long diff; - - mid = (last - first) /2 + first; - diff = mid->insn - value; -if (diff ==0 ) -return mid; -else if (diff <0 ) - first = mid+1 ; -else - last = mid-1 ; - } -return NULL ; -}
arch/um/sys-i386/Makefile renamed from arch/um/sys-i386/Makefile.orig +1 -1
@@ -1,4 +1,4 @@ -obj-y = bugs.o checksum.o extable.o fault.o ksyms.o ldt.o ptrace.o \ +obj-y = bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o \ ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o time.o obj-$(CONFIG_HIGHMEM) += highmem.o
include/linux/config.h renamed from include/linux/config.h.orig +1 -1
@@ -2,7 +2,7 @@#define _LINUX_CONFIG_H#include <linux/autoconf.h> -#if defined(__i386__) && !defined(IN_BOOTLOADER ) +#if defined(CONFIG_X86 ) && !defined(IN_BOOTLOADER )#include <asm/kgdb.h> #endif
include/asm-i386/page.h renamed from include/asm-i386/page.h.orig +0 -24
@@ -79,30 +79,6 @@ typedef struct { unsigned long pgprot; }#define PAGE_ALIGN (addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)/* -* This handles the memory map.. We could make this a config -* option, but too many people screw it up, and too few need -* it. -* -* A __PAGE_OFFSET of 0xC0000000 means that the kernel has -* a virtual address space of one gigabyte, which limits the -* amount of physical memory you can use to about 950MB. -* -* If you want more physical memory than this then see the CONFIG_HIGHMEM4G -* and CONFIG_HIGHMEM64G options in the kernel configuration. -* -* Note: on PAE the kernel must never go below 32 MB, we use the -* first 8 entries of the 2-level boot pgd for PAE magic. -*/ - -#ifdef CONFIG_X86_4G_VM_LAYOUT -#define __PAGE_OFFSET (0x02000000) -#define TASK_SIZE (0xff000000) -#else -#define __PAGE_OFFSET (0xc0000000) -#define TASK_SIZE (0xc0000000) -#endif - -/* * This much address space is reserved for vmalloc() and iomap() * as well as fixmap mappings. */
include/asm-i386/processor.h renamed from include/asm-i386/processor.h.orig +24 -0
@@ -291,6 +291,30 @@ extern unsigned int machine_submodel_id;extern unsigned int BIOS_revision;extern unsigned int mca_pentium_flag; +/* +* This handles the memory map.. We could make this a config +* option, but too many people screw it up, and too few need +* it. +* +* A __PAGE_OFFSET of 0xC0000000 means that the kernel has +* a virtual address space of one gigabyte, which limits the +* amount of physical memory you can use to about 950MB. +* +* If you want more physical memory than this then see the CONFIG_HIGHMEM4G +* and CONFIG_HIGHMEM64G options in the kernel configuration. +* +* Note: on PAE the kernel must never go below 32 MB, we use the +* first 8 entries of the 2-level boot pgd for PAE magic. +*/ + +#ifdef CONFIG_X86_4G_VM_LAYOUT +#define __PAGE_OFFSET (0x02000000) +#define TASK_SIZE (0xff000000) +#else +#define __PAGE_OFFSET (0xc0000000) +#define TASK_SIZE (0xc0000000) +#endif +/* This decides where the kernel will search for a free chunk of vm * space during mmap's. */
Makefile renamed from Makefile.orig +4 -0
@@ -404,6 +404,10 @@ endif include $(srctree)/arch/$(ARCH)/Makefile +# Let architecture Makefiles change CPPFLAGS if needed +CFLAGS := $(CPPFLAGS) $(CFLAGS) +AFLAGS := $(CPPFLAGS) $(AFLAGS) + core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
PATCH 1/1 uml-fixes2-2.6.1-mm5-A0
plus the attached patch is needed ontop of the previous one, to make x86 compile too. (and UML still compiles & works.)
Ingo
arch/i386/kernel/head.S renamed from arch/i386/kernel/head.S.orig +1 -0
@@ -13,6 +13,7 @@ #include <linux/linkage.h> #include <asm/segment.h> #include <asm/page.h> +#include <asm/processor.h> #include <asm/pgtable.h> #include <asm/desc.h> #include <asm/cache.h>
arch/i386/kernel/vmlinux.lds.S renamed from arch/i386/kernel/vmlinux.lds.S.orig +1 -0
@@ -5,6 +5,7 @@ #include <asm-generic/vmlinux.lds.h> #include <linux/config.h> #include <asm/page.h> +#include <asm/processor.h> #include <asm/asm_offsets.h> OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S.orig +1 -0
@@ -59,6 +59,7 @@ #include <asm/e820.h> #include <asm/edd.h> #include <asm/page.h> +#include <asm/processor.h> /* Signature words to ensure LILO loaded us right */ #define SIG1 0xAA55
include/asm-i386/processor.h renamed from include/asm-i386/processor.h.orig +28 -0
@@ -7,6 +7,8 @@#ifndef __ASM_I386_PROCESSOR_H#define __ASM_I386_PROCESSOR_H +#ifndef __ASSEMBLY__ +#include <asm/vm86.h> #include <asm/math_emu.h> #include <asm/segment.h>
@@ -649,4 +651,30 @@ extern void select_idle_routine(const st#define ARCH_HAS_SCHED_WAKE_BALANCE #endif +#endif /* ! __ASSEMBLY__ */ + +/* +* This handles the memory map.. We could make this a config +* option, but too many people screw it up, and too few need +* it. +* +* A __PAGE_OFFSET of 0xC0000000 means that the kernel has +* a virtual address space of one gigabyte, which limits the +* amount of physical memory you can use to about 950MB. +* +* If you want more physical memory than this then see the CONFIG_HIGHMEM4G +* and CONFIG_HIGHMEM64G options in the kernel configuration. +* +* Note: on PAE the kernel must never go below 32 MB, we use the +* first 8 entries of the 2-level boot pgd for PAE magic. +*/ + +#ifdef CONFIG_X86_4G_VM_LAYOUT +#define __PAGE_OFFSET (0x02000000) +#define TASK_SIZE (0xff000000) +#else +#define __PAGE_OFFSET (0xc0000000) +#define TASK_SIZE (0xc0000000) +#endif +#endif /* __ASM_I386_PROCESSOR_H */
scripts/Makefile.lib renamed from scripts/Makefile.lib.orig +7 -7
@@ -144,7 +144,8 @@ _hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_ # If building the kernel in a separate objtree expand all occurrences -# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). +# of -Idir to -Idir -I$(srctree)/dir. +# hereby allowing gcc to locate files in both trees. Local tree first. ifeq ($(KBUILD_SRC),) __c_flags = $(_c_flags)
@@ -153,16 +154,15 @@ __hostc_flags = $(_hostc_flags) __hostcxx_flags = $(_hostcxx_flags) else flags = $(foreach o,$($(1)),\ - $(if $(filter -I%,$(filter-out -I/%,$(o))), \ - $(patsubst -I%,-I$(srctree)/%,$(o)),$(o))) + $(if $(filter -I%,$(o)),$(patsubst -I%,-I$(srctree)/%,$(o)),$(o))) -# -I$(obj) locates generated .h files -# -I$(srctree)/$(src) locates .h files in srctree, from generated .c files -# FIXME: Replace both with specific EXTRA_CFLAGS statements in the makefiles +# -I$(obj) locate generated .h files +# -I$(srctree)/$(src) locate .h files in srctree, from generated .c files +# FIXME: Replace both with specific EXTRA_CFLAGS statements __c_flags = -I$(obj) -I$(srctree)/$(src) $(call flags,_c_flags) __a_flags = $(call flags,_a_flags) __hostc_flags = -I$(obj) $(call flags,_hostc_flags) -__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) +__hostcxx_flags = $(call flags,_hostcxx_flags) endif c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
Makefile renamed from Makefile.orig +1 -5
@@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 1 -EXTRAVERSION = -mm5 +EXTRAVERSION = # *DOCUMENTATION* # To see a list of typical targets execute "make help"
@@ -445,10 +445,6 @@ ifdef CONFIG_DEBUG_INFO CFLAGS += -g endif -# Enable unit-at-a-time mode when possible. It shrinks the -# kernel considerably. -CFLAGS += $(call check_gcc,-funit-at-a-time,) - # warn about C99 declaration after statement CFLAGS += $(call check_gcc,-Wdeclaration-after-statement,)
PATCH 1/1 uml-fixes2-2.6.1-mm5-A1
Quoted 3 lines
plus the attached patch is needed ontop of the previous one, to make x86 compile too. (and UML still compiles & works.)
i've attached uml-fixes2-2.6.1-A1 which is a replacement for the uml-fixes2-2.6.1-A0 patch - the Makefile.lib and Makefile diffs were superfluous.
Ingo
arch/i386/kernel/head.S renamed from arch/i386/kernel/head.S.orig +1 -0
@@ -13,6 +13,7 @@ #include <linux/linkage.h> #include <asm/segment.h> #include <asm/page.h> +#include <asm/processor.h> #include <asm/pgtable.h> #include <asm/desc.h> #include <asm/cache.h>
arch/i386/kernel/vmlinux.lds.S renamed from arch/i386/kernel/vmlinux.lds.S.orig +1 -0
@@ -5,6 +5,7 @@ #include <asm-generic/vmlinux.lds.h> #include <linux/config.h> #include <asm/page.h> +#include <asm/processor.h> #include <asm/asm_offsets.h> OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S.orig +1 -0
@@ -59,6 +59,7 @@ #include <asm/e820.h> #include <asm/edd.h> #include <asm/page.h> +#include <asm/processor.h> /* Signature words to ensure LILO loaded us right */ #define SIG1 0xAA55
include/asm-i386/processor.h renamed from include/asm-i386/processor.h.orig +28 -0
@@ -7,6 +7,8 @@#ifndef __ASM_I386_PROCESSOR_H#define __ASM_I386_PROCESSOR_H +#ifndef __ASSEMBLY__ +#include <asm/vm86.h> #include <asm/math_emu.h> #include <asm/segment.h>
@@ -649,4 +651,30 @@ extern void select_idle_routine(const st#define ARCH_HAS_SCHED_WAKE_BALANCE #endif +#endif /* ! __ASSEMBLY__ */ + +/* +* This handles the memory map.. We could make this a config +* option, but too many people screw it up, and too few need +* it. +* +* A __PAGE_OFFSET of 0xC0000000 means that the kernel has +* a virtual address space of one gigabyte, which limits the +* amount of physical memory you can use to about 950MB. +* +* If you want more physical memory than this then see the CONFIG_HIGHMEM4G +* and CONFIG_HIGHMEM64G options in the kernel configuration. +* +* Note: on PAE the kernel must never go below 32 MB, we use the +* first 8 entries of the 2-level boot pgd for PAE magic. +*/ + +#ifdef CONFIG_X86_4G_VM_LAYOUT +#define __PAGE_OFFSET (0x02000000) +#define TASK_SIZE (0xff000000) +#else +#define __PAGE_OFFSET (0xc0000000) +#define TASK_SIZE (0xc0000000) +#endif +#endif /* __ASM_I386_PROCESSOR_H */
PATCH 1/1 uml fixes, 2.6.1-mm5-A2
the patch below fixes a bug in UML that i've reproduced under 2.6.1-mm5.
The bug hits in the following race scenario: if userspace() is just about to handle a SIGTRAP signal that it wants to relay_signal(), and SIGVTALRM hits the context before this happens but after is_user is set to 1 in userspace(), then we get a kernelspace-signal panic. Ought to be rare but definitely triggerable.
Ingo
arch/um/kernel/skas/trap_user.c renamed from arch/um/kernel/skas/trap_user.c.orig +3 -0
@@ -19,8 +19,10 @@ void sig_handler_common_skas(int sig, vostruct skas_regs *r;struct signal_info *info;int save_errno = errno; +int save_user; r = &TASK_REGS (get_current ())->skas; + save_user = r->is_user; r->is_user =0 ; r->fault_addr =SC_FAULT_ADDR (sc); r->fault_type =SC_FAULT_TYPE (sc);
@@ -32,6 +34,7 @@ void sig_handler_common_skas(int sig, vo (*info->handler)(sig, (union uml_pt_regs *) r); + r->is_user = save_user; errno = save_errno; }
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Jeff Dike
AppliedRe: [uml-devel] [patch] uml fixes, 2.6.1-mm5-A2
Quoted 7 lines · Ingo Molnar
the patch below fixes a bug in UML that i've reproduced under 2.6.1-mm5.
The bug hits in the following race scenario: if
userspace()is just about to handle a SIGTRAP signal that it wants torelay_signal(), and SIGVTALRM hits the context before this happens but afteris_useris set to 1 inuserspace(), then we get a kernelspace-signal panic. Ought to be rare but definitely triggerable.
Applied, nice catch.
Jeff
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] Re: [patch] uml fixes, 2.6.1-mm5-A2
In reply to Ingo Molnarhm, there's this code in arch/um/sys-i386/bugs.c:arch_handle_signal():
ip = UPT_IP(regs);
if((*((char *) ip) != 0x0f) || ((*((char *) (ip + 1)) & 0xf0) != 0x40))
return(0);we are running in the UML kernel context here. Is the dereferencing of IP safe? Or does this SIGILL only ever happen for kernel code? (we dont seem to be filtering that out.)
Ingo
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] Re: [patch] uml fixes, 2.6.1-mm5-A2
Quoted 8 lines · Ingo Molnar
hm, there's this code in arch/um/sys-i386/bugs.c:arch_handle_signal():
ip = UPT_IP(regs); if((*((char *) ip) != 0x0f) || ((*((char *) (ip + 1)) & 0xf0) != 0x40)) return(0);we are running in the UML kernel context here. Is the dereferencing of IP safe?
No, it's not. There needs to be a copy_from_user in there.
Jeff
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] Re: [patch] uml fixes, 2.6.1-mm5-A2
Quoted 11 lines · Jeff Dike
Quoted 8 lines · Ingo Molnar
hm, there's this code in arch/um/sys-i386/bugs.c:arch_handle_signal():
ip = UPT_IP(regs); if((*((char *) ip) != 0x0f) || ((*((char *) (ip + 1)) & 0xf0) != 0x40)) return(0);we are running in the UML kernel context here. Is the dereferencing of IP safe?
No, it's not. There needs to be a
copy_from_userin there.
ok - partial patch below. (Couldnt figure out how to include the proper uaccess.h file to get copy_from_user() - so the build will fail with this patch for the time being.)
Ingo
arch/um/sys-i386/bugs.c renamed from arch/um/sys-i386/bugs.c.orig +4 -3
@@ -183,15 +183,16 @@ void arch_check_bugs(void)int arch_handle_signal (int sig,union uml_pt_regs *regs) { -unsigned long ip; +unsigned char tmp[2 ];/* This is testing for a cmov (0x0f 0x4x) instruction causing a * SIGILL in init. */ if ((sig !=SIGILL ) || (TASK_PID (get_current ()) !=1 ))return (0 ); - ip =UPT_IP (regs); -if ((*((char *) ip) !=0x0f ) || ((*((char *) (ip +1 )) &0xf0 ) !=0x40 )) +if (copy_from_user (tmp,UPT_IP (regs),2 )) +panic ("SIGILL in init, could not read instructions!\n" ); +if ((tmp[0 ] !=0x0f ) || ((tmp[1 ] &0xf0 ) !=0x40 ))return (0 );if (host_has_cmov ==0 )
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Jeff Dike
Applied[uml-devel] Re: [patch] uml fixes, 2.6.1-mm5-A2
Quoted 1 line · Ingo Molnar
ok - partial patch below.
Applied, thanks.
BTW, in skas mode, this was more than just unsafe - it was just completely wrong, since the kernel has no direct access to process memory.
Quoted 3 lines
(Couldnt figure out how to include the proper
uaccess.hfile to getcopy_from_user()- so the build will fail with this patch for the time being.)
There is a procedure, copy_from_user_proc, which exists for this reason.
Jeff
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] [patch] uml fixes, 2.6.1-mm5-A2
In reply to Ingo MolnarQuoted 2 lines · Ingo Molnar
the patch below fixes a bug in UML that i've reproduced under 2.6.1-mm5.
This fixes the bug "skas mode panic - ltrace strace" that occurs in uml-patch-2.4.23-2 and below. Could this patch please be applied to the 2.4.x kernels as well?
Thanks,
Dion.
Quoted 14 lines
arch/um/kernel/skas/trap_user.c renamed from arch/um/kernel/skas/trap_user.c.orig +2
-0@@ -19,8 +19,10 @@ void sig_handler_common_skas(int sig, vostruct skas_regs *r;struct signal_info *info;int save_errno = errno; +int save_user; r = &TASK_REGS (get_current ())->skas; + save_user = r->is_user; r->is_user =0 ; r->fault_addr =SC_FAULT_ADDR (sc); r->fault_type =SC_FAULT_TYPE (sc);
arch/um/kernel/skas/trap_user.c void sig_handler_common_skas(int sig, vo · line 40
Quoted 7 lines
arch/um/kernel/skas/trap_user.c renamed from arch/um/kernel/skas/trap_user.c.orig +1
-0@@ -32,6 +34,7 @@ void sig_handler_common_skas(int sig, vo (*info->handler)(sig, (union uml_pt_regs *) r); + r->is_user = save_user; errno = save_errno; }
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] [patch] uml fixes, 2.6.1-mm5-A2
Quoted 3 lines · [email protected] said:
This fixes the bug "skas mode panic - ltrace strace" that occurs in uml-patch-2.4.23-2 and below. Could this patch please be applied to the 2.4.x kernels as well?
I did, and it will be in the next patch.
Jeff
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel