From: naddy Date: Sun, 4 Jun 2017 23:03:19 +0000 (+0000) Subject: Catch up with changes made on amd64 (kettenis@): X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5ffbff1ad788f591009fe26b896b4eeb03a792a0;p=openbsd Catch up with changes made on amd64 (kettenis@): Generating mixed 16-bit/32-bit/64-bit code with clang's integrated assembler is a bit tricky. It supports the .code16, .code32 and .code64 directives. But it doesn't know about the data16/data32 and addr16/addr32 instruction prefixes. Instead it tries to determine those from the instruction opcode. It mostly succeeds, but there are a couple of corner cases where clang will generate the "addr32" form where gas generates the "addr16" form in .code16 segments. That should be no problem (and just waste a couple of bytes), but it makes comparing the generated code a bit difficult. Allow the trampoline code to be compiled with both. For clang #define away the addr32 prefix and avoid using the data32 prefix by using a mnemonic that explicitly encodes the size of the operand. Add a few addr32 prefixes in .code16 blocks to reduce the differences between code generated by clang and gas. ok deraadt@ --- diff --git a/sys/arch/i386/i386/acpi_wakecode.S b/sys/arch/i386/i386/acpi_wakecode.S index 1d722180278..2bda411e4a8 100644 --- a/sys/arch/i386/i386/acpi_wakecode.S +++ b/sys/arch/i386/i386/acpi_wakecode.S @@ -52,6 +52,10 @@ #include #include +#ifdef __clang__ +#define addr32 +#endif + #define _ACPI_TRMP_LABEL(a) a = . - _C_LABEL(acpi_real_mode_resume) + ACPI_TRAMPOLINE #define _ACPI_TRMP_OFFSET(a) a = . - _C_LABEL(acpi_real_mode_resume) #define _ACPI_TRMP_DATA_LABEL(a) a = . - _C_LABEL(acpi_tramp_data_start) + \ @@ -108,7 +112,7 @@ _ACPI_TRMP_OFFSET(acpi_s3_vector_real) movw %ax, %ss movw %cs, %ax movw %ax, %es - lidtl clean_idt + addr32 lidtl clean_idt /* * Set up stack to grow down from offset 0x0FFE. @@ -140,7 +144,7 @@ _ACPI_TRMP_OFFSET(acpi_s3_vector_real) * to sleep (although on i386, the saved GDT will most likely * represent something similar based on machine/segment.h). */ - data32 addr32 lgdt tmp_gdt + addr32 lgdtl tmp_gdt /* * Enable protected mode by setting the PE bit in CR0 @@ -342,7 +346,7 @@ _ACPI_TRMP_LABEL(hibernate_resume_vector_3) movw %ax, %fs movw %ax, %gs movl $0x0FFE, %esp - lidtl clean_idt + addr32 lidtl clean_idt /* Jump to the S3 resume vector */ ljmp $(_ACPI_RM_CODE_SEG), $acpi_s3_vector_real diff --git a/sys/arch/i386/i386/mptramp.s b/sys/arch/i386/i386/mptramp.s index 3a7f94334e1..148a7e852e3 100644 --- a/sys/arch/i386/i386/mptramp.s +++ b/sys/arch/i386/i386/mptramp.s @@ -1,4 +1,4 @@ -/* $OpenBSD: mptramp.s,v 1.20 2017/02/06 01:50:36 mlarkin Exp $ */ +/* $OpenBSD: mptramp.s,v 1.21 2017/06/04 23:03:19 naddy Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -84,6 +84,10 @@ #include #include +#ifdef __clang__ +#define addr32 +#endif + #define GDTE(a,b) .byte 0xff,0xff,0x0,0x0,0x0,a,b,0x0 #define _RELOC(x) ((x) - KERNBASE) #define RELOC(x) _RELOC(_C_LABEL(x)) @@ -115,7 +119,7 @@ _C_LABEL(cpu_spinup_trampoline): movw %cs, %ax movw %ax, %es movw %ax, %ss - data32 addr32 lgdt (gdt_desc) # load flat descriptor table + addr32 lgdtl (gdt_desc) # load flat descriptor table movl %cr0, %eax # get cr0 orl $0x1, %eax # enable protected mode movl %eax, %cr0 # doit