* Uml left showstopper bugs for 2.6.14
@ 2005-10-09 19:18 Blaisorblade
2005-10-09 19:37 ` [PATCH 1/6] Uml: hide commands when not being verbose Paolo 'Blaisorblade' Giarrusso
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Blaisorblade @ 2005-10-09 19:18 UTC (permalink / raw)
To: Andrew Morton, Linus Torvalds; +Cc: Jeff Dike, user-mode-linux-devel, LKML
Here's a short and updated list of showstoppers for 2.6.14 release, from the
UML point of view.
It's all things for which we (me and Jeff) have fixes, we are just in the
progress of cleaning them and/or in the queues.
I initially read 2.6.14 ETA's was around October 7, when is it now?
However, here we go with the showstoppers (mostly regression):
1) problems with UBD (i.e. _the_ uml block driver): this is pretty dangerous
and untrivial to fix, even if the code exists - so I and Jeff agreed to revert
the change altogether. Jeff will send the thing.
2) Someone broke endianness of COW driver macros in a header cleanup. I have
fixes.
3) SKAS0 is broken on amd64 hosts, when frame pointers are disabled. Jeff has
the fix, waiting end of testing.
4) SKAS0 is broken with GCC 3.2.3, and potentially other GCC releases - look
at arch/um/include/sysdep-i386/stub.h: stub_syscall*() to see how. I have two
fixes, choosing the safer one (it's all just simply reusing code from
<asm/unistd.h>).
5) Compile-time regression with SKAS mode disabled, will fix later (I'm going
to have dinner now).
--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 1/6] Uml: hide commands when not being verbose 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade @ 2005-10-09 19:37 ` Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 2/6] uml: add mode=skas0 as a synonym of skas0 Paolo 'Blaisorblade' Giarrusso ` (6 subsequent siblings) 7 siblings, 0 replies; 11+ messages in thread From: Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 UTC (permalink / raw) To: Linus Torvalds, Andrew Morton Cc: Jeff Dike, linux-kernel, user-mode-linux-devel From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Add a missing $(Q) to a "ln" invocation. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> --- arch/um/Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/um/Makefile b/arch/um/Makefile --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -152,7 +152,7 @@ archclean: $(SYMLINK_HEADERS): @echo ' SYMLINK $@' ifneq ($(KBUILD_SRC),) - ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ + $(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ else $(Q)cd $(TOPDIR)/$(dir $@) ; \ ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@) ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/6] uml: add mode=skas0 as a synonym of skas0 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade 2005-10-09 19:37 ` [PATCH 1/6] Uml: hide commands when not being verbose Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 ` Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 3/6] uml: allow building .s/.i/.lst files from userspace files Paolo 'Blaisorblade' Giarrusso ` (5 subsequent siblings) 7 siblings, 0 replies; 11+ messages in thread From: Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 UTC (permalink / raw) To: Linus Torvalds, Andrew Morton Cc: Jeff Dike, linux-kernel, user-mode-linux-devel From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Too many people were confused by skas0 and tried using "mode=skas0". And after all, they are right - accept this. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> --- arch/um/os-Linux/start_up.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c @@ -143,11 +143,22 @@ static int __init skas0_cmd_param(char * return 0; } +/* The two __uml_setup would conflict, without this stupid alias. */ + +static int __init mode_skas0_cmd_param(char *str, int* add) + __attribute__((alias("skas0_cmd_param"))); + __uml_setup("skas0", skas0_cmd_param, "skas0\n" " Disables SKAS3 usage, so that SKAS0 is used, unless \n" " you specify mode=tt.\n\n"); +__uml_setup("mode=skas0", mode_skas0_cmd_param, + "mode=skas0\n" + " Disables SKAS3 usage, so that SKAS0 is used, unless you \n" + " specify mode=tt. Note that this was recently added - on \n" + " older kernels you must use simply \"skas0\".\n\n"); + static int force_sysemu_disabled = 0; static int __init nosysemu_cmd_param(char *str, int* add) ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/6] uml: allow building .s/.i/.lst files from userspace files 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade 2005-10-09 19:37 ` [PATCH 1/6] Uml: hide commands when not being verbose Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 2/6] uml: add mode=skas0 as a synonym of skas0 Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 ` Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 4/6] uml: restore include breakage, breaking binary format of COW driver Paolo 'Blaisorblade' Giarrusso ` (4 subsequent siblings) 7 siblings, 0 replies; 11+ messages in thread From: Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 UTC (permalink / raw) To: Linus Torvalds, Andrew Morton Cc: Jeff Dike, linux-kernel, user-mode-linux-devel From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> For files which need to include glibc headers (i.e. userspace files), we specified the correct flags only for .o, not for .s/.lst/.i. Fix this. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> --- arch/um/scripts/Makefile.rules | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules @@ -7,8 +7,8 @@ USER_SINGLE_OBJS := \ USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) -$(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ - $(CFLAGS_$(notdir $@)) +$(USER_OBJS) $(USER_OBJS:.o=.i) $(USER_OBJS:.o=.s) $(USER_OBJS:.o=.lst): \ + c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(notdir $@)) $(USER_OBJS): cmd_checksrc = $(USER_OBJS): quiet_cmd_checksrc = $(USER_OBJS): cmd_force_checksrc = ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/6] uml: restore include breakage, breaking binary format of COW driver 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade ` (2 preceding siblings ...) 2005-10-09 19:37 ` [PATCH 3/6] uml: allow building .s/.i/.lst files from userspace files Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 ` Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 5/6] uml: cleanup byte order macros for " Paolo 'Blaisorblade' Giarrusso ` (3 subsequent siblings) 7 siblings, 0 replies; 11+ messages in thread From: Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 UTC (permalink / raw) To: Linus Torvalds, Andrew Morton Cc: Jeff Dike, linux-kernel, user-mode-linux-devel From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Commit 44456d37b59d8e541936ed26d8b6e08d27e88ac1, between 2.6.13-rc3 and -rc4, was a "nice cleanup" which broke something. Revert the offending part. It broke because: a) because this part doesn't fall under the description b) the author didn't know what he was doing here c) the author didn't try to compile the existing code and see that it worked perfectly. d) the author didn't ask us what was happening e) you didn't either, and somebody there should have learned that UML is a bit different. In fact, UML is special in linking to host libc and using its includes. In particular, since host includes always define both __BIG_ENDIAN and __LITTLE_ENDIAN, ntohll() macros started thinking to be in a big-endian world; and on-disk compatibility was broken. Many thanks go to Nix for reporting the problem and correctly diagnosing an endianness problem. Btw, this patch restores the previous code, which worked; but the definitions would be uncorrect if used in kernelspace files. Next patch addresses that. Cc: Nix <nix@esperi.org.uk>, Olaf Hering <olh@suse.de> Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> --- arch/um/drivers/cow.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h --- a/arch/um/drivers/cow.h +++ b/arch/um/drivers/cow.h @@ -3,10 +3,10 @@ #include <asm/types.h> -#if defined(__BIG_ENDIAN) +#if __BYTE_ORDER == __BIG_ENDIAN # define ntohll(x) (x) # define htonll(x) (x) -#elif defined(__LITTLE_ENDIAN) +#elif __BYTE_ORDER == __LITTLE_ENDIAN # define ntohll(x) bswap_64(x) # define htonll(x) bswap_64(x) #else ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/6] uml: cleanup byte order macros for COW driver 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade ` (3 preceding siblings ...) 2005-10-09 19:37 ` [PATCH 4/6] uml: restore include breakage, breaking binary format of COW driver Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 ` Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 6/6] uml: cleanup whitespace " Paolo 'Blaisorblade' Giarrusso ` (2 subsequent siblings) 7 siblings, 0 replies; 11+ messages in thread From: Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 UTC (permalink / raw) To: Linus Torvalds, Andrew Morton Cc: Jeff Dike, linux-kernel, user-mode-linux-devel From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> After restoring the existing code, make it work also when included in kernelspace code (which isn't currently the case, but at least this will prevent people from "fixing" it as just happened). Whitespace is fixed in next patch - it cluttered the diff too much. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> --- arch/um/drivers/cow.h | 27 ++++++++++++++++++++++++++- arch/um/drivers/cow_user.c | 1 - 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h --- a/arch/um/drivers/cow.h +++ b/arch/um/drivers/cow.h @@ -3,6 +3,26 @@ #include <asm/types.h> +#if defined(__KERNEL__) + +# include <asm/byteorder.h> + +# if defined(__BIG_ENDIAN) +# define ntohll(x) (x) +# define htonll(x) (x) +# elif defined(__LITTLE_ENDIAN) +# define ntohll(x) be64_to_cpu(x) +# define htonll(x) cpu_to_be64(x) +# else +# error "Could not determine byte order" +# endif + +#else +/* For the definition of ntohl, htonl and __BYTE_ORDER */ +#include <endian.h> +#include <netinet/in.h> +#if defined(__BYTE_ORDER) + #if __BYTE_ORDER == __BIG_ENDIAN # define ntohll(x) (x) # define htonll(x) (x) @@ -10,8 +30,13 @@ # define ntohll(x) bswap_64(x) # define htonll(x) bswap_64(x) #else -#error "__BYTE_ORDER not defined" +# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" +#endif + +#else /* ! defined(__BYTE_ORDER) */ +# error "Could not determine byte order: __BYTE_ORDER not defined" #endif +#endif /* ! defined(__KERNEL__) */ extern int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, int alignment, int *bitmap_offset_out, diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c --- a/arch/um/drivers/cow_user.c +++ b/arch/um/drivers/cow_user.c @@ -9,7 +9,6 @@ #include <sys/time.h> #include <sys/param.h> #include <sys/user.h> -#include <netinet/in.h> #include "os.h" ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 6/6] uml: cleanup whitespace for COW driver 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade ` (4 preceding siblings ...) 2005-10-09 19:37 ` [PATCH 5/6] uml: cleanup byte order macros for " Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 ` Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:42 ` [uml-devel] Uml left showstopper bugs for 2.6.14 Blaisorblade 2005-10-09 22:41 ` Jeff Dike 7 siblings, 0 replies; 11+ messages in thread From: Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:37 UTC (permalink / raw) To: Linus Torvalds, Andrew Morton Cc: Jeff Dike, linux-kernel, user-mode-linux-devel From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Fix whitespace - I split this off the previous patch for easier review. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> --- arch/um/drivers/cow.h | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h --- a/arch/um/drivers/cow.h +++ b/arch/um/drivers/cow.h @@ -23,15 +23,15 @@ #include <netinet/in.h> #if defined(__BYTE_ORDER) -#if __BYTE_ORDER == __BIG_ENDIAN -# define ntohll(x) (x) -# define htonll(x) (x) -#elif __BYTE_ORDER == __LITTLE_ENDIAN -# define ntohll(x) bswap_64(x) -# define htonll(x) bswap_64(x) -#else -# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" -#endif +# if __BYTE_ORDER == __BIG_ENDIAN +# define ntohll(x) (x) +# define htonll(x) (x) +# elif __BYTE_ORDER == __LITTLE_ENDIAN +# define ntohll(x) bswap_64(x) +# define htonll(x) bswap_64(x) +# else +# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" +# endif #else /* ! defined(__BYTE_ORDER) */ # error "Could not determine byte order: __BYTE_ORDER not defined" ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [uml-devel] Uml left showstopper bugs for 2.6.14 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade ` (5 preceding siblings ...) 2005-10-09 19:37 ` [PATCH 6/6] uml: cleanup whitespace " Paolo 'Blaisorblade' Giarrusso @ 2005-10-09 19:42 ` Blaisorblade 2005-11-02 21:44 ` Kai Tan 2005-10-09 22:41 ` Jeff Dike 7 siblings, 1 reply; 11+ messages in thread From: Blaisorblade @ 2005-10-09 19:42 UTC (permalink / raw) To: user-mode-linux-devel; +Cc: Jeff Dike, LKML, Kai Tan [-- Attachment #1: Type: text/plain, Size: 1428 bytes --] Kai - go to the end, there are patches for your SKAS0 problem. On Sunday 09 October 2005 21:18, Blaisorblade wrote: > Here's a short and updated list of showstoppers for 2.6.14 release, from > the UML point of view. > 2) Someone broke endianness of COW driver macros in a header cleanup. I > have fixes. Just sent them. > 3) SKAS0 is broken on amd64 hosts, when frame pointers are disabled. Jeff > has the fix, waiting end of testing. > 4) SKAS0 is broken with GCC 3.2.3, and potentially other GCC releases - > look at arch/um/include/sysdep-i386/stub.h: stub_syscall*() to see how. I > have two fixes, choosing the safer one (it's all just simply reusing code > from <asm/unistd.h>). Jeff, I've attached patches for this. Also found another problematic piece of code, in stub-segv (same bad idea). The patch for that changes a bit more things that strictly needed - complain if that's a problem for merging in 2.6.14. Kai Tan, the order of the patches is: uml-fix-misassembling-skas0-stub uml-fix-misassembling-skas0-stub-segv Note that the second is a bit less tested, so if both together cause problems, try with only the first one. And remember to add "skas0" to the cmd line, to force UML to run in SKAS0 mode. -- Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894) http://www.user-mode-linux.org/~blaisorblade [-- Attachment #2: uml-fix-misassembling-skas0-stub --] [-- Type: text/x-diff, Size: 6434 bytes --] uml: fix SKAS0 assembly stubs - use proper constraints From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Jeff Dike noted that the assembly code for syscall stubs is misassembled with GCC 3.2.3: the values copied in registers weren't preserved between one asm() and the following one. So I fixed the thing by rewriting the __asm__ constraints more like unistd.h ones. Note: in syscall6 case I had to add one more instruction (i.e. moving arg6 in eax and shuffling things around) - it's needed for the function to be valid in general (we can't load the value from the stack, relative to ebp, because we change it), but could be avoided since we actually use a constant as param 6. The only fix would be to turn stub_syscall6 to a macro and use a "i" constraint for arg6 (i.e., specify it's a constant value). Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Index: linux-2.6.13/arch/um/include/sysdep-i386/stub.h =================================================================== --- linux-2.6.13.orig/arch/um/include/sysdep-i386/stub.h +++ linux-2.6.13/arch/um/include/sysdep-i386/stub.h @@ -16,45 +16,69 @@ extern void stub_clone_handler(void); #define STUB_MMAP_NR __NR_mmap2 #define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT) +static inline long stub_syscall1(long syscall, long arg1) +{ + long ret; + + __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1)); + + return ret; +} + static inline long stub_syscall2(long syscall, long arg1, long arg2) { long ret; - __asm__("movl %0, %%ecx; " : : "g" (arg2) : "%ecx"); - __asm__("movl %0, %%ebx; " : : "g" (arg1) : "%ebx"); - __asm__("movl %0, %%eax; " : : "g" (syscall) : "%eax"); - __asm__("int $0x80;" : : : "%eax"); - __asm__ __volatile__("movl %%eax, %0; " : "=g" (ret) :); - return(ret); + __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), + "c" (arg2)); + + return ret; } static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) { - __asm__("movl %0, %%edx; " : : "g" (arg3) : "%edx"); - return(stub_syscall2(syscall, arg1, arg2)); + long ret; + + __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), + "c" (arg2), "d" (arg3)); + + return ret; } static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, long arg4) { - __asm__("movl %0, %%esi; " : : "g" (arg4) : "%esi"); - return(stub_syscall3(syscall, arg1, arg2, arg3)); + long ret; + + __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), + "c" (arg2), "d" (arg3), "S" (arg4)); + + return ret; +} + +static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3, + long arg4, long arg5) +{ + long ret; + + __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), + "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)); + + return ret; } static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) { long ret; - __asm__("movl %0, %%eax; " : : "g" (syscall) : "%eax"); - __asm__("movl %0, %%ebx; " : : "g" (arg1) : "%ebx"); - __asm__("movl %0, %%ecx; " : : "g" (arg2) : "%ecx"); - __asm__("movl %0, %%edx; " : : "g" (arg3) : "%edx"); - __asm__("movl %0, %%esi; " : : "g" (arg4) : "%esi"); - __asm__("movl %0, %%edi; " : : "g" (arg5) : "%edi"); - __asm__ __volatile__("pushl %%ebp ; movl %1, %%ebp; " - "int $0x80; popl %%ebp ; " - "movl %%eax, %0; " : "=g" (ret) : "g" (arg6) : "%eax"); - return(ret); + + __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; " + "int $0x80 ; pop %%ebp" + : "=a" (ret) + : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3), + "S" (arg4), "D" (arg5), "0" (arg6)); + + return ret; } static inline void trap_myself(void) Index: linux-2.6.13/arch/um/include/sysdep-x86_64/stub.h =================================================================== --- linux-2.6.13.orig/arch/um/include/sysdep-x86_64/stub.h +++ linux-2.6.13/arch/um/include/sysdep-x86_64/stub.h @@ -17,37 +17,72 @@ extern void stub_clone_handler(void); #define STUB_MMAP_NR __NR_mmap #define MMAP_OFFSET(o) (o) +#define __syscall_clobber "r11","rcx","memory" +#define __syscall "syscall" + static inline long stub_syscall2(long syscall, long arg1, long arg2) { long ret; - __asm__("movq %0, %%rsi; " : : "g" (arg2) : "%rsi"); - __asm__("movq %0, %%rdi; " : : "g" (arg1) : "%rdi"); - __asm__("movq %0, %%rax; " : : "g" (syscall) : "%rax"); - __asm__("syscall;" : : : "%rax", "%r11", "%rcx"); - __asm__ __volatile__("movq %%rax, %0; " : "=g" (ret) :); - return(ret); + __asm__ volatile (__syscall + : "=a" (ret) + : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber ); + + return ret; } static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) { - __asm__("movq %0, %%rdx; " : : "g" (arg3) : "%rdx"); - return(stub_syscall2(syscall, arg1, arg2)); + long ret; + + __asm__ volatile (__syscall + : "=a" (ret) + : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3) + : __syscall_clobber ); + + return ret; } static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, long arg4) { - __asm__("movq %0, %%r10; " : : "g" (arg4) : "%r10"); - return(stub_syscall3(syscall, arg1, arg2, arg3)); + long ret; + + __asm__ volatile ("movq %5,%%r10 ; " __syscall + : "=a" (ret) + : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3), + "g" (arg4) + : __syscall_clobber, "r10" ); + + return ret; +} + +static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3, + long arg4, long arg5) +{ + long ret; + + __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall + : "=a" (ret) + : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3), + "g" (arg4), "g" (arg5) + : __syscall_clobber, "r10", "r8" ); + + return ret; } static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) { - __asm__("movq %0, %%r9; " : : "g" (arg6) : "%r9"); - __asm__("movq %0, %%r8; " : : "g" (arg5) : "%r8"); - return(stub_syscall4(syscall, arg1, arg2, arg3, arg4)); + long ret; + + __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " + "movq %7, %%r9; " __syscall : "=a" (ret) + : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3), + "g" (arg4), "g" (arg5), "g" (arg6) + : __syscall_clobber, "r10", "r8", "r9" ); + + return ret; } static inline void trap_myself(void) [-- Attachment #3: uml-fix-misassembling-skas0-stub-segv --] [-- Type: text/x-diff, Size: 3093 bytes --] uml: fix assembly stub for segv From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Even here, we reuse values from one asm statement to the next without telling this to GCC - so fix this. While at it, a bit of improvements to the generated asm code, with better use of constraints. Still TODO: convert all this to the syscall_stub macros we already have. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Index: linux-2.6.13/arch/um/sys-i386/stub_segv.c =================================================================== --- linux-2.6.13.orig/arch/um/sys-i386/stub_segv.c +++ linux-2.6.13/arch/um/sys-i386/stub_segv.c @@ -14,17 +14,19 @@ void __attribute__ ((__section__ (".__sy stub_segv_handler(int sig) { struct sigcontext *sc = (struct sigcontext *) (&sig + 1); + long pid; GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA), sc); - __asm__("movl %0, %%eax ; int $0x80": : "g" (__NR_getpid)); - __asm__("movl %%eax, %%ebx ; movl %0, %%eax ; movl %1, %%ecx ;" - "int $0x80": : "g" (__NR_kill), "g" (SIGUSR1)); + __asm__("movl %1, %%eax ; int $0x80": "=&a" (pid): "i" (__NR_getpid)); + __asm__("movl %0, %%eax ; movl %1, %%ecx ;" + "int $0x80": : "i" (__NR_kill), "i" (SIGUSR1), "b" (pid) + : "eax", "ecx"); /* Load pointer to sigcontext into esp, since we need to leave * the stack in its original form when we do the sigreturn here, by * hand. */ __asm__("mov %0,%%esp ; movl %1, %%eax ; " - "int $0x80" : : "a" (sc), "g" (__NR_sigreturn)); + "int $0x80" : : "r" (sc), "i" (__NR_sigreturn)); } Index: linux-2.6.13/arch/um/sys-x86_64/stub_segv.c =================================================================== --- linux-2.6.13.orig/arch/um/sys-x86_64/stub_segv.c +++ linux-2.6.13/arch/um/sys-x86_64/stub_segv.c @@ -30,15 +30,17 @@ void __attribute__ ((__section__ (".__sy stub_segv_handler(int sig) { struct ucontext *uc; + long pid; __asm__("movq %%rdx, %0" : "=g" (uc) : ); GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA), &uc->uc_mcontext); - __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid) : "%rax"); - __asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;" - "syscall": : "g" (__NR_kill), "g" (SIGUSR1) : - "%rdi", "%rax", "%rsi"); + __asm__("movq %0, %%rax ; syscall": "=&a" (pid) : "g" (__NR_getpid) + : "rax", __syscall_clobber); + __asm__("movq %0, %%rax ; movq %1, %%rsi ;" + "syscall": : "i" (__NR_kill), "i" (SIGUSR1), "D" (pid) : + "rdi", "rax", "rsi", __syscall_clobber); /* sys_sigreturn expects that the stack pointer will be 8 bytes into * the signal frame. So, we use the ucontext pointer, which we know * already, to get the signal frame pointer, and add 8 to that. @@ -46,5 +48,5 @@ stub_segv_handler(int sig) __asm__("movq %0, %%rsp": : "g" ((unsigned long) container_of(uc, struct rt_sigframe, uc) + 8)); - __asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn) : "%rax"); + __asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn) : "rax"); } ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [uml-devel] Uml left showstopper bugs for 2.6.14 2005-10-09 19:42 ` [uml-devel] Uml left showstopper bugs for 2.6.14 Blaisorblade @ 2005-11-02 21:44 ` Kai Tan 2005-11-02 22:47 ` Blaisorblade 0 siblings, 1 reply; 11+ messages in thread From: Kai Tan @ 2005-11-02 21:44 UTC (permalink / raw) To: blaisorblade, user-mode-linux-devel; +Cc: jdike, linux-kernel I tried the first patch, got the following error: Kernel panic - not syncing: copy_context_skas0 : failed to wait for SIGUSR1/SIGTRAP, pid = 7182, n = 7182, errno = 0, status = 0xb7f I got the same error even after applying the second patch. My run command is the following: linux stderr=1 ubd0=../../root_fs.rh-7.2-full.pristine.20020312 >From: Blaisorblade <blaisorblade@yahoo.it> >To: user-mode-linux-devel@lists.sourceforge.net >CC: Jeff Dike <jdike@addtoit.com>, LKML <linux-kernel@vger.kernel.org>, >"Kai Tan" <mineown@hotmail.com> >Subject: Re: [uml-devel] Uml left showstopper bugs for 2.6.14 >Date: Sun, 9 Oct 2005 21:42:32 +0200 > >Kai - go to the end, there are patches for your SKAS0 problem. > >On Sunday 09 October 2005 21:18, Blaisorblade wrote: > > Here's a short and updated list of showstoppers for 2.6.14 release, from > > the UML point of view. > > > 2) Someone broke endianness of COW driver macros in a header cleanup. I > > have fixes. >Just sent them. > > 3) SKAS0 is broken on amd64 hosts, when frame pointers are disabled. >Jeff > > has the fix, waiting end of testing. > > > 4) SKAS0 is broken with GCC 3.2.3, and potentially other GCC releases - > > look at arch/um/include/sysdep-i386/stub.h: stub_syscall*() to see how. >I > > have two fixes, choosing the safer one (it's all just simply reusing >code > > from <asm/unistd.h>). >Jeff, I've attached patches for this. Also found another problematic piece >of >code, in stub-segv (same bad idea). > >The patch for that changes a bit more things that strictly needed - >complain >if that's a problem for merging in 2.6.14. > >Kai Tan, the order of the patches is: > >uml-fix-misassembling-skas0-stub >uml-fix-misassembling-skas0-stub-segv > >Note that the second is a bit less tested, so if both together cause >problems, >try with only the first one. > >And remember to add "skas0" to the cmd line, to force UML to run in SKAS0 >mode. >-- >Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". >Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ >215621894) >http://www.user-mode-linux.org/~blaisorblade ><< uml-fix-misassembling-skas0-stub >> ><< uml-fix-misassembling-skas0-stub-segv >> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [uml-devel] Uml left showstopper bugs for 2.6.14 2005-11-02 21:44 ` Kai Tan @ 2005-11-02 22:47 ` Blaisorblade 0 siblings, 0 replies; 11+ messages in thread From: Blaisorblade @ 2005-11-02 22:47 UTC (permalink / raw) To: Kai Tan; +Cc: user-mode-linux-devel, jdike, linux-kernel On Wednesday 02 November 2005 22:44, Kai Tan wrote: > I tried the first patch, got the following error: > > Kernel panic - not syncing: copy_context_skas0 : failed to wait for > SIGUSR1/SIGTRAP, pid = 7182, n = 7182, errno = 0, status = 0xb7f Ok, segmentation fault, again: $ ./testprogs/waitstatus $[0xb7f] WSTOPSIG(status) is 11 The signal is: Segmentation fault > I got the same error even after applying the second patch. Oh, sorry. Can you just try doing a "make clean" and forcing a full recompilation? In any case, I will try investigating further... I'll probably request you to give me the complete binary (without debug info and compressed) along with your .config. Please save them for now, I must check further before... For now, IIRC you can keep running with mode=tt, right? > My run command is the following: > > linux stderr=1 ubd0=../../root_fs.rh-7.2-full.pristine.20020312 -- Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894) http://www.user-mode-linux.org/~blaisorblade ____________________________________ Con Yahoo! Mail proteggi la tua casella di posta da virus e posta indesiderata http://mail.yahoo.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Uml left showstopper bugs for 2.6.14 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade ` (6 preceding siblings ...) 2005-10-09 19:42 ` [uml-devel] Uml left showstopper bugs for 2.6.14 Blaisorblade @ 2005-10-09 22:41 ` Jeff Dike 7 siblings, 0 replies; 11+ messages in thread From: Jeff Dike @ 2005-10-09 22:41 UTC (permalink / raw) To: Blaisorblade; +Cc: Andrew Morton, Linus Torvalds, user-mode-linux-devel, LKML On Sun, Oct 09, 2005 at 09:18:20PM +0200, Blaisorblade wrote: > 1) problems with UBD (i.e. _the_ uml block driver): this is pretty dangerous > and untrivial to fix, even if the code exists - so I and Jeff agreed to revert > the change altogether. Jeff will send the thing. My current plan is to revert the ubd-aio patch. I need to look at this and run some testing on it. > 3) SKAS0 is broken on amd64 hosts, when frame pointers are disabled. Jeff has > the fix, waiting end of testing. This has been sent to Linus. > 5) Compile-time regression with SKAS mode disabled, will fix later (I'm going > to have dinner now). I looked at the patch and requested the sender forward it to Linus, with my approval. If he doesn't in the next day or so, then I'll send it in myself. Jeff ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-11-02 22:42 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-10-09 19:18 Uml left showstopper bugs for 2.6.14 Blaisorblade 2005-10-09 19:37 ` [PATCH 1/6] Uml: hide commands when not being verbose Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 2/6] uml: add mode=skas0 as a synonym of skas0 Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 3/6] uml: allow building .s/.i/.lst files from userspace files Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 4/6] uml: restore include breakage, breaking binary format of COW driver Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 5/6] uml: cleanup byte order macros for " Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:37 ` [PATCH 6/6] uml: cleanup whitespace " Paolo 'Blaisorblade' Giarrusso 2005-10-09 19:42 ` [uml-devel] Uml left showstopper bugs for 2.6.14 Blaisorblade 2005-11-02 21:44 ` Kai Tan 2005-11-02 22:47 ` Blaisorblade 2005-10-09 22:41 ` Jeff Dike
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox