Index: lib/libc/sys/Symbol.map =================================================================== --- lib/libc/sys/Symbol.map +++ lib/libc/sys/Symbol.map @@ -413,6 +413,7 @@ getfhat; funlinkat; memfd_create; + pmc_op; shm_create_largepage; shm_rename; }; Index: lib/libpmc/libpmc.c =================================================================== --- lib/libpmc/libpmc.c +++ lib/libpmc/libpmc.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -79,7 +80,7 @@ #endif /* __powerpc__ */ #define PMC_CALL(cmd, params) \ - syscall(pmc_syscall, PMC_OP_##cmd, (params)) + pmc_op(PMC_OP_##cmd, (params)) /* * Event aliases provide a way for the user to ask for generic events @@ -292,7 +293,7 @@ /* * Filled in by pmc_init(). */ -static int pmc_syscall = -1; +static bool pmc_initialized = false; static struct pmc_cpuinfo cpu_info; static struct pmc_op_getdyneventinfo soft_event_info; @@ -1117,7 +1118,7 @@ int pmc_cpuinfo(const struct pmc_cpuinfo **pci) { - if (pmc_syscall == -1) { + if (!pmc_initialized) { errno = ENXIO; return (-1); } @@ -1325,7 +1326,7 @@ struct module_stat pmc_modstat; struct pmc_op_getcpuinfo op_cpu_info; - if (pmc_syscall != -1) /* already inited */ + if (pmc_initialized) /* already inited */ return (0); /* retrieve the system call number from the KLD */ @@ -1336,22 +1337,20 @@ if ((error = modstat(pmc_mod_id, &pmc_modstat)) < 0) return (-1); - pmc_syscall = pmc_modstat.data.intval; - /* check the kernel module's ABI against our compiled-in version */ abi_version = PMC_VERSION; if (PMC_CALL(GETMODULEVERSION, &abi_version) < 0) - return (pmc_syscall = -1); + return (-1); /* ignore patch & minor numbers for the comparison */ if ((abi_version & 0xFF000000) != (PMC_VERSION & 0xFF000000)) { errno = EPROGMISMATCH; - return (pmc_syscall = -1); + return (-1); } bzero(&op_cpu_info, sizeof(op_cpu_info)); if (PMC_CALL(GETCPUINFO, &op_cpu_info) < 0) - return (pmc_syscall = -1); + return (-1); cpu_info.pm_cputype = op_cpu_info.pm_cputype; cpu_info.pm_ncpu = op_cpu_info.pm_ncpu; @@ -1375,7 +1374,7 @@ */ soft_event_info.pm_class = PMC_CLASS_SOFT; if (PMC_CALL(GETDYNEVENTINFO, &soft_event_info) < 0) - return (pmc_syscall = -1); + return (-1); /* Map soft events to static list. */ for (n = 0; n < soft_event_info.pm_nevent; n++) { @@ -1484,9 +1483,10 @@ break; #endif errno = ENXIO; - return (pmc_syscall = -1); + return (-1); } + pmc_initialized = true; return (0); } @@ -1662,7 +1662,7 @@ int pmc_ncpu(void) { - if (pmc_syscall == -1) { + if (!pmc_initialized) { errno = ENXIO; return (-1); } @@ -1673,7 +1673,7 @@ int pmc_npmc(int cpu) { - if (pmc_syscall == -1) { + if (!pmc_initialized) { errno = ENXIO; return (-1); } Index: sys/compat/freebsd32/freebsd32_syscall.h =================================================================== --- sys/compat/freebsd32/freebsd32_syscall.h +++ sys/compat/freebsd32/freebsd32_syscall.h @@ -506,4 +506,4 @@ #define FREEBSD32_SYS___specialfd 577 #define FREEBSD32_SYS_freebsd32_aio_writev 578 #define FREEBSD32_SYS_freebsd32_aio_readv 579 -#define FREEBSD32_SYS_MAXSYSCALL 580 +#define FREEBSD32_SYS_MAXSYSCALL 581 Index: sys/compat/freebsd32/freebsd32_syscalls.c =================================================================== --- sys/compat/freebsd32/freebsd32_syscalls.c +++ sys/compat/freebsd32/freebsd32_syscalls.c @@ -616,4 +616,5 @@ "__specialfd", /* 577 = __specialfd */ "freebsd32_aio_writev", /* 578 = freebsd32_aio_writev */ "freebsd32_aio_readv", /* 579 = freebsd32_aio_readv */ + "#580", /* 580 = freebsd32_pmc_op */ }; Index: sys/compat/freebsd32/freebsd32_sysent.c =================================================================== --- sys/compat/freebsd32/freebsd32_sysent.c +++ sys/compat/freebsd32/freebsd32_sysent.c @@ -669,4 +669,5 @@ { .sy_narg = AS(__specialfd_args), .sy_call = (sy_call_t *)sys___specialfd, .sy_auevent = AUE_SPECIALFD, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 577 = __specialfd */ { .sy_narg = AS(freebsd32_aio_writev_args), .sy_call = (sy_call_t *)freebsd32_aio_writev, .sy_auevent = AUE_AIO_WRITEV, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 578 = freebsd32_aio_writev */ { .sy_narg = AS(freebsd32_aio_readv_args), .sy_call = (sy_call_t *)freebsd32_aio_readv, .sy_auevent = AUE_AIO_READV, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 579 = freebsd32_aio_readv */ + { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 580 = freebsd32_pmc_op */ }; Index: sys/compat/freebsd32/syscalls.master =================================================================== --- sys/compat/freebsd32/syscalls.master +++ sys/compat/freebsd32/syscalls.master @@ -1174,5 +1174,6 @@ struct aiocb32 *aiocbp); } 579 AUE_AIO_READV STD { int freebsd32_aio_readv( \ struct aiocb32 *aiocbp); } +580 AUE_NULL UNIMPL freebsd32_pmc_op ; vim: syntax=off Index: sys/dev/hwpmc/hwpmc_mod.c =================================================================== --- sys/dev/hwpmc/hwpmc_mod.c +++ sys/dev/hwpmc/hwpmc_mod.c @@ -60,9 +60,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -97,7 +99,7 @@ * The offset in sysent where the syscall is allocated. */ -static int pmc_syscall_num = NO_SYSCALL; +static int pmc_syscall_num = SYS_pmc_op; struct pmc_cpu **pmc_pcpu; /* per-cpu state */ pmc_value_t *pmc_pcpu_saved; /* saved PMC values: CSW handling */ @@ -254,7 +256,6 @@ static void pmc_select_cpu(int cpu); static int pmc_start(struct pmc *pm); static int pmc_stop(struct pmc *pm); -static int pmc_syscall_handler(struct thread *td, void *syscall_args); static struct pmc_thread *pmc_thread_descriptor_pool_alloc(void); static void pmc_thread_descriptor_pool_drain(void); static void pmc_thread_descriptor_pool_free(struct pmc_thread *pt); @@ -403,7 +404,7 @@ /* The `sysent' for the new syscall */ static struct sysent pmc_sysent = { .sy_narg = 2, - .sy_call = pmc_syscall_handler, + .sy_call = (sy_call_t *)sys_pmc_op, }; static struct syscall_module_data pmc_syscall_mod = { @@ -3373,17 +3374,15 @@ is_sx_downgraded = 1; \ } while (0) -static int -pmc_syscall_handler(struct thread *td, void *syscall_args) +int +sys_pmc_op(struct thread *td, struct pmc_op_args *uap) { int error, is_sx_downgraded, op; - struct pmc_syscall_args *c; void *pmclog_proc_handle; void *arg; - c = (struct pmc_syscall_args *)syscall_args; - op = c->pmop_code; - arg = c->pmop_data; + op = uap->pmop_code; + arg = uap->pmop_data; /* PMC isn't set up yet */ if (pmc_hook == NULL) return (EINVAL); Index: sys/kern/init_sysent.c =================================================================== --- sys/kern/init_sysent.c +++ sys/kern/init_sysent.c @@ -635,4 +635,5 @@ { .sy_narg = AS(__specialfd_args), .sy_call = (sy_call_t *)sys___specialfd, .sy_auevent = AUE_SPECIALFD, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 577 = __specialfd */ { .sy_narg = AS(aio_writev_args), .sy_call = (sy_call_t *)sys_aio_writev, .sy_auevent = AUE_AIO_WRITEV, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 578 = aio_writev */ { .sy_narg = AS(aio_readv_args), .sy_call = (sy_call_t *)sys_aio_readv, .sy_auevent = AUE_AIO_READV, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 579 = aio_readv */ + { .sy_narg = AS(pmc_op_args), .sy_call = (sy_call_t *)lkmressys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 580 = pmc_op */ }; Index: sys/kern/syscalls.c =================================================================== --- sys/kern/syscalls.c +++ sys/kern/syscalls.c @@ -586,4 +586,5 @@ "__specialfd", /* 577 = __specialfd */ "aio_writev", /* 578 = aio_writev */ "aio_readv", /* 579 = aio_readv */ + "pmc_op", /* 580 = pmc_op */ }; Index: sys/kern/syscalls.master =================================================================== --- sys/kern/syscalls.master +++ sys/kern/syscalls.master @@ -3238,6 +3238,12 @@ _Inout_ struct aiocb *aiocbp ); } +580 AUE_NULL NOSTD { + int pmc_op( + uint64_t pmop_code, + _Inout_ void *pmop_data + ); + } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master Index: sys/kern/systrace_args.c =================================================================== --- sys/kern/systrace_args.c +++ sys/kern/systrace_args.c @@ -3399,6 +3399,14 @@ *n_args = 1; break; } + /* pmc_op */ + case 580: { + struct pmc_op_args *p = params; + uarg[0] = p->pmop_code; /* uint64_t */ + uarg[1] = (intptr_t)p->pmop_data; /* void * */ + *n_args = 2; + break; + } default: *n_args = 0; break; @@ -9088,6 +9096,19 @@ break; }; break; + /* pmc_op */ + case 580: + switch (ndx) { + case 0: + p = "uint64_t"; + break; + case 1: + p = "userland void *"; + break; + default: + break; + }; + break; default: break; }; @@ -11034,6 +11055,11 @@ if (ndx == 0 || ndx == 1) p = "int"; break; + /* pmc_op */ + case 580: + if (ndx == 0 || ndx == 1) + p = "int"; + break; default: break; }; Index: sys/sys/pmc.h =================================================================== --- sys/sys/pmc.h +++ sys/sys/pmc.h @@ -667,15 +667,6 @@ * (p) - pmc_sx (sx) */ -/* - * PMC commands - */ - -struct pmc_syscall_args { - register_t pmop_code; /* one of PMC_OP_* */ - void *pmop_data; /* syscall parameter */ -}; - /* * Interface to processor specific s1tuff */ @@ -1223,5 +1214,7 @@ struct pmc_mdep *pmc_mdep_alloc(int nclasses); void pmc_mdep_free(struct pmc_mdep *md); uint64_t pmc_rdtsc(void); +#else +int pmc_op(uint64_t code, void *data); #endif /* _KERNEL */ #endif /* _SYS_PMC_H_ */ Index: sys/sys/syscall.h =================================================================== --- sys/sys/syscall.h +++ sys/sys/syscall.h @@ -515,4 +515,5 @@ #define SYS___specialfd 577 #define SYS_aio_writev 578 #define SYS_aio_readv 579 -#define SYS_MAXSYSCALL 580 +#define SYS_pmc_op 580 +#define SYS_MAXSYSCALL 581 Index: sys/sys/syscall.mk =================================================================== --- sys/sys/syscall.mk +++ sys/sys/syscall.mk @@ -420,4 +420,5 @@ rpctls_syscall.o \ __specialfd.o \ aio_writev.o \ - aio_readv.o + aio_readv.o \ + pmc_op.o Index: sys/sys/sysproto.h =================================================================== --- sys/sys/sysproto.h +++ sys/sys/sysproto.h @@ -1847,6 +1847,10 @@ struct aio_readv_args { char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)]; }; +struct pmc_op_args { + char pmop_code_l_[PADL_(uint64_t)]; uint64_t pmop_code; char pmop_code_r_[PADR_(uint64_t)]; + char pmop_data_l_[PADL_(void *)]; void * pmop_data; char pmop_data_r_[PADR_(void *)]; +}; int nosys(struct thread *, struct nosys_args *); void sys_sys_exit(struct thread *, struct sys_exit_args *); int sys_fork(struct thread *, struct fork_args *); @@ -2241,6 +2245,7 @@ int sys___specialfd(struct thread *, struct __specialfd_args *); int sys_aio_writev(struct thread *, struct aio_writev_args *); int sys_aio_readv(struct thread *, struct aio_readv_args *); +int sys_pmc_op(struct thread *, struct pmc_op_args *); #ifdef COMPAT_43 @@ -3175,6 +3180,7 @@ #define SYS_AUE___specialfd AUE_SPECIALFD #define SYS_AUE_aio_writev AUE_AIO_WRITEV #define SYS_AUE_aio_readv AUE_AIO_READV +#define SYS_AUE_pmc_op AUE_NULL #undef PAD_ #undef PADL_