diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2022-11-29 02:19:30 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2022-11-29 02:19:30 +0000 |
commit | 21f5c141c3eb573c18c30481f0cbe17188416083 (patch) | |
tree | 8491459c176f23685478056f2a17a33289e2bbce /sys/arch/amd64 | |
parent | e4a2c825a848052b2f19fefce2448c8226944713 (diff) |
Put the original image of the MP-startup and ACPI-suspend/hibernate
trampolines into .rodata instead of .text. While here, give types
and sizes to all the global symbols and delete some superfluous
directives and unrelocated symbols in the ACPI trampoline image.
ok mlarkin@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/acpi_wakecode.S | 33 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/mptramp.S | 30 |
2 files changed, 45 insertions, 18 deletions
diff --git a/sys/arch/amd64/amd64/acpi_wakecode.S b/sys/arch/amd64/amd64/acpi_wakecode.S index eaf8e887c83..cd9c9240bf8 100644 --- a/sys/arch/amd64/amd64/acpi_wakecode.S +++ b/sys/arch/amd64/amd64/acpi_wakecode.S @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_wakecode.S,v 1.47 2021/09/04 22:15:33 bluhm Exp $ */ +/* $OpenBSD: acpi_wakecode.S,v 1.48 2022/11/29 02:19:29 guenther Exp $ */ /* * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org> * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> @@ -85,18 +85,18 @@ * 3. Reenable paging * 4. Enter long mode * 5. Restore saved CPU registers + * + * Initial copy of this code gets placed in .rodata, kernel makes + * RX copy of it in the ACPI trampoline page. */ - .text + .section .rodata .code16 .align 4, 0xcc - .global _C_LABEL(acpi_real_mode_resume) - .global _C_LABEL(acpi_protected_mode_resume) - .global _C_LABEL(acpi_long_mode_resume) .global _C_LABEL(acpi_resume_end) .global _C_LABEL(acpi_pdirpa) .global _C_LABEL(acpi_tramp_data_start) .global _C_LABEL(acpi_tramp_data_end) -_C_LABEL(acpi_real_mode_resume): +GENTRY(acpi_real_mode_resume) _ACPI_TRMP_OFFSET(.Lacpi_s3_vector_real) nop cli @@ -163,7 +163,7 @@ _ACPI_TRMP_OFFSET(.Lacpi_s3_vector_real) .code32 .align 16, 0xcc _ACPI_TRMP_LABEL(.Lacpi_protected_mode_trampoline) -_C_LABEL(acpi_protected_mode_resume): + /* acpi_protected_mode_resume: */ nop /* @@ -231,7 +231,6 @@ _C_LABEL(acpi_protected_mode_resume): .code64 .align 16, 0xcc _ACPI_TRMP_LABEL(.Lacpi_long_mode_trampoline) -_C_LABEL(acpi_long_mode_resume): /* Reset stack */ movq $(ACPI_TRAMP_DATA + 0x0FF8), %rsp @@ -393,6 +392,9 @@ NENTRY(hibernate_resume_machdep) /* Jump to the identity mapped version of ourself */ mov $.Lhibernate_resume_vector_2, %rax jmp *%rax +END(hibernate_resume_machdep) + + .section .rodata _ACPI_TRMP_LABEL(.Lhibernate_resume_vector_2) /* Get out of 64 bit CS */ @@ -435,6 +437,9 @@ NENTRY(hibernate_drop_to_real_mode) /* Jump to the identity mapped version of ourself */ mov $.Lhibernate_resume_vector_2b, %rax jmp *%rax +END(hibernate_drop_to_real_mode) + + .section .rodata _ACPI_TRMP_LABEL(.Lhibernate_resume_vector_2b) /* Get out of 64 bit CS */ @@ -492,6 +497,7 @@ NENTRY(hibernate_activate_resume_pt_machdep) 1: RETGUARD_CHECK(hibernate_activate_resume_pt_machdep, r11) ret lfence +END(hibernate_activate_resume_pt_machdep) /* * Switch to the private resume-time hibernate stack @@ -507,6 +513,7 @@ NENTRY(hibernate_switch_stack_machdep) RETGUARD_CHECK(hibernate_switch_stack_machdep, r11) ret lfence +END(hibernate_switch_stack_machdep) NENTRY(hibernate_flush) RETGUARD_SETUP(hibernate_flush, r11) @@ -514,18 +521,23 @@ NENTRY(hibernate_flush) RETGUARD_CHECK(hibernate_flush, r11) ret lfence +END(hibernate_flush) #endif /* HIBERNATE */ /* * End of resume code (code copied to ACPI_TRAMPOLINE) */ + .section .rodata + .type acpi_resume_end,@object _C_LABEL(acpi_resume_end): +END(acpi_real_mode_resume) /* * Initial copy of this data gets placed in .rodata, kernel makes * RW copy of it in the tramp data page. */ .section .rodata + .type acpi_tramp_data_start,@object _C_LABEL(acpi_tramp_data_start): _ACPI_TRMP_DATA_OFFSET(.Ltmp_gdt) .word .Ltmp_gdt_end - .Ltmp_gdtable @@ -689,8 +701,10 @@ _ACPI_TRMP_DATA_LABEL(.Lacpi_saved_apicbase) #endif .align 4, 0xcc + .type acpi_pdirpa,@object _ACPI_TRMP_DATA_LABEL(acpi_pdirpa) .long 0 + .size acpi_pdirpa, 4 #ifdef HIBERNATE _ACPI_TRMP_DATA_LABEL(.Lhibernate_indirect_16) .long .Lhibernate_resume_vector_3 @@ -700,7 +714,9 @@ _ACPI_TRMP_DATA_LABEL(.Lhibernate_indirect_16b) .word 0x18 #endif /* HIBERNATE */ + .type acpi_tramp_data_end,@object _C_LABEL(acpi_tramp_data_end): +END(acpi_tramp_data_start) /* * acpi_savecpu saves the processor's registers and flags @@ -810,3 +826,4 @@ NENTRY(acpi_savecpu) RETGUARD_CHECK(acpi_savecpu, r11) ret lfence +END(acpi_savecpu) diff --git a/sys/arch/amd64/amd64/mptramp.S b/sys/arch/amd64/amd64/mptramp.S index c6b18b65a23..4bb5dac0b9d 100644 --- a/sys/arch/amd64/amd64/mptramp.S +++ b/sys/arch/amd64/amd64/mptramp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: mptramp.S,v 1.20 2019/10/08 16:58:09 mlarkin Exp $ */ +/* $OpenBSD: mptramp.S,v 1.21 2022/11/29 02:19:29 guenther Exp $ */ /* $NetBSD: mptramp.S,v 1.1 2003/04/26 18:39:30 fvdl Exp $ */ /*- @@ -95,18 +95,18 @@ MP_TRAMP_DATA #define _TRMP_DATA_OFFSET(a) a = . - _C_LABEL(mp_tramp_data_start) - .global _C_LABEL(cpu_spinup_trampoline) .global _C_LABEL(cpu_spinup_trampoline_end) - .global _C_LABEL(cpu_hatch) - .global _C_LABEL(local_apic) - .global _C_LABEL(mp_pdirpa) .global _C_LABEL(mp_tramp_data_start) .global _C_LABEL(mp_tramp_data_end) - .text + /* + * Initial copy of this code gets placed in .rodata, kernel + * makes RX copy of it in the MP trampoline page. + */ + .section .rodata .align 4, 0xcc .code16 -_C_LABEL(cpu_spinup_trampoline): +GENTRY(cpu_spinup_trampoline) cli movw $(MP_TRAMP_DATA >> 4), %ax movw %ax, %ds @@ -184,12 +184,15 @@ _TRMP_LABEL(.Lmp_startup) _TRMP_LABEL(.Lmptramp_longmode) .code64 - movabsq $_C_LABEL(cpu_spinup_trampoline_end),%rax + movabsq $cpu_spinup_finish,%rax jmp *%rax - + .type cpu_spinup_trampoline_end,@object _C_LABEL(cpu_spinup_trampoline_end): #end of code copied to MP_TRAMPOLINE - .globl _C_LABEL(x2apic_enabled) +END(cpu_spinup_trampoline) + + .text +GENTRY(cpu_spinup_finish) movl x2apic_enabled,%eax testl %eax,%eax jz 1f @@ -231,17 +234,21 @@ _C_LABEL(cpu_spinup_trampoline_end): #end of code copied to MP_TRAMPOLINE movl $CR0_DEFAULT,%eax movq %rax,%cr0 call _C_LABEL(cpu_hatch) +END(cpu_spinup_finish) /* NOTREACHED */ .section .rodata + .type mp_tramp_data_start,@object _C_LABEL(mp_tramp_data_start): _TRMP_DATA_LABEL(.Lmptramp_jmp64) .long .Lmptramp_longmode .word GSEL(GCODE_SEL, SEL_KPL) .global mp_pdirpa + .type mp_pdirpa,@object _TRMP_DATA_LABEL(mp_pdirpa) .long 0 + .size mp_pdirpa,4 _TRMP_DATA_LABEL(.Lmptramp_gdt32) @@ -259,4 +266,7 @@ _TRMP_DATA_LABEL(.Lmptramp_gdt64) _TRMP_DATA_LABEL(.Lmptramp_gdt64_desc) .word 0x17 .long .Lmptramp_gdt64 + + .type mp_tramp_data_end,@object _C_LABEL(mp_tramp_data_end): +END(mp_tramp_data_start) |