From: visa Date: Thu, 11 Feb 2021 14:44:13 +0000 (+0000) Subject: Leave out gp initialization from kernel entry on mips64 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5b34c8b171a4ddaff75b436d37df77a3c2241a24;p=openbsd Leave out gp initialization from kernel entry on mips64 On OpenBSD/mips64, the kernel is compiled with -mno-abicalls. This disables gp-relative addressing and essentially makes gp a spare register in the kernel. Hence it is unnecessary to initialize gp when entering the kernel. The _gp symbol is not needed either. Suggested by miod@ --- diff --git a/sys/arch/loongson/conf/ld.script b/sys/arch/loongson/conf/ld.script index c8680b0fc6c..d529e3df319 100644 --- a/sys/arch/loongson/conf/ld.script +++ b/sys/arch/loongson/conf/ld.script @@ -7,7 +7,6 @@ SECTIONS .text : { *(.text .text.* .gnu.linkonce.t.*) } PROVIDE (etext = .); .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } - _gp = ALIGN(16) + 0x7ff0; .data : { *(.data .data.* .gnu.linkonce.d.*) } .openbsd.randomdata : { diff --git a/sys/arch/loongson/loongson/locore.S b/sys/arch/loongson/loongson/locore.S index 481235ec782..fe50aa52cbb 100644 --- a/sys/arch/loongson/loongson/locore.S +++ b/sys/arch/loongson/loongson/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.8 2017/06/08 11:44:00 visa Exp $ */ +/* $OpenBSD: locore.S,v 1.9 2021/02/11 14:44:13 visa Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -53,7 +53,6 @@ locore_start: * Initialize stack and call machine startup. */ LA t0, start - FRAMESZ(CF_SZ) - LA gp, _gp PTR_S ra, CF_RA_OFFS(t0) # save pmon return address PTR_S sp, 0(t0) # and stack move sp, t0 @@ -111,7 +110,7 @@ LEAF(hw_cpu_spinup_trampoline, 0) LA t0, cpu_spinup_sp ld sp, 0(t0) jal hw_cpu_hatch - LA gp, _gp + nop END(hw_cpu_spinup_trampoline) LEAF(hw_getcurcpu, 0) diff --git a/sys/arch/mips64/mips64/exception.S b/sys/arch/mips64/mips64/exception.S index 5d67f094ec4..e4067189fbe 100644 --- a/sys/arch/mips64/mips64/exception.S +++ b/sys/arch/mips64/mips64/exception.S @@ -1,4 +1,4 @@ -/* $OpenBSD: exception.S,v 1.40 2019/05/06 12:54:51 visa Exp $ */ +/* $OpenBSD: exception.S,v 1.41 2021/02/11 14:44:13 visa Exp $ */ /* * Copyright (c) 2002-2003 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -205,7 +205,6 @@ NNON_LEAF(k_intr, FRAMESZ(KERN_EXC_FRAME_SIZE), ra) #endif .set at move sp, k0 # Already on kernel stack - LA gp, _gp and t0, a1, ~(SR_COP_1_BIT | SR_EXL | SR_INT_ENAB | SR_KSU_MASK) MTC0 t0, COP_0_STATUS_REG MTC0_SR_IE_HAZARD @@ -242,7 +241,6 @@ NNON_LEAF(u_intr, FRAMESZ(CF_SZ), ra) SAVE_REG(v1, IC, k0, 0) #endif PTR_ADDU sp, k0, USPACE-FRAMESZ(CF_SZ) - LA gp, _gp .set at and t0, a1, ~(SR_COP_1_BIT | SR_EXL | SR_INT_ENAB | SR_KSU_MASK) MTC0 t0, COP_0_STATUS_REG @@ -328,7 +326,6 @@ NNON_LEAF(k_general, FRAMESZ(KERN_EXC_FRAME_SIZE), ra) #endif .set at move sp, k0 # Already on kernel stack - LA gp, _gp and t0, a1, ~(SR_COP_1_BIT | SR_EXL | SR_INT_ENAB | SR_KSU_MASK) MTC0 t0, COP_0_STATUS_REG MTC0_SR_IE_HAZARD @@ -370,7 +367,6 @@ NNON_LEAF(u_general, FRAMESZ(CF_SZ), ra) #endif SAVE_CPU_SREG(k0, 0) PTR_ADDU sp, k0, USPACE-FRAMESZ(CF_SZ) - LA gp, _gp .set at and t0, a1, ~(SR_COP_1_BIT | SR_EXL | SR_INT_ENAB | SR_KSU_MASK) MTC0 t0, COP_0_STATUS_REG diff --git a/sys/arch/mips64/mips64/exception_tfp.S b/sys/arch/mips64/mips64/exception_tfp.S index e1ca77e2346..6fdf3686b4d 100644 --- a/sys/arch/mips64/mips64/exception_tfp.S +++ b/sys/arch/mips64/mips64/exception_tfp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: exception_tfp.S,v 1.7 2018/05/09 15:03:04 visa Exp $ */ +/* $OpenBSD: exception_tfp.S,v 1.8 2021/02/11 14:44:13 visa Exp $ */ /* * Copyright (c) 2012 Miodrag Vallat. @@ -288,7 +288,6 @@ u_intr: SAVE_CPU(k0, 0) SAVE_CPU_SREG(k0, 0) PTR_ADDU sp, k0, USPACE-FRAMESZ(CF_SZ) - LA gp, _gp .set at and t0, a1, ~(SR_COP_1_BIT | SR_EXL | SR_INT_ENAB | SR_KSU_MASK) DMTC0 t0, COP_0_STATUS_REG @@ -400,7 +399,6 @@ k_intr: #endif .set at move sp, k0 # Already on kernel stack - LA gp, _gp and t0, a1, ~(SR_COP_1_BIT | SR_EXL | SR_INT_ENAB | SR_KSU_MASK) DMTC0 t0, COP_0_STATUS_REG MTC0_SR_IE_HAZARD diff --git a/sys/arch/octeon/conf/ld.script b/sys/arch/octeon/conf/ld.script index 9fe8c665b08..c5613cc31b3 100644 --- a/sys/arch/octeon/conf/ld.script +++ b/sys/arch/octeon/conf/ld.script @@ -1,4 +1,4 @@ -/* $OpenBSD: ld.script,v 1.6 2021/02/06 09:31:47 visa Exp $ */ +/* $OpenBSD: ld.script,v 1.7 2021/02/11 14:44:13 visa Exp $ */ OUTPUT_FORMAT("elf64-tradbigmips") OUTPUT_ARCH(mips) @@ -40,7 +40,6 @@ SECTIONS . = ALIGN(8); PROVIDE (__kernel_randomdata_end = .); - _gp = ALIGN(16) + 0x7ff0; .data : { *(.data .data.* .gnu.linkonce.d.*) diff --git a/sys/arch/octeon/octeon/locore.S b/sys/arch/octeon/octeon/locore.S index 609d476fd6b..ff2c794e9ef 100644 --- a/sys/arch/octeon/octeon/locore.S +++ b/sys/arch/octeon/octeon/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.21 2020/07/11 15:18:08 visa Exp $ */ +/* $OpenBSD: locore.S,v 1.22 2021/02/11 14:44:14 visa Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -72,8 +72,6 @@ locore_start: mtc0 zero, COP_0_CAUSE_REG # Clear soft interrupts - LA gp, _gp - /* Let the init core continue. The others have to wait. */ bne a2, zero, 2f nop diff --git a/sys/arch/sgi/conf/ld.script b/sys/arch/sgi/conf/ld.script index ac05ba0956f..99134c0ea6e 100644 --- a/sys/arch/sgi/conf/ld.script +++ b/sys/arch/sgi/conf/ld.script @@ -7,7 +7,6 @@ SECTIONS .text : { *(.text .text.* .gnu.linkonce.t.*) } PROVIDE (etext = .); .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } - _gp = ALIGN(16) + 0x7ff0; .data : { *(.data .data.* .gnu.linkonce.d.*) } .openbsd.randomdata : { diff --git a/sys/arch/sgi/sgi/ip30_nmi.S b/sys/arch/sgi/sgi/ip30_nmi.S index 1402c986a13..f13c50f2b3a 100644 --- a/sys/arch/sgi/sgi/ip30_nmi.S +++ b/sys/arch/sgi/sgi/ip30_nmi.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ip30_nmi.S,v 1.6 2012/10/03 11:18:23 miod Exp $ */ +/* $OpenBSD: ip30_nmi.S,v 1.7 2021/02/11 14:44:14 visa Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -71,7 +71,6 @@ ip30_nmi: .set at PTR_ADDU sp, k0, 0x2000 - LA gp, _gp /* * Interrupts should be disabled. Just in case they aren't, diff --git a/sys/arch/sgi/sgi/locore.S b/sys/arch/sgi/sgi/locore.S index 10703adb4a0..39e076bc880 100644 --- a/sys/arch/sgi/sgi/locore.S +++ b/sys/arch/sgi/sgi/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.19 2019/06/30 07:37:47 visa Exp $ */ +/* $OpenBSD: locore.S,v 1.20 2021/02/11 14:44:14 visa Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -55,7 +55,6 @@ locore_start: * Initialize stack and call machine startup. */ LA sp, start - FRAMESZ(CF_SZ) - LA gp, _gp jal mips_init # mips_init(argc, argv, envp) PTR_S zero, CF_RA_OFFS(sp) # Zero out old ra for debugger @@ -73,7 +72,6 @@ LEAF(hw_cpu_spinup_trampoline, 0) ori v0, SR_KX | SR_UX MTC0 v0, COP_0_STATUS_REG # disable all interrupts MTC0 zero, COP_0_CAUSE_REG # Clear soft interrupts - LA gp, _gp jal hw_cpu_hatch NOP END(hw_cpu_spinup_trampoline) @@ -122,7 +120,6 @@ LEAF(ip27_cpu_spinup_trampoline, 0) and v0, v1 MTC0 v0, COP_0_STATUS_REG # Disable all interrupts. MTC0 zero, COP_0_CAUSE_REG # Clear soft interrupts. - LA gp, _gp /* Wait the turn of this CPU. */ LA v1, ip27_spinup_turn