[syslinux] efilinux release 0.8

Matt Fleming matt at console-pimps.org
Mon Aug 22 11:22:31 PDT 2011


On Mon, 2011-08-22 at 18:14 +0100, Matt Fleming wrote:
> 
> I don't think the stack alignment issue that you've been referring to is
> the problem here. gnu-efi adheres to the 16-byte stack alignment
> required by the UEFI 2.1 spec.

But let's find out for sure. Here's a test case from Peter that should
apply to gnu-efi trunk. Could you apply the patch and run the 'tcc' app
on your effected machine and let me know the output, please?


diff --git a/gnu-efi-3.0/apps/Makefile b/gnu-efi-3.0/apps/Makefile
index d14bd00..1e43821 100644
--- a/gnu-efi-3.0/apps/Makefile
+++ b/gnu-efi-3.0/apps/Makefile
@@ -58,7 +58,7 @@ LDFLAGS		+= -T $(LDSCRIPT) -shared -Bsymbolic -L../lib -L../gnuefi $(CRTOBJS)
 LOADLIBES	= -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
 FORMAT		= efi-app-$(ARCH)
 
-TARGETS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi printenv.efi t7.efi
+TARGETS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi printenv.efi t7.efi tcc.efi
 
 all:	$(TARGETS)
 
diff --git a/gnu-efi-3.0/apps/tcc.c b/gnu-efi-3.0/apps/tcc.c
new file mode 100644
index 0000000..d26dfac
--- /dev/null
+++ b/gnu-efi-3.0/apps/tcc.c
@@ -0,0 +1,441 @@
+/*
+ * Test if our calling convention gymnastics actually work
+ */
+
+#include <efi.h>
+#include <efilib.h>
+
+#ifdef __x86_64__
+#include <x86_64/pe.h>
+#endif
+
+#if 0
+	asm volatile("out %0,%1" : : "a" ((uint8_t)a), "dN" (0x80));
+#endif
+
+extern void dump_stack(void);
+asm(	".globl	dump_stack\n"
+	"dump_stack:\n"
+	"	movq %rsp, %rdi\n"
+	"	jmp *dump_stack_helper at GOTPCREL(%rip)\n"
+	".size	dump_stack, .-dump_stack");
+
+void dump_stack_helper(uint64_t rsp_val)
+{
+	uint64_t *rsp = (uint64_t *)rsp_val;
+	int x;
+
+	Print(L"%%rsp: 0x%08x%08x stack:\r\n",
+					(rsp_val & 0xffffffff00000000) >>32,
+					 rsp_val & 0xffffffff);
+	for (x = 0; x < 8; x++) {
+		Print(L"%08x: ", ((uint64_t)rsp) & 0xffffffff);
+		Print(L"%016x ", *rsp++);
+		Print(L"%016x ", *rsp++);
+		Print(L"%016x ", *rsp++);
+		Print(L"%016x\r\n", *rsp++);
+	}
+}
+
+EFI_STATUS EFI_FUNCTION test_failure_callback(void)
+{
+	return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS test_failure(void)
+{
+	return uefi_call_wrapper(test_failure_callback, 0);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call0_callback(void)
+{
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call0(void)
+{
+	return uefi_call_wrapper(test_call0_callback, 0);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call1_callback(UINT32 a)
+{
+	if (a != 0x12345678) {
+		return EFI_LOAD_ERROR;
+	}
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call1(void)
+{
+	return uefi_call_wrapper(test_call1_callback, 1,0x12345678);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call2_callback(UINT32 a, UINT32 b)
+{
+	if (a != 0x12345678) {
+		return EFI_LOAD_ERROR;
+	}
+	if (b != 0x23456789) {
+		return EFI_INVALID_PARAMETER;
+	}
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call2(void)
+{
+	return uefi_call_wrapper(test_call2_callback, 2,
+		0x12345678, 0x23456789);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call3_callback(UINT32 a, UINT32 b,
+	UINT32 c)
+{
+	if (a != 0x12345678)
+		return EFI_LOAD_ERROR;
+	if (b != 0x23456789)
+		return EFI_INVALID_PARAMETER;
+	if (c != 0x3456789a)
+		return EFI_UNSUPPORTED;
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call3(void)
+{
+	return uefi_call_wrapper(test_call3_callback, 3,
+		0x12345678, 0x23456789, 0x3456789a);
+}
+
+EFI_STATUS EFI_FUNCTION test_call4_callback(UINT32 a, UINT32 b,
+	UINT32 c, UINT32 d)
+{
+	if (a != 0x12345678)
+		return EFI_LOAD_ERROR;
+	if (b != 0x23456789)
+		return EFI_INVALID_PARAMETER;
+	if (c != 0x3456789a)
+		return EFI_UNSUPPORTED;
+	if (d != 0x456789ab)
+		return EFI_BAD_BUFFER_SIZE;
+
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call4(void)
+{
+	return uefi_call_wrapper(test_call4_callback, 4,
+		0x12345678, 0x23456789, 0x3456789a, 0x456789ab);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call5_callback(UINT32 a, UINT32 b,
+	UINT32 c, UINT32 d, UINT32 e)
+{
+	if (a != 0x12345678)
+		return EFI_LOAD_ERROR;
+	if (b != 0x23456789)
+		return EFI_INVALID_PARAMETER;
+	if (c != 0x3456789a)
+		return EFI_UNSUPPORTED;
+	if (d != 0x456789ab)
+		return EFI_BAD_BUFFER_SIZE;
+	if (e != 0x56789abc)
+		return EFI_BUFFER_TOO_SMALL;
+
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call5(void)
+{
+	return uefi_call_wrapper(test_call5_callback, 5,
+		0x12345678, 0x23456789, 0x3456789a, 0x456789ab, 0x56789abc);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call6_callback(UINT32 a, UINT32 b,
+	UINT32 c, UINT32 d, UINT32 e, UINT32 f)
+{
+	if (a != 0x12345678)
+		return EFI_LOAD_ERROR;
+	if (b != 0x23456789)
+		return EFI_INVALID_PARAMETER;
+	if (c != 0x3456789a)
+		return EFI_UNSUPPORTED;
+	if (d != 0x456789ab)
+		return EFI_BAD_BUFFER_SIZE;
+	if (e != 0x56789abc)
+		return EFI_BUFFER_TOO_SMALL;
+	if (f != 0x6789abcd)
+		return EFI_NOT_READY;
+	
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call6(void)
+{
+	return uefi_call_wrapper(test_call6_callback, 6,
+		0x12345678, 0x23456789, 0x3456789a, 0x456789ab, 0x56789abc,
+		0x6789abcd);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call7_callback(UINT32 a, UINT32 b,
+	UINT32 c, UINT32 d, UINT32 e, UINT32 f, UINT32 g)
+{
+	if (a != 0x12345678)
+		return EFI_LOAD_ERROR;
+	if (b != 0x23456789)
+		return EFI_INVALID_PARAMETER;
+	if (c != 0x3456789a)
+		return EFI_UNSUPPORTED;
+	if (d != 0x456789ab)
+		return EFI_BAD_BUFFER_SIZE;
+	if (e != 0x56789abc)
+		return EFI_BUFFER_TOO_SMALL;
+	if (f != 0x6789abcd)
+		return EFI_NOT_READY;
+	if (g != 0x789abcde)
+		return EFI_DEVICE_ERROR;
+	
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call7(void)
+{
+	return uefi_call_wrapper(test_call7_callback, 7,
+		0x12345678, 0x23456789, 0x3456789a, 0x456789ab,
+		0x56789abc, 0x6789abcd, 0x789abcde);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call8_callback(UINT32 a, UINT32 b,
+	UINT32 c, UINT32 d, UINT32 e, UINT32 f, UINT32 g, UINT32 h)
+{
+	if (a != 0x12345678)
+		return EFI_LOAD_ERROR;
+	if (b != 0x23456789)
+		return EFI_INVALID_PARAMETER;
+	if (c != 0x3456789a)
+		return EFI_UNSUPPORTED;
+	if (d != 0x456789ab)
+		return EFI_BAD_BUFFER_SIZE;
+	if (e != 0x56789abc)
+		return EFI_BUFFER_TOO_SMALL;
+	if (f != 0x6789abcd)
+		return EFI_NOT_READY;
+	if (g != 0x789abcde)
+		return EFI_DEVICE_ERROR;
+	if (h != 0x89abcdef)
+		return EFI_WRITE_PROTECTED;
+
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call8(void)
+{
+	return uefi_call_wrapper(test_call8_callback, 8,
+		0x12345678,
+		0x23456789,
+		0x3456789a,
+		0x456789ab,
+		0x56789abc,
+		0x6789abcd,
+		0x789abcde,
+		0x89abcdef);	
+}
+
+EFI_STATUS EFI_FUNCTION test_call9_callback(UINT32 a, UINT32 b,
+	UINT32 c, UINT32 d, UINT32 e, UINT32 f, UINT32 g, UINT32 h, UINT32 i)
+{
+	if (a != 0x12345678)
+		return EFI_LOAD_ERROR;
+	if (b != 0x23456789)
+		return EFI_INVALID_PARAMETER;
+	if (c != 0x3456789a)
+		return EFI_UNSUPPORTED;
+	if (d != 0x456789ab)
+		return EFI_BAD_BUFFER_SIZE;
+	if (e != 0x56789abc)
+		return EFI_BUFFER_TOO_SMALL;
+	if (f != 0x6789abcd)
+		return EFI_NOT_READY;
+	if (g != 0x789abcde)
+		return EFI_DEVICE_ERROR;
+	if (h != 0x89abcdef)
+		return EFI_WRITE_PROTECTED;
+	if (i != 0x9abcdef0)
+		return EFI_OUT_OF_RESOURCES;
+
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call9(void)
+{
+	return uefi_call_wrapper(test_call9_callback, 9,
+		0x12345678,
+		0x23456789,
+		0x3456789a,
+		0x456789ab,
+		0x56789abc,
+		0x6789abcd,
+		0x789abcde,
+		0x89abcdef,
+		0x9abcdef0);	
+}
+
+extern EFI_STATUS test_call10(void);
+EFI_STATUS EFI_FUNCTION test_call10_callback(UINT32 a, UINT32 b,
+	UINT32 c, UINT32 d, UINT32 e, UINT32 f, UINT32 g, UINT32 h, UINT32 i,
+	UINT32 j)
+{
+	if (a != 0x12345678)
+		return EFI_LOAD_ERROR;
+	if (b != 0x23456789)
+		return EFI_INVALID_PARAMETER;
+	if (c != 0x3456789a)
+		return EFI_UNSUPPORTED;
+	if (d != 0x456789ab)
+		return EFI_BAD_BUFFER_SIZE;
+	if (e != 0x56789abc)
+		return EFI_BUFFER_TOO_SMALL;
+	if (f != 0x6789abcd)
+		return EFI_NOT_READY;
+	if (g != 0x789abcde)
+		return EFI_DEVICE_ERROR;
+	if (h != 0x89abcdef)
+		return EFI_WRITE_PROTECTED;
+	if (i != 0x9abcdef0)
+		return EFI_OUT_OF_RESOURCES;
+	if (j != 0xabcdef01)
+		return EFI_VOLUME_CORRUPTED;
+
+	return EFI_SUCCESS;
+}
+
+EFI_STATUS test_call10(void)
+{
+	return uefi_call_wrapper(test_call10_callback, 10,
+		0x12345678,
+		0x23456789,
+		0x3456789a,
+		0x456789ab,
+		0x56789abc,
+		0x6789abcd,
+		0x789abcde,
+		0x89abcdef,
+		0x9abcdef0,
+		0xabcdef01);	
+}
+
+EFI_STATUS
+efi_main (EFI_HANDLE *image, EFI_SYSTEM_TABLE *systab)
+{
+	EFI_STATUS rc = EFI_SUCCESS;
+
+	InitializeLib(image, systab);
+	PoolAllocationType = 2; /* klooj */
+
+#ifndef __x86_64__
+	uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut,
+		L"This test is only valid on x86_64\n");
+	return EFI_UNSUPPORTED;
+#endif
+
+	asm volatile("out %0,%1" : : "a" ((uint8_t)0x14), "dN" (0x80));
+
+	Print(L"Hello\r\n");
+	rc = test_failure();
+	if (EFI_ERROR(rc)) {
+		Print(L"Returning Failure works\n");
+	} else {
+		Print(L"Returning failure doesn't work.\r\n");
+		Print(L"%%rax was 0x%016x, should have been 0x%016x\n",
+			rc, EFI_UNSUPPORTED);
+		return EFI_INVALID_PARAMETER;
+	} 
+
+	rc = test_call0();
+	if (!EFI_ERROR(rc)) {
+		Print(L"0 args works just fine here.\r\n");
+	} else {
+		Print(L"0 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call1();
+	if (!EFI_ERROR(rc)) {
+		Print(L"1 arg works just fine here.\r\n");
+	} else {
+		Print(L"1 arg failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call2();
+	if (!EFI_ERROR(rc)) {
+		Print(L"2 args works just fine here.\r\n");
+	} else {
+		Print(L"2 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call3();
+	if (!EFI_ERROR(rc)) {
+		Print(L"3 args works just fine here.\r\n");
+	} else {
+		Print(L"3 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call4();
+	if (!EFI_ERROR(rc)) {
+		Print(L"4 args works just fine here.\r\n");
+	} else {
+		Print(L"4 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call5();
+	if (!EFI_ERROR(rc)) {
+		Print(L"5 args works just fine here.\r\n");
+	} else {
+		Print(L"5 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call6();
+	if (!EFI_ERROR(rc)) {
+		Print(L"6 args works just fine here.\r\n");
+	} else {
+		Print(L"6 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call7();
+	if (!EFI_ERROR(rc)) {
+		Print(L"7 args works just fine here.\r\n");
+	} else {
+		Print(L"7 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call8();
+	if (!EFI_ERROR(rc)) {
+		Print(L"8 args works just fine here.\r\n");
+	} else {
+		Print(L"8 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call9();
+	if (!EFI_ERROR(rc)) {
+		Print(L"9 args works just fine here.\r\n");
+	} else {
+		Print(L"9 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	rc = test_call10();
+	if (!EFI_ERROR(rc)) {
+		Print(L"10 args works just fine here.\r\n");
+	} else {
+		Print(L"10 args failed: 0x%016x\n", rc);
+		return rc;
+	}
+
+	return rc;
+}
diff --git a/gnu-efi-3.0/inc/x86_64/efibind.h b/gnu-efi-3.0/inc/x86_64/efibind.h
index 1f8e735..ba36dde 100644
--- a/gnu-efi-3.0/inc/x86_64/efibind.h
+++ b/gnu-efi-3.0/inc/x86_64/efibind.h
@@ -260,9 +260,8 @@ typedef uint64_t   UINTN;
 /* for x86_64, EFI_FUNCTION_WRAPPER must be defined */
 #ifdef  EFI_FUNCTION_WRAPPER
 UINTN uefi_call_wrapper(void *func, unsigned long va_num, ...);
-#else
-#error "EFI_FUNCTION_WRAPPER must be defined for x86_64 architecture"
 #endif
+#define EFI_FUNCTION __attribute__((ms_abi))
 
 #ifdef _MSC_EXTENSIONS
 #pragma warning ( disable : 4731 )  // Suppress warnings about modification of EBP





More information about the Syslinux mailing list