Home | History | Annotate | Line # | Download | only in ufetchstore
      1  1.4  thorpej /*	$NetBSD: t_ufetchstore.c,v 1.4 2019/04/07 15:50:12 thorpej Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*
      4  1.1  thorpej  * Copyright (c) 2019 The NetBSD Foundation, Inc.
      5  1.1  thorpej  * All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  thorpej  * by Jason R. Thorpe.
      9  1.1  thorpej  *
     10  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     11  1.1  thorpej  * modification, are permitted provided that the following conditions
     12  1.1  thorpej  * are met:
     13  1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     14  1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     15  1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     18  1.1  thorpej  *
     19  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1  thorpej  */
     31  1.1  thorpej 
     32  1.1  thorpej #include <sys/cdefs.h>
     33  1.1  thorpej __COPYRIGHT("@(#) Copyright (c) 2019\
     34  1.1  thorpej  The NetBSD Foundation, inc. All rights reserved.");
     35  1.4  thorpej __RCSID("$NetBSD: t_ufetchstore.c,v 1.4 2019/04/07 15:50:12 thorpej Exp $");
     36  1.1  thorpej 
     37  1.1  thorpej #include <sys/types.h>
     38  1.1  thorpej #include <sys/endian.h>
     39  1.1  thorpej #include <sys/module.h>
     40  1.1  thorpej #include <sys/sysctl.h>
     41  1.1  thorpej 
     42  1.1  thorpej #include <err.h>
     43  1.1  thorpej #include <errno.h>
     44  1.1  thorpej #include <limits.h>
     45  1.1  thorpej 
     46  1.1  thorpej #include <atf-c.h>
     47  1.1  thorpej 
     48  1.1  thorpej #include "common.h"
     49  1.1  thorpej 
     50  1.1  thorpej #define	mib_name	"kern.ufetchstore_test.test"
     51  1.1  thorpej 
     52  1.1  thorpej static bool module_loaded;
     53  1.1  thorpej 
     54  1.1  thorpej #define	MODULE_PATH	\
     55  1.1  thorpej 	"/usr/tests/modules/ufetchstore_tester/ufetchstore_tester.kmod"
     56  1.1  thorpej #define	MODULE_NAME	"ufetchstore_tester"
     57  1.1  thorpej 
     58  1.1  thorpej #define	CHECK_MODULE()							\
     59  1.1  thorpej do {									\
     60  1.1  thorpej 	load_module();							\
     61  1.1  thorpej 	if (! module_loaded) {						\
     62  1.1  thorpej 		atf_tc_skip("loading '%s' module failed.", MODULE_NAME);\
     63  1.1  thorpej 	}								\
     64  1.1  thorpej } while (/*CONSTCOND*/0)
     65  1.1  thorpej 
     66  1.1  thorpej static void
     67  1.1  thorpej load_module(void)
     68  1.1  thorpej {
     69  1.1  thorpej #ifndef SKIP_MODULE
     70  1.1  thorpej 	if (module_loaded)
     71  1.1  thorpej 		return;
     72  1.1  thorpej 
     73  1.1  thorpej 	modctl_load_t params = {
     74  1.1  thorpej 		.ml_filename = MODULE_PATH,
     75  1.1  thorpej 		.ml_flags = MODCTL_NO_PROP,
     76  1.1  thorpej 	};
     77  1.1  thorpej 
     78  1.1  thorpej 	if (modctl(MODCTL_LOAD, &params) != 0) {
     79  1.1  thorpej 		warn("failed to load module '%s'", MODULE_PATH);
     80  1.1  thorpej 	} else {
     81  1.1  thorpej 		module_loaded = true;
     82  1.1  thorpej 	}
     83  1.1  thorpej #else
     84  1.1  thorpej 	module_loaded = true;
     85  1.1  thorpej #endif /* ! SKIP_MODULE */
     86  1.1  thorpej }
     87  1.1  thorpej 
     88  1.3      rin #define	UADDR(x)	((uintptr_t)(x))
     89  1.1  thorpej 
     90  1.1  thorpej static void
     91  1.1  thorpej unload_module(void)
     92  1.1  thorpej {
     93  1.1  thorpej #ifndef SKIP_MODULE
     94  1.1  thorpej 	char module_name[] = MODULE_NAME;
     95  1.1  thorpej 
     96  1.1  thorpej 	if (modctl(MODCTL_UNLOAD, module_name) != 0) {
     97  1.1  thorpej 		warn("failed to unload module '%s'", MODULE_NAME);
     98  1.1  thorpej 	} else {
     99  1.1  thorpej 		module_loaded = false;
    100  1.1  thorpej 	}
    101  1.1  thorpej #endif /* ! SKIP_MODULE */
    102  1.1  thorpej }
    103  1.1  thorpej 
    104  1.4  thorpej static unsigned long
    105  1.4  thorpej vm_max_address_raw(void)
    106  1.1  thorpej {
    107  1.1  thorpej 	static unsigned long max_addr = 0;
    108  1.1  thorpej 	int rv;
    109  1.1  thorpej 
    110  1.1  thorpej 	if (max_addr == 0) {
    111  1.1  thorpej 		size_t max_addr_size = sizeof(max_addr);
    112  1.1  thorpej 		rv = sysctlbyname("vm.maxaddress", &max_addr, &max_addr_size,
    113  1.1  thorpej 				  NULL, 0);
    114  1.1  thorpej 		if (rv != 0)
    115  1.1  thorpej 	                err(1, "sysctlbyname('vm.maxaddress')");
    116  1.1  thorpej         }
    117  1.4  thorpej 	return max_addr;
    118  1.4  thorpej }
    119  1.4  thorpej 
    120  1.4  thorpej static void *
    121  1.4  thorpej vm_max_address(void)
    122  1.4  thorpej {
    123  1.4  thorpej 	return (void *)vm_max_address_raw();
    124  1.4  thorpej }
    125  1.4  thorpej 
    126  1.4  thorpej static void *
    127  1.4  thorpej vm_max_address_minus(unsigned int adj)
    128  1.4  thorpej {
    129  1.4  thorpej 	return (void *)(vm_max_address_raw() - adj);
    130  1.1  thorpej }
    131  1.1  thorpej 
    132  1.1  thorpej static int
    133  1.1  thorpej do_sysctl(struct ufetchstore_test_args *args)
    134  1.1  thorpej {
    135  1.1  thorpej 	uint64_t arg_addr64 = (uintptr_t)args;
    136  1.1  thorpej 	int rv;
    137  1.1  thorpej 
    138  1.1  thorpej 	args->fetchstore_error = EBADF;	/* poison */
    139  1.1  thorpej 	args->pointer_size = (int)sizeof(void *);
    140  1.1  thorpej 
    141  1.1  thorpej 	/*
    142  1.1  thorpej 	 * Yes, the intent is to provide the pointer, not the structure,
    143  1.1  thorpej 	 * to the kernel side of the test harness.
    144  1.1  thorpej 	 */
    145  1.1  thorpej 	rv = sysctlbyname(mib_name, NULL, NULL, &arg_addr64,
    146  1.1  thorpej 			  sizeof(arg_addr64));
    147  1.1  thorpej 	if (rv != 0) {
    148  1.1  thorpej 		rv = errno;
    149  1.1  thorpej 		warn("sysctlbyname('%s') -> %d", mib_name, rv);
    150  1.1  thorpej 		return rv;
    151  1.1  thorpej 	}
    152  1.1  thorpej 	return 0;
    153  1.1  thorpej }
    154  1.1  thorpej 
    155  1.1  thorpej static int
    156  1.1  thorpej do_ufetch_8(const uint8_t *uaddr, uint8_t *res)
    157  1.1  thorpej {
    158  1.1  thorpej 	struct ufetchstore_test_args args = {
    159  1.3      rin 		.uaddr64 = UADDR(uaddr),
    160  1.1  thorpej 		.test_op = OP_LOAD,
    161  1.1  thorpej 		.size = 8,
    162  1.1  thorpej 	};
    163  1.1  thorpej 
    164  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    165  1.1  thorpej 	*res = args.val8;
    166  1.1  thorpej 	return args.fetchstore_error;
    167  1.1  thorpej }
    168  1.1  thorpej 
    169  1.1  thorpej static int
    170  1.1  thorpej do_ufetch_16(const uint16_t *uaddr, uint16_t *res)
    171  1.1  thorpej {
    172  1.1  thorpej 	struct ufetchstore_test_args args = {
    173  1.3      rin 		.uaddr64 = UADDR(uaddr),
    174  1.1  thorpej 		.test_op = OP_LOAD,
    175  1.1  thorpej 		.size = 16,
    176  1.1  thorpej 	};
    177  1.1  thorpej 
    178  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    179  1.1  thorpej 	*res = args.val16;
    180  1.1  thorpej 	return args.fetchstore_error;
    181  1.1  thorpej }
    182  1.1  thorpej 
    183  1.1  thorpej static int
    184  1.1  thorpej do_ufetch_32(const uint32_t *uaddr, uint32_t *res)
    185  1.1  thorpej {
    186  1.1  thorpej 	struct ufetchstore_test_args args = {
    187  1.3      rin 		.uaddr64 = UADDR(uaddr),
    188  1.1  thorpej 		.test_op = OP_LOAD,
    189  1.1  thorpej 		.size = 32,
    190  1.1  thorpej 	};
    191  1.1  thorpej 
    192  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    193  1.1  thorpej 	*res = args.val32;
    194  1.1  thorpej 	return args.fetchstore_error;
    195  1.1  thorpej }
    196  1.1  thorpej 
    197  1.1  thorpej #ifdef _LP64
    198  1.1  thorpej static int
    199  1.1  thorpej do_ufetch_64(const uint64_t *uaddr, uint64_t *res)
    200  1.1  thorpej {
    201  1.1  thorpej 	struct ufetchstore_test_args args = {
    202  1.3      rin 		.uaddr64 = UADDR(uaddr),
    203  1.1  thorpej 		.test_op = OP_LOAD,
    204  1.1  thorpej 		.size = 64,
    205  1.1  thorpej 	};
    206  1.1  thorpej 
    207  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    208  1.1  thorpej 	*res = args.val64;
    209  1.1  thorpej 	return args.fetchstore_error;
    210  1.1  thorpej }
    211  1.1  thorpej #endif /* _LP64 */
    212  1.1  thorpej 
    213  1.1  thorpej static int
    214  1.1  thorpej do_ustore_8(uint8_t *uaddr, uint8_t val)
    215  1.1  thorpej {
    216  1.1  thorpej 	struct ufetchstore_test_args args = {
    217  1.3      rin 		.uaddr64 = UADDR(uaddr),
    218  1.1  thorpej 		.test_op = OP_STORE,
    219  1.1  thorpej 		.size = 8,
    220  1.1  thorpej 		.val8 = val,
    221  1.1  thorpej 	};
    222  1.1  thorpej 
    223  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    224  1.1  thorpej 	return args.fetchstore_error;
    225  1.1  thorpej }
    226  1.1  thorpej 
    227  1.1  thorpej static int
    228  1.1  thorpej do_ustore_16(uint16_t *uaddr, uint16_t val)
    229  1.1  thorpej {
    230  1.1  thorpej 	struct ufetchstore_test_args args = {
    231  1.3      rin 		.uaddr64 = UADDR(uaddr),
    232  1.1  thorpej 		.test_op = OP_STORE,
    233  1.1  thorpej 		.size = 16,
    234  1.1  thorpej 		.val16 = val,
    235  1.1  thorpej 	};
    236  1.1  thorpej 
    237  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    238  1.1  thorpej 	return args.fetchstore_error;
    239  1.1  thorpej }
    240  1.1  thorpej 
    241  1.1  thorpej static int
    242  1.1  thorpej do_ustore_32(uint32_t *uaddr, uint32_t val)
    243  1.1  thorpej {
    244  1.1  thorpej 	struct ufetchstore_test_args args = {
    245  1.3      rin 		.uaddr64 = UADDR(uaddr),
    246  1.1  thorpej 		.test_op = OP_STORE,
    247  1.1  thorpej 		.size = 32,
    248  1.1  thorpej 		.val32 = val,
    249  1.1  thorpej 	};
    250  1.1  thorpej 
    251  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    252  1.1  thorpej 	return args.fetchstore_error;
    253  1.1  thorpej }
    254  1.1  thorpej 
    255  1.1  thorpej #ifdef _LP64
    256  1.1  thorpej static int
    257  1.1  thorpej do_ustore_64(uint64_t *uaddr, uint64_t val)
    258  1.1  thorpej {
    259  1.1  thorpej 	struct ufetchstore_test_args args = {
    260  1.3      rin 		.uaddr64 = UADDR(uaddr),
    261  1.1  thorpej 		.test_op = OP_STORE,
    262  1.1  thorpej 		.size = 64,
    263  1.1  thorpej 		.val64 = val,
    264  1.1  thorpej 	};
    265  1.1  thorpej 
    266  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    267  1.1  thorpej 	return args.fetchstore_error;
    268  1.1  thorpej }
    269  1.1  thorpej #endif /* _LP64 */
    270  1.1  thorpej 
    271  1.1  thorpej static int
    272  1.1  thorpej do_ucas_32(uint32_t *uaddr, uint32_t expected, uint32_t new, uint32_t *actualp)
    273  1.1  thorpej {
    274  1.1  thorpej 	struct ufetchstore_test_args args = {
    275  1.3      rin 		.uaddr64 = UADDR(uaddr),
    276  1.1  thorpej 		.test_op = OP_CAS,
    277  1.1  thorpej 		.size = 32,
    278  1.1  thorpej 		.val32 = new,
    279  1.1  thorpej 		.ea_val32 = expected,
    280  1.1  thorpej 	};
    281  1.1  thorpej 
    282  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    283  1.1  thorpej 	*actualp = args.ea_val32;
    284  1.1  thorpej 	return args.fetchstore_error;
    285  1.1  thorpej }
    286  1.1  thorpej 
    287  1.1  thorpej #ifdef _LP64
    288  1.1  thorpej static int
    289  1.1  thorpej do_ucas_64(uint64_t *uaddr, uint64_t expected, uint64_t new, uint64_t *actualp)
    290  1.1  thorpej {
    291  1.1  thorpej 	struct ufetchstore_test_args args = {
    292  1.3      rin 		.uaddr64 = UADDR(uaddr),
    293  1.1  thorpej 		.test_op = OP_CAS,
    294  1.1  thorpej 		.size = 64,
    295  1.1  thorpej 		.val64 = new,
    296  1.1  thorpej 		.ea_val64 = expected,
    297  1.1  thorpej 	};
    298  1.1  thorpej 
    299  1.1  thorpej 	ATF_REQUIRE_EQ(do_sysctl(&args), 0);
    300  1.1  thorpej 	*actualp = args.ea_val64;
    301  1.1  thorpej 	return args.fetchstore_error;
    302  1.1  thorpej }
    303  1.1  thorpej #endif /* _LP64 */
    304  1.1  thorpej 
    305  1.1  thorpej struct memory_cell {
    306  1.1  thorpej 	unsigned long guard0;
    307  1.1  thorpej 	union {
    308  1.1  thorpej 		unsigned long test_cell;
    309  1.1  thorpej #ifdef _LP64
    310  1.1  thorpej 		uint64_t val64;
    311  1.1  thorpej #endif
    312  1.1  thorpej 		uint32_t val32[sizeof(long) / 4];
    313  1.1  thorpej 		uint16_t val16[sizeof(long) / 2];
    314  1.1  thorpej 		uint8_t  val8 [sizeof(long)    ];
    315  1.1  thorpej 	};
    316  1.1  thorpej 	unsigned long guard1;
    317  1.1  thorpej };
    318  1.1  thorpej 
    319  1.1  thorpej #define	index8		1
    320  1.1  thorpej #define	index16		1
    321  1.1  thorpej #define	index32		0
    322  1.1  thorpej 
    323  1.1  thorpej #define	test_pattern8	0xa5
    324  1.1  thorpej #define	test_pattern16	0x5a6b
    325  1.1  thorpej #define	test_pattern32	0xb01cafe1
    326  1.1  thorpej #ifdef _LP64
    327  1.1  thorpej #define	test_pattern64	0xcafedeadfeedbabe
    328  1.1  thorpej #endif
    329  1.1  thorpej 
    330  1.1  thorpej #if _BYTE_ORDER == _LITTLE_ENDIAN
    331  1.1  thorpej #define	test_cell_val8	((unsigned long)test_pattern8  << (index8  * NBBY))
    332  1.1  thorpej #define	test_cell_val16	((unsigned long)test_pattern16 << (index16 * NBBY*2))
    333  1.1  thorpej #define	test_cell_val32	((unsigned long)test_pattern32 << (index32 * NBBY*4))
    334  1.1  thorpej #ifdef _LP64
    335  1.1  thorpej #define	test_cell_val64	((unsigned long)test_pattern64)
    336  1.1  thorpej #endif
    337  1.1  thorpej #endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
    338  1.1  thorpej 
    339  1.1  thorpej #if _BYTE_ORDER == _BIG_ENDIAN
    340  1.1  thorpej #ifdef _LP64
    341  1.1  thorpej #define	test_cell_val8	((unsigned long)test_pattern8  << (56-(index8  * NBBY)))
    342  1.1  thorpej #define	test_cell_val16	((unsigned long)test_pattern16 << (48-(index16 * NBBY*2)))
    343  1.1  thorpej #define	test_cell_val32	((unsigned long)test_pattern32 << (32-(index32 * NBBY*4)))
    344  1.1  thorpej #define	test_cell_val64	((unsigned long)test_pattern64)
    345  1.1  thorpej #else /* ! _LP64 */
    346  1.1  thorpej #define	test_cell_val8	((unsigned long)test_pattern8  << (24-(index8  * NBBY)))
    347  1.1  thorpej #define	test_cell_val16	((unsigned long)test_pattern16 << (16-(index16 * NBBY*2)))
    348  1.1  thorpej #define	test_cell_val32	((unsigned long)test_pattern32)
    349  1.1  thorpej #endif /* _LP64 */
    350  1.1  thorpej #endif /* #if _BYTE_ORDER == _BIG_ENDIAN */
    351  1.1  thorpej 
    352  1.1  thorpej #define	read_test_cell(cell)		(cell)->test_cell
    353  1.1  thorpej #define	write_test_cell(cell, v)	(cell)->test_cell = (v)
    354  1.1  thorpej 
    355  1.1  thorpej #define	memory_cell_initializer		\
    356  1.1  thorpej 	{				\
    357  1.1  thorpej 		.guard0 = ULONG_MAX,	\
    358  1.1  thorpej 		.test_cell = 0,		\
    359  1.1  thorpej 		.guard1 = ULONG_MAX,	\
    360  1.1  thorpej 	}
    361  1.1  thorpej 
    362  1.1  thorpej static bool
    363  1.1  thorpej memory_cell_check_guard(const struct memory_cell * const cell)
    364  1.1  thorpej {
    365  1.1  thorpej 	return cell->guard0 == ULONG_MAX &&
    366  1.1  thorpej 	       cell->guard1 == ULONG_MAX;
    367  1.1  thorpej }
    368  1.1  thorpej 
    369  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_8);
    370  1.1  thorpej ATF_TC_HEAD(ufetch_8, tc)
    371  1.1  thorpej {
    372  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    373  1.1  thorpej 	    "test for correct ufetch_8 behavior");
    374  1.1  thorpej }
    375  1.1  thorpej ATF_TC_BODY(ufetch_8, tc)
    376  1.1  thorpej {
    377  1.1  thorpej 	struct memory_cell cell = memory_cell_initializer;
    378  1.1  thorpej 	uint8_t res;
    379  1.1  thorpej 
    380  1.1  thorpej 	CHECK_MODULE();
    381  1.1  thorpej 
    382  1.1  thorpej 	write_test_cell(&cell, test_cell_val8);
    383  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_8(&cell.val8[index8], &res), 0);
    384  1.1  thorpej 	ATF_REQUIRE(memory_cell_check_guard(&cell));
    385  1.1  thorpej 	ATF_REQUIRE(res == test_pattern8);
    386  1.1  thorpej }
    387  1.1  thorpej ATF_TC_CLEANUP(ufetch_8, tc)
    388  1.1  thorpej {
    389  1.1  thorpej 	unload_module();
    390  1.1  thorpej }
    391  1.1  thorpej 
    392  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_16);
    393  1.1  thorpej ATF_TC_HEAD(ufetch_16, tc)
    394  1.1  thorpej {
    395  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    396  1.1  thorpej 	    "test for correct ufetch_16 behavior");
    397  1.1  thorpej }
    398  1.1  thorpej ATF_TC_BODY(ufetch_16, tc)
    399  1.1  thorpej {
    400  1.1  thorpej 	struct memory_cell cell = memory_cell_initializer;
    401  1.1  thorpej 	uint16_t res;
    402  1.1  thorpej 
    403  1.1  thorpej 	CHECK_MODULE();
    404  1.1  thorpej 
    405  1.1  thorpej 	write_test_cell(&cell, test_cell_val16);
    406  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_16(&cell.val16[index16], &res), 0);
    407  1.1  thorpej 	ATF_REQUIRE(memory_cell_check_guard(&cell));
    408  1.1  thorpej 	ATF_REQUIRE(res == test_pattern16);
    409  1.1  thorpej }
    410  1.1  thorpej ATF_TC_CLEANUP(ufetch_16, tc)
    411  1.1  thorpej {
    412  1.1  thorpej 	unload_module();
    413  1.1  thorpej }
    414  1.1  thorpej 
    415  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_32);
    416  1.1  thorpej ATF_TC_HEAD(ufetch_32, tc)
    417  1.1  thorpej {
    418  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    419  1.1  thorpej 	    "test for correct ufetch_32 behavior");
    420  1.1  thorpej }
    421  1.1  thorpej ATF_TC_BODY(ufetch_32, tc)
    422  1.1  thorpej {
    423  1.1  thorpej 	struct memory_cell cell = memory_cell_initializer;
    424  1.1  thorpej 	uint32_t res;
    425  1.1  thorpej 
    426  1.1  thorpej 	CHECK_MODULE();
    427  1.1  thorpej 
    428  1.1  thorpej 	write_test_cell(&cell, test_cell_val32);
    429  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_32(&cell.val32[index32], &res), 0);
    430  1.1  thorpej 	ATF_REQUIRE(memory_cell_check_guard(&cell));
    431  1.1  thorpej 	ATF_REQUIRE(res == test_pattern32);
    432  1.1  thorpej }
    433  1.1  thorpej ATF_TC_CLEANUP(ufetch_32, tc)
    434  1.1  thorpej {
    435  1.1  thorpej 	unload_module();
    436  1.1  thorpej }
    437  1.1  thorpej 
    438  1.1  thorpej #ifdef _LP64
    439  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_64);
    440  1.1  thorpej ATF_TC_HEAD(ufetch_64, tc)
    441  1.1  thorpej {
    442  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    443  1.1  thorpej 	    "test for correct ufetch_64 behavior");
    444  1.1  thorpej }
    445  1.1  thorpej ATF_TC_BODY(ufetch_64, tc)
    446  1.1  thorpej {
    447  1.1  thorpej 	struct memory_cell cell = memory_cell_initializer;
    448  1.1  thorpej 	uint64_t res;
    449  1.1  thorpej 
    450  1.1  thorpej 	CHECK_MODULE();
    451  1.1  thorpej 
    452  1.1  thorpej 	write_test_cell(&cell, test_cell_val64);
    453  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_64(&cell.val64, &res), 0);
    454  1.1  thorpej 	ATF_REQUIRE(memory_cell_check_guard(&cell));
    455  1.1  thorpej 	ATF_REQUIRE(res == test_pattern64);
    456  1.1  thorpej }
    457  1.1  thorpej ATF_TC_CLEANUP(ufetch_64, tc)
    458  1.1  thorpej {
    459  1.1  thorpej 	unload_module();
    460  1.1  thorpej }
    461  1.1  thorpej #endif /* _LP64 */
    462  1.1  thorpej 
    463  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_8_null);
    464  1.1  thorpej ATF_TC_HEAD(ufetch_8_null, tc)
    465  1.1  thorpej {
    466  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    467  1.1  thorpej 	    "test for correct ufetch_8 NULL pointer behavior");
    468  1.1  thorpej }
    469  1.1  thorpej ATF_TC_BODY(ufetch_8_null, tc)
    470  1.1  thorpej {
    471  1.1  thorpej 	uint8_t res;
    472  1.1  thorpej 
    473  1.1  thorpej 	CHECK_MODULE();
    474  1.1  thorpej 
    475  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_8(NULL, &res), EFAULT);
    476  1.1  thorpej }
    477  1.1  thorpej ATF_TC_CLEANUP(ufetch_8_null, tc)
    478  1.1  thorpej {
    479  1.1  thorpej 	unload_module();
    480  1.1  thorpej }
    481  1.1  thorpej 
    482  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_16_null);
    483  1.1  thorpej ATF_TC_HEAD(ufetch_16_null, tc)
    484  1.1  thorpej {
    485  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    486  1.1  thorpej 	    "test for correct ufetch_16 NULL pointer behavior");
    487  1.1  thorpej }
    488  1.1  thorpej ATF_TC_BODY(ufetch_16_null, tc)
    489  1.1  thorpej {
    490  1.1  thorpej 	uint16_t res;
    491  1.1  thorpej 
    492  1.1  thorpej 	CHECK_MODULE();
    493  1.1  thorpej 
    494  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_16(NULL, &res), EFAULT);
    495  1.1  thorpej }
    496  1.1  thorpej ATF_TC_CLEANUP(ufetch_16_null, tc)
    497  1.1  thorpej {
    498  1.1  thorpej 	unload_module();
    499  1.1  thorpej }
    500  1.1  thorpej 
    501  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_32_null);
    502  1.1  thorpej ATF_TC_HEAD(ufetch_32_null, tc)
    503  1.1  thorpej {
    504  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    505  1.1  thorpej 	    "test for correct ufetch_32 NULL pointer behavior");
    506  1.1  thorpej }
    507  1.1  thorpej ATF_TC_BODY(ufetch_32_null, tc)
    508  1.1  thorpej {
    509  1.1  thorpej 	uint32_t res;
    510  1.1  thorpej 
    511  1.1  thorpej 	CHECK_MODULE();
    512  1.1  thorpej 
    513  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_32(NULL, &res), EFAULT);
    514  1.1  thorpej }
    515  1.1  thorpej ATF_TC_CLEANUP(ufetch_32_null, tc)
    516  1.1  thorpej {
    517  1.1  thorpej 	unload_module();
    518  1.1  thorpej }
    519  1.1  thorpej 
    520  1.1  thorpej #ifdef _LP64
    521  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_64_null);
    522  1.1  thorpej ATF_TC_HEAD(ufetch_64_null, tc)
    523  1.1  thorpej {
    524  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    525  1.1  thorpej 	    "test for correct ufetch_64 NULL pointer behavior");
    526  1.1  thorpej }
    527  1.1  thorpej ATF_TC_BODY(ufetch_64_null, tc)
    528  1.1  thorpej {
    529  1.1  thorpej 	uint64_t res;
    530  1.1  thorpej 
    531  1.1  thorpej 	CHECK_MODULE();
    532  1.1  thorpej 
    533  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_64(NULL, &res), EFAULT);
    534  1.1  thorpej }
    535  1.1  thorpej ATF_TC_CLEANUP(ufetch_64_null, tc)
    536  1.1  thorpej {
    537  1.1  thorpej 	unload_module();
    538  1.1  thorpej }
    539  1.1  thorpej #endif /* _LP64 */
    540  1.1  thorpej 
    541  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_8_max);
    542  1.1  thorpej ATF_TC_HEAD(ufetch_8_max, tc)
    543  1.1  thorpej {
    544  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    545  1.1  thorpej 	    "test for correct ufetch_8 VM_MAX_ADDRESS pointer behavior");
    546  1.1  thorpej }
    547  1.1  thorpej ATF_TC_BODY(ufetch_8_max, tc)
    548  1.1  thorpej {
    549  1.1  thorpej 	uint8_t res;
    550  1.1  thorpej 
    551  1.1  thorpej 	CHECK_MODULE();
    552  1.1  thorpej 
    553  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_8(vm_max_address(), &res), EFAULT);
    554  1.1  thorpej }
    555  1.1  thorpej ATF_TC_CLEANUP(ufetch_8_max, tc)
    556  1.1  thorpej {
    557  1.1  thorpej 	unload_module();
    558  1.1  thorpej }
    559  1.1  thorpej 
    560  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_16_max);
    561  1.1  thorpej ATF_TC_HEAD(ufetch_16_max, tc)
    562  1.1  thorpej {
    563  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    564  1.1  thorpej 	    "test for correct ufetch_16 VM_MAX_ADDRESS pointer behavior");
    565  1.1  thorpej }
    566  1.1  thorpej ATF_TC_BODY(ufetch_16_max, tc)
    567  1.1  thorpej {
    568  1.1  thorpej 	uint16_t res;
    569  1.1  thorpej 
    570  1.1  thorpej 	CHECK_MODULE();
    571  1.1  thorpej 
    572  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_16(vm_max_address(), &res), EFAULT);
    573  1.1  thorpej }
    574  1.1  thorpej ATF_TC_CLEANUP(ufetch_16_max, tc)
    575  1.1  thorpej {
    576  1.1  thorpej 	unload_module();
    577  1.1  thorpej }
    578  1.1  thorpej 
    579  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_32_max);
    580  1.1  thorpej ATF_TC_HEAD(ufetch_32_max, tc)
    581  1.1  thorpej {
    582  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    583  1.1  thorpej 	    "test for correct ufetch_32 VM_MAX_ADDRESS pointer behavior");
    584  1.1  thorpej }
    585  1.1  thorpej ATF_TC_BODY(ufetch_32_max, tc)
    586  1.1  thorpej {
    587  1.1  thorpej 	uint32_t res;
    588  1.1  thorpej 
    589  1.1  thorpej 	CHECK_MODULE();
    590  1.1  thorpej 
    591  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_32(vm_max_address(), &res), EFAULT);
    592  1.1  thorpej }
    593  1.1  thorpej ATF_TC_CLEANUP(ufetch_32_max, tc)
    594  1.1  thorpej {
    595  1.1  thorpej 	unload_module();
    596  1.1  thorpej }
    597  1.1  thorpej 
    598  1.1  thorpej #ifdef _LP64
    599  1.1  thorpej ATF_TC_WITH_CLEANUP(ufetch_64_max);
    600  1.1  thorpej ATF_TC_HEAD(ufetch_64_max, tc)
    601  1.1  thorpej {
    602  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    603  1.1  thorpej 	    "test for correct ufetch_64 VM_MAX_ADDRESS pointer behavior");
    604  1.1  thorpej }
    605  1.1  thorpej ATF_TC_BODY(ufetch_64_max, tc)
    606  1.1  thorpej {
    607  1.1  thorpej 	uint64_t res;
    608  1.1  thorpej 
    609  1.1  thorpej 	CHECK_MODULE();
    610  1.1  thorpej 
    611  1.1  thorpej 	ATF_REQUIRE_EQ(do_ufetch_64(vm_max_address(), &res), EFAULT);
    612  1.1  thorpej }
    613  1.1  thorpej ATF_TC_CLEANUP(ufetch_64_max, tc)
    614  1.1  thorpej {
    615  1.1  thorpej 	unload_module();
    616  1.1  thorpej }
    617  1.1  thorpej #endif /* _LP64 */
    618  1.1  thorpej 
    619  1.4  thorpej ATF_TC_WITH_CLEANUP(ufetch_16_nearmax_overflow);
    620  1.4  thorpej ATF_TC_HEAD(ufetch_16_nearmax_overflow, tc)
    621  1.4  thorpej {
    622  1.4  thorpej 	atf_tc_set_md_var(tc, "descr",
    623  1.4  thorpej 	    "test for correct ufetch_16 near-VM_MAX_ADDRESS pointer behavior");
    624  1.4  thorpej }
    625  1.4  thorpej ATF_TC_BODY(ufetch_16_nearmax_overflow, tc)
    626  1.4  thorpej {
    627  1.4  thorpej 	uint16_t res;
    628  1.4  thorpej 
    629  1.4  thorpej 	CHECK_MODULE();
    630  1.4  thorpej 
    631  1.4  thorpej 	/*
    632  1.4  thorpej 	 * For no-strict-alignment platforms: address checks must return
    633  1.4  thorpej 	 * EFAULT.
    634  1.4  thorpej 	 *
    635  1.4  thorpej 	 * For strict-alignment platforms: alignment checks must return
    636  1.4  thorpej 	 * EFAULT.
    637  1.4  thorpej 	 */
    638  1.4  thorpej 	ATF_REQUIRE_EQ(do_ufetch_16(vm_max_address_minus(1), &res), EFAULT);
    639  1.4  thorpej }
    640  1.4  thorpej ATF_TC_CLEANUP(ufetch_16_nearmax_overflow, tc)
    641  1.4  thorpej {
    642  1.4  thorpej 	unload_module();
    643  1.4  thorpej }
    644  1.4  thorpej 
    645  1.4  thorpej ATF_TC_WITH_CLEANUP(ufetch_32_nearmax_overflow);
    646  1.4  thorpej ATF_TC_HEAD(ufetch_32_nearmax_overflow, tc)
    647  1.4  thorpej {
    648  1.4  thorpej 	atf_tc_set_md_var(tc, "descr",
    649  1.4  thorpej 	    "test for correct ufetch_32 near-VM_MAX_ADDRESS pointer behavior");
    650  1.4  thorpej }
    651  1.4  thorpej ATF_TC_BODY(ufetch_32_nearmax_overflow, tc)
    652  1.4  thorpej {
    653  1.4  thorpej 	uint32_t res;
    654  1.4  thorpej 
    655  1.4  thorpej 	CHECK_MODULE();
    656  1.4  thorpej 
    657  1.4  thorpej 	/*
    658  1.4  thorpej 	 * For no-strict-alignment platforms: address checks must return
    659  1.4  thorpej 	 * EFAULT.
    660  1.4  thorpej 	 *
    661  1.4  thorpej 	 * For strict-alignment platforms: alignment checks must return
    662  1.4  thorpej 	 * EFAULT.
    663  1.4  thorpej 	 */
    664  1.4  thorpej 	ATF_REQUIRE_EQ(do_ufetch_32(vm_max_address_minus(3), &res), EFAULT);
    665  1.4  thorpej }
    666  1.4  thorpej ATF_TC_CLEANUP(ufetch_32_nearmax_overflow, tc)
    667  1.4  thorpej {
    668  1.4  thorpej 	unload_module();
    669  1.4  thorpej }
    670  1.4  thorpej 
    671  1.4  thorpej #ifdef _LP64
    672  1.4  thorpej ATF_TC_WITH_CLEANUP(ufetch_64_nearmax_overflow);
    673  1.4  thorpej ATF_TC_HEAD(ufetch_64_nearmax_overflow, tc)
    674  1.4  thorpej {
    675  1.4  thorpej 	atf_tc_set_md_var(tc, "descr",
    676  1.4  thorpej 	    "test for correct ufetch_64 near-VM_MAX_ADDRESS pointer behavior");
    677  1.4  thorpej }
    678  1.4  thorpej ATF_TC_BODY(ufetch_64_nearmax_overflow, tc)
    679  1.4  thorpej {
    680  1.4  thorpej 	uint64_t res;
    681  1.4  thorpej 
    682  1.4  thorpej 	CHECK_MODULE();
    683  1.4  thorpej 
    684  1.4  thorpej 	/*
    685  1.4  thorpej 	 * For no-strict-alignment platforms: address checks must return
    686  1.4  thorpej 	 * EFAULT.
    687  1.4  thorpej 	 *
    688  1.4  thorpej 	 * For strict-alignment platforms: alignment checks must return
    689  1.4  thorpej 	 * EFAULT.
    690  1.4  thorpej 	 */
    691  1.4  thorpej 	ATF_REQUIRE_EQ(do_ufetch_64(vm_max_address_minus(7), &res), EFAULT);
    692  1.4  thorpej }
    693  1.4  thorpej ATF_TC_CLEANUP(ufetch_64_nearmax_overflow, tc)
    694  1.4  thorpej {
    695  1.4  thorpej 	unload_module();
    696  1.4  thorpej }
    697  1.4  thorpej #endif /* _LP64 */
    698  1.4  thorpej 
    699  1.4  thorpej 
    700  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_8);
    701  1.1  thorpej ATF_TC_HEAD(ustore_8, tc)
    702  1.1  thorpej {
    703  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    704  1.1  thorpej 	    "test for correct ustore_8 behavior");
    705  1.1  thorpej }
    706  1.1  thorpej ATF_TC_BODY(ustore_8, tc)
    707  1.1  thorpej {
    708  1.1  thorpej 	struct memory_cell cell = memory_cell_initializer;
    709  1.1  thorpej 
    710  1.1  thorpej 	CHECK_MODULE();
    711  1.1  thorpej 
    712  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_8(&cell.val8[index8], test_pattern8), 0);
    713  1.1  thorpej 	ATF_REQUIRE(memory_cell_check_guard(&cell));
    714  1.1  thorpej 	ATF_REQUIRE(read_test_cell(&cell) == test_cell_val8);
    715  1.1  thorpej }
    716  1.1  thorpej ATF_TC_CLEANUP(ustore_8, tc)
    717  1.1  thorpej {
    718  1.1  thorpej 	unload_module();
    719  1.1  thorpej }
    720  1.1  thorpej 
    721  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_16);
    722  1.1  thorpej ATF_TC_HEAD(ustore_16, tc)
    723  1.1  thorpej {
    724  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    725  1.1  thorpej 	    "test for correct ustore_16 behavior");
    726  1.1  thorpej }
    727  1.1  thorpej ATF_TC_BODY(ustore_16, tc)
    728  1.1  thorpej {
    729  1.1  thorpej 	struct memory_cell cell = memory_cell_initializer;
    730  1.1  thorpej 
    731  1.1  thorpej 	CHECK_MODULE();
    732  1.1  thorpej 
    733  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_16(&cell.val16[index16], test_pattern16), 0);
    734  1.1  thorpej 	ATF_REQUIRE(memory_cell_check_guard(&cell));
    735  1.1  thorpej 	ATF_REQUIRE(read_test_cell(&cell) == test_cell_val16);
    736  1.1  thorpej }
    737  1.1  thorpej ATF_TC_CLEANUP(ustore_16, tc)
    738  1.1  thorpej {
    739  1.1  thorpej 	unload_module();
    740  1.1  thorpej }
    741  1.1  thorpej 
    742  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_32);
    743  1.1  thorpej ATF_TC_HEAD(ustore_32, tc)
    744  1.1  thorpej {
    745  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    746  1.1  thorpej 	    "test for correct ustore_32 behavior");
    747  1.1  thorpej }
    748  1.1  thorpej ATF_TC_BODY(ustore_32, tc)
    749  1.1  thorpej {
    750  1.1  thorpej 	struct memory_cell cell = memory_cell_initializer;
    751  1.1  thorpej 
    752  1.1  thorpej 	CHECK_MODULE();
    753  1.1  thorpej 
    754  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_32(&cell.val32[index32], test_pattern32), 0);
    755  1.1  thorpej 	ATF_REQUIRE(memory_cell_check_guard(&cell));
    756  1.1  thorpej 	ATF_REQUIRE(read_test_cell(&cell) == test_cell_val32);
    757  1.1  thorpej }
    758  1.1  thorpej ATF_TC_CLEANUP(ustore_32, tc)
    759  1.1  thorpej {
    760  1.1  thorpej 	unload_module();
    761  1.1  thorpej }
    762  1.1  thorpej 
    763  1.1  thorpej #ifdef _LP64
    764  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_64);
    765  1.1  thorpej ATF_TC_HEAD(ustore_64, tc)
    766  1.1  thorpej {
    767  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    768  1.1  thorpej 	    "test for correct ustore_64 behavior");
    769  1.1  thorpej }
    770  1.1  thorpej ATF_TC_BODY(ustore_64, tc)
    771  1.1  thorpej {
    772  1.1  thorpej 	struct memory_cell cell = memory_cell_initializer;
    773  1.1  thorpej 
    774  1.1  thorpej 	CHECK_MODULE();
    775  1.1  thorpej 
    776  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_64(&cell.val64, test_pattern64), 0);
    777  1.1  thorpej 	ATF_REQUIRE(memory_cell_check_guard(&cell));
    778  1.1  thorpej 	ATF_REQUIRE(read_test_cell(&cell) == test_cell_val64);
    779  1.1  thorpej }
    780  1.1  thorpej ATF_TC_CLEANUP(ustore_64, tc)
    781  1.1  thorpej {
    782  1.1  thorpej 	unload_module();
    783  1.1  thorpej }
    784  1.1  thorpej #endif /* _LP64 */
    785  1.1  thorpej 
    786  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_8_null);
    787  1.1  thorpej ATF_TC_HEAD(ustore_8_null, tc)
    788  1.1  thorpej {
    789  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    790  1.1  thorpej 	    "test for correct ustore_8 NULL pointer behavior");
    791  1.1  thorpej }
    792  1.1  thorpej ATF_TC_BODY(ustore_8_null, tc)
    793  1.1  thorpej {
    794  1.1  thorpej 	CHECK_MODULE();
    795  1.1  thorpej 
    796  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_8(NULL, 0), EFAULT);
    797  1.1  thorpej }
    798  1.1  thorpej ATF_TC_CLEANUP(ustore_8_null, tc)
    799  1.1  thorpej {
    800  1.1  thorpej 	unload_module();
    801  1.1  thorpej }
    802  1.1  thorpej 
    803  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_16_null);
    804  1.1  thorpej ATF_TC_HEAD(ustore_16_null, tc)
    805  1.1  thorpej {
    806  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    807  1.1  thorpej 	    "test for correct ustore_16 NULL pointer behavior");
    808  1.1  thorpej }
    809  1.1  thorpej ATF_TC_BODY(ustore_16_null, tc)
    810  1.1  thorpej {
    811  1.1  thorpej 	CHECK_MODULE();
    812  1.1  thorpej 
    813  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_16(NULL, 0), EFAULT);
    814  1.1  thorpej }
    815  1.1  thorpej ATF_TC_CLEANUP(ustore_16_null, tc)
    816  1.1  thorpej {
    817  1.1  thorpej 	unload_module();
    818  1.1  thorpej }
    819  1.1  thorpej 
    820  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_32_null);
    821  1.1  thorpej ATF_TC_HEAD(ustore_32_null, tc)
    822  1.1  thorpej {
    823  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    824  1.1  thorpej 	    "test for correct ustore_32 NULL pointer behavior");
    825  1.1  thorpej }
    826  1.1  thorpej ATF_TC_BODY(ustore_32_null, tc)
    827  1.1  thorpej {
    828  1.1  thorpej 	CHECK_MODULE();
    829  1.1  thorpej 
    830  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_32(NULL, 0), EFAULT);
    831  1.1  thorpej }
    832  1.1  thorpej ATF_TC_CLEANUP(ustore_32_null, tc)
    833  1.1  thorpej {
    834  1.1  thorpej 	unload_module();
    835  1.1  thorpej }
    836  1.1  thorpej 
    837  1.1  thorpej #ifdef _LP64
    838  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_64_null);
    839  1.1  thorpej ATF_TC_HEAD(ustore_64_null, tc)
    840  1.1  thorpej {
    841  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    842  1.1  thorpej 	    "test for correct ustore_64 NULL pointer behavior");
    843  1.1  thorpej }
    844  1.1  thorpej ATF_TC_BODY(ustore_64_null, tc)
    845  1.1  thorpej {
    846  1.1  thorpej 	CHECK_MODULE();
    847  1.1  thorpej 
    848  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_64(NULL, 0), EFAULT);
    849  1.1  thorpej }
    850  1.1  thorpej ATF_TC_CLEANUP(ustore_64_null, tc)
    851  1.1  thorpej {
    852  1.1  thorpej 	unload_module();
    853  1.1  thorpej }
    854  1.1  thorpej #endif /* _LP64 */
    855  1.1  thorpej 
    856  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_8_max);
    857  1.1  thorpej ATF_TC_HEAD(ustore_8_max, tc)
    858  1.1  thorpej {
    859  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    860  1.1  thorpej 	    "test for correct ustore_8 VM_MAX_ADDRESS pointer behavior");
    861  1.1  thorpej }
    862  1.1  thorpej ATF_TC_BODY(ustore_8_max, tc)
    863  1.1  thorpej {
    864  1.1  thorpej 	CHECK_MODULE();
    865  1.1  thorpej 
    866  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_8(vm_max_address(), 0), EFAULT);
    867  1.1  thorpej }
    868  1.1  thorpej ATF_TC_CLEANUP(ustore_8_max, tc)
    869  1.1  thorpej {
    870  1.1  thorpej 	unload_module();
    871  1.1  thorpej }
    872  1.1  thorpej 
    873  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_16_max);
    874  1.1  thorpej ATF_TC_HEAD(ustore_16_max, tc)
    875  1.1  thorpej {
    876  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    877  1.1  thorpej 	    "test for correct ustore_16 VM_MAX_ADDRESS pointer behavior");
    878  1.1  thorpej }
    879  1.1  thorpej ATF_TC_BODY(ustore_16_max, tc)
    880  1.1  thorpej {
    881  1.1  thorpej 	CHECK_MODULE();
    882  1.1  thorpej 
    883  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_16(vm_max_address(), 0), EFAULT);
    884  1.1  thorpej }
    885  1.1  thorpej ATF_TC_CLEANUP(ustore_16_max, tc)
    886  1.1  thorpej {
    887  1.1  thorpej 	unload_module();
    888  1.1  thorpej }
    889  1.1  thorpej 
    890  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_32_max);
    891  1.1  thorpej ATF_TC_HEAD(ustore_32_max, tc)
    892  1.1  thorpej {
    893  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    894  1.1  thorpej 	    "test for correct ustore_32 VM_MAX_ADDRESS pointer behavior");
    895  1.1  thorpej }
    896  1.1  thorpej ATF_TC_BODY(ustore_32_max, tc)
    897  1.1  thorpej {
    898  1.1  thorpej 	CHECK_MODULE();
    899  1.1  thorpej 
    900  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_32(vm_max_address(), 0), EFAULT);
    901  1.1  thorpej }
    902  1.1  thorpej ATF_TC_CLEANUP(ustore_32_max, tc)
    903  1.1  thorpej {
    904  1.1  thorpej 	unload_module();
    905  1.1  thorpej }
    906  1.1  thorpej 
    907  1.1  thorpej #ifdef _LP64
    908  1.1  thorpej ATF_TC_WITH_CLEANUP(ustore_64_max);
    909  1.1  thorpej ATF_TC_HEAD(ustore_64_max, tc)
    910  1.1  thorpej {
    911  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
    912  1.1  thorpej 	    "test for correct ustore_64 VM_MAX_ADDRESS pointer behavior");
    913  1.1  thorpej }
    914  1.1  thorpej ATF_TC_BODY(ustore_64_max, tc)
    915  1.1  thorpej {
    916  1.1  thorpej 	CHECK_MODULE();
    917  1.1  thorpej 
    918  1.1  thorpej 	ATF_REQUIRE_EQ(do_ustore_64(vm_max_address(), 0), EFAULT);
    919  1.1  thorpej }
    920  1.1  thorpej ATF_TC_CLEANUP(ustore_64_max, tc)
    921  1.1  thorpej {
    922  1.1  thorpej 	unload_module();
    923  1.1  thorpej }
    924  1.1  thorpej #endif /* _LP64 */
    925  1.1  thorpej 
    926  1.4  thorpej ATF_TC_WITH_CLEANUP(ustore_16_nearmax_overflow);
    927  1.4  thorpej ATF_TC_HEAD(ustore_16_nearmax_overflow, tc)
    928  1.4  thorpej {
    929  1.4  thorpej 	atf_tc_set_md_var(tc, "descr",
    930  1.4  thorpej 	    "test for correct ustore_16 VM_MAX_ADDRESS pointer behavior");
    931  1.4  thorpej }
    932  1.4  thorpej ATF_TC_BODY(ustore_16_nearmax_overflow, tc)
    933  1.4  thorpej {
    934  1.4  thorpej 	CHECK_MODULE();
    935  1.4  thorpej 
    936  1.4  thorpej 	/*
    937  1.4  thorpej 	 * For no-strict-alignment platforms: address checks must return
    938  1.4  thorpej 	 * EFAULT.
    939  1.4  thorpej 	 *
    940  1.4  thorpej 	 * For strict-alignment platforms: alignment checks must return
    941  1.4  thorpej 	 * EFAULT.
    942  1.4  thorpej 	 */
    943  1.4  thorpej 	ATF_REQUIRE_EQ(do_ustore_16(vm_max_address_minus(1), 0), EFAULT);
    944  1.4  thorpej }
    945  1.4  thorpej ATF_TC_CLEANUP(ustore_16_nearmax_overflow, tc)
    946  1.4  thorpej {
    947  1.4  thorpej 	unload_module();
    948  1.4  thorpej }
    949  1.4  thorpej 
    950  1.4  thorpej ATF_TC_WITH_CLEANUP(ustore_32_nearmax_overflow);
    951  1.4  thorpej ATF_TC_HEAD(ustore_32_nearmax_overflow, tc)
    952  1.4  thorpej {
    953  1.4  thorpej 	atf_tc_set_md_var(tc, "descr",
    954  1.4  thorpej 	    "test for correct ustore_32 VM_MAX_ADDRESS pointer behavior");
    955  1.4  thorpej }
    956  1.4  thorpej ATF_TC_BODY(ustore_32_nearmax_overflow, tc)
    957  1.4  thorpej {
    958  1.4  thorpej 	CHECK_MODULE();
    959  1.4  thorpej 
    960  1.4  thorpej 	/*
    961  1.4  thorpej 	 * For no-strict-alignment platforms: address checks must return
    962  1.4  thorpej 	 * EFAULT.
    963  1.4  thorpej 	 *
    964  1.4  thorpej 	 * For strict-alignment platforms: alignment checks must return
    965  1.4  thorpej 	 * EFAULT.
    966  1.4  thorpej 	 */
    967  1.4  thorpej 	ATF_REQUIRE_EQ(do_ustore_32(vm_max_address_minus(3), 0), EFAULT);
    968  1.4  thorpej }
    969  1.4  thorpej ATF_TC_CLEANUP(ustore_32_nearmax_overflow, tc)
    970  1.4  thorpej {
    971  1.4  thorpej 	unload_module();
    972  1.4  thorpej }
    973  1.4  thorpej 
    974  1.4  thorpej #ifdef _LP64
    975  1.4  thorpej ATF_TC_WITH_CLEANUP(ustore_64_nearmax_overflow);
    976  1.4  thorpej ATF_TC_HEAD(ustore_64_nearmax_overflow, tc)
    977  1.4  thorpej {
    978  1.4  thorpej 	atf_tc_set_md_var(tc, "descr",
    979  1.4  thorpej 	    "test for correct ustore_64 VM_MAX_ADDRESS pointer behavior");
    980  1.4  thorpej }
    981  1.4  thorpej ATF_TC_BODY(ustore_64_nearmax_overflow, tc)
    982  1.4  thorpej {
    983  1.4  thorpej 	CHECK_MODULE();
    984  1.4  thorpej 
    985  1.4  thorpej 	/*
    986  1.4  thorpej 	 * For no-strict-alignment platforms: address checks must return
    987  1.4  thorpej 	 * EFAULT.
    988  1.4  thorpej 	 *
    989  1.4  thorpej 	 * For strict-alignment platforms: alignment checks must return
    990  1.4  thorpej 	 * EFAULT.
    991  1.4  thorpej 	 */
    992  1.4  thorpej 	ATF_REQUIRE_EQ(do_ustore_64(vm_max_address_minus(7), 0), EFAULT);
    993  1.4  thorpej }
    994  1.4  thorpej ATF_TC_CLEANUP(ustore_64_nearmax_overflow, tc)
    995  1.4  thorpej {
    996  1.4  thorpej 	unload_module();
    997  1.4  thorpej }
    998  1.4  thorpej #endif /* _LP64 */
    999  1.4  thorpej 
   1000  1.4  thorpej 
   1001  1.1  thorpej ATF_TC_WITH_CLEANUP(ucas_32);
   1002  1.1  thorpej ATF_TC_HEAD(ucas_32, tc)
   1003  1.1  thorpej {
   1004  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
   1005  1.1  thorpej 	    "test for correct ucas_32 behavior");
   1006  1.1  thorpej }
   1007  1.1  thorpej ATF_TC_BODY(ucas_32, tc)
   1008  1.1  thorpej {
   1009  1.1  thorpej 	uint32_t cell = 0xdeadbeef;
   1010  1.1  thorpej 	uint32_t actual = 0;
   1011  1.1  thorpej 
   1012  1.1  thorpej 	CHECK_MODULE();
   1013  1.1  thorpej 
   1014  1.1  thorpej 	ATF_REQUIRE_EQ(do_ucas_32(&cell, 0xdeadbeef, 0xbeefdead, &actual), 0);
   1015  1.1  thorpej 	ATF_REQUIRE(actual == 0xdeadbeef);
   1016  1.1  thorpej 	ATF_REQUIRE(cell == 0xbeefdead);
   1017  1.1  thorpej }
   1018  1.1  thorpej ATF_TC_CLEANUP(ucas_32, tc)
   1019  1.1  thorpej {
   1020  1.1  thorpej 	unload_module();
   1021  1.1  thorpej }
   1022  1.1  thorpej 
   1023  1.1  thorpej #ifdef _LP64
   1024  1.1  thorpej ATF_TC_WITH_CLEANUP(ucas_64);
   1025  1.1  thorpej ATF_TC_HEAD(ucas_64, tc)
   1026  1.1  thorpej {
   1027  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
   1028  1.1  thorpej 	    "test for correct ucas_64 behavior");
   1029  1.1  thorpej }
   1030  1.1  thorpej ATF_TC_BODY(ucas_64, tc)
   1031  1.1  thorpej {
   1032  1.1  thorpej 	uint64_t cell = 0xdeadbeef;
   1033  1.1  thorpej 	uint64_t actual = 0;
   1034  1.1  thorpej 
   1035  1.1  thorpej 	CHECK_MODULE();
   1036  1.1  thorpej 
   1037  1.1  thorpej 	ATF_REQUIRE_EQ(do_ucas_64(&cell, 0xdeadbeef, 0xbeefdead, &actual), 0);
   1038  1.1  thorpej 	ATF_REQUIRE(actual == 0xdeadbeef);
   1039  1.1  thorpej 	ATF_REQUIRE(cell == 0xbeefdead);
   1040  1.1  thorpej }
   1041  1.1  thorpej ATF_TC_CLEANUP(ucas_64, tc)
   1042  1.1  thorpej {
   1043  1.1  thorpej 	unload_module();
   1044  1.1  thorpej }
   1045  1.1  thorpej #endif /* _LP64 */
   1046  1.1  thorpej 
   1047  1.1  thorpej ATF_TC_WITH_CLEANUP(ucas_32_miscompare);
   1048  1.1  thorpej ATF_TC_HEAD(ucas_32_miscompare, tc)
   1049  1.1  thorpej {
   1050  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
   1051  1.1  thorpej 	    "test for correct ucas_32 behavior with miscompare");
   1052  1.1  thorpej }
   1053  1.1  thorpej ATF_TC_BODY(ucas_32_miscompare, tc)
   1054  1.1  thorpej {
   1055  1.1  thorpej 	uint32_t cell = 0xa5a5a5a5;
   1056  1.1  thorpej 	uint32_t actual = 0;
   1057  1.1  thorpej 
   1058  1.1  thorpej 	CHECK_MODULE();
   1059  1.1  thorpej 
   1060  1.1  thorpej 	ATF_REQUIRE_EQ(do_ucas_32(&cell, 0xdeadbeef, 0xbeefdead, &actual), 0);
   1061  1.1  thorpej 	ATF_REQUIRE(actual == 0xa5a5a5a5);
   1062  1.1  thorpej 	ATF_REQUIRE(cell == 0xa5a5a5a5);
   1063  1.1  thorpej }
   1064  1.1  thorpej ATF_TC_CLEANUP(ucas_32_miscompare, tc)
   1065  1.1  thorpej {
   1066  1.1  thorpej 	unload_module();
   1067  1.1  thorpej }
   1068  1.1  thorpej 
   1069  1.1  thorpej #ifdef _LP64
   1070  1.1  thorpej ATF_TC_WITH_CLEANUP(ucas_64_miscompare);
   1071  1.1  thorpej ATF_TC_HEAD(ucas_64_miscompare, tc)
   1072  1.1  thorpej {
   1073  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
   1074  1.1  thorpej 	    "test for correct ucas_64 behavior with miscompare");
   1075  1.1  thorpej }
   1076  1.1  thorpej ATF_TC_BODY(ucas_64_miscompare, tc)
   1077  1.1  thorpej {
   1078  1.1  thorpej 	uint64_t cell = 0xa5a5a5a5;
   1079  1.1  thorpej 	uint64_t actual = 0;
   1080  1.1  thorpej 
   1081  1.1  thorpej 	CHECK_MODULE();
   1082  1.1  thorpej 
   1083  1.1  thorpej 	ATF_REQUIRE_EQ(do_ucas_64(&cell, 0xdeadbeef, 0xbeefdead, &actual), 0);
   1084  1.1  thorpej 	ATF_REQUIRE(actual == 0xa5a5a5a5);
   1085  1.1  thorpej 	ATF_REQUIRE(cell == 0xa5a5a5a5);
   1086  1.1  thorpej }
   1087  1.1  thorpej ATF_TC_CLEANUP(ucas_64_miscompare, tc)
   1088  1.1  thorpej {
   1089  1.1  thorpej 	unload_module();
   1090  1.1  thorpej }
   1091  1.1  thorpej #endif /* _LP64 */
   1092  1.1  thorpej 
   1093  1.1  thorpej ATF_TC_WITH_CLEANUP(ucas_32_null);
   1094  1.1  thorpej ATF_TC_HEAD(ucas_32_null, tc)
   1095  1.1  thorpej {
   1096  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
   1097  1.1  thorpej 	    "test for correct ucas_32 NULL pointer behavior");
   1098  1.1  thorpej }
   1099  1.1  thorpej ATF_TC_BODY(ucas_32_null, tc)
   1100  1.1  thorpej {
   1101  1.1  thorpej 	uint32_t actual = 0;
   1102  1.1  thorpej 
   1103  1.1  thorpej 	CHECK_MODULE();
   1104  1.1  thorpej 
   1105  1.1  thorpej 	ATF_REQUIRE_EQ(do_ucas_32(NULL, 0xdeadbeef, 0xbeefdead, &actual),
   1106  1.1  thorpej 	    EFAULT);
   1107  1.1  thorpej }
   1108  1.1  thorpej ATF_TC_CLEANUP(ucas_32_null, tc)
   1109  1.1  thorpej {
   1110  1.1  thorpej 	unload_module();
   1111  1.1  thorpej }
   1112  1.1  thorpej 
   1113  1.1  thorpej #ifdef _LP64
   1114  1.1  thorpej ATF_TC_WITH_CLEANUP(ucas_64_null);
   1115  1.1  thorpej ATF_TC_HEAD(ucas_64_null, tc)
   1116  1.1  thorpej {
   1117  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
   1118  1.1  thorpej 	    "test for correct ucas_64 NULL pointer behavior");
   1119  1.1  thorpej }
   1120  1.1  thorpej ATF_TC_BODY(ucas_64_null, tc)
   1121  1.1  thorpej {
   1122  1.1  thorpej 	uint64_t actual = 0;
   1123  1.1  thorpej 
   1124  1.1  thorpej 	CHECK_MODULE();
   1125  1.1  thorpej 
   1126  1.1  thorpej 	ATF_REQUIRE_EQ(do_ucas_64(NULL, 0xdeadbeef, 0xbeefdead, &actual),
   1127  1.1  thorpej 	    EFAULT);
   1128  1.1  thorpej }
   1129  1.1  thorpej ATF_TC_CLEANUP(ucas_64_null, tc)
   1130  1.1  thorpej {
   1131  1.1  thorpej 	unload_module();
   1132  1.1  thorpej }
   1133  1.1  thorpej #endif /* _LP64 */
   1134  1.1  thorpej 
   1135  1.1  thorpej ATF_TC_WITH_CLEANUP(ucas_32_max);
   1136  1.1  thorpej ATF_TC_HEAD(ucas_32_max, tc)
   1137  1.1  thorpej {
   1138  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
   1139  1.1  thorpej 	    "test for correct ucas_32 VM_MAX_ADDRESS pointer behavior");
   1140  1.1  thorpej }
   1141  1.1  thorpej ATF_TC_BODY(ucas_32_max, tc)
   1142  1.1  thorpej {
   1143  1.1  thorpej 	uint32_t actual = 0;
   1144  1.1  thorpej 
   1145  1.1  thorpej 	CHECK_MODULE();
   1146  1.1  thorpej 
   1147  1.1  thorpej 	ATF_REQUIRE_EQ(do_ucas_32(vm_max_address(), 0xdeadbeef, 0xbeefdead,
   1148  1.1  thorpej 	    &actual), EFAULT);
   1149  1.1  thorpej }
   1150  1.1  thorpej ATF_TC_CLEANUP(ucas_32_max, tc)
   1151  1.1  thorpej {
   1152  1.1  thorpej 	unload_module();
   1153  1.1  thorpej }
   1154  1.1  thorpej 
   1155  1.1  thorpej #ifdef _LP64
   1156  1.1  thorpej ATF_TC_WITH_CLEANUP(ucas_64_max);
   1157  1.1  thorpej ATF_TC_HEAD(ucas_64_max, tc)
   1158  1.1  thorpej {
   1159  1.1  thorpej 	atf_tc_set_md_var(tc, "descr",
   1160  1.1  thorpej 	    "test for correct ucas_64 VM_MAX_ADDRESS pointer behavior");
   1161  1.1  thorpej }
   1162  1.1  thorpej ATF_TC_BODY(ucas_64_max, tc)
   1163  1.1  thorpej {
   1164  1.1  thorpej 	uint64_t actual = 0;
   1165  1.1  thorpej 
   1166  1.1  thorpej 	CHECK_MODULE();
   1167  1.1  thorpej 
   1168  1.1  thorpej 	ATF_REQUIRE_EQ(do_ucas_64(vm_max_address(), 0xdeadbeef, 0xbeefdead,
   1169  1.1  thorpej 	    &actual), EFAULT);
   1170  1.1  thorpej }
   1171  1.1  thorpej ATF_TC_CLEANUP(ucas_64_max, tc)
   1172  1.1  thorpej {
   1173  1.1  thorpej 	unload_module();
   1174  1.1  thorpej }
   1175  1.1  thorpej #endif /* _LP64 */
   1176  1.1  thorpej 
   1177  1.4  thorpej ATF_TC_WITH_CLEANUP(ucas_32_nearmax_overflow);
   1178  1.4  thorpej ATF_TC_HEAD(ucas_32_nearmax_overflow, tc)
   1179  1.4  thorpej {
   1180  1.4  thorpej 	atf_tc_set_md_var(tc, "descr",
   1181  1.4  thorpej 	    "test for correct ucas_32 near-VM_MAX_ADDRESS pointer behavior");
   1182  1.4  thorpej }
   1183  1.4  thorpej ATF_TC_BODY(ucas_32_nearmax_overflow, tc)
   1184  1.4  thorpej {
   1185  1.4  thorpej 	uint32_t actual = 0;
   1186  1.4  thorpej 
   1187  1.4  thorpej 	CHECK_MODULE();
   1188  1.4  thorpej 
   1189  1.4  thorpej 	/*
   1190  1.4  thorpej 	 * For no-strict-alignment platforms: address checks must return
   1191  1.4  thorpej 	 * EFAULT.
   1192  1.4  thorpej 	 *
   1193  1.4  thorpej 	 * For strict-alignment platforms: alignment checks must return
   1194  1.4  thorpej 	 * EFAULT.
   1195  1.4  thorpej 	 */
   1196  1.4  thorpej 	ATF_REQUIRE_EQ(do_ucas_32(vm_max_address_minus(3), 0xdeadbeef,
   1197  1.4  thorpej 	    0xbeefdead, &actual), EFAULT);
   1198  1.4  thorpej }
   1199  1.4  thorpej ATF_TC_CLEANUP(ucas_32_nearmax_overflow, tc)
   1200  1.4  thorpej {
   1201  1.4  thorpej 	unload_module();
   1202  1.4  thorpej }
   1203  1.4  thorpej 
   1204  1.4  thorpej #ifdef _LP64
   1205  1.4  thorpej ATF_TC_WITH_CLEANUP(ucas_64_nearmax_overflow);
   1206  1.4  thorpej ATF_TC_HEAD(ucas_64_nearmax_overflow, tc)
   1207  1.4  thorpej {
   1208  1.4  thorpej 	atf_tc_set_md_var(tc, "descr",
   1209  1.4  thorpej 	    "test for correct ucas_64 near-VM_MAX_ADDRESS pointer behavior");
   1210  1.4  thorpej }
   1211  1.4  thorpej ATF_TC_BODY(ucas_64_nearmax_overflow, tc)
   1212  1.4  thorpej {
   1213  1.4  thorpej 	uint64_t actual = 0;
   1214  1.4  thorpej 
   1215  1.4  thorpej 	CHECK_MODULE();
   1216  1.4  thorpej 
   1217  1.4  thorpej 	/*
   1218  1.4  thorpej 	 * For no-strict-alignment platforms: address checks must return
   1219  1.4  thorpej 	 * EFAULT.
   1220  1.4  thorpej 	 *
   1221  1.4  thorpej 	 * For strict-alignment platforms: alignment checks must return
   1222  1.4  thorpej 	 * EFAULT.
   1223  1.4  thorpej 	 */
   1224  1.4  thorpej 	ATF_REQUIRE_EQ(do_ucas_64(vm_max_address_minus(7), 0xdeadbeef,
   1225  1.4  thorpej 	    0xbeefdead, &actual), EFAULT);
   1226  1.4  thorpej }
   1227  1.4  thorpej ATF_TC_CLEANUP(ucas_64_nearmax_overflow, tc)
   1228  1.4  thorpej {
   1229  1.4  thorpej 	unload_module();
   1230  1.4  thorpej }
   1231  1.4  thorpej #endif /* _LP64 */
   1232  1.4  thorpej 
   1233  1.1  thorpej ATF_TP_ADD_TCS(tp)
   1234  1.1  thorpej {
   1235  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_8);
   1236  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_16);
   1237  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_32);
   1238  1.1  thorpej #ifdef _LP64
   1239  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_64);
   1240  1.1  thorpej #endif
   1241  1.1  thorpej 
   1242  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_8_null);
   1243  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_16_null);
   1244  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_32_null);
   1245  1.1  thorpej #ifdef _LP64
   1246  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_64_null);
   1247  1.1  thorpej #endif
   1248  1.1  thorpej 
   1249  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_8_max);
   1250  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_16_max);
   1251  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_32_max);
   1252  1.1  thorpej #ifdef _LP64
   1253  1.1  thorpej 	ATF_TP_ADD_TC(tp, ufetch_64_max);
   1254  1.1  thorpej #endif
   1255  1.1  thorpej 
   1256  1.4  thorpej 	ATF_TP_ADD_TC(tp, ufetch_16_nearmax_overflow);
   1257  1.4  thorpej 	ATF_TP_ADD_TC(tp, ufetch_32_nearmax_overflow);
   1258  1.4  thorpej #ifdef _LP64
   1259  1.4  thorpej 	ATF_TP_ADD_TC(tp, ufetch_64_nearmax_overflow);
   1260  1.4  thorpej #endif
   1261  1.4  thorpej 
   1262  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_8);
   1263  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_16);
   1264  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_32);
   1265  1.1  thorpej #ifdef _LP64
   1266  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_64);
   1267  1.1  thorpej #endif
   1268  1.1  thorpej 
   1269  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_8_null);
   1270  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_16_null);
   1271  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_32_null);
   1272  1.1  thorpej #ifdef _LP64
   1273  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_64_null);
   1274  1.1  thorpej #endif
   1275  1.1  thorpej 
   1276  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_8_max);
   1277  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_16_max);
   1278  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_32_max);
   1279  1.1  thorpej #ifdef _LP64
   1280  1.1  thorpej 	ATF_TP_ADD_TC(tp, ustore_64_max);
   1281  1.1  thorpej #endif
   1282  1.1  thorpej 
   1283  1.4  thorpej 	ATF_TP_ADD_TC(tp, ustore_16_nearmax_overflow);
   1284  1.4  thorpej 	ATF_TP_ADD_TC(tp, ustore_32_nearmax_overflow);
   1285  1.4  thorpej #ifdef _LP64
   1286  1.4  thorpej 	ATF_TP_ADD_TC(tp, ustore_64_nearmax_overflow);
   1287  1.4  thorpej #endif
   1288  1.4  thorpej 
   1289  1.1  thorpej 	ATF_TP_ADD_TC(tp, ucas_32);
   1290  1.1  thorpej #ifdef _LP64
   1291  1.1  thorpej 	ATF_TP_ADD_TC(tp, ucas_64);
   1292  1.1  thorpej #endif
   1293  1.1  thorpej 
   1294  1.1  thorpej 	ATF_TP_ADD_TC(tp, ucas_32_miscompare);
   1295  1.1  thorpej #ifdef _LP64
   1296  1.1  thorpej 	ATF_TP_ADD_TC(tp, ucas_64_miscompare);
   1297  1.1  thorpej #endif
   1298  1.1  thorpej 
   1299  1.1  thorpej 	ATF_TP_ADD_TC(tp, ucas_32_null);
   1300  1.1  thorpej #ifdef _LP64
   1301  1.1  thorpej 	ATF_TP_ADD_TC(tp, ucas_64_null);
   1302  1.1  thorpej #endif
   1303  1.1  thorpej 
   1304  1.1  thorpej 	ATF_TP_ADD_TC(tp, ucas_32_max);
   1305  1.1  thorpej #ifdef _LP64
   1306  1.1  thorpej 	ATF_TP_ADD_TC(tp, ucas_64_max);
   1307  1.1  thorpej #endif
   1308  1.1  thorpej 
   1309  1.4  thorpej 	ATF_TP_ADD_TC(tp, ucas_32_nearmax_overflow);
   1310  1.4  thorpej #ifdef _LP64
   1311  1.4  thorpej 	ATF_TP_ADD_TC(tp, ucas_64_nearmax_overflow);
   1312  1.4  thorpej #endif
   1313  1.4  thorpej 
   1314  1.1  thorpej 	return atf_no_error();
   1315  1.1  thorpej }
   1316