VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
97870c34b4532 (Alex Dewar                     2019-08-25 10:49:18 +0100   1) // SPDX-License-Identifier: GPL-2.0
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800   2) /*
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800   3)  * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800   4)  */
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800   5) 
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700   6) #include <stdio.h>
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700   7) #include <stddef.h>
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800   8) #include <stdlib.h>
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700   9) #include <unistd.h>
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700  10) #include <errno.h>
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700  11) #include <fcntl.h>
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800  12) #include <string.h>
fb967ecc584c2 (Liu Aleaxander                 2010-06-29 15:05:40 -0700  13) #include <sys/stat.h>
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700  14) #include <sys/mman.h>
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  15) #include <sys/vfs.h>
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  16) #include <linux/magic.h>
37185b3324087 (Al Viro                        2012-10-08 03:27:32 +0100  17) #include <init.h>
37185b3324087 (Al Viro                        2012-10-08 03:27:32 +0100  18) #include <os.h>
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700  19) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  20) /* Set by make_tempfile() during early boot. */
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700  21) static char *tempdir = NULL;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700  22) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  23) /* Check if dir is on tmpfs. Return 0 if yes, -1 if no or error. */
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  24) static int __init check_tmpfs(const char *dir)
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700  25) {
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  26) 	struct statfs st;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700  27) 
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900  28) 	os_info("Checking if %s is on tmpfs...", dir);
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  29) 	if (statfs(dir, &st) < 0) {
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900  30) 		os_info("%s\n", strerror(errno));
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  31) 	} else if (st.f_type != TMPFS_MAGIC) {
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900  32) 		os_info("no\n");
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  33) 	} else {
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900  34) 		os_info("OK\n");
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  35) 		return 0;
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700  36) 	}
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  37) 	return -1;
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  38) }
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  39) 
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  40) /*
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  41)  * Choose the tempdir to use. We want something on tmpfs so that our memory is
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  42)  * not subject to the host's vm.dirty_ratio. If a tempdir is specified in the
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  43)  * environment, we use that even if it's not on tmpfs, but we warn the user.
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  44)  * Otherwise, we try common tmpfs locations, and if no tmpfs directory is found
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  45)  * then we fall back to /tmp.
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  46)  */
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  47) static char * __init choose_tempdir(void)
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  48) {
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  49) 	static const char * const vars[] = {
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  50) 		"TMPDIR",
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  51) 		"TMP",
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  52) 		"TEMP",
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  53) 		NULL
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  54) 	};
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  55) 	static const char fallback_dir[] = "/tmp";
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  56) 	static const char * const tmpfs_dirs[] = {
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  57) 		"/dev/shm",
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  58) 		fallback_dir,
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  59) 		NULL
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  60) 	};
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  61) 	int i;
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  62) 	const char *dir;
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  63) 
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900  64) 	os_info("Checking environment variables for a tempdir...");
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  65) 	for (i = 0; vars[i]; i++) {
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  66) 		dir = getenv(vars[i]);
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  67) 		if ((dir != NULL) && (*dir != '\0')) {
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900  68) 			os_info("%s\n", dir);
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  69) 			if (check_tmpfs(dir) >= 0)
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  70) 				goto done;
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  71) 			else
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  72) 				goto warn;
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  73) 		}
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  74) 	}
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900  75) 	os_info("none found\n");
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  76) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  77) 	for (i = 0; tmpfs_dirs[i]; i++) {
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  78) 		dir = tmpfs_dirs[i];
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  79) 		if (check_tmpfs(dir) >= 0)
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  80) 			goto done;
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  81) 	}
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  82) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  83) 	dir = fallback_dir;
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  84) warn:
0936d4f3d5a3d (Masami Hiramatsu               2017-05-18 02:19:31 +0900  85) 	os_warn("Warning: tempdir %s is not on tmpfs\n", dir);
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  86) done:
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  87) 	/* Make a copy since getenv results may not remain valid forever. */
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  88) 	return strdup(dir);
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700  89) }
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700  90) 
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800  91) /*
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  92)  * Create an unlinked tempfile in a suitable tempdir. template must be the
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  93)  * basename part of the template with a leading '/'.
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700  94)  */
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  95) static int __init make_tempfile(const char *template)
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700  96) {
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500  97) 	char *tempname;
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400  98) 	int fd;
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700  99) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 100) 	if (tempdir == NULL) {
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 101) 		tempdir = choose_tempdir();
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 102) 		if (tempdir == NULL) {
0936d4f3d5a3d (Masami Hiramatsu               2017-05-18 02:19:31 +0900 103) 			os_warn("Failed to choose tempdir: %s\n",
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 104) 				strerror(errno));
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 105) 			return -1;
7473534130c31 (Tristan Schmelcher             2013-07-08 16:19:49 -0400 106) 		}
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 107) 	}
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 108) 
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 109) #ifdef O_TMPFILE
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 110) 	fd = open(tempdir, O_CLOEXEC | O_RDWR | O_EXCL | O_TMPFILE, 0700);
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 111) 	/*
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 112) 	 * If the running system does not support O_TMPFILE flag then retry
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 113) 	 * without it.
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 114) 	 */
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 115) 	if (fd != -1 || (errno != EINVAL && errno != EISDIR &&
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 116) 			errno != EOPNOTSUPP))
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 117) 		return fd;
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 118) #endif
3e46b25376321 (Mickaël Salaün                 2015-12-22 22:15:10 +0100 119) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 120) 	tempname = malloc(strlen(tempdir) + strlen(template) + 1);
11a7ac23a2d74 (Jim Meyering                   2008-02-08 04:22:09 -0800 121) 	if (tempname == NULL)
11a7ac23a2d74 (Jim Meyering                   2008-02-08 04:22:09 -0800 122) 		return -1;
87276f721a940 (Paolo 'Blaisorblade' Giarrusso 2006-04-10 22:53:39 -0700 123) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 124) 	strcpy(tempname, tempdir);
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 125) 	strcat(tempname, template);
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 126) 	fd = mkstemp(tempname);
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 127) 	if (fd < 0) {
0936d4f3d5a3d (Masami Hiramatsu               2017-05-18 02:19:31 +0900 128) 		os_warn("open - cannot create %s: %s\n", tempname,
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 129) 			strerror(errno));
87276f721a940 (Paolo 'Blaisorblade' Giarrusso 2006-04-10 22:53:39 -0700 130) 		goto out;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 131) 	}
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 132) 	if (unlink(tempname) < 0) {
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 133) 		perror("unlink");
2a6d0ac182688 (Davidlohr Bueso                2011-07-25 17:12:52 -0700 134) 		goto close;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 135) 	}
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 136) 	free(tempname);
81999a01c786e (Jeff Dike                      2007-02-10 01:44:21 -0800 137) 	return fd;
2a6d0ac182688 (Davidlohr Bueso                2011-07-25 17:12:52 -0700 138) close:
2a6d0ac182688 (Davidlohr Bueso                2011-07-25 17:12:52 -0700 139) 	close(fd);
87276f721a940 (Paolo 'Blaisorblade' Giarrusso 2006-04-10 22:53:39 -0700 140) out:
87276f721a940 (Paolo 'Blaisorblade' Giarrusso 2006-04-10 22:53:39 -0700 141) 	free(tempname);
87276f721a940 (Paolo 'Blaisorblade' Giarrusso 2006-04-10 22:53:39 -0700 142) 	return -1;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 143) }
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 144) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 145) #define TEMPNAME_TEMPLATE "/vm_file-XXXXXX"
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 146) 
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 147) static int __init create_tmp_file(unsigned long long len)
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 148) {
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 149) 	int fd, err;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 150) 	char zero;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 151) 
0d71832e3004a (Tristan Schmelcher             2013-11-11 13:03:06 -0500 152) 	fd = make_tempfile(TEMPNAME_TEMPLATE);
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 153) 	if (fd < 0)
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 154) 		exit(1);
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 155) 
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 156) 	/*
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 157) 	 * Seek to len - 1 because writing a character there will
190f4939222b8 (Jeff Dike                      2006-06-30 01:55:55 -0700 158) 	 * increase the file size by one byte, to the desired length.
190f4939222b8 (Jeff Dike                      2006-06-30 01:55:55 -0700 159) 	 */
190f4939222b8 (Jeff Dike                      2006-06-30 01:55:55 -0700 160) 	if (lseek64(fd, len - 1, SEEK_SET) < 0) {
512b6fb1c14d4 (Jeff Dike                      2007-10-16 01:27:11 -0700 161) 		perror("lseek64");
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 162) 		exit(1);
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 163) 	}
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 164) 
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 165) 	zero = 0;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 166) 
a61f334fd2864 (Jeff Dike                      2007-05-06 14:51:35 -0700 167) 	err = write(fd, &zero, 1);
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 168) 	if (err != 1) {
a61f334fd2864 (Jeff Dike                      2007-05-06 14:51:35 -0700 169) 		perror("write");
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 170) 		exit(1);
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 171) 	}
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 172) 
81999a01c786e (Jeff Dike                      2007-02-10 01:44:21 -0800 173) 	return fd;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 174) }
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 175) 
36e454630473c (Jeff Dike                      2007-05-06 14:51:11 -0700 176) int __init create_mem_file(unsigned long long len)
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 177) {
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 178) 	int err, fd;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 179) 
02dea0875b0f9 (Jeff Dike                      2006-03-31 02:30:08 -0800 180) 	fd = create_tmp_file(len);
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 181) 
512b6fb1c14d4 (Jeff Dike                      2007-10-16 01:27:11 -0700 182) 	err = os_set_exec_close(fd);
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 183) 	if (err < 0) {
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 184) 		errno = -err;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 185) 		perror("exec_close");
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 186) 	}
81999a01c786e (Jeff Dike                      2007-02-10 01:44:21 -0800 187) 	return fd;
0f80bc85c587e (Jeff Dike                      2005-09-16 19:27:50 -0700 188) }
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 189) 
36e454630473c (Jeff Dike                      2007-05-06 14:51:11 -0700 190) void __init check_tmpexec(void)
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 191) {
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 192) 	void *addr;
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 193) 	int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE);
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 194) 
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 195) 	addr = mmap(NULL, UM_KERN_PAGE_SIZE,
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 196) 		    PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900 197) 	os_info("Checking PROT_EXEC mmap in %s...", tempdir);
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 198) 	if (addr == MAP_FAILED) {
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 199) 		err = errno;
0936d4f3d5a3d (Masami Hiramatsu               2017-05-18 02:19:31 +0900 200) 		os_warn("%s\n", strerror(err));
c9a3072d13e4b (WANG Cong                      2008-02-04 22:30:35 -0800 201) 		close(fd);
5134d8fea06ab (Jeff Dike                      2008-02-08 04:22:08 -0800 202) 		if (err == EPERM)
0936d4f3d5a3d (Masami Hiramatsu               2017-05-18 02:19:31 +0900 203) 			os_warn("%s must be not mounted noexec\n", tempdir);
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 204) 		exit(1);
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 205) 	}
d3878bb800300 (Masami Hiramatsu               2017-05-18 02:17:14 +0900 206) 	os_info("OK\n");
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 207) 	munmap(addr, UM_KERN_PAGE_SIZE);
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 208) 
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 209) 	close(fd);
966a082f80a07 (Rob Landley                    2006-04-18 22:21:43 -0700 210) }