kern_sharedpage.c (237431) | kern_sharedpage.c (237433) |
---|---|
1/*- 2 * Copyright (c) 1993, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1993, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/kern_exec.c 237431 2012-06-22 06:39:28Z kib $"); | 28__FBSDID("$FreeBSD: head/sys/kern/kern_exec.c 237433 2012-06-22 07:06:40Z kib $"); |
29 30#include "opt_capsicum.h" | 29 30#include "opt_capsicum.h" |
31#include "opt_compat.h" |
|
31#include "opt_hwpmc_hooks.h" 32#include "opt_kdtrace.h" 33#include "opt_ktrace.h" 34#include "opt_vm.h" 35 36#include <sys/param.h> 37#include <sys/capability.h> 38#include <sys/systm.h> --- 20 unchanged lines hidden (view full) --- 59#include <sys/resourcevar.h> 60#include <sys/sched.h> 61#include <sys/sdt.h> 62#include <sys/sf_buf.h> 63#include <sys/syscallsubr.h> 64#include <sys/sysent.h> 65#include <sys/shm.h> 66#include <sys/sysctl.h> | 32#include "opt_hwpmc_hooks.h" 33#include "opt_kdtrace.h" 34#include "opt_ktrace.h" 35#include "opt_vm.h" 36 37#include <sys/param.h> 38#include <sys/capability.h> 39#include <sys/systm.h> --- 20 unchanged lines hidden (view full) --- 60#include <sys/resourcevar.h> 61#include <sys/sched.h> 62#include <sys/sdt.h> 63#include <sys/sf_buf.h> 64#include <sys/syscallsubr.h> 65#include <sys/sysent.h> 66#include <sys/shm.h> 67#include <sys/sysctl.h> |
68#include <sys/vdso.h> |
|
67#include <sys/vnode.h> 68#include <sys/stat.h> 69#ifdef KTRACE 70#include <sys/ktrace.h> 71#endif 72 73#include <vm/vm.h> 74#include <vm/vm_param.h> --- 1528 unchanged lines hidden (view full) --- 1603 VM_ALLOC_ZERO); 1604 m->valid = VM_PAGE_BITS_ALL; 1605 VM_OBJECT_UNLOCK(shared_page_obj); 1606} 1607 1608SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)shared_page_init, 1609 NULL); 1610 | 69#include <sys/vnode.h> 70#include <sys/stat.h> 71#ifdef KTRACE 72#include <sys/ktrace.h> 73#endif 74 75#include <vm/vm.h> 76#include <vm/vm_param.h> --- 1528 unchanged lines hidden (view full) --- 1605 VM_ALLOC_ZERO); 1606 m->valid = VM_PAGE_BITS_ALL; 1607 VM_OBJECT_UNLOCK(shared_page_obj); 1608} 1609 1610SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)shared_page_init, 1611 NULL); 1612 |
1613static void 1614timehands_update(void *arg) 1615{ 1616 struct sysentvec *sv; 1617 struct sf_buf *sf; 1618 struct vdso_timehands th; 1619 struct vdso_timekeep *tk; 1620 uint32_t enabled, idx; 1621 1622 sv = arg; 1623 sx_xlock(&shared_page_alloc_sx); 1624 enabled = tc_fill_vdso_timehands(&th); 1625 sf = shared_page_write_start(sv->sv_timekeep_off); 1626 tk = (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); 1627 idx = sv->sv_timekeep_curr; 1628 atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); 1629 if (++idx >= VDSO_TH_NUM) 1630 idx = 0; 1631 sv->sv_timekeep_curr = idx; 1632 if (++sv->sv_timekeep_gen == 0) 1633 sv->sv_timekeep_gen = 1; 1634 th.th_gen = 0; 1635 if (enabled) 1636 tk->tk_th[idx] = th; 1637 tk->tk_enabled = enabled; 1638 atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); 1639 tk->tk_current = idx; 1640 shared_page_write_end(sf); 1641 sx_xunlock(&shared_page_alloc_sx); 1642} 1643 1644#ifdef COMPAT_FREEBSD32 1645static void 1646timehands_update32(void *arg) 1647{ 1648 struct sysentvec *sv; 1649 struct sf_buf *sf; 1650 struct vdso_timekeep32 *tk; 1651 struct vdso_timehands32 th; 1652 uint32_t enabled, idx; 1653 1654 sv = arg; 1655 sx_xlock(&shared_page_alloc_sx); 1656 enabled = tc_fill_vdso_timehands32(&th); 1657 sf = shared_page_write_start(sv->sv_timekeep_off); 1658 tk = (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); 1659 idx = sv->sv_timekeep_curr; 1660 atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); 1661 if (++idx >= VDSO_TH_NUM) 1662 idx = 0; 1663 sv->sv_timekeep_curr = idx; 1664 if (++sv->sv_timekeep_gen == 0) 1665 sv->sv_timekeep_gen = 1; 1666 th.th_gen = 0; 1667 if (enabled) 1668 tk->tk_th[idx] = th; 1669 tk->tk_enabled = enabled; 1670 atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); 1671 tk->tk_current = idx; 1672 shared_page_write_end(sf); 1673 sx_xunlock(&shared_page_alloc_sx); 1674} 1675#endif 1676 |
|
1611void 1612exec_sysvec_init(void *param) 1613{ 1614 struct sysentvec *sv; | 1677void 1678exec_sysvec_init(void *param) 1679{ 1680 struct sysentvec *sv; |
1681 int tk_base; 1682 uint32_t tk_ver; |
|
1615 1616 sv = (struct sysentvec *)param; 1617 1618 if ((sv->sv_flags & SV_SHP) == 0) 1619 return; 1620 sv->sv_shared_page_obj = shared_page_obj; 1621 sv->sv_sigcode_base = sv->sv_shared_page_base + 1622 shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode); | 1683 1684 sv = (struct sysentvec *)param; 1685 1686 if ((sv->sv_flags & SV_SHP) == 0) 1687 return; 1688 sv->sv_shared_page_obj = shared_page_obj; 1689 sv->sv_sigcode_base = sv->sv_shared_page_base + 1690 shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode); |
1691 tk_ver = VDSO_TK_VER_CURR; 1692#ifdef COMPAT_FREEBSD32 1693 if ((sv->sv_flags & SV_ILP32) != 0) { 1694 tk_base = shared_page_alloc(sizeof(struct vdso_timekeep32) + 1695 sizeof(struct vdso_timehands32) * VDSO_TH_NUM, 16); 1696 KASSERT(tk_base != -1, ("tk_base -1 for 32bit")); 1697 EVENTHANDLER_REGISTER(tc_windup, timehands_update32, sv, 1698 EVENTHANDLER_PRI_ANY); 1699 shared_page_write(tk_base + offsetof(struct vdso_timekeep32, 1700 tk_ver), sizeof(uint32_t), &tk_ver); 1701 } else { 1702#endif 1703 tk_base = shared_page_alloc(sizeof(struct vdso_timekeep) + 1704 sizeof(struct vdso_timehands) * VDSO_TH_NUM, 16); 1705 KASSERT(tk_base != -1, ("tk_base -1 for native")); 1706 EVENTHANDLER_REGISTER(tc_windup, timehands_update, sv, 1707 EVENTHANDLER_PRI_ANY); 1708 shared_page_write(tk_base + offsetof(struct vdso_timekeep, 1709 tk_ver), sizeof(uint32_t), &tk_ver); 1710#ifdef COMPAT_FREEBSD32 1711 } 1712#endif 1713 sv->sv_timekeep_base = sv->sv_shared_page_base + tk_base; 1714 sv->sv_timekeep_off = tk_base; 1715 EVENTHANDLER_INVOKE(tc_windup); |
|
1623} | 1716} |