Hi, Mattia I'm sorry you got this, after I asked to enable iasl on all arches to be able to use it in qemu. I started investigating this last week or so, but didn't file a bug report because I've not come yet with a complete solution. Below my current analysis anyway, if I've time I'll try to come up with a full fix...
On Sun, 2006-12-03 at 13:13:19 +0100, Mattia Dongili wrote: > On Sat, Dec 02, 2006 at 02:27:40AM +0100, Andreas Henriksson wrote: > > On fre, 2006-12-01 at 15:43 -0800, Moore, Robert wrote: > > > I'm not sure I understand what you are describing, please clarify. > > Please see http://bugs.debian.org/401153 for the original bug > > report. Basically, iasl successfully compiles the atteched dsl > > file on a regular i386 pc, but when running the same program on > > PowerPC (Debian GNU/Linux) then you get a segmentation fault. There > > is probably a bug in the program somewhere which seems to only > > trigger on powerpc at the moment. > > > > It has been tracked down to being related to Asl.Value.String being > > NULL. This state seems invalid and makes the program crash. Do you > > have any idea what might have failed and how this variable could be > > uninitialized? It would be really appreciated if you have any hints > > about possible failures that we can investigate... This is a problem of endinaness. iasl does not work on big-endian boxes. The main issue is that the bison parser is using Value.Integer (which is an ACPI_INTEGER and in 32 bit arches it's a 64 bit type) to assign the values to the union ACPI_PARSE_VALUE. And then when accessing the pointers or the 'Size' variable it gets only the MSW, which is 0, so my workaround has been to define that we cannot use a 64 bit type for ACPI_INTEGER on 32 bit arches. Ideally the union should be filled using the proper member. This fixes the segfault. There's mentions in the changes.txt from 2003 of added support for big-endian systems, which was the first thing I tried, to enable the ACPI_BIG_ENDIAN macro for those arches (that's included in the patch anyway), but this didn't help. I suppose the code has evolved since then and that support has been lost because no one run it on such arches. Then the next problem is that iasl generates output, but that output is wrong. The output needs to be swapped to make it little-endian. AFAIS the problem is located in compiler/aslcodegen.c in most of the functions that are using CgLocalWriteAmlData, as they should be converting those values to little-endian when writting. But it didn't feel right to keep the TableHeader stored as little-endian in memory, as some other parts of the code use and reference it. So problably this needs to be swapped when dumping to the disk. > Just as a side note, I tried compiling the mentioned DSDT on an ARM > platform and I get a different error: I was trying it on arm little endian and it worked, the same for mipsel. The attached patch fixes the segfault, and corrects the CFLAGS handling for upstream and Debian, it also adds alpha to the list of 64 bit arches. The fix for compiler/aslopcodes.c is needed because the macros ACPI_UINT32_MAX: and ACPI_INTEGER_MAX are the same if ACPI_INTEGER is defined to be 32 bits. regards, guillem
diff -ur acpica-unix-20060912.orig/compiler/aslopcodes.c acpica-unix-20060912/compiler/aslopcodes.c --- acpica-unix-20060912.orig/compiler/aslopcodes.c 2006-09-12 20:49:25.000000000 +0300 +++ acpica-unix-20060912/compiler/aslopcodes.c 2006-11-27 09:40:52.000000000 +0200 @@ -329,6 +329,7 @@ } break; +#ifndef ACPI_NO_INTEGER64_SUPPORT case ACPI_INTEGER_MAX: /* Check for table integer width (32 or 64) */ @@ -341,6 +342,7 @@ return 1; } break; +#endif default: break; diff -ur acpica-unix-20060912.orig/compiler/Makefile acpica-unix-20060912/compiler/Makefile --- acpica-unix-20060912.orig/compiler/Makefile 2006-09-12 20:49:26.000000000 +0300 +++ acpica-unix-20060912/compiler/Makefile 2006-11-27 06:48:01.000000000 +0200 @@ -89,7 +89,8 @@ ../osunixxf.c NOMAN= YES -CFLAGS+= -Wall -O2 -Wstrict-prototypes -D_LINUX -DACPI_ASL_COMPILER -I../include +MK_CFLAGS = -DACPI_ASL_COMPILER -I../include +CFLAGS= -Wall -Wstrict-prototypes -O2 #YACC= yacc YACC= bison @@ -103,6 +104,9 @@ #CFLAGS+= -D_USE_BERKELEY_YACC #.endif +%.o: %.c + $(CC) $(MK_CFLAGS) $(CFLAGS) -c -o $@ $< + aslmain : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) \ $(LOADLIBES) $(LDLIBS) -o iasl diff -ur acpica-unix-20060912.orig/debian/rules acpica-unix-20060912/debian/rules --- acpica-unix-20060912.orig/debian/rules 2006-11-27 06:38:05.000000000 +0200 +++ acpica-unix-20060912/debian/rules 2006-11-27 06:40:31.000000000 +0200 @@ -32,7 +32,7 @@ # Commands to compile the package. cd compiler && \ - $(MAKE) && \ + $(MAKE) CFLAGS="$(CFLAGS)" && \ cd .. touch build-stamp diff -ur acpica-unix-20060912.orig/include/actypes.h acpica-unix-20060912/include/actypes.h --- acpica-unix-20060912.orig/include/actypes.h 2006-09-12 20:49:31.000000000 +0300 +++ acpica-unix-20060912/include/actypes.h 2006-11-27 09:37:32.000000000 +0200 @@ -274,6 +272,7 @@ #define ACPI_MAX_PTR ACPI_UINT32_MAX #define ACPI_SIZE_MAX ACPI_UINT32_MAX +#define ACPI_NO_INTEGER64_SUPPORT /******************************************************************************* * diff -ur acpica-unix-20060912.orig/include/platform/aclinux.h acpica-unix-20060912/include/platform/aclinux.h --- acpica-unix-20060912.orig/include/platform/aclinux.h 2006-09-12 20:49:32.000000000 +0300 +++ acpica-unix-20060912/include/platform/aclinux.h 2006-11-27 07:18:34.000000000 +0200 @@ -146,8 +146,9 @@ #include <stdlib.h> #include <ctype.h> #include <unistd.h> +#include <endian.h> -#if defined(__ia64__) || defined(__x86_64__) +#if defined(__ia64__) || defined(__x86_64__) || defined(__alpha__) #define ACPI_MACHINE_WIDTH 64 #define COMPILER_DEPENDENT_INT64 long #define COMPILER_DEPENDENT_UINT64 unsigned long @@ -158,6 +159,10 @@ #define ACPI_USE_NATIVE_DIVIDE #endif +#if __BYTE_ORDER == __BIG_ENDIAN +#define ACPI_BIG_ENDIAN +#endif + #define __cdecl #define ACPI_FLUSH_CPU_CACHE() #endif /* __KERNEL__ */ diff -ur acpica-unix-20060912.orig/tools/acpiexec/Makefile acpica-unix-20060912/tools/acpiexec/Makefile --- acpica-unix-20060912.orig/tools/acpiexec/Makefile 2006-09-12 20:49:39.000000000 +0300 +++ acpica-unix-20060912/tools/acpiexec/Makefile 2006-11-27 06:48:25.000000000 +0200 @@ -129,8 +129,12 @@ ../../osunixxf.c -CFLAGS+= -Wall -g -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP -D_MULTI_THREADED -Wstrict-prototypes -I../../include +MK_CFLAGS = -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP -D_MULTI_THREADED \ + -I../../include +CFLAGS = -Wall -Wstrict-prototypes -O2 -g +%.o: %.c + $(CC) $(MK_CFLAGS) $(CFLAGS) -c -o $@ $< acpiexec : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG) diff -ur acpica-unix-20060912.orig/tools/acpisrc/Makefile acpica-unix-20060912/tools/acpisrc/Makefile --- acpica-unix-20060912.orig/tools/acpisrc/Makefile 2006-09-12 20:49:40.000000000 +0300 +++ acpica-unix-20060912/tools/acpisrc/Makefile 2006-11-27 06:48:32.000000000 +0200 @@ -4,8 +4,11 @@ SRCS= ascase.c asconvrt.c asfile.c asmain.c asremove.c astable.c \ asutils.c osunixdir.c ../../common/getopt.c -CFLAGS+= -Wall -O2 -D_LINUX -DACPI_APPLICATION -Wstrict-prototypes -I../../include +MK_CFLAGS= -DACPI_APPLICATION -I../../include +CFLAGS= -Wall -Wstrict-prototypes -O2 +%.o: %.c + $(CC) $(MK_CFLAGS) $(CFLAGS) -c -o $@ $< aslmain : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG) diff -ur acpica-unix-20060912.orig/tools/acpixtract/Makefile acpica-unix-20060912/tools/acpixtract/Makefile --- acpica-unix-20060912.orig/tools/acpixtract/Makefile 2006-09-12 20:49:40.000000000 +0300 +++ acpica-unix-20060912/tools/acpixtract/Makefile 2006-11-27 06:48:38.000000000 +0200 @@ -3,8 +3,11 @@ PROG= acpixtract SRCS= acpixtract.c -CFLAGS+= -Wall -O2 -D_LINUX -DACPI_APPLICATION -Wstrict-prototypes -I../../include +MK_CFLAGS= -DACPI_APPLICATION -I../../include +CFLAGS= -Wall -Wstrict-prototypes -O2 +%.o: %.c + $(CC) $(MK_CFLAGS) $(CFLAGS) -c -o $@ $< acpixtract : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG)