Deleted Added
full compact
cloudabi32_module.c (297613) cloudabi32_module.c (303941)
1/*-
2 * Copyright (c) 2015 Nuxi, https://nuxi.nl/
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2015 Nuxi, https://nuxi.nl/
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/compat/cloudabi64/cloudabi64_module.c 297613 2016-04-06 11:11:31Z ed $");
27__FBSDID("$FreeBSD: head/sys/compat/cloudabi64/cloudabi64_module.c 303941 2016-08-10 21:02:41Z ed $");
28
29#include <sys/param.h>
30#include <sys/imgact.h>
31#include <sys/kernel.h>
32#include <sys/module.h>
33#include <sys/proc.h>
34#include <sys/smp.h>
35#include <sys/sysctl.h>
36#include <sys/sysent.h>
37#include <sys/systm.h>
38
39#include <contrib/cloudabi/cloudabi64_types.h>
40
28
29#include <sys/param.h>
30#include <sys/imgact.h>
31#include <sys/kernel.h>
32#include <sys/module.h>
33#include <sys/proc.h>
34#include <sys/smp.h>
35#include <sys/sysctl.h>
36#include <sys/sysent.h>
37#include <sys/systm.h>
38
39#include <contrib/cloudabi/cloudabi64_types.h>
40
41#include <compat/cloudabi/cloudabi_util.h>
42
41#include <compat/cloudabi64/cloudabi64_util.h>
42
43#include <compat/cloudabi64/cloudabi64_util.h>
44
45extern char _binary_cloudabi64_vdso_o_start[];
46extern char _binary_cloudabi64_vdso_o_end[];
47
43register_t *
44cloudabi64_copyout_strings(struct image_params *imgp)
45{
46 struct image_args *args;
47 uintptr_t begin;
48 size_t len;
49
50 /* Copy out program arguments. */

--- 51 unchanged lines hidden (view full) ---

102 VAL(CLOUDABI_AT_BASE, args->base),
103 PTR(CLOUDABI_AT_CANARY, canary),
104 VAL(CLOUDABI_AT_CANARYLEN, sizeof(canarybuf)),
105 VAL(CLOUDABI_AT_NCPUS, mp_ncpus),
106 VAL(CLOUDABI_AT_PAGESZ, args->pagesz),
107 PTR(CLOUDABI_AT_PHDR, args->phdr),
108 VAL(CLOUDABI_AT_PHNUM, args->phnum),
109 VAL(CLOUDABI_AT_TID, td->td_tid),
48register_t *
49cloudabi64_copyout_strings(struct image_params *imgp)
50{
51 struct image_args *args;
52 uintptr_t begin;
53 size_t len;
54
55 /* Copy out program arguments. */

--- 51 unchanged lines hidden (view full) ---

107 VAL(CLOUDABI_AT_BASE, args->base),
108 PTR(CLOUDABI_AT_CANARY, canary),
109 VAL(CLOUDABI_AT_CANARYLEN, sizeof(canarybuf)),
110 VAL(CLOUDABI_AT_NCPUS, mp_ncpus),
111 VAL(CLOUDABI_AT_PAGESZ, args->pagesz),
112 PTR(CLOUDABI_AT_PHDR, args->phdr),
113 VAL(CLOUDABI_AT_PHNUM, args->phnum),
114 VAL(CLOUDABI_AT_TID, td->td_tid),
115 PTR(CLOUDABI_AT_SYSINFO_EHDR,
116 imgp->proc->p_sysent->sv_shared_page_base),
110#undef VAL
111#undef PTR
112 { .a_type = CLOUDABI_AT_NULL },
113 };
114 *stack_base -= howmany(sizeof(auxv), sizeof(register_t));
115 error = copyout(auxv, *stack_base, sizeof(auxv));
116 if (error != 0)
117 return (error);

--- 4 unchanged lines hidden (view full) ---

122}
123
124static int
125cloudabi64_modevent(module_t mod, int type, void *data)
126{
127
128 switch (type) {
129 case MOD_LOAD:
117#undef VAL
118#undef PTR
119 { .a_type = CLOUDABI_AT_NULL },
120 };
121 *stack_base -= howmany(sizeof(auxv), sizeof(register_t));
122 error = copyout(auxv, *stack_base, sizeof(auxv));
123 if (error != 0)
124 return (error);

--- 4 unchanged lines hidden (view full) ---

129}
130
131static int
132cloudabi64_modevent(module_t mod, int type, void *data)
133{
134
135 switch (type) {
136 case MOD_LOAD:
137 cloudabi_vdso_init(cloudabi64_brand.sysvec,
138 _binary_cloudabi64_vdso_o_start,
139 _binary_cloudabi64_vdso_o_end);
130 if (elf64_insert_brand_entry(&cloudabi64_brand) < 0) {
131 printf("Failed to add CloudABI ELF brand handler\n");
132 return (EINVAL);
133 }
134 return (0);
135 case MOD_UNLOAD:
136 if (elf64_brand_inuse(&cloudabi64_brand))
137 return (EBUSY);
138 if (elf64_remove_brand_entry(&cloudabi64_brand) < 0) {
139 printf("Failed to remove CloudABI ELF brand handler\n");
140 return (EINVAL);
141 }
140 if (elf64_insert_brand_entry(&cloudabi64_brand) < 0) {
141 printf("Failed to add CloudABI ELF brand handler\n");
142 return (EINVAL);
143 }
144 return (0);
145 case MOD_UNLOAD:
146 if (elf64_brand_inuse(&cloudabi64_brand))
147 return (EBUSY);
148 if (elf64_remove_brand_entry(&cloudabi64_brand) < 0) {
149 printf("Failed to remove CloudABI ELF brand handler\n");
150 return (EINVAL);
151 }
152 cloudabi_vdso_destroy(cloudabi64_brand.sysvec);
142 return (0);
143 default:
144 return (EOPNOTSUPP);
145 }
146}
147
148static moduledata_t cloudabi64_module = {
149 "cloudabi64",
150 cloudabi64_modevent,
151 NULL
152};
153
154DECLARE_MODULE_TIED(cloudabi64, cloudabi64_module, SI_SUB_EXEC, SI_ORDER_ANY);
155MODULE_DEPEND(cloudabi64, cloudabi, 1, 1, 1);
156FEATURE(cloudabi64, "CloudABI 64bit support");
153 return (0);
154 default:
155 return (EOPNOTSUPP);
156 }
157}
158
159static moduledata_t cloudabi64_module = {
160 "cloudabi64",
161 cloudabi64_modevent,
162 NULL
163};
164
165DECLARE_MODULE_TIED(cloudabi64, cloudabi64_module, SI_SUB_EXEC, SI_ORDER_ANY);
166MODULE_DEPEND(cloudabi64, cloudabi, 1, 1, 1);
167FEATURE(cloudabi64, "CloudABI 64bit support");