Date: Fri, 2 Apr 2021 12:49:50 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: aa3ea612be36 - main - x86: remove gcov kernel support Message-ID: <202104021249.132CnoXQ061379@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=aa3ea612be3659881392251e91912682b038ce78 commit aa3ea612be3659881392251e91912682b038ce78 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-03-31 21:04:55 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-04-02 12:41:51 +0000 x86: remove gcov kernel support Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D29529 --- sys/amd64/amd64/apic_vector.S | 14 -- sys/amd64/amd64/atpic_vector.S | 2 - sys/amd64/amd64/exception.S | 25 +- sys/amd64/amd64/locore.S | 10 +- sys/amd64/amd64/prof_machdep.c | 323 ------------------------ sys/amd64/amd64/sigtramp.S | 2 +- sys/amd64/amd64/support.S | 1 - sys/amd64/amd64/xen-locore.S | 6 +- sys/amd64/conf/NOTES | 4 - sys/amd64/ia32/ia32_exception.S | 2 - sys/amd64/include/asmacros.h | 82 +----- sys/amd64/include/profile.h | 81 +----- sys/amd64/linux/linux_locore.asm | 10 +- sys/amd64/linux32/linux32_locore.asm | 6 +- sys/cddl/dev/dtrace/amd64/dtrace_asm.S | 3 +- sys/conf/Makefile.arm | 2 +- sys/conf/files | 27 +- sys/conf/files.amd64 | 1 - sys/conf/files.arm | 2 +- sys/conf/files.arm64 | 18 +- sys/conf/files.i386 | 1 - sys/conf/files.x86 | 10 +- sys/conf/kern.post.mk | 3 - sys/conf/kern.pre.mk | 42 +--- sys/conf/options.i386 | 1 - sys/dev/hyperv/vmbus/amd64/vmbus_vector.S | 2 - sys/dev/hyperv/vmbus/i386/vmbus_vector.S | 2 - sys/i386/conf/NOTES | 5 - sys/i386/i386/apic_vector.s | 14 -- sys/i386/i386/atpic_vector.s | 2 - sys/i386/i386/exception.s | 30 +-- sys/i386/i386/locore.s | 4 +- sys/i386/i386/mpboot.s | 4 +- sys/i386/i386/prof_machdep.c | 404 ------------------------------ sys/i386/i386/sigtramp.s | 2 +- sys/i386/i386/support.s | 2 - sys/i386/i386/vm86bios.s | 1 - sys/i386/include/asmacros.h | 82 +----- sys/i386/include/profile.h | 94 +------ sys/i386/linux/linux_locore.asm | 6 +- sys/kern/subr_prof.c | 345 ------------------------- sys/libkern/mcount.c | 316 ----------------------- 42 files changed, 79 insertions(+), 1914 deletions(-) diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S index 4de39283f92f..21696a93fc5f 100644 --- a/sys/amd64/amd64/apic_vector.S +++ b/sys/amd64/amd64/apic_vector.S @@ -81,7 +81,6 @@ as_lapic_eoi: */ .macro ISR_VEC index, vec_name INTR_HANDLER \vec_name - FAKE_MCOUNT(TF_RIP(%rsp)) cmpl $0,x2apic_mode je 1f movl $(MSR_APIC_ISR0 + \index),%ecx @@ -98,7 +97,6 @@ as_lapic_eoi: movl %eax, %edi /* pass the IRQ */ call lapic_handle_intr 3: - MEXITCOUNT jmp doreti .endm @@ -127,28 +125,22 @@ IDTVEC(spuriousint) * Local APIC periodic timer handler. */ INTR_HANDLER timerint - FAKE_MCOUNT(TF_RIP(%rsp)) movq %rsp, %rdi call lapic_handle_timer - MEXITCOUNT jmp doreti /* * Local APIC CMCI handler. */ INTR_HANDLER cmcint - FAKE_MCOUNT(TF_RIP(%rsp)) call lapic_handle_cmc - MEXITCOUNT jmp doreti /* * Local APIC error interrupt handler. */ INTR_HANDLER errorint - FAKE_MCOUNT(TF_RIP(%rsp)) call lapic_handle_error - MEXITCOUNT jmp doreti #ifdef XENHVM @@ -157,10 +149,8 @@ IDTVEC(spuriousint) * Only used when the hypervisor supports direct vector callbacks. */ INTR_HANDLER xen_intr_upcall - FAKE_MCOUNT(TF_RIP(%rsp)) movq %rsp, %rdi call xen_intr_handle_upcall - MEXITCOUNT jmp doreti #endif @@ -184,9 +174,7 @@ IDTVEC(spuriousint) */ INTR_HANDLER ipi_intr_bitmap_handler call as_lapic_eoi - FAKE_MCOUNT(TF_RIP(%rsp)) call ipi_bitmap_handler - MEXITCOUNT jmp doreti /* @@ -210,9 +198,7 @@ IDTVEC(spuriousint) */ INTR_HANDLER ipi_swi call as_lapic_eoi - FAKE_MCOUNT(TF_RIP(%rsp)) call ipi_swi_handler - MEXITCOUNT jmp doreti /* diff --git a/sys/amd64/amd64/atpic_vector.S b/sys/amd64/amd64/atpic_vector.S index d82ffd30e1c9..d76331a887ad 100644 --- a/sys/amd64/amd64/atpic_vector.S +++ b/sys/amd64/amd64/atpic_vector.S @@ -44,11 +44,9 @@ */ .macro INTR irq_num, vec_name INTR_HANDLER \vec_name - FAKE_MCOUNT(TF_RIP(%rsp)) movq %rsp, %rsi movl $\irq_num, %edi /* pass the IRQ */ call atpic_handle_intr - MEXITCOUNT jmp doreti .endm diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S index 3fb518179406..4716ca8cd7c2 100644 --- a/sys/amd64/amd64/exception.S +++ b/sys/amd64/amd64/exception.S @@ -101,9 +101,6 @@ dtrace_invop_calltrap_addr: * registers are reloaded on return to the usermode. */ -MCOUNT_LABEL(user) -MCOUNT_LABEL(btrap) - /* Traps that we leave interrupts disabled for. */ .macro TRAP_NOEN l, trapno PTI_ENTRY \l,\l\()_pti_k,\l\()_pti_u @@ -257,7 +254,6 @@ alltraps_pushregs_no_rax: pushfq andq $~(PSL_D | PSL_AC),(%rsp) popfq - FAKE_MCOUNT(TF_RIP(%rsp)) #ifdef KDTRACE_HOOKS /* * DTrace Function Boundary Trace (fbt) probes are triggered @@ -288,7 +284,6 @@ alltraps_pushregs_no_rax: calltrap: movq %rsp,%rdi call trap_check - MEXITCOUNT jmp doreti /* Handle any pending ASTs */ /* @@ -576,7 +571,6 @@ fast_syscall_common: movq %r14,TF_R14(%rsp) /* C preserved */ movq %r15,TF_R15(%rsp) /* C preserved */ movl $TF_HASSEGS,TF_FLAGS(%rsp) - FAKE_MCOUNT(TF_RIP(%rsp)) movq PCPU(CURTHREAD),%rdi movq %rsp,TD_FRAME(%rdi) movl TF_RFLAGS(%rsp),%esi @@ -594,7 +588,6 @@ fast_syscall_common: call handle_ibrs_exit callq *mds_handler /* Restore preserved registers. */ - MEXITCOUNT movq TF_RDI(%rsp),%rdi /* bonus; preserve arg 1 */ movq TF_RSI(%rsp),%rsi /* bonus: preserve arg 2 */ movq TF_RDX(%rsp),%rdx /* return value 2 */ @@ -621,7 +614,6 @@ fast_syscall_common: jmp 1b 4: /* Requested full context restore, use doreti for that. */ - MEXITCOUNT jmp doreti /* @@ -692,10 +684,8 @@ IDTVEC(dbg) rdmsr movl %eax,%r14d call handle_ibrs_entry -2: FAKE_MCOUNT(TF_RIP(%rsp)) - movq %rsp,%rdi +2: movq %rsp,%rdi call trap - MEXITCOUNT testl $CPUID_STDEXT3_IBPB,cpu_stdext_feature3(%rip) je 3f movl %r14d,%eax @@ -866,10 +856,8 @@ nmi_fromuserspace: 3: /* Note: this label is also used by ddb and gdb: */ nmi_calltrap: - FAKE_MCOUNT(TF_RIP(%rsp)) movq %rsp,%rdi call trap - MEXITCOUNT #ifdef HWPMC_HOOKS /* * Capture a userspace callchain if needed. @@ -1055,10 +1043,8 @@ mchk_fromuserspace: 1: call handle_ibrs_entry /* Note: this label is also used by ddb and gdb: */ mchk_calltrap: - FAKE_MCOUNT(TF_RIP(%rsp)) movq %rsp,%rdi call mca_intr - MEXITCOUNT testl %ebx,%ebx /* %ebx != 0 => return to userland */ jnz doreti_exit /* @@ -1089,7 +1075,6 @@ ENTRY(fork_trampoline) movq %rbx,%rsi /* arg1 */ movq %rsp,%rdx /* trapframe pointer */ call fork_exit - MEXITCOUNT jmp doreti /* Handle any ASTs */ /* @@ -1115,8 +1100,6 @@ ENTRY(fork_trampoline) .p2align 4 .text SUPERALIGN_TEXT -MCOUNT_LABEL(bintr) - #include <amd64/amd64/apic_vector.S> #ifdef DEV_ATPIC @@ -1128,9 +1111,6 @@ MCOUNT_LABEL(bintr) #include <amd64/amd64/atpic_vector.S> #endif - .text -MCOUNT_LABEL(eintr) - /* * void doreti(struct trapframe) * @@ -1141,7 +1121,6 @@ MCOUNT_LABEL(eintr) .type doreti,@function .globl doreti doreti: - FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */ /* * Check if ASTs can be handled now. */ @@ -1171,7 +1150,6 @@ doreti_ast: * registers. The fault is handled in trap.c. */ doreti_exit: - MEXITCOUNT movq PCPU(CURPCB),%r8 /* @@ -1332,7 +1310,6 @@ doreti_iret_fault: movl $T_PROTFLT,TF_TRAPNO(%rsp) movq $0,TF_ERR(%rsp) /* XXX should be the error code */ movq $0,TF_ADDR(%rsp) - FAKE_MCOUNT(TF_RIP(%rsp)) jmp calltrap ALIGN_TEXT diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S index 3addc3fb10cd..4f6283b88bd2 100644 --- a/sys/amd64/amd64/locore.S +++ b/sys/amd64/amd64/locore.S @@ -54,7 +54,7 @@ * * We are already in long mode, on a 64 bit %cs and running at KERNBASE. */ -NON_GPROF_ENTRY(btext) +ENTRY(btext) /* Tell the bios to warmboot next time */ movw $0x1234,0x472 @@ -79,7 +79,7 @@ NON_GPROF_ENTRY(btext) jmp 0b /* la57_trampoline(%rdi pml5) */ -NON_GPROF_ENTRY(la57_trampoline) +ENTRY(la57_trampoline) movq %rsp,%r11 movq %rbx,%r10 leaq la57_trampoline_end(%rip),%rsp @@ -118,11 +118,11 @@ l2: movq %r11,%rsp movq %r10,%rbx retq .p2align 4,0 -NON_GPROF_ENTRY(la57_trampoline_gdt_desc) +ENTRY(la57_trampoline_gdt_desc) .word la57_trampoline_end - la57_trampoline_gdt .long 0 /* filled by pmap_bootstrap_la57 */ .p2align 4,0 -NON_GPROF_ENTRY(la57_trampoline_gdt) +ENTRY(la57_trampoline_gdt) .long 0x00000000 /* null desc */ .long 0x00000000 .long 0x00000000 /* 64bit code */ @@ -132,7 +132,7 @@ NON_GPROF_ENTRY(la57_trampoline_gdt) .long 0x0000ffff /* universal data */ .long 0x00cf9300 .dcb.l 16,0 -NON_GPROF_ENTRY(la57_trampoline_end) +ENTRY(la57_trampoline_end) .bss ALIGN_DATA /* just to be sure */ diff --git a/sys/amd64/amd64/prof_machdep.c b/sys/amd64/amd64/prof_machdep.c deleted file mode 100644 index 72b18faef028..000000000000 --- a/sys/amd64/amd64/prof_machdep.c +++ /dev/null @@ -1,323 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1996 Bruce D. Evans. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#ifdef GUPROF - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/bus.h> -#include <sys/cpu.h> -#include <sys/eventhandler.h> -#include <sys/gmon.h> -#include <sys/kernel.h> -#include <sys/smp.h> -#include <sys/sysctl.h> - -#include <machine/clock.h> -#include <machine/timerreg.h> - -#define CPUTIME_CLOCK_UNINITIALIZED 0 -#define CPUTIME_CLOCK_I8254 1 -#define CPUTIME_CLOCK_TSC 2 -#define CPUTIME_CLOCK_I8254_SHIFT 7 - -int cputime_bias = 1; /* initialize for locality of reference */ - -static int cputime_clock = CPUTIME_CLOCK_UNINITIALIZED; -static int cputime_prof_active; -#endif /* GUPROF */ - -#ifdef __GNUCLIKE_ASM -#if defined(SMP) && defined(GUPROF) -#define MPLOCK " \n\ - movl $1,%edx \n\ -9: \n\ - xorl %eax,%eax \n\ - lock \n\ - cmpxchgl %edx,mcount_lock \n\ - jne 9b \n" -#define MPUNLOCK "movl $0,mcount_lock \n" -#else /* !(SMP && GUPROF) */ -#define MPLOCK -#define MPUNLOCK -#endif /* SMP && GUPROF */ - -__asm(" \n\ -GM_STATE = 0 \n\ -GMON_PROF_OFF = 3 \n\ - \n\ - .text \n\ - .p2align 4,0x90 \n\ - .globl __mcount \n\ - .type __mcount,@function \n\ -__mcount: \n\ - # \n\ - # Check that we are profiling. Do it early for speed. \n\ - # \n\ - cmpl $GMON_PROF_OFF,_gmonparam+GM_STATE \n\ - je .mcount_exit \n\ - # \n\ - # __mcount is the same as [.]mcount except the caller \n\ - # hasn't changed the stack except to call here, so the \n\ - # caller's raddr is above our raddr. \n\ - # \n\ - pushq %rax \n\ - pushq %rdx \n\ - pushq %rcx \n\ - pushq %rsi \n\ - pushq %rdi \n\ - pushq %r8 \n\ - pushq %r9 \n\ - movq 7*8+8(%rsp),%rdi \n\ - jmp .got_frompc \n\ - \n\ - .p2align 4,0x90 \n\ - .globl .mcount \n\ -.mcount: \n\ - cmpl $GMON_PROF_OFF,_gmonparam+GM_STATE \n\ - je .mcount_exit \n\ - # \n\ - # The caller's stack frame has already been built, so \n\ - # %rbp is the caller's frame pointer. The caller's \n\ - # raddr is in the caller's frame following the caller's \n\ - # caller's frame pointer. \n\ - # \n\ - pushq %rax \n\ - pushq %rdx \n\ - pushq %rcx \n\ - pushq %rsi \n\ - pushq %rdi \n\ - pushq %r8 \n\ - pushq %r9 \n\ - movq 8(%rbp),%rdi \n\ -.got_frompc: \n\ - # \n\ - # Our raddr is the caller's pc. \n\ - # \n\ - movq 7*8(%rsp),%rsi \n\ - \n\ - pushfq \n\ - cli \n" - MPLOCK " \n\ - call mcount \n" - MPUNLOCK " \n\ - popfq \n\ - popq %r9 \n\ - popq %r8 \n\ - popq %rdi \n\ - popq %rsi \n\ - popq %rcx \n\ - popq %rdx \n\ - popq %rax \n\ -.mcount_exit: \n\ - ret $0 \n\ -"); -#else /* !__GNUCLIKE_ASM */ -#error "this file needs to be ported to your compiler" -#endif /* __GNUCLIKE_ASM */ - -#ifdef GUPROF -/* - * [.]mexitcount saves the return register(s), loads selfpc and calls - * mexitcount(selfpc) to do the work. Someday it should be in a machine - * dependent file together with cputime(), __mcount and [.]mcount. cputime() - * can't just be put in machdep.c because it has to be compiled without -pg. - */ -#ifdef __GNUCLIKE_ASM -__asm(" \n\ - .text \n\ -# \n\ -# Dummy label to be seen when gprof -u hides [.]mexitcount. \n\ -# \n\ - .p2align 4,0x90 \n\ - .globl __mexitcount \n\ - .type __mexitcount,@function \n\ -__mexitcount: \n\ - nop \n\ - \n\ -GMON_PROF_HIRES = 4 \n\ - \n\ - .p2align 4,0x90 \n\ - .globl .mexitcount \n\ -.mexitcount: \n\ - cmpl $GMON_PROF_HIRES,_gmonparam+GM_STATE \n\ - jne .mexitcount_exit \n\ - pushq %rax \n\ - pushq %rdx \n\ - pushq %rcx \n\ - pushq %rsi \n\ - pushq %rdi \n\ - pushq %r8 \n\ - pushq %r9 \n\ - movq 7*8(%rsp),%rdi \n\ - pushfq \n\ - cli \n" - MPLOCK " \n\ - call mexitcount \n" - MPUNLOCK " \n\ - popfq \n\ - popq %r9 \n\ - popq %r8 \n\ - popq %rdi \n\ - popq %rsi \n\ - popq %rcx \n\ - popq %rdx \n\ - popq %rax \n\ -.mexitcount_exit: \n\ - ret $0 \n\ -"); -#endif /* __GNUCLIKE_ASM */ - -/* - * Return the time elapsed since the last call. The units are machine- - * dependent. - */ -int -cputime() -{ - u_int count; - int delta; - u_char high, low; - static u_int prev_count; - - if (cputime_clock == CPUTIME_CLOCK_TSC) { - /* - * Scale the TSC a little to make cputime()'s frequency - * fit in an int, assuming that the TSC frequency fits - * in a u_int. Use a fixed scale since dynamic scaling - * would be slower and we can't really use the low bit - * of precision. - */ - count = (u_int)rdtsc() & ~1u; - delta = (int)(count - prev_count) >> 1; - prev_count = count; - return (delta); - } - - /* - * Read the current value of the 8254 timer counter 0. - */ - outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH); - low = inb(TIMER_CNTR0); - high = inb(TIMER_CNTR0); - count = ((high << 8) | low) << CPUTIME_CLOCK_I8254_SHIFT; - - /* - * The timer counts down from TIMER_CNTR0_MAX to 0 and then resets. - * While profiling is enabled, this routine is called at least twice - * per timer reset (for mcounting and mexitcounting hardclock()), - * so at most one reset has occurred since the last call, and one - * has occurred iff the current count is larger than the previous - * count. This allows counter underflow to be detected faster - * than in microtime(). - */ - delta = prev_count - count; - prev_count = count; - if ((int) delta <= 0) - return (delta + (i8254_max_count << CPUTIME_CLOCK_I8254_SHIFT)); - return (delta); -} - -static int -sysctl_machdep_cputime_clock(SYSCTL_HANDLER_ARGS) -{ - int clock; - int error; - - clock = cputime_clock; - error = sysctl_handle_opaque(oidp, &clock, sizeof clock, req); - if (error == 0 && req->newptr != NULL) { - if (clock < 0 || clock > CPUTIME_CLOCK_TSC) - return (EINVAL); - cputime_clock = clock; - } - return (error); -} - -SYSCTL_PROC(_machdep, OID_AUTO, cputime_clock, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, 0, sizeof(u_int), - sysctl_machdep_cputime_clock, "I", - ""); - -/* - * The start and stop routines need not be here since we turn off profiling - * before calling them. They are here for convenience. - */ - -void -startguprof(gp) - struct gmonparam *gp; -{ - uint64_t freq; - - freq = atomic_load_acq_64(&tsc_freq); - if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) { - if (freq != 0 && mp_ncpus == 1) - cputime_clock = CPUTIME_CLOCK_TSC; - else - cputime_clock = CPUTIME_CLOCK_I8254; - } - if (cputime_clock == CPUTIME_CLOCK_TSC) { - gp->profrate = freq >> 1; - cputime_prof_active = 1; - } else - gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT; - cputime_bias = 0; - cputime(); -} - -void -stopguprof(gp) - struct gmonparam *gp; -{ - if (cputime_clock == CPUTIME_CLOCK_TSC) - cputime_prof_active = 0; -} - -/* If the cpu frequency changed while profiling, report a warning. */ -static void -tsc_freq_changed(void *arg, const struct cf_level *level, int status) -{ - - /* - * If there was an error during the transition or - * TSC is P-state invariant, don't do anything. - */ - if (status != 0 || tsc_is_invariant) - return; - if (cputime_prof_active && cputime_clock == CPUTIME_CLOCK_TSC) - printf("warning: cpu freq changed while profiling active\n"); -} - -EVENTHANDLER_DEFINE(cpufreq_post_change, tsc_freq_changed, NULL, - EVENTHANDLER_PRI_ANY); - -#endif /* GUPROF */ diff --git a/sys/amd64/amd64/sigtramp.S b/sys/amd64/amd64/sigtramp.S index a249a1a646f2..9983edf229a3 100644 --- a/sys/amd64/amd64/sigtramp.S +++ b/sys/amd64/amd64/sigtramp.S @@ -38,7 +38,7 @@ * Signal trampoline, copied to top of user stack * */ -NON_GPROF_ENTRY(sigcode) +ENTRY(sigcode) call *SIGF_HANDLER(%rsp) /* call signal handler */ lea SIGF_UC(%rsp),%rdi /* get ucontext_t */ pushq $0 /* junk to fake return addr. */ diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index 4c0f7da87ef8..0db6f2f04099 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -1490,7 +1490,6 @@ ENTRY(lgdt) popq %rax pushq $KCSEL pushq %rax - MEXITCOUNT lretq END(lgdt) diff --git a/sys/amd64/amd64/xen-locore.S b/sys/amd64/amd64/xen-locore.S index 7c7707a3864e..97d81711a051 100644 --- a/sys/amd64/amd64/xen-locore.S +++ b/sys/amd64/amd64/xen-locore.S @@ -69,11 +69,11 @@ .text .p2align PAGE_SHIFT, 0x90 /* Hypercall_page needs to be PAGE aligned */ -NON_GPROF_ENTRY(hypercall_page) +ENTRY(hypercall_page) .skip 0x1000, 0x90 /* Fill with "nop"s */ /* Legacy PVH entry point, to be removed. */ -NON_GPROF_ENTRY(xen_start) +ENTRY(xen_start) /* Don't trust what the loader gives for rflags. */ pushq $PSL_KERNEL popfq @@ -97,7 +97,7 @@ NON_GPROF_ENTRY(xen_start) /* PVH entry point. */ .code32 -NON_GPROF_ENTRY(xen_start32) +ENTRY(xen_start32) /* Load flat GDT */ movl $VTOP(gdtdesc32), %eax diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index 60d171721cf1..5627ce5377d3 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -7,10 +7,6 @@ # $FreeBSD$ # -# -# We want LINT to cover profiling as well. -profile 2 - # # Enable the kernel DTrace hooks which are required to load the DTrace # kernel modules. diff --git a/sys/amd64/ia32/ia32_exception.S b/sys/amd64/ia32/ia32_exception.S index c7bfb02f0281..a1c40ced168f 100644 --- a/sys/amd64/ia32/ia32_exception.S +++ b/sys/amd64/ia32/ia32_exception.S @@ -73,8 +73,6 @@ int0x80_syscall_common: pushfq andq $~(PSL_D | PSL_AC),(%rsp) popfq - FAKE_MCOUNT(TF_RIP(%rsp)) movq %rsp, %rdi call ia32_syscall - MEXITCOUNT jmp doreti diff --git a/sys/amd64/include/asmacros.h b/sys/amd64/include/asmacros.h index b8541bed310c..438f4ec26f61 100644 --- a/sys/amd64/include/asmacros.h +++ b/sys/amd64/include/asmacros.h @@ -55,92 +55,14 @@ #define CNAME(csym) csym #define ALIGN_DATA .p2align 3 /* 8 byte alignment, zero filled */ -#ifdef GPROF #define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ -#else -#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ -#endif #define SUPERALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ #define GEN_ENTRY(name) ALIGN_TEXT; .globl CNAME(name); \ .type CNAME(name),@function; CNAME(name): -#define NON_GPROF_ENTRY(name) GEN_ENTRY(name) -#define NON_GPROF_RET .byte 0xc3 /* opcode for `ret' */ - -#define END(name) .size name, . - name - -#ifdef GPROF -/* - * __mcount is like [.]mcount except that doesn't require its caller to set - * up a frame pointer. It must be called before pushing anything onto the - * stack. gcc should eventually generate code to call __mcount in most - * cases. This would make -pg in combination with -fomit-frame-pointer - * useful. gcc has a configuration variable PROFILE_BEFORE_PROLOGUE to - * allow profiling before setting up the frame pointer, but this is - * inadequate for good handling of special cases, e.g., -fpic works best - * with profiling after the prologue. - * - * [.]mexitcount is a new function to support non-statistical profiling if an - * accurate clock is available. For C sources, calls to it are generated - * by the FreeBSD extension `-mprofiler-epilogue' to gcc. It is best to - * call [.]mexitcount at the end of a function like the MEXITCOUNT macro does, - * but gcc currently generates calls to it at the start of the epilogue to - * avoid problems with -fpic. - * - * [.]mcount and __mcount may clobber the call-used registers and %ef. - * [.]mexitcount may clobber %ecx and %ef. - * - * Cross-jumping makes non-statistical profiling timing more complicated. - * It is handled in many cases by calling [.]mexitcount before jumping. It - * is handled for conditional jumps using CROSSJUMP() and CROSSJUMP_LABEL(). - * It is handled for some fault-handling jumps by not sharing the exit - * routine. - * - * ALTENTRY() must be before a corresponding ENTRY() so that it can jump to - * the main entry point. Note that alt entries are counted twice. They - * have to be counted as ordinary entries for gprof to get the call times - * right for the ordinary entries. - * - * High local labels are used in macros to avoid clashes with local labels - * in functions. - * - * Ordinary `ret' is used instead of a macro `RET' because there are a lot - * of `ret's. 0xc3 is the opcode for `ret' (`#define ret ... ret' can't - * be used because this file is sometimes preprocessed in traditional mode). - * `ret' clobbers eflags but this doesn't matter. - */ -#define ALTENTRY(name) GEN_ENTRY(name) ; MCOUNT ; MEXITCOUNT ; jmp 9f -#define CROSSJUMP(jtrue, label, jfalse) \ - jfalse 8f; MEXITCOUNT; jmp __CONCAT(to,label); 8: -#define CROSSJUMPTARGET(label) \ - ALIGN_TEXT; __CONCAT(to,label): ; MCOUNT; jmp label -#define ENTRY(name) GEN_ENTRY(name) ; 9: ; MCOUNT -#define FAKE_MCOUNT(caller) pushq caller ; call __mcount ; popq %rcx -#define MCOUNT call __mcount -#define MCOUNT_LABEL(name) GEN_ENTRY(name) ; nop ; ALIGN_TEXT -#ifdef GUPROF -#define MEXITCOUNT call .mexitcount -#define ret MEXITCOUNT ; NON_GPROF_RET -#else -#define MEXITCOUNT -#endif - -#else /* !GPROF */ -/* - * ALTENTRY() has to align because it is before a corresponding ENTRY(). - * ENTRY() has to align to because there may be no ALTENTRY() before it. - * If there is a previous ALTENTRY() then the alignment code for ENTRY() - * is empty. - */ -#define ALTENTRY(name) GEN_ENTRY(name) -#define CROSSJUMP(jtrue, label, jfalse) jtrue label -#define CROSSJUMPTARGET(label) #define ENTRY(name) GEN_ENTRY(name) -#define FAKE_MCOUNT(caller) -#define MCOUNT -#define MCOUNT_LABEL(name) -#define MEXITCOUNT -#endif /* GPROF */ +#define ALTENTRY(name) GEN_ENTRY(name) +#define END(name) .size name, . - name /* * Convenience for adding frame pointers to hand-coded ASM. Useful for diff --git a/sys/amd64/include/profile.h b/sys/amd64/include/profile.h index 2e19918cfb76..b0fb469f5354 100644 --- a/sys/amd64/include/profile.h +++ b/sys/amd64/include/profile.h @@ -35,74 +35,9 @@ #ifndef _MACHINE_PROFILE_H_ #define _MACHINE_PROFILE_H_ -#ifndef _SYS_CDEFS_H_ -#error this file needs sys/cdefs.h as a prerequisite -#endif - -#ifdef _KERNEL - -/* - * Config generates something to tell the compiler to align functions on 16 - * byte boundaries. A strict alignment is good for keeping the tables small. - */ -#define FUNCTION_ALIGNMENT 16 - -/* - * The kernel uses assembler stubs instead of unportable inlines. - * This is mainly to save a little time when profiling is not enabled, - * which is the usual case for the kernel. - */ -#define _MCOUNT_DECL void mcount -#define MCOUNT - -#ifdef GUPROF -#define MCOUNT_DECL(s) -#define MCOUNT_ENTER(s) -#define MCOUNT_EXIT(s) -#ifdef __GNUCLIKE_ASM -#define MCOUNT_OVERHEAD(label) \ - __asm __volatile("pushq %0; call __mcount; popq %%rcx" \ - : \ - : "i" (label) \ - : "cx", "r10", "r11", "memory") -#define MEXITCOUNT_OVERHEAD() \ - __asm __volatile("call .mexitcount; 1:" \ - : : \ - : "r10", "r11", "memory") -#define MEXITCOUNT_OVERHEAD_GETLABEL(labelp) \ - __asm __volatile("movq $1b,%0" : "=rm" (labelp)) -#else -#error this file needs to be ported to your compiler -#endif /* !__GNUCLIKE_ASM */ -#else /* !GUPROF */ -#define MCOUNT_DECL(s) register_t s; -#ifdef SMP -extern int mcount_lock; -#define MCOUNT_ENTER(s) { s = intr_disable(); \ - while (!atomic_cmpset_acq_int(&mcount_lock, 0, 1)) \ - /* nothing */ ; } -#define MCOUNT_EXIT(s) { atomic_store_rel_int(&mcount_lock, 0); \ - intr_restore(s); } -#else -#define MCOUNT_ENTER(s) { s = intr_disable(); } -#define MCOUNT_EXIT(s) (intr_restore(s)) -#endif -#endif /* GUPROF */ - -void bintr(void); -void btrap(void); -void eintr(void); -void user(void); - -#define MCOUNT_FROMPC_USER(pc) \ - ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) +#ifndef _KERNEL -#define MCOUNT_FROMPC_INTR(pc) \ - ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ - ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ - (uintfptr_t)btrap) : ~0UL) - -#else /* !_KERNEL */ +#include <sys/cdefs.h> #define FUNCTION_ALIGNMENT 4 @@ -172,28 +107,18 @@ mcount() \ typedef u_long uintfptr_t; -#endif /* _KERNEL */ - /* * An unsigned integral type that can hold non-negative difference between * function pointers. */ typedef u_long fptrdiff_t; -#ifdef _KERNEL - -void mcount(uintfptr_t frompc, uintfptr_t selfpc); - -#else /* !_KERNEL */ - -#include <sys/cdefs.h> - __BEGIN_DECLS #ifdef __GNUCLIKE_ASM void mcount(void) __asm(".mcount"); #endif __END_DECLS -#endif /* _KERNEL */ +#endif /* !_KERNEL */ #endif /* !_MACHINE_PROFILE_H_ */ diff --git a/sys/amd64/linux/linux_locore.asm b/sys/amd64/linux/linux_locore.asm index 1bcf05bc57dd..4e358f583a45 100644 --- a/sys/amd64/linux/linux_locore.asm +++ b/sys/amd64/linux/linux_locore.asm @@ -17,7 +17,7 @@ linux_platform: * To avoid excess stack frame the signal trampoline code emulates * the 'call' instruction. */ -NON_GPROF_ENTRY(linux_rt_sigcode) +ENTRY(linux_rt_sigcode) movq %rsp, %rbx /* preserve sigframe */ call .getip .getip: @@ -32,28 +32,28 @@ NON_GPROF_ENTRY(linux_rt_sigcode) .endrtsigcode: 0: jmp 0b -NON_GPROF_ENTRY(__vdso_clock_gettime) +ENTRY(__vdso_clock_gettime) movq $LINUX_SYS_linux_clock_gettime,%rax syscall ret .weak clock_gettime .set clock_gettime, __vdso_clock_gettime -NON_GPROF_ENTRY(__vdso_time) +ENTRY(__vdso_time) movq $LINUX_SYS_linux_time,%rax *** 2138 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104021249.132CnoXQ061379>