Home | History | Annotate | Line # | Download | only in kern
compat_stub.c revision 1.20.2.1
      1  1.20.2.1   thorpej /* $NetBSD: compat_stub.c,v 1.20.2.1 2020/12/14 14:38:13 thorpej Exp $	*/
      2       1.2  pgoyette 
      3       1.2  pgoyette /*-
      4       1.2  pgoyette  * Copyright (c) 2018 The NetBSD Foundation, Inc.
      5       1.2  pgoyette  * All rights reserved.
      6       1.2  pgoyette  *
      7       1.2  pgoyette  * This code is derived from software contributed to The NetBSD Foundation
      8       1.2  pgoyette  * by Paul Goyette
      9       1.2  pgoyette  *
     10       1.2  pgoyette  * Redistribution and use in source and binary forms, with or without
     11       1.2  pgoyette  * modification, are permitted provided that the following conditions
     12       1.2  pgoyette  * are met:
     13       1.2  pgoyette  * 1. Redistributions of source code must retain the above copyright
     14       1.2  pgoyette  *    notice, this list of conditions and the following disclaimer.
     15       1.2  pgoyette  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.2  pgoyette  *    notice, this list of conditions and the following disclaimer in the
     17       1.2  pgoyette  *    documentation and/or other materials provided with the distribution.
     18       1.2  pgoyette  *
     19       1.2  pgoyette  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.2  pgoyette  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.2  pgoyette  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.2  pgoyette  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.2  pgoyette  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.2  pgoyette  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.2  pgoyette  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.2  pgoyette  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.2  pgoyette  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.2  pgoyette  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.2  pgoyette  * POSSIBILITY OF SUCH DAMAGE.
     30       1.2  pgoyette  */
     31       1.2  pgoyette 
     32       1.2  pgoyette #include <sys/cdefs.h>
     33       1.2  pgoyette 
     34       1.2  pgoyette #ifdef _KERNEL_OPT
     35       1.2  pgoyette #include "opt_ntp.h"
     36       1.2  pgoyette #endif
     37       1.2  pgoyette 
     38       1.2  pgoyette #include <sys/systm.h>
     39       1.2  pgoyette #include <sys/compat_stub.h>
     40       1.2  pgoyette 
     41       1.2  pgoyette #ifdef NTP
     42       1.2  pgoyette #include <sys/timespec.h>
     43       1.2  pgoyette #include <sys/timex.h>
     44       1.2  pgoyette #endif
     45       1.2  pgoyette 
     46       1.2  pgoyette /*
     47       1.2  pgoyette  * Routine vectors for compat_50___sys_ntp_gettime
     48       1.2  pgoyette  *
     49       1.2  pgoyette  * MP-hooks not needed since the NTP code is not modular
     50       1.2  pgoyette  */
     51       1.2  pgoyette 
     52       1.2  pgoyette #ifdef NTP
     53       1.2  pgoyette void (*vec_ntp_gettime)(struct ntptimeval *) = ntp_gettime;
     54       1.2  pgoyette int (*vec_ntp_timestatus)(void) = ntp_timestatus;
     55       1.2  pgoyette void (*vec_ntp_adjtime1)(struct timex *) = ntp_adjtime1;
     56       1.2  pgoyette #else
     57       1.2  pgoyette void (*vec_ntp_gettime)(struct ntptimeval *) = NULL;
     58       1.2  pgoyette int (*vec_ntp_timestatus)(void) = NULL;
     59       1.2  pgoyette void (*vec_ntp_adjtime1)(struct timex *) = NULL;
     60       1.2  pgoyette #endif
     61       1.2  pgoyette 
     62       1.2  pgoyette /*
     63       1.2  pgoyette  * Routine vectors for sctp (called from within rtsock)
     64       1.2  pgoyette  *
     65       1.2  pgoyette  * MP-hooks not needed since the SCTP code is not modular
     66      1.14  pgoyette  *
     67      1.14  pgoyette  * For now, just point these at NULL.  Network initialization code
     68      1.14  pgoyette  * in if.c will overwrite these with correct values.  This is needed
     69      1.14  pgoyette  * to enable building of rumpkern library without creating circular
     70      1.14  pgoyette  * dependency with rumpnet library
     71       1.2  pgoyette  */
     72       1.2  pgoyette 
     73       1.2  pgoyette void (*vec_sctp_add_ip_address)(struct ifaddr *) = NULL;
     74       1.2  pgoyette void (*vec_sctp_delete_ip_address)(struct ifaddr *) = NULL;
     75       1.2  pgoyette 
     76       1.2  pgoyette 
     77       1.2  pgoyette /*
     78       1.2  pgoyette  * usb device_info compatability
     79       1.2  pgoyette  */
     80       1.6  pgoyette struct usb_subr_fill_30_hook_t usb_subr_fill_30_hook;
     81       1.6  pgoyette struct usb_subr_copy_30_hook_t usb_subr_copy_30_hook;
     82       1.2  pgoyette 
     83       1.2  pgoyette /*
     84       1.2  pgoyette  * ccd device compatability ioctl
     85       1.2  pgoyette  */
     86       1.2  pgoyette 
     87       1.2  pgoyette struct ccd_ioctl_60_hook_t ccd_ioctl_60_hook;
     88       1.2  pgoyette 
     89       1.2  pgoyette /*
     90       1.2  pgoyette  * clockctl device compatability ioctl
     91       1.2  pgoyette  */
     92       1.2  pgoyette 
     93       1.2  pgoyette struct clockctl_ioctl_50_hook_t clockctl_ioctl_50_hook;
     94       1.2  pgoyette 
     95       1.2  pgoyette /*
     96       1.2  pgoyette  * if_sppp device compatability ioctl subroutine
     97       1.2  pgoyette  */
     98       1.2  pgoyette 
     99       1.2  pgoyette struct sppp_params_50_hook_t sppp_params_50_hook;
    100       1.2  pgoyette 
    101       1.2  pgoyette /*
    102       1.2  pgoyette  * cryptodev compatability ioctl
    103       1.2  pgoyette  */
    104       1.2  pgoyette 
    105       1.2  pgoyette struct ocryptof_50_hook_t ocryptof_50_hook;
    106       1.2  pgoyette 
    107       1.2  pgoyette /*
    108       1.2  pgoyette  * raidframe compatability
    109       1.2  pgoyette  */
    110       1.6  pgoyette struct raidframe_ioctl_50_hook_t raidframe_ioctl_50_hook;
    111       1.6  pgoyette struct raidframe_ioctl_80_hook_t raidframe_ioctl_80_hook;
    112       1.8  christos struct raidframe_netbsd32_ioctl_hook_t raidframe_netbsd32_ioctl_hook;
    113       1.2  pgoyette 
    114       1.2  pgoyette /*
    115       1.2  pgoyette  * puffs compatability
    116       1.2  pgoyette  */
    117       1.2  pgoyette 
    118       1.6  pgoyette struct puffs_out_50_hook_t puffs_out_50_hook;
    119       1.6  pgoyette struct puffs_in_50_hook_t puffs_in_50_hook;
    120       1.2  pgoyette 
    121       1.2  pgoyette /*
    122       1.2  pgoyette  * wsevents compatability
    123       1.2  pgoyette  */
    124       1.6  pgoyette struct wscons_copyout_events_50_hook_t wscons_copyout_events_50_hook;
    125       1.2  pgoyette 
    126       1.2  pgoyette /*
    127       1.2  pgoyette  * sysmon_power compatability
    128       1.2  pgoyette  */
    129       1.2  pgoyette struct compat_sysmon_power_40_hook_t compat_sysmon_power_40_hook;
    130       1.2  pgoyette 
    131       1.2  pgoyette /*
    132       1.2  pgoyette  * compat_bio compatability
    133       1.2  pgoyette  */
    134       1.2  pgoyette struct compat_bio_30_hook_t compat_bio_30_hook;
    135       1.2  pgoyette 
    136       1.2  pgoyette /*
    137       1.2  pgoyette  * vnd ioctl compatability
    138       1.2  pgoyette  */
    139       1.2  pgoyette struct compat_vndioctl_30_hook_t compat_vndioctl_30_hook;
    140       1.2  pgoyette struct compat_vndioctl_50_hook_t compat_vndioctl_50_hook;
    141       1.2  pgoyette 
    142       1.2  pgoyette /*
    143       1.2  pgoyette  * ieee80211 ioctl compatability
    144       1.2  pgoyette  */
    145       1.6  pgoyette struct ieee80211_ioctl_20_hook_t ieee80211_ioctl_20_hook;
    146       1.2  pgoyette 
    147       1.2  pgoyette /*
    148       1.2  pgoyette  * if_43 compatability
    149       1.2  pgoyette  */
    150       1.6  pgoyette struct if_cvtcmd_43_hook_t if_cvtcmd_43_hook;
    151       1.6  pgoyette struct if_ifioctl_43_hook_t if_ifioctl_43_hook;
    152       1.2  pgoyette 
    153       1.2  pgoyette /*
    154       1.5  pgoyette  * if43_cvtcmd_20 compatability
    155       1.2  pgoyette  */
    156       1.5  pgoyette struct if43_cvtcmd_20_hook_t if43_cvtcmd_20_hook;
    157       1.2  pgoyette 
    158       1.3  christos /*
    159       1.3  christos  * tty 43 ioctl compatibility
    160       1.3  christos  */
    161       1.6  pgoyette struct tty_ttioctl_43_hook_t tty_ttioctl_43_hook;
    162       1.3  christos 
    163       1.2  pgoyette /*
    164       1.9  pgoyette  * uipc_syscalls_40 compatibility
    165       1.2  pgoyette  */
    166       1.2  pgoyette struct uipc_syscalls_40_hook_t uipc_syscalls_40_hook;
    167       1.2  pgoyette 
    168       1.2  pgoyette /*
    169       1.9  pgoyette  * uipc_socket_50 compatibility
    170       1.9  pgoyette  */
    171       1.9  pgoyette struct uipc_socket_50_setopt1_hook_t uipc_socket_50_setopt1_hook;
    172       1.9  pgoyette struct uipc_socket_50_getopt1_hook_t uipc_socket_50_getopt1_hook;
    173       1.9  pgoyette struct uipc_socket_50_sbts_hook_t uipc_socket_50_sbts_hook;
    174       1.9  pgoyette 
    175       1.9  pgoyette /*
    176       1.3  christos  * uipc_syscalls_50 compatability
    177       1.2  pgoyette  */
    178       1.2  pgoyette struct uipc_syscalls_50_hook_t uipc_syscalls_50_hook;
    179       1.2  pgoyette 
    180       1.2  pgoyette /*
    181       1.2  pgoyette  * rtsock 14 compatability
    182       1.2  pgoyette  */
    183       1.6  pgoyette struct rtsock_oifmsg_14_hook_t rtsock_oifmsg_14_hook;
    184       1.6  pgoyette struct rtsock_iflist_14_hook_t rtsock_iflist_14_hook;
    185       1.2  pgoyette 
    186       1.2  pgoyette /*
    187       1.2  pgoyette  * rtsock 50 compatability
    188       1.2  pgoyette  */
    189       1.6  pgoyette struct rtsock_iflist_50_hook_t rtsock_iflist_50_hook;
    190       1.6  pgoyette struct rtsock_oifmsg_50_hook_t rtsock_oifmsg_50_hook;
    191       1.6  pgoyette struct rtsock_rt_missmsg_50_hook_t rtsock_rt_missmsg_50_hook;
    192       1.6  pgoyette struct rtsock_rt_ifmsg_50_hook_t rtsock_rt_ifmsg_50_hook;
    193       1.6  pgoyette struct rtsock_rt_ifannouncemsg_50_hook_t rtsock_rt_ifannouncemsg_50_hook;
    194      1.10       roy struct rtsock_rt_addrmsg_rt_50_hook_t rtsock_rt_addrmsg_rt_50_hook;
    195      1.11       roy struct rtsock_rt_addrmsg_src_50_hook_t rtsock_rt_addrmsg_src_50_hook;
    196      1.10       roy struct rtsock_rt_addrmsg_50_hook_t rtsock_rt_addrmsg_50_hook;
    197       1.6  pgoyette struct rtsock_rt_ieee80211msg_50_hook_t rtsock_rt_ieee80211msg_50_hook;
    198       1.2  pgoyette 
    199       1.2  pgoyette /*
    200       1.2  pgoyette  * rtsock 70 compatability
    201       1.2  pgoyette  */
    202       1.6  pgoyette struct rtsock_newaddr_70_hook_t rtsock_newaddr_70_hook;
    203       1.6  pgoyette struct rtsock_iflist_70_hook_t rtsock_iflist_70_hook;
    204       1.2  pgoyette 
    205       1.2  pgoyette /*
    206       1.2  pgoyette  * modctl handler for old style OSTAT
    207       1.2  pgoyette  */
    208       1.2  pgoyette struct compat_modstat_80_hook_t compat_modstat_80_hook;
    209       1.2  pgoyette 
    210       1.2  pgoyette /*
    211       1.2  pgoyette  * mask for kern_sig_43's killpg (updated by compat_09)
    212       1.2  pgoyette  */
    213       1.2  pgoyette int kern_sig_43_pgid_mask = ~0;
    214       1.2  pgoyette 
    215       1.2  pgoyette /*
    216       1.2  pgoyette  * hook for kern_proc_32
    217       1.2  pgoyette  */
    218       1.6  pgoyette struct kern_proc32_copyin_hook_t kern_proc32_copyin_hook;
    219       1.6  pgoyette struct kern_proc32_base_hook_t kern_proc32_base_hook;
    220       1.2  pgoyette 
    221       1.2  pgoyette /*
    222       1.2  pgoyette  * Hook for sparc fpu code to check if a process is running
    223       1.2  pgoyette  * under sunos emulation
    224       1.2  pgoyette  */
    225       1.2  pgoyette struct get_emul_sunos_hook_t get_emul_sunos_hook;
    226       1.2  pgoyette 
    227       1.2  pgoyette /*
    228       1.2  pgoyette  * Hook for rnd_ioctl_50 callbacks
    229       1.2  pgoyette  */
    230       1.2  pgoyette struct rnd_ioctl_50_hook_t rnd_ioctl_50_hook;
    231       1.6  pgoyette struct rnd_ioctl32_50_hook_t rnd_ioctl32_50_hook;
    232       1.2  pgoyette 
    233       1.2  pgoyette /*
    234       1.2  pgoyette  * Hooks for compat_60 ttioctl and ptmioctl
    235       1.2  pgoyette  */
    236       1.6  pgoyette struct tty_ttioctl_60_hook_t tty_ttioctl_60_hook;
    237       1.6  pgoyette struct tty_ptmioctl_60_hook_t tty_ptmioctl_60_hook;
    238       1.2  pgoyette 
    239       1.2  pgoyette /*
    240       1.2  pgoyette  * Hook for compat_10 openat
    241       1.2  pgoyette  */
    242       1.6  pgoyette struct vfs_openat_10_hook_t vfs_openat_10_hook;
    243       1.2  pgoyette 
    244       1.2  pgoyette /*
    245       1.2  pgoyette  * Hook for compat_70_unp_addsockcred
    246       1.2  pgoyette  */
    247       1.6  pgoyette struct uipc_unp_70_hook_t uipc_unp_70_hook;
    248       1.2  pgoyette 
    249       1.2  pgoyette /*
    250       1.2  pgoyette  * Hook for sysvipc50_sysctl
    251       1.2  pgoyette  */
    252       1.6  pgoyette struct sysvipc_sysctl_50_hook_t sysvipc_sysctl_50_hook;
    253       1.2  pgoyette 
    254       1.2  pgoyette /*
    255      1.12   msaitoh  * ifmedia_80 compatability
    256      1.12   msaitoh  */
    257      1.12   msaitoh struct ifmedia_80_pre_hook_t ifmedia_80_pre_hook;
    258      1.12   msaitoh struct ifmedia_80_post_hook_t ifmedia_80_post_hook;
    259      1.12   msaitoh 
    260      1.12   msaitoh /*
    261       1.2  pgoyette  * Hook for 32-bit machine name
    262       1.2  pgoyette  *
    263       1.2  pgoyette  * This probably would be better placed in compat/netbsd32/netbsd32_mod.c
    264       1.2  pgoyette  * but the consumer code in linux32_exec_elf32.c is sometimes included in
    265       1.2  pgoyette  * the main kernel, and not in a compat_netbsd32 module.  (In particular,
    266       1.2  pgoyette  * this is true for i386 and sgimips.)
    267       1.2  pgoyette  */
    268       1.2  pgoyette struct netbsd32_machine32_hook_t netbsd32_machine32_hook;
    269      1.15  christos struct netbsd32_reg_validate_hook_t netbsd32_reg_validate_hook;
    270      1.16  pgoyette 
    271      1.16  pgoyette /*
    272      1.16  pgoyette  * Hook for sendsig_sigcontext_16
    273      1.16  pgoyette  */
    274      1.16  pgoyette struct sendsig_sigcontext_16_hook_t sendsig_sigcontext_16_hook;
    275      1.17  pgoyette 
    276      1.17  pgoyette /*
    277      1.19  pgoyette  * Hooks for coredumps
    278      1.17  pgoyette  */
    279      1.17  pgoyette struct coredump_hook_t coredump_hook;
    280      1.19  pgoyette struct coredump_offset_hook_t coredump_offset_hook;
    281      1.19  pgoyette struct coredump_write_hook_t coredump_write_hook;
    282      1.19  pgoyette struct coredump_netbsd_hook_t coredump_netbsd_hook;
    283  1.20.2.1   thorpej struct coredump_netbsd32_hook_t coredump_netbsd32_hook;
    284      1.20  christos struct coredump_elf32_hook_t coredump_elf32_hook;
    285      1.20  christos struct coredump_elf64_hook_t coredump_elf64_hook;
    286      1.19  pgoyette struct uvm_coredump_walkmap_hook_t uvm_coredump_walkmap_hook;
    287      1.19  pgoyette struct uvm_coredump_count_segs_hook_t uvm_coredump_count_segs_hook;
    288      1.19  pgoyette 
    289      1.19  pgoyette 
    290