1*c3061c70Sthorpej /* $NetBSD: t_ufetchstore.c,v 1.4 2019/04/07 15:50:12 thorpej Exp $ */
291bfaeb6Sthorpej
391bfaeb6Sthorpej /*
491bfaeb6Sthorpej * Copyright (c) 2019 The NetBSD Foundation, Inc.
591bfaeb6Sthorpej * All rights reserved.
691bfaeb6Sthorpej *
791bfaeb6Sthorpej * This code is derived from software contributed to The NetBSD Foundation
891bfaeb6Sthorpej * by Jason R. Thorpe.
991bfaeb6Sthorpej *
1091bfaeb6Sthorpej * Redistribution and use in source and binary forms, with or without
1191bfaeb6Sthorpej * modification, are permitted provided that the following conditions
1291bfaeb6Sthorpej * are met:
1391bfaeb6Sthorpej * 1. Redistributions of source code must retain the above copyright
1491bfaeb6Sthorpej * notice, this list of conditions and the following disclaimer.
1591bfaeb6Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
1691bfaeb6Sthorpej * notice, this list of conditions and the following disclaimer in the
1791bfaeb6Sthorpej * documentation and/or other materials provided with the distribution.
1891bfaeb6Sthorpej *
1991bfaeb6Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2091bfaeb6Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2191bfaeb6Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2291bfaeb6Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2391bfaeb6Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2491bfaeb6Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2591bfaeb6Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2691bfaeb6Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2791bfaeb6Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2891bfaeb6Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2991bfaeb6Sthorpej * POSSIBILITY OF SUCH DAMAGE.
3091bfaeb6Sthorpej */
3191bfaeb6Sthorpej
3291bfaeb6Sthorpej #include <sys/cdefs.h>
3391bfaeb6Sthorpej __COPYRIGHT("@(#) Copyright (c) 2019\
3491bfaeb6Sthorpej The NetBSD Foundation, inc. All rights reserved.");
35*c3061c70Sthorpej __RCSID("$NetBSD: t_ufetchstore.c,v 1.4 2019/04/07 15:50:12 thorpej Exp $");
3691bfaeb6Sthorpej
3791bfaeb6Sthorpej #include <sys/types.h>
3891bfaeb6Sthorpej #include <sys/endian.h>
3991bfaeb6Sthorpej #include <sys/module.h>
4091bfaeb6Sthorpej #include <sys/sysctl.h>
4191bfaeb6Sthorpej
4291bfaeb6Sthorpej #include <err.h>
4391bfaeb6Sthorpej #include <errno.h>
4491bfaeb6Sthorpej #include <limits.h>
4591bfaeb6Sthorpej
4691bfaeb6Sthorpej #include <atf-c.h>
4791bfaeb6Sthorpej
4891bfaeb6Sthorpej #include "common.h"
4991bfaeb6Sthorpej
5091bfaeb6Sthorpej #define mib_name "kern.ufetchstore_test.test"
5191bfaeb6Sthorpej
5291bfaeb6Sthorpej static bool module_loaded;
5391bfaeb6Sthorpej
5491bfaeb6Sthorpej #define MODULE_PATH \
5591bfaeb6Sthorpej "/usr/tests/modules/ufetchstore_tester/ufetchstore_tester.kmod"
5691bfaeb6Sthorpej #define MODULE_NAME "ufetchstore_tester"
5791bfaeb6Sthorpej
5891bfaeb6Sthorpej #define CHECK_MODULE() \
5991bfaeb6Sthorpej do { \
6091bfaeb6Sthorpej load_module(); \
6191bfaeb6Sthorpej if (! module_loaded) { \
6291bfaeb6Sthorpej atf_tc_skip("loading '%s' module failed.", MODULE_NAME);\
6391bfaeb6Sthorpej } \
6491bfaeb6Sthorpej } while (/*CONSTCOND*/0)
6591bfaeb6Sthorpej
6691bfaeb6Sthorpej static void
load_module(void)6791bfaeb6Sthorpej load_module(void)
6891bfaeb6Sthorpej {
6991bfaeb6Sthorpej #ifndef SKIP_MODULE
7091bfaeb6Sthorpej if (module_loaded)
7191bfaeb6Sthorpej return;
7291bfaeb6Sthorpej
7391bfaeb6Sthorpej modctl_load_t params = {
7491bfaeb6Sthorpej .ml_filename = MODULE_PATH,
7591bfaeb6Sthorpej .ml_flags = MODCTL_NO_PROP,
7691bfaeb6Sthorpej };
7791bfaeb6Sthorpej
7891bfaeb6Sthorpej if (modctl(MODCTL_LOAD, ¶ms) != 0) {
7991bfaeb6Sthorpej warn("failed to load module '%s'", MODULE_PATH);
8091bfaeb6Sthorpej } else {
8191bfaeb6Sthorpej module_loaded = true;
8291bfaeb6Sthorpej }
8391bfaeb6Sthorpej #else
8491bfaeb6Sthorpej module_loaded = true;
8591bfaeb6Sthorpej #endif /* ! SKIP_MODULE */
8691bfaeb6Sthorpej }
8791bfaeb6Sthorpej
88398d80afSrin #define UADDR(x) ((uintptr_t)(x))
8991bfaeb6Sthorpej
9091bfaeb6Sthorpej static void
unload_module(void)9191bfaeb6Sthorpej unload_module(void)
9291bfaeb6Sthorpej {
9391bfaeb6Sthorpej #ifndef SKIP_MODULE
9491bfaeb6Sthorpej char module_name[] = MODULE_NAME;
9591bfaeb6Sthorpej
9691bfaeb6Sthorpej if (modctl(MODCTL_UNLOAD, module_name) != 0) {
9791bfaeb6Sthorpej warn("failed to unload module '%s'", MODULE_NAME);
9891bfaeb6Sthorpej } else {
9991bfaeb6Sthorpej module_loaded = false;
10091bfaeb6Sthorpej }
10191bfaeb6Sthorpej #endif /* ! SKIP_MODULE */
10291bfaeb6Sthorpej }
10391bfaeb6Sthorpej
104*c3061c70Sthorpej static unsigned long
vm_max_address_raw(void)105*c3061c70Sthorpej vm_max_address_raw(void)
10691bfaeb6Sthorpej {
10791bfaeb6Sthorpej static unsigned long max_addr = 0;
10891bfaeb6Sthorpej int rv;
10991bfaeb6Sthorpej
11091bfaeb6Sthorpej if (max_addr == 0) {
11191bfaeb6Sthorpej size_t max_addr_size = sizeof(max_addr);
11291bfaeb6Sthorpej rv = sysctlbyname("vm.maxaddress", &max_addr, &max_addr_size,
11391bfaeb6Sthorpej NULL, 0);
11491bfaeb6Sthorpej if (rv != 0)
11591bfaeb6Sthorpej err(1, "sysctlbyname('vm.maxaddress')");
11691bfaeb6Sthorpej }
117*c3061c70Sthorpej return max_addr;
118*c3061c70Sthorpej }
119*c3061c70Sthorpej
120*c3061c70Sthorpej static void *
vm_max_address(void)121*c3061c70Sthorpej vm_max_address(void)
122*c3061c70Sthorpej {
123*c3061c70Sthorpej return (void *)vm_max_address_raw();
124*c3061c70Sthorpej }
125*c3061c70Sthorpej
126*c3061c70Sthorpej static void *
vm_max_address_minus(unsigned int adj)127*c3061c70Sthorpej vm_max_address_minus(unsigned int adj)
128*c3061c70Sthorpej {
129*c3061c70Sthorpej return (void *)(vm_max_address_raw() - adj);
13091bfaeb6Sthorpej }
13191bfaeb6Sthorpej
13291bfaeb6Sthorpej static int
do_sysctl(struct ufetchstore_test_args * args)13391bfaeb6Sthorpej do_sysctl(struct ufetchstore_test_args *args)
13491bfaeb6Sthorpej {
13591bfaeb6Sthorpej uint64_t arg_addr64 = (uintptr_t)args;
13691bfaeb6Sthorpej int rv;
13791bfaeb6Sthorpej
13891bfaeb6Sthorpej args->fetchstore_error = EBADF; /* poison */
13991bfaeb6Sthorpej args->pointer_size = (int)sizeof(void *);
14091bfaeb6Sthorpej
14191bfaeb6Sthorpej /*
14291bfaeb6Sthorpej * Yes, the intent is to provide the pointer, not the structure,
14391bfaeb6Sthorpej * to the kernel side of the test harness.
14491bfaeb6Sthorpej */
14591bfaeb6Sthorpej rv = sysctlbyname(mib_name, NULL, NULL, &arg_addr64,
14691bfaeb6Sthorpej sizeof(arg_addr64));
14791bfaeb6Sthorpej if (rv != 0) {
14891bfaeb6Sthorpej rv = errno;
14991bfaeb6Sthorpej warn("sysctlbyname('%s') -> %d", mib_name, rv);
15091bfaeb6Sthorpej return rv;
15191bfaeb6Sthorpej }
15291bfaeb6Sthorpej return 0;
15391bfaeb6Sthorpej }
15491bfaeb6Sthorpej
15591bfaeb6Sthorpej static int
do_ufetch_8(const uint8_t * uaddr,uint8_t * res)15691bfaeb6Sthorpej do_ufetch_8(const uint8_t *uaddr, uint8_t *res)
15791bfaeb6Sthorpej {
15891bfaeb6Sthorpej struct ufetchstore_test_args args = {
159398d80afSrin .uaddr64 = UADDR(uaddr),
16091bfaeb6Sthorpej .test_op = OP_LOAD,
16191bfaeb6Sthorpej .size = 8,
16291bfaeb6Sthorpej };
16391bfaeb6Sthorpej
16491bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
16591bfaeb6Sthorpej *res = args.val8;
16691bfaeb6Sthorpej return args.fetchstore_error;
16791bfaeb6Sthorpej }
16891bfaeb6Sthorpej
16991bfaeb6Sthorpej static int
do_ufetch_16(const uint16_t * uaddr,uint16_t * res)17091bfaeb6Sthorpej do_ufetch_16(const uint16_t *uaddr, uint16_t *res)
17191bfaeb6Sthorpej {
17291bfaeb6Sthorpej struct ufetchstore_test_args args = {
173398d80afSrin .uaddr64 = UADDR(uaddr),
17491bfaeb6Sthorpej .test_op = OP_LOAD,
17591bfaeb6Sthorpej .size = 16,
17691bfaeb6Sthorpej };
17791bfaeb6Sthorpej
17891bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
17991bfaeb6Sthorpej *res = args.val16;
18091bfaeb6Sthorpej return args.fetchstore_error;
18191bfaeb6Sthorpej }
18291bfaeb6Sthorpej
18391bfaeb6Sthorpej static int
do_ufetch_32(const uint32_t * uaddr,uint32_t * res)18491bfaeb6Sthorpej do_ufetch_32(const uint32_t *uaddr, uint32_t *res)
18591bfaeb6Sthorpej {
18691bfaeb6Sthorpej struct ufetchstore_test_args args = {
187398d80afSrin .uaddr64 = UADDR(uaddr),
18891bfaeb6Sthorpej .test_op = OP_LOAD,
18991bfaeb6Sthorpej .size = 32,
19091bfaeb6Sthorpej };
19191bfaeb6Sthorpej
19291bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
19391bfaeb6Sthorpej *res = args.val32;
19491bfaeb6Sthorpej return args.fetchstore_error;
19591bfaeb6Sthorpej }
19691bfaeb6Sthorpej
19791bfaeb6Sthorpej #ifdef _LP64
19891bfaeb6Sthorpej static int
do_ufetch_64(const uint64_t * uaddr,uint64_t * res)19991bfaeb6Sthorpej do_ufetch_64(const uint64_t *uaddr, uint64_t *res)
20091bfaeb6Sthorpej {
20191bfaeb6Sthorpej struct ufetchstore_test_args args = {
202398d80afSrin .uaddr64 = UADDR(uaddr),
20391bfaeb6Sthorpej .test_op = OP_LOAD,
20491bfaeb6Sthorpej .size = 64,
20591bfaeb6Sthorpej };
20691bfaeb6Sthorpej
20791bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
20891bfaeb6Sthorpej *res = args.val64;
20991bfaeb6Sthorpej return args.fetchstore_error;
21091bfaeb6Sthorpej }
21191bfaeb6Sthorpej #endif /* _LP64 */
21291bfaeb6Sthorpej
21391bfaeb6Sthorpej static int
do_ustore_8(uint8_t * uaddr,uint8_t val)21491bfaeb6Sthorpej do_ustore_8(uint8_t *uaddr, uint8_t val)
21591bfaeb6Sthorpej {
21691bfaeb6Sthorpej struct ufetchstore_test_args args = {
217398d80afSrin .uaddr64 = UADDR(uaddr),
21891bfaeb6Sthorpej .test_op = OP_STORE,
21991bfaeb6Sthorpej .size = 8,
22091bfaeb6Sthorpej .val8 = val,
22191bfaeb6Sthorpej };
22291bfaeb6Sthorpej
22391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
22491bfaeb6Sthorpej return args.fetchstore_error;
22591bfaeb6Sthorpej }
22691bfaeb6Sthorpej
22791bfaeb6Sthorpej static int
do_ustore_16(uint16_t * uaddr,uint16_t val)22891bfaeb6Sthorpej do_ustore_16(uint16_t *uaddr, uint16_t val)
22991bfaeb6Sthorpej {
23091bfaeb6Sthorpej struct ufetchstore_test_args args = {
231398d80afSrin .uaddr64 = UADDR(uaddr),
23291bfaeb6Sthorpej .test_op = OP_STORE,
23391bfaeb6Sthorpej .size = 16,
23491bfaeb6Sthorpej .val16 = val,
23591bfaeb6Sthorpej };
23691bfaeb6Sthorpej
23791bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
23891bfaeb6Sthorpej return args.fetchstore_error;
23991bfaeb6Sthorpej }
24091bfaeb6Sthorpej
24191bfaeb6Sthorpej static int
do_ustore_32(uint32_t * uaddr,uint32_t val)24291bfaeb6Sthorpej do_ustore_32(uint32_t *uaddr, uint32_t val)
24391bfaeb6Sthorpej {
24491bfaeb6Sthorpej struct ufetchstore_test_args args = {
245398d80afSrin .uaddr64 = UADDR(uaddr),
24691bfaeb6Sthorpej .test_op = OP_STORE,
24791bfaeb6Sthorpej .size = 32,
24891bfaeb6Sthorpej .val32 = val,
24991bfaeb6Sthorpej };
25091bfaeb6Sthorpej
25191bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
25291bfaeb6Sthorpej return args.fetchstore_error;
25391bfaeb6Sthorpej }
25491bfaeb6Sthorpej
25591bfaeb6Sthorpej #ifdef _LP64
25691bfaeb6Sthorpej static int
do_ustore_64(uint64_t * uaddr,uint64_t val)25791bfaeb6Sthorpej do_ustore_64(uint64_t *uaddr, uint64_t val)
25891bfaeb6Sthorpej {
25991bfaeb6Sthorpej struct ufetchstore_test_args args = {
260398d80afSrin .uaddr64 = UADDR(uaddr),
26191bfaeb6Sthorpej .test_op = OP_STORE,
26291bfaeb6Sthorpej .size = 64,
26391bfaeb6Sthorpej .val64 = val,
26491bfaeb6Sthorpej };
26591bfaeb6Sthorpej
26691bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
26791bfaeb6Sthorpej return args.fetchstore_error;
26891bfaeb6Sthorpej }
26991bfaeb6Sthorpej #endif /* _LP64 */
27091bfaeb6Sthorpej
27191bfaeb6Sthorpej static int
do_ucas_32(uint32_t * uaddr,uint32_t expected,uint32_t new,uint32_t * actualp)27291bfaeb6Sthorpej do_ucas_32(uint32_t *uaddr, uint32_t expected, uint32_t new, uint32_t *actualp)
27391bfaeb6Sthorpej {
27491bfaeb6Sthorpej struct ufetchstore_test_args args = {
275398d80afSrin .uaddr64 = UADDR(uaddr),
27691bfaeb6Sthorpej .test_op = OP_CAS,
27791bfaeb6Sthorpej .size = 32,
27891bfaeb6Sthorpej .val32 = new,
27991bfaeb6Sthorpej .ea_val32 = expected,
28091bfaeb6Sthorpej };
28191bfaeb6Sthorpej
28291bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
28391bfaeb6Sthorpej *actualp = args.ea_val32;
28491bfaeb6Sthorpej return args.fetchstore_error;
28591bfaeb6Sthorpej }
28691bfaeb6Sthorpej
28791bfaeb6Sthorpej #ifdef _LP64
28891bfaeb6Sthorpej static int
do_ucas_64(uint64_t * uaddr,uint64_t expected,uint64_t new,uint64_t * actualp)28991bfaeb6Sthorpej do_ucas_64(uint64_t *uaddr, uint64_t expected, uint64_t new, uint64_t *actualp)
29091bfaeb6Sthorpej {
29191bfaeb6Sthorpej struct ufetchstore_test_args args = {
292398d80afSrin .uaddr64 = UADDR(uaddr),
29391bfaeb6Sthorpej .test_op = OP_CAS,
29491bfaeb6Sthorpej .size = 64,
29591bfaeb6Sthorpej .val64 = new,
29691bfaeb6Sthorpej .ea_val64 = expected,
29791bfaeb6Sthorpej };
29891bfaeb6Sthorpej
29991bfaeb6Sthorpej ATF_REQUIRE_EQ(do_sysctl(&args), 0);
30091bfaeb6Sthorpej *actualp = args.ea_val64;
30191bfaeb6Sthorpej return args.fetchstore_error;
30291bfaeb6Sthorpej }
30391bfaeb6Sthorpej #endif /* _LP64 */
30491bfaeb6Sthorpej
30591bfaeb6Sthorpej struct memory_cell {
30691bfaeb6Sthorpej unsigned long guard0;
30791bfaeb6Sthorpej union {
30891bfaeb6Sthorpej unsigned long test_cell;
30991bfaeb6Sthorpej #ifdef _LP64
31091bfaeb6Sthorpej uint64_t val64;
31191bfaeb6Sthorpej #endif
31291bfaeb6Sthorpej uint32_t val32[sizeof(long) / 4];
31391bfaeb6Sthorpej uint16_t val16[sizeof(long) / 2];
31491bfaeb6Sthorpej uint8_t val8 [sizeof(long) ];
31591bfaeb6Sthorpej };
31691bfaeb6Sthorpej unsigned long guard1;
31791bfaeb6Sthorpej };
31891bfaeb6Sthorpej
31991bfaeb6Sthorpej #define index8 1
32091bfaeb6Sthorpej #define index16 1
32191bfaeb6Sthorpej #define index32 0
32291bfaeb6Sthorpej
32391bfaeb6Sthorpej #define test_pattern8 0xa5
32491bfaeb6Sthorpej #define test_pattern16 0x5a6b
32591bfaeb6Sthorpej #define test_pattern32 0xb01cafe1
32691bfaeb6Sthorpej #ifdef _LP64
32791bfaeb6Sthorpej #define test_pattern64 0xcafedeadfeedbabe
32891bfaeb6Sthorpej #endif
32991bfaeb6Sthorpej
33091bfaeb6Sthorpej #if _BYTE_ORDER == _LITTLE_ENDIAN
33191bfaeb6Sthorpej #define test_cell_val8 ((unsigned long)test_pattern8 << (index8 * NBBY))
33291bfaeb6Sthorpej #define test_cell_val16 ((unsigned long)test_pattern16 << (index16 * NBBY*2))
33391bfaeb6Sthorpej #define test_cell_val32 ((unsigned long)test_pattern32 << (index32 * NBBY*4))
33491bfaeb6Sthorpej #ifdef _LP64
33591bfaeb6Sthorpej #define test_cell_val64 ((unsigned long)test_pattern64)
33691bfaeb6Sthorpej #endif
33791bfaeb6Sthorpej #endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
33891bfaeb6Sthorpej
33991bfaeb6Sthorpej #if _BYTE_ORDER == _BIG_ENDIAN
34091bfaeb6Sthorpej #ifdef _LP64
34191bfaeb6Sthorpej #define test_cell_val8 ((unsigned long)test_pattern8 << (56-(index8 * NBBY)))
34291bfaeb6Sthorpej #define test_cell_val16 ((unsigned long)test_pattern16 << (48-(index16 * NBBY*2)))
34391bfaeb6Sthorpej #define test_cell_val32 ((unsigned long)test_pattern32 << (32-(index32 * NBBY*4)))
34491bfaeb6Sthorpej #define test_cell_val64 ((unsigned long)test_pattern64)
34591bfaeb6Sthorpej #else /* ! _LP64 */
34691bfaeb6Sthorpej #define test_cell_val8 ((unsigned long)test_pattern8 << (24-(index8 * NBBY)))
34791bfaeb6Sthorpej #define test_cell_val16 ((unsigned long)test_pattern16 << (16-(index16 * NBBY*2)))
34891bfaeb6Sthorpej #define test_cell_val32 ((unsigned long)test_pattern32)
34991bfaeb6Sthorpej #endif /* _LP64 */
35091bfaeb6Sthorpej #endif /* #if _BYTE_ORDER == _BIG_ENDIAN */
35191bfaeb6Sthorpej
35291bfaeb6Sthorpej #define read_test_cell(cell) (cell)->test_cell
35391bfaeb6Sthorpej #define write_test_cell(cell, v) (cell)->test_cell = (v)
35491bfaeb6Sthorpej
35591bfaeb6Sthorpej #define memory_cell_initializer \
35691bfaeb6Sthorpej { \
35791bfaeb6Sthorpej .guard0 = ULONG_MAX, \
35891bfaeb6Sthorpej .test_cell = 0, \
35991bfaeb6Sthorpej .guard1 = ULONG_MAX, \
36091bfaeb6Sthorpej }
36191bfaeb6Sthorpej
36291bfaeb6Sthorpej static bool
memory_cell_check_guard(const struct memory_cell * const cell)36391bfaeb6Sthorpej memory_cell_check_guard(const struct memory_cell * const cell)
36491bfaeb6Sthorpej {
36591bfaeb6Sthorpej return cell->guard0 == ULONG_MAX &&
36691bfaeb6Sthorpej cell->guard1 == ULONG_MAX;
36791bfaeb6Sthorpej }
36891bfaeb6Sthorpej
36991bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_8);
ATF_TC_HEAD(ufetch_8,tc)37091bfaeb6Sthorpej ATF_TC_HEAD(ufetch_8, tc)
37191bfaeb6Sthorpej {
37291bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
37391bfaeb6Sthorpej "test for correct ufetch_8 behavior");
37491bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_8,tc)37591bfaeb6Sthorpej ATF_TC_BODY(ufetch_8, tc)
37691bfaeb6Sthorpej {
37791bfaeb6Sthorpej struct memory_cell cell = memory_cell_initializer;
37891bfaeb6Sthorpej uint8_t res;
37991bfaeb6Sthorpej
38091bfaeb6Sthorpej CHECK_MODULE();
38191bfaeb6Sthorpej
38291bfaeb6Sthorpej write_test_cell(&cell, test_cell_val8);
38391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_8(&cell.val8[index8], &res), 0);
38491bfaeb6Sthorpej ATF_REQUIRE(memory_cell_check_guard(&cell));
38591bfaeb6Sthorpej ATF_REQUIRE(res == test_pattern8);
38691bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_8,tc)38791bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_8, tc)
38891bfaeb6Sthorpej {
38991bfaeb6Sthorpej unload_module();
39091bfaeb6Sthorpej }
39191bfaeb6Sthorpej
39291bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_16);
ATF_TC_HEAD(ufetch_16,tc)39391bfaeb6Sthorpej ATF_TC_HEAD(ufetch_16, tc)
39491bfaeb6Sthorpej {
39591bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
39691bfaeb6Sthorpej "test for correct ufetch_16 behavior");
39791bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_16,tc)39891bfaeb6Sthorpej ATF_TC_BODY(ufetch_16, tc)
39991bfaeb6Sthorpej {
40091bfaeb6Sthorpej struct memory_cell cell = memory_cell_initializer;
40191bfaeb6Sthorpej uint16_t res;
40291bfaeb6Sthorpej
40391bfaeb6Sthorpej CHECK_MODULE();
40491bfaeb6Sthorpej
40591bfaeb6Sthorpej write_test_cell(&cell, test_cell_val16);
40691bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_16(&cell.val16[index16], &res), 0);
40791bfaeb6Sthorpej ATF_REQUIRE(memory_cell_check_guard(&cell));
40891bfaeb6Sthorpej ATF_REQUIRE(res == test_pattern16);
40991bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_16,tc)41091bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_16, tc)
41191bfaeb6Sthorpej {
41291bfaeb6Sthorpej unload_module();
41391bfaeb6Sthorpej }
41491bfaeb6Sthorpej
41591bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_32);
ATF_TC_HEAD(ufetch_32,tc)41691bfaeb6Sthorpej ATF_TC_HEAD(ufetch_32, tc)
41791bfaeb6Sthorpej {
41891bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
41991bfaeb6Sthorpej "test for correct ufetch_32 behavior");
42091bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_32,tc)42191bfaeb6Sthorpej ATF_TC_BODY(ufetch_32, tc)
42291bfaeb6Sthorpej {
42391bfaeb6Sthorpej struct memory_cell cell = memory_cell_initializer;
42491bfaeb6Sthorpej uint32_t res;
42591bfaeb6Sthorpej
42691bfaeb6Sthorpej CHECK_MODULE();
42791bfaeb6Sthorpej
42891bfaeb6Sthorpej write_test_cell(&cell, test_cell_val32);
42991bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_32(&cell.val32[index32], &res), 0);
43091bfaeb6Sthorpej ATF_REQUIRE(memory_cell_check_guard(&cell));
43191bfaeb6Sthorpej ATF_REQUIRE(res == test_pattern32);
43291bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_32,tc)43391bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_32, tc)
43491bfaeb6Sthorpej {
43591bfaeb6Sthorpej unload_module();
43691bfaeb6Sthorpej }
43791bfaeb6Sthorpej
43891bfaeb6Sthorpej #ifdef _LP64
43991bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_64);
ATF_TC_HEAD(ufetch_64,tc)44091bfaeb6Sthorpej ATF_TC_HEAD(ufetch_64, tc)
44191bfaeb6Sthorpej {
44291bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
44391bfaeb6Sthorpej "test for correct ufetch_64 behavior");
44491bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_64,tc)44591bfaeb6Sthorpej ATF_TC_BODY(ufetch_64, tc)
44691bfaeb6Sthorpej {
44791bfaeb6Sthorpej struct memory_cell cell = memory_cell_initializer;
44891bfaeb6Sthorpej uint64_t res;
44991bfaeb6Sthorpej
45091bfaeb6Sthorpej CHECK_MODULE();
45191bfaeb6Sthorpej
45291bfaeb6Sthorpej write_test_cell(&cell, test_cell_val64);
45391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_64(&cell.val64, &res), 0);
45491bfaeb6Sthorpej ATF_REQUIRE(memory_cell_check_guard(&cell));
45591bfaeb6Sthorpej ATF_REQUIRE(res == test_pattern64);
45691bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_64,tc)45791bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_64, tc)
45891bfaeb6Sthorpej {
45991bfaeb6Sthorpej unload_module();
46091bfaeb6Sthorpej }
46191bfaeb6Sthorpej #endif /* _LP64 */
46291bfaeb6Sthorpej
46391bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_8_null);
ATF_TC_HEAD(ufetch_8_null,tc)46491bfaeb6Sthorpej ATF_TC_HEAD(ufetch_8_null, tc)
46591bfaeb6Sthorpej {
46691bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
46791bfaeb6Sthorpej "test for correct ufetch_8 NULL pointer behavior");
46891bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_8_null,tc)46991bfaeb6Sthorpej ATF_TC_BODY(ufetch_8_null, tc)
47091bfaeb6Sthorpej {
47191bfaeb6Sthorpej uint8_t res;
47291bfaeb6Sthorpej
47391bfaeb6Sthorpej CHECK_MODULE();
47491bfaeb6Sthorpej
47591bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_8(NULL, &res), EFAULT);
47691bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_8_null,tc)47791bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_8_null, tc)
47891bfaeb6Sthorpej {
47991bfaeb6Sthorpej unload_module();
48091bfaeb6Sthorpej }
48191bfaeb6Sthorpej
48291bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_16_null);
ATF_TC_HEAD(ufetch_16_null,tc)48391bfaeb6Sthorpej ATF_TC_HEAD(ufetch_16_null, tc)
48491bfaeb6Sthorpej {
48591bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
48691bfaeb6Sthorpej "test for correct ufetch_16 NULL pointer behavior");
48791bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_16_null,tc)48891bfaeb6Sthorpej ATF_TC_BODY(ufetch_16_null, tc)
48991bfaeb6Sthorpej {
49091bfaeb6Sthorpej uint16_t res;
49191bfaeb6Sthorpej
49291bfaeb6Sthorpej CHECK_MODULE();
49391bfaeb6Sthorpej
49491bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_16(NULL, &res), EFAULT);
49591bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_16_null,tc)49691bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_16_null, tc)
49791bfaeb6Sthorpej {
49891bfaeb6Sthorpej unload_module();
49991bfaeb6Sthorpej }
50091bfaeb6Sthorpej
50191bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_32_null);
ATF_TC_HEAD(ufetch_32_null,tc)50291bfaeb6Sthorpej ATF_TC_HEAD(ufetch_32_null, tc)
50391bfaeb6Sthorpej {
50491bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
50591bfaeb6Sthorpej "test for correct ufetch_32 NULL pointer behavior");
50691bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_32_null,tc)50791bfaeb6Sthorpej ATF_TC_BODY(ufetch_32_null, tc)
50891bfaeb6Sthorpej {
50991bfaeb6Sthorpej uint32_t res;
51091bfaeb6Sthorpej
51191bfaeb6Sthorpej CHECK_MODULE();
51291bfaeb6Sthorpej
51391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_32(NULL, &res), EFAULT);
51491bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_32_null,tc)51591bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_32_null, tc)
51691bfaeb6Sthorpej {
51791bfaeb6Sthorpej unload_module();
51891bfaeb6Sthorpej }
51991bfaeb6Sthorpej
52091bfaeb6Sthorpej #ifdef _LP64
52191bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_64_null);
ATF_TC_HEAD(ufetch_64_null,tc)52291bfaeb6Sthorpej ATF_TC_HEAD(ufetch_64_null, tc)
52391bfaeb6Sthorpej {
52491bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
52591bfaeb6Sthorpej "test for correct ufetch_64 NULL pointer behavior");
52691bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_64_null,tc)52791bfaeb6Sthorpej ATF_TC_BODY(ufetch_64_null, tc)
52891bfaeb6Sthorpej {
52991bfaeb6Sthorpej uint64_t res;
53091bfaeb6Sthorpej
53191bfaeb6Sthorpej CHECK_MODULE();
53291bfaeb6Sthorpej
53391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_64(NULL, &res), EFAULT);
53491bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_64_null,tc)53591bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_64_null, tc)
53691bfaeb6Sthorpej {
53791bfaeb6Sthorpej unload_module();
53891bfaeb6Sthorpej }
53991bfaeb6Sthorpej #endif /* _LP64 */
54091bfaeb6Sthorpej
54191bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_8_max);
ATF_TC_HEAD(ufetch_8_max,tc)54291bfaeb6Sthorpej ATF_TC_HEAD(ufetch_8_max, tc)
54391bfaeb6Sthorpej {
54491bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
54591bfaeb6Sthorpej "test for correct ufetch_8 VM_MAX_ADDRESS pointer behavior");
54691bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_8_max,tc)54791bfaeb6Sthorpej ATF_TC_BODY(ufetch_8_max, tc)
54891bfaeb6Sthorpej {
54991bfaeb6Sthorpej uint8_t res;
55091bfaeb6Sthorpej
55191bfaeb6Sthorpej CHECK_MODULE();
55291bfaeb6Sthorpej
55391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_8(vm_max_address(), &res), EFAULT);
55491bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_8_max,tc)55591bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_8_max, tc)
55691bfaeb6Sthorpej {
55791bfaeb6Sthorpej unload_module();
55891bfaeb6Sthorpej }
55991bfaeb6Sthorpej
56091bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_16_max);
ATF_TC_HEAD(ufetch_16_max,tc)56191bfaeb6Sthorpej ATF_TC_HEAD(ufetch_16_max, tc)
56291bfaeb6Sthorpej {
56391bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
56491bfaeb6Sthorpej "test for correct ufetch_16 VM_MAX_ADDRESS pointer behavior");
56591bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_16_max,tc)56691bfaeb6Sthorpej ATF_TC_BODY(ufetch_16_max, tc)
56791bfaeb6Sthorpej {
56891bfaeb6Sthorpej uint16_t res;
56991bfaeb6Sthorpej
57091bfaeb6Sthorpej CHECK_MODULE();
57191bfaeb6Sthorpej
57291bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_16(vm_max_address(), &res), EFAULT);
57391bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_16_max,tc)57491bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_16_max, tc)
57591bfaeb6Sthorpej {
57691bfaeb6Sthorpej unload_module();
57791bfaeb6Sthorpej }
57891bfaeb6Sthorpej
57991bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_32_max);
ATF_TC_HEAD(ufetch_32_max,tc)58091bfaeb6Sthorpej ATF_TC_HEAD(ufetch_32_max, tc)
58191bfaeb6Sthorpej {
58291bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
58391bfaeb6Sthorpej "test for correct ufetch_32 VM_MAX_ADDRESS pointer behavior");
58491bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_32_max,tc)58591bfaeb6Sthorpej ATF_TC_BODY(ufetch_32_max, tc)
58691bfaeb6Sthorpej {
58791bfaeb6Sthorpej uint32_t res;
58891bfaeb6Sthorpej
58991bfaeb6Sthorpej CHECK_MODULE();
59091bfaeb6Sthorpej
59191bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_32(vm_max_address(), &res), EFAULT);
59291bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_32_max,tc)59391bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_32_max, tc)
59491bfaeb6Sthorpej {
59591bfaeb6Sthorpej unload_module();
59691bfaeb6Sthorpej }
59791bfaeb6Sthorpej
59891bfaeb6Sthorpej #ifdef _LP64
59991bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ufetch_64_max);
ATF_TC_HEAD(ufetch_64_max,tc)60091bfaeb6Sthorpej ATF_TC_HEAD(ufetch_64_max, tc)
60191bfaeb6Sthorpej {
60291bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
60391bfaeb6Sthorpej "test for correct ufetch_64 VM_MAX_ADDRESS pointer behavior");
60491bfaeb6Sthorpej }
ATF_TC_BODY(ufetch_64_max,tc)60591bfaeb6Sthorpej ATF_TC_BODY(ufetch_64_max, tc)
60691bfaeb6Sthorpej {
60791bfaeb6Sthorpej uint64_t res;
60891bfaeb6Sthorpej
60991bfaeb6Sthorpej CHECK_MODULE();
61091bfaeb6Sthorpej
61191bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ufetch_64(vm_max_address(), &res), EFAULT);
61291bfaeb6Sthorpej }
ATF_TC_CLEANUP(ufetch_64_max,tc)61391bfaeb6Sthorpej ATF_TC_CLEANUP(ufetch_64_max, tc)
61491bfaeb6Sthorpej {
61591bfaeb6Sthorpej unload_module();
61691bfaeb6Sthorpej }
61791bfaeb6Sthorpej #endif /* _LP64 */
61891bfaeb6Sthorpej
619*c3061c70Sthorpej ATF_TC_WITH_CLEANUP(ufetch_16_nearmax_overflow);
ATF_TC_HEAD(ufetch_16_nearmax_overflow,tc)620*c3061c70Sthorpej ATF_TC_HEAD(ufetch_16_nearmax_overflow, tc)
621*c3061c70Sthorpej {
622*c3061c70Sthorpej atf_tc_set_md_var(tc, "descr",
623*c3061c70Sthorpej "test for correct ufetch_16 near-VM_MAX_ADDRESS pointer behavior");
624*c3061c70Sthorpej }
ATF_TC_BODY(ufetch_16_nearmax_overflow,tc)625*c3061c70Sthorpej ATF_TC_BODY(ufetch_16_nearmax_overflow, tc)
626*c3061c70Sthorpej {
627*c3061c70Sthorpej uint16_t res;
628*c3061c70Sthorpej
629*c3061c70Sthorpej CHECK_MODULE();
630*c3061c70Sthorpej
631*c3061c70Sthorpej /*
632*c3061c70Sthorpej * For no-strict-alignment platforms: address checks must return
633*c3061c70Sthorpej * EFAULT.
634*c3061c70Sthorpej *
635*c3061c70Sthorpej * For strict-alignment platforms: alignment checks must return
636*c3061c70Sthorpej * EFAULT.
637*c3061c70Sthorpej */
638*c3061c70Sthorpej ATF_REQUIRE_EQ(do_ufetch_16(vm_max_address_minus(1), &res), EFAULT);
639*c3061c70Sthorpej }
ATF_TC_CLEANUP(ufetch_16_nearmax_overflow,tc)640*c3061c70Sthorpej ATF_TC_CLEANUP(ufetch_16_nearmax_overflow, tc)
641*c3061c70Sthorpej {
642*c3061c70Sthorpej unload_module();
643*c3061c70Sthorpej }
644*c3061c70Sthorpej
645*c3061c70Sthorpej ATF_TC_WITH_CLEANUP(ufetch_32_nearmax_overflow);
ATF_TC_HEAD(ufetch_32_nearmax_overflow,tc)646*c3061c70Sthorpej ATF_TC_HEAD(ufetch_32_nearmax_overflow, tc)
647*c3061c70Sthorpej {
648*c3061c70Sthorpej atf_tc_set_md_var(tc, "descr",
649*c3061c70Sthorpej "test for correct ufetch_32 near-VM_MAX_ADDRESS pointer behavior");
650*c3061c70Sthorpej }
ATF_TC_BODY(ufetch_32_nearmax_overflow,tc)651*c3061c70Sthorpej ATF_TC_BODY(ufetch_32_nearmax_overflow, tc)
652*c3061c70Sthorpej {
653*c3061c70Sthorpej uint32_t res;
654*c3061c70Sthorpej
655*c3061c70Sthorpej CHECK_MODULE();
656*c3061c70Sthorpej
657*c3061c70Sthorpej /*
658*c3061c70Sthorpej * For no-strict-alignment platforms: address checks must return
659*c3061c70Sthorpej * EFAULT.
660*c3061c70Sthorpej *
661*c3061c70Sthorpej * For strict-alignment platforms: alignment checks must return
662*c3061c70Sthorpej * EFAULT.
663*c3061c70Sthorpej */
664*c3061c70Sthorpej ATF_REQUIRE_EQ(do_ufetch_32(vm_max_address_minus(3), &res), EFAULT);
665*c3061c70Sthorpej }
ATF_TC_CLEANUP(ufetch_32_nearmax_overflow,tc)666*c3061c70Sthorpej ATF_TC_CLEANUP(ufetch_32_nearmax_overflow, tc)
667*c3061c70Sthorpej {
668*c3061c70Sthorpej unload_module();
669*c3061c70Sthorpej }
670*c3061c70Sthorpej
671*c3061c70Sthorpej #ifdef _LP64
672*c3061c70Sthorpej ATF_TC_WITH_CLEANUP(ufetch_64_nearmax_overflow);
ATF_TC_HEAD(ufetch_64_nearmax_overflow,tc)673*c3061c70Sthorpej ATF_TC_HEAD(ufetch_64_nearmax_overflow, tc)
674*c3061c70Sthorpej {
675*c3061c70Sthorpej atf_tc_set_md_var(tc, "descr",
676*c3061c70Sthorpej "test for correct ufetch_64 near-VM_MAX_ADDRESS pointer behavior");
677*c3061c70Sthorpej }
ATF_TC_BODY(ufetch_64_nearmax_overflow,tc)678*c3061c70Sthorpej ATF_TC_BODY(ufetch_64_nearmax_overflow, tc)
679*c3061c70Sthorpej {
680*c3061c70Sthorpej uint64_t res;
681*c3061c70Sthorpej
682*c3061c70Sthorpej CHECK_MODULE();
683*c3061c70Sthorpej
684*c3061c70Sthorpej /*
685*c3061c70Sthorpej * For no-strict-alignment platforms: address checks must return
686*c3061c70Sthorpej * EFAULT.
687*c3061c70Sthorpej *
688*c3061c70Sthorpej * For strict-alignment platforms: alignment checks must return
689*c3061c70Sthorpej * EFAULT.
690*c3061c70Sthorpej */
691*c3061c70Sthorpej ATF_REQUIRE_EQ(do_ufetch_64(vm_max_address_minus(7), &res), EFAULT);
692*c3061c70Sthorpej }
ATF_TC_CLEANUP(ufetch_64_nearmax_overflow,tc)693*c3061c70Sthorpej ATF_TC_CLEANUP(ufetch_64_nearmax_overflow, tc)
694*c3061c70Sthorpej {
695*c3061c70Sthorpej unload_module();
696*c3061c70Sthorpej }
697*c3061c70Sthorpej #endif /* _LP64 */
698*c3061c70Sthorpej
699*c3061c70Sthorpej
70091bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_8);
ATF_TC_HEAD(ustore_8,tc)70191bfaeb6Sthorpej ATF_TC_HEAD(ustore_8, tc)
70291bfaeb6Sthorpej {
70391bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
70491bfaeb6Sthorpej "test for correct ustore_8 behavior");
70591bfaeb6Sthorpej }
ATF_TC_BODY(ustore_8,tc)70691bfaeb6Sthorpej ATF_TC_BODY(ustore_8, tc)
70791bfaeb6Sthorpej {
70891bfaeb6Sthorpej struct memory_cell cell = memory_cell_initializer;
70991bfaeb6Sthorpej
71091bfaeb6Sthorpej CHECK_MODULE();
71191bfaeb6Sthorpej
71291bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_8(&cell.val8[index8], test_pattern8), 0);
71391bfaeb6Sthorpej ATF_REQUIRE(memory_cell_check_guard(&cell));
71491bfaeb6Sthorpej ATF_REQUIRE(read_test_cell(&cell) == test_cell_val8);
71591bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_8,tc)71691bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_8, tc)
71791bfaeb6Sthorpej {
71891bfaeb6Sthorpej unload_module();
71991bfaeb6Sthorpej }
72091bfaeb6Sthorpej
72191bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_16);
ATF_TC_HEAD(ustore_16,tc)72291bfaeb6Sthorpej ATF_TC_HEAD(ustore_16, tc)
72391bfaeb6Sthorpej {
72491bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
72591bfaeb6Sthorpej "test for correct ustore_16 behavior");
72691bfaeb6Sthorpej }
ATF_TC_BODY(ustore_16,tc)72791bfaeb6Sthorpej ATF_TC_BODY(ustore_16, tc)
72891bfaeb6Sthorpej {
72991bfaeb6Sthorpej struct memory_cell cell = memory_cell_initializer;
73091bfaeb6Sthorpej
73191bfaeb6Sthorpej CHECK_MODULE();
73291bfaeb6Sthorpej
73391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_16(&cell.val16[index16], test_pattern16), 0);
73491bfaeb6Sthorpej ATF_REQUIRE(memory_cell_check_guard(&cell));
73591bfaeb6Sthorpej ATF_REQUIRE(read_test_cell(&cell) == test_cell_val16);
73691bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_16,tc)73791bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_16, tc)
73891bfaeb6Sthorpej {
73991bfaeb6Sthorpej unload_module();
74091bfaeb6Sthorpej }
74191bfaeb6Sthorpej
74291bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_32);
ATF_TC_HEAD(ustore_32,tc)74391bfaeb6Sthorpej ATF_TC_HEAD(ustore_32, tc)
74491bfaeb6Sthorpej {
74591bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
74691bfaeb6Sthorpej "test for correct ustore_32 behavior");
74791bfaeb6Sthorpej }
ATF_TC_BODY(ustore_32,tc)74891bfaeb6Sthorpej ATF_TC_BODY(ustore_32, tc)
74991bfaeb6Sthorpej {
75091bfaeb6Sthorpej struct memory_cell cell = memory_cell_initializer;
75191bfaeb6Sthorpej
75291bfaeb6Sthorpej CHECK_MODULE();
75391bfaeb6Sthorpej
75491bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_32(&cell.val32[index32], test_pattern32), 0);
75591bfaeb6Sthorpej ATF_REQUIRE(memory_cell_check_guard(&cell));
75691bfaeb6Sthorpej ATF_REQUIRE(read_test_cell(&cell) == test_cell_val32);
75791bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_32,tc)75891bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_32, tc)
75991bfaeb6Sthorpej {
76091bfaeb6Sthorpej unload_module();
76191bfaeb6Sthorpej }
76291bfaeb6Sthorpej
76391bfaeb6Sthorpej #ifdef _LP64
76491bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_64);
ATF_TC_HEAD(ustore_64,tc)76591bfaeb6Sthorpej ATF_TC_HEAD(ustore_64, tc)
76691bfaeb6Sthorpej {
76791bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
76891bfaeb6Sthorpej "test for correct ustore_64 behavior");
76991bfaeb6Sthorpej }
ATF_TC_BODY(ustore_64,tc)77091bfaeb6Sthorpej ATF_TC_BODY(ustore_64, tc)
77191bfaeb6Sthorpej {
77291bfaeb6Sthorpej struct memory_cell cell = memory_cell_initializer;
77391bfaeb6Sthorpej
77491bfaeb6Sthorpej CHECK_MODULE();
77591bfaeb6Sthorpej
77691bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_64(&cell.val64, test_pattern64), 0);
77791bfaeb6Sthorpej ATF_REQUIRE(memory_cell_check_guard(&cell));
77891bfaeb6Sthorpej ATF_REQUIRE(read_test_cell(&cell) == test_cell_val64);
77991bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_64,tc)78091bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_64, tc)
78191bfaeb6Sthorpej {
78291bfaeb6Sthorpej unload_module();
78391bfaeb6Sthorpej }
78491bfaeb6Sthorpej #endif /* _LP64 */
78591bfaeb6Sthorpej
78691bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_8_null);
ATF_TC_HEAD(ustore_8_null,tc)78791bfaeb6Sthorpej ATF_TC_HEAD(ustore_8_null, tc)
78891bfaeb6Sthorpej {
78991bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
79091bfaeb6Sthorpej "test for correct ustore_8 NULL pointer behavior");
79191bfaeb6Sthorpej }
ATF_TC_BODY(ustore_8_null,tc)79291bfaeb6Sthorpej ATF_TC_BODY(ustore_8_null, tc)
79391bfaeb6Sthorpej {
79491bfaeb6Sthorpej CHECK_MODULE();
79591bfaeb6Sthorpej
79691bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_8(NULL, 0), EFAULT);
79791bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_8_null,tc)79891bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_8_null, tc)
79991bfaeb6Sthorpej {
80091bfaeb6Sthorpej unload_module();
80191bfaeb6Sthorpej }
80291bfaeb6Sthorpej
80391bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_16_null);
ATF_TC_HEAD(ustore_16_null,tc)80491bfaeb6Sthorpej ATF_TC_HEAD(ustore_16_null, tc)
80591bfaeb6Sthorpej {
80691bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
80791bfaeb6Sthorpej "test for correct ustore_16 NULL pointer behavior");
80891bfaeb6Sthorpej }
ATF_TC_BODY(ustore_16_null,tc)80991bfaeb6Sthorpej ATF_TC_BODY(ustore_16_null, tc)
81091bfaeb6Sthorpej {
81191bfaeb6Sthorpej CHECK_MODULE();
81291bfaeb6Sthorpej
81391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_16(NULL, 0), EFAULT);
81491bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_16_null,tc)81591bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_16_null, tc)
81691bfaeb6Sthorpej {
81791bfaeb6Sthorpej unload_module();
81891bfaeb6Sthorpej }
81991bfaeb6Sthorpej
82091bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_32_null);
ATF_TC_HEAD(ustore_32_null,tc)82191bfaeb6Sthorpej ATF_TC_HEAD(ustore_32_null, tc)
82291bfaeb6Sthorpej {
82391bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
82491bfaeb6Sthorpej "test for correct ustore_32 NULL pointer behavior");
82591bfaeb6Sthorpej }
ATF_TC_BODY(ustore_32_null,tc)82691bfaeb6Sthorpej ATF_TC_BODY(ustore_32_null, tc)
82791bfaeb6Sthorpej {
82891bfaeb6Sthorpej CHECK_MODULE();
82991bfaeb6Sthorpej
83091bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_32(NULL, 0), EFAULT);
83191bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_32_null,tc)83291bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_32_null, tc)
83391bfaeb6Sthorpej {
83491bfaeb6Sthorpej unload_module();
83591bfaeb6Sthorpej }
83691bfaeb6Sthorpej
83791bfaeb6Sthorpej #ifdef _LP64
83891bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_64_null);
ATF_TC_HEAD(ustore_64_null,tc)83991bfaeb6Sthorpej ATF_TC_HEAD(ustore_64_null, tc)
84091bfaeb6Sthorpej {
84191bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
84291bfaeb6Sthorpej "test for correct ustore_64 NULL pointer behavior");
84391bfaeb6Sthorpej }
ATF_TC_BODY(ustore_64_null,tc)84491bfaeb6Sthorpej ATF_TC_BODY(ustore_64_null, tc)
84591bfaeb6Sthorpej {
84691bfaeb6Sthorpej CHECK_MODULE();
84791bfaeb6Sthorpej
84891bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_64(NULL, 0), EFAULT);
84991bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_64_null,tc)85091bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_64_null, tc)
85191bfaeb6Sthorpej {
85291bfaeb6Sthorpej unload_module();
85391bfaeb6Sthorpej }
85491bfaeb6Sthorpej #endif /* _LP64 */
85591bfaeb6Sthorpej
85691bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_8_max);
ATF_TC_HEAD(ustore_8_max,tc)85791bfaeb6Sthorpej ATF_TC_HEAD(ustore_8_max, tc)
85891bfaeb6Sthorpej {
85991bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
86091bfaeb6Sthorpej "test for correct ustore_8 VM_MAX_ADDRESS pointer behavior");
86191bfaeb6Sthorpej }
ATF_TC_BODY(ustore_8_max,tc)86291bfaeb6Sthorpej ATF_TC_BODY(ustore_8_max, tc)
86391bfaeb6Sthorpej {
86491bfaeb6Sthorpej CHECK_MODULE();
86591bfaeb6Sthorpej
86691bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_8(vm_max_address(), 0), EFAULT);
86791bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_8_max,tc)86891bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_8_max, tc)
86991bfaeb6Sthorpej {
87091bfaeb6Sthorpej unload_module();
87191bfaeb6Sthorpej }
87291bfaeb6Sthorpej
87391bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_16_max);
ATF_TC_HEAD(ustore_16_max,tc)87491bfaeb6Sthorpej ATF_TC_HEAD(ustore_16_max, tc)
87591bfaeb6Sthorpej {
87691bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
87791bfaeb6Sthorpej "test for correct ustore_16 VM_MAX_ADDRESS pointer behavior");
87891bfaeb6Sthorpej }
ATF_TC_BODY(ustore_16_max,tc)87991bfaeb6Sthorpej ATF_TC_BODY(ustore_16_max, tc)
88091bfaeb6Sthorpej {
88191bfaeb6Sthorpej CHECK_MODULE();
88291bfaeb6Sthorpej
88391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_16(vm_max_address(), 0), EFAULT);
88491bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_16_max,tc)88591bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_16_max, tc)
88691bfaeb6Sthorpej {
88791bfaeb6Sthorpej unload_module();
88891bfaeb6Sthorpej }
88991bfaeb6Sthorpej
89091bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_32_max);
ATF_TC_HEAD(ustore_32_max,tc)89191bfaeb6Sthorpej ATF_TC_HEAD(ustore_32_max, tc)
89291bfaeb6Sthorpej {
89391bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
89491bfaeb6Sthorpej "test for correct ustore_32 VM_MAX_ADDRESS pointer behavior");
89591bfaeb6Sthorpej }
ATF_TC_BODY(ustore_32_max,tc)89691bfaeb6Sthorpej ATF_TC_BODY(ustore_32_max, tc)
89791bfaeb6Sthorpej {
89891bfaeb6Sthorpej CHECK_MODULE();
89991bfaeb6Sthorpej
90091bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_32(vm_max_address(), 0), EFAULT);
90191bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_32_max,tc)90291bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_32_max, tc)
90391bfaeb6Sthorpej {
90491bfaeb6Sthorpej unload_module();
90591bfaeb6Sthorpej }
90691bfaeb6Sthorpej
90791bfaeb6Sthorpej #ifdef _LP64
90891bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ustore_64_max);
ATF_TC_HEAD(ustore_64_max,tc)90991bfaeb6Sthorpej ATF_TC_HEAD(ustore_64_max, tc)
91091bfaeb6Sthorpej {
91191bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
91291bfaeb6Sthorpej "test for correct ustore_64 VM_MAX_ADDRESS pointer behavior");
91391bfaeb6Sthorpej }
ATF_TC_BODY(ustore_64_max,tc)91491bfaeb6Sthorpej ATF_TC_BODY(ustore_64_max, tc)
91591bfaeb6Sthorpej {
91691bfaeb6Sthorpej CHECK_MODULE();
91791bfaeb6Sthorpej
91891bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ustore_64(vm_max_address(), 0), EFAULT);
91991bfaeb6Sthorpej }
ATF_TC_CLEANUP(ustore_64_max,tc)92091bfaeb6Sthorpej ATF_TC_CLEANUP(ustore_64_max, tc)
92191bfaeb6Sthorpej {
92291bfaeb6Sthorpej unload_module();
92391bfaeb6Sthorpej }
92491bfaeb6Sthorpej #endif /* _LP64 */
92591bfaeb6Sthorpej
926*c3061c70Sthorpej ATF_TC_WITH_CLEANUP(ustore_16_nearmax_overflow);
ATF_TC_HEAD(ustore_16_nearmax_overflow,tc)927*c3061c70Sthorpej ATF_TC_HEAD(ustore_16_nearmax_overflow, tc)
928*c3061c70Sthorpej {
929*c3061c70Sthorpej atf_tc_set_md_var(tc, "descr",
930*c3061c70Sthorpej "test for correct ustore_16 VM_MAX_ADDRESS pointer behavior");
931*c3061c70Sthorpej }
ATF_TC_BODY(ustore_16_nearmax_overflow,tc)932*c3061c70Sthorpej ATF_TC_BODY(ustore_16_nearmax_overflow, tc)
933*c3061c70Sthorpej {
934*c3061c70Sthorpej CHECK_MODULE();
935*c3061c70Sthorpej
936*c3061c70Sthorpej /*
937*c3061c70Sthorpej * For no-strict-alignment platforms: address checks must return
938*c3061c70Sthorpej * EFAULT.
939*c3061c70Sthorpej *
940*c3061c70Sthorpej * For strict-alignment platforms: alignment checks must return
941*c3061c70Sthorpej * EFAULT.
942*c3061c70Sthorpej */
943*c3061c70Sthorpej ATF_REQUIRE_EQ(do_ustore_16(vm_max_address_minus(1), 0), EFAULT);
944*c3061c70Sthorpej }
ATF_TC_CLEANUP(ustore_16_nearmax_overflow,tc)945*c3061c70Sthorpej ATF_TC_CLEANUP(ustore_16_nearmax_overflow, tc)
946*c3061c70Sthorpej {
947*c3061c70Sthorpej unload_module();
948*c3061c70Sthorpej }
949*c3061c70Sthorpej
950*c3061c70Sthorpej ATF_TC_WITH_CLEANUP(ustore_32_nearmax_overflow);
ATF_TC_HEAD(ustore_32_nearmax_overflow,tc)951*c3061c70Sthorpej ATF_TC_HEAD(ustore_32_nearmax_overflow, tc)
952*c3061c70Sthorpej {
953*c3061c70Sthorpej atf_tc_set_md_var(tc, "descr",
954*c3061c70Sthorpej "test for correct ustore_32 VM_MAX_ADDRESS pointer behavior");
955*c3061c70Sthorpej }
ATF_TC_BODY(ustore_32_nearmax_overflow,tc)956*c3061c70Sthorpej ATF_TC_BODY(ustore_32_nearmax_overflow, tc)
957*c3061c70Sthorpej {
958*c3061c70Sthorpej CHECK_MODULE();
959*c3061c70Sthorpej
960*c3061c70Sthorpej /*
961*c3061c70Sthorpej * For no-strict-alignment platforms: address checks must return
962*c3061c70Sthorpej * EFAULT.
963*c3061c70Sthorpej *
964*c3061c70Sthorpej * For strict-alignment platforms: alignment checks must return
965*c3061c70Sthorpej * EFAULT.
966*c3061c70Sthorpej */
967*c3061c70Sthorpej ATF_REQUIRE_EQ(do_ustore_32(vm_max_address_minus(3), 0), EFAULT);
968*c3061c70Sthorpej }
ATF_TC_CLEANUP(ustore_32_nearmax_overflow,tc)969*c3061c70Sthorpej ATF_TC_CLEANUP(ustore_32_nearmax_overflow, tc)
970*c3061c70Sthorpej {
971*c3061c70Sthorpej unload_module();
972*c3061c70Sthorpej }
973*c3061c70Sthorpej
974*c3061c70Sthorpej #ifdef _LP64
975*c3061c70Sthorpej ATF_TC_WITH_CLEANUP(ustore_64_nearmax_overflow);
ATF_TC_HEAD(ustore_64_nearmax_overflow,tc)976*c3061c70Sthorpej ATF_TC_HEAD(ustore_64_nearmax_overflow, tc)
977*c3061c70Sthorpej {
978*c3061c70Sthorpej atf_tc_set_md_var(tc, "descr",
979*c3061c70Sthorpej "test for correct ustore_64 VM_MAX_ADDRESS pointer behavior");
980*c3061c70Sthorpej }
ATF_TC_BODY(ustore_64_nearmax_overflow,tc)981*c3061c70Sthorpej ATF_TC_BODY(ustore_64_nearmax_overflow, tc)
982*c3061c70Sthorpej {
983*c3061c70Sthorpej CHECK_MODULE();
984*c3061c70Sthorpej
985*c3061c70Sthorpej /*
986*c3061c70Sthorpej * For no-strict-alignment platforms: address checks must return
987*c3061c70Sthorpej * EFAULT.
988*c3061c70Sthorpej *
989*c3061c70Sthorpej * For strict-alignment platforms: alignment checks must return
990*c3061c70Sthorpej * EFAULT.
991*c3061c70Sthorpej */
992*c3061c70Sthorpej ATF_REQUIRE_EQ(do_ustore_64(vm_max_address_minus(7), 0), EFAULT);
993*c3061c70Sthorpej }
ATF_TC_CLEANUP(ustore_64_nearmax_overflow,tc)994*c3061c70Sthorpej ATF_TC_CLEANUP(ustore_64_nearmax_overflow, tc)
995*c3061c70Sthorpej {
996*c3061c70Sthorpej unload_module();
997*c3061c70Sthorpej }
998*c3061c70Sthorpej #endif /* _LP64 */
999*c3061c70Sthorpej
1000*c3061c70Sthorpej
100191bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ucas_32);
ATF_TC_HEAD(ucas_32,tc)100291bfaeb6Sthorpej ATF_TC_HEAD(ucas_32, tc)
100391bfaeb6Sthorpej {
100491bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
100591bfaeb6Sthorpej "test for correct ucas_32 behavior");
100691bfaeb6Sthorpej }
ATF_TC_BODY(ucas_32,tc)100791bfaeb6Sthorpej ATF_TC_BODY(ucas_32, tc)
100891bfaeb6Sthorpej {
100991bfaeb6Sthorpej uint32_t cell = 0xdeadbeef;
101091bfaeb6Sthorpej uint32_t actual = 0;
101191bfaeb6Sthorpej
101291bfaeb6Sthorpej CHECK_MODULE();
101391bfaeb6Sthorpej
101491bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ucas_32(&cell, 0xdeadbeef, 0xbeefdead, &actual), 0);
101591bfaeb6Sthorpej ATF_REQUIRE(actual == 0xdeadbeef);
101691bfaeb6Sthorpej ATF_REQUIRE(cell == 0xbeefdead);
101791bfaeb6Sthorpej }
ATF_TC_CLEANUP(ucas_32,tc)101891bfaeb6Sthorpej ATF_TC_CLEANUP(ucas_32, tc)
101991bfaeb6Sthorpej {
102091bfaeb6Sthorpej unload_module();
102191bfaeb6Sthorpej }
102291bfaeb6Sthorpej
102391bfaeb6Sthorpej #ifdef _LP64
102491bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ucas_64);
ATF_TC_HEAD(ucas_64,tc)102591bfaeb6Sthorpej ATF_TC_HEAD(ucas_64, tc)
102691bfaeb6Sthorpej {
102791bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
102891bfaeb6Sthorpej "test for correct ucas_64 behavior");
102991bfaeb6Sthorpej }
ATF_TC_BODY(ucas_64,tc)103091bfaeb6Sthorpej ATF_TC_BODY(ucas_64, tc)
103191bfaeb6Sthorpej {
103291bfaeb6Sthorpej uint64_t cell = 0xdeadbeef;
103391bfaeb6Sthorpej uint64_t actual = 0;
103491bfaeb6Sthorpej
103591bfaeb6Sthorpej CHECK_MODULE();
103691bfaeb6Sthorpej
103791bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ucas_64(&cell, 0xdeadbeef, 0xbeefdead, &actual), 0);
103891bfaeb6Sthorpej ATF_REQUIRE(actual == 0xdeadbeef);
103991bfaeb6Sthorpej ATF_REQUIRE(cell == 0xbeefdead);
104091bfaeb6Sthorpej }
ATF_TC_CLEANUP(ucas_64,tc)104191bfaeb6Sthorpej ATF_TC_CLEANUP(ucas_64, tc)
104291bfaeb6Sthorpej {
104391bfaeb6Sthorpej unload_module();
104491bfaeb6Sthorpej }
104591bfaeb6Sthorpej #endif /* _LP64 */
104691bfaeb6Sthorpej
104791bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ucas_32_miscompare);
ATF_TC_HEAD(ucas_32_miscompare,tc)104891bfaeb6Sthorpej ATF_TC_HEAD(ucas_32_miscompare, tc)
104991bfaeb6Sthorpej {
105091bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
105191bfaeb6Sthorpej "test for correct ucas_32 behavior with miscompare");
105291bfaeb6Sthorpej }
ATF_TC_BODY(ucas_32_miscompare,tc)105391bfaeb6Sthorpej ATF_TC_BODY(ucas_32_miscompare, tc)
105491bfaeb6Sthorpej {
105591bfaeb6Sthorpej uint32_t cell = 0xa5a5a5a5;
105691bfaeb6Sthorpej uint32_t actual = 0;
105791bfaeb6Sthorpej
105891bfaeb6Sthorpej CHECK_MODULE();
105991bfaeb6Sthorpej
106091bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ucas_32(&cell, 0xdeadbeef, 0xbeefdead, &actual), 0);
106191bfaeb6Sthorpej ATF_REQUIRE(actual == 0xa5a5a5a5);
106291bfaeb6Sthorpej ATF_REQUIRE(cell == 0xa5a5a5a5);
106391bfaeb6Sthorpej }
ATF_TC_CLEANUP(ucas_32_miscompare,tc)106491bfaeb6Sthorpej ATF_TC_CLEANUP(ucas_32_miscompare, tc)
106591bfaeb6Sthorpej {
106691bfaeb6Sthorpej unload_module();
106791bfaeb6Sthorpej }
106891bfaeb6Sthorpej
106991bfaeb6Sthorpej #ifdef _LP64
107091bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ucas_64_miscompare);
ATF_TC_HEAD(ucas_64_miscompare,tc)107191bfaeb6Sthorpej ATF_TC_HEAD(ucas_64_miscompare, tc)
107291bfaeb6Sthorpej {
107391bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
107491bfaeb6Sthorpej "test for correct ucas_64 behavior with miscompare");
107591bfaeb6Sthorpej }
ATF_TC_BODY(ucas_64_miscompare,tc)107691bfaeb6Sthorpej ATF_TC_BODY(ucas_64_miscompare, tc)
107791bfaeb6Sthorpej {
107891bfaeb6Sthorpej uint64_t cell = 0xa5a5a5a5;
107991bfaeb6Sthorpej uint64_t actual = 0;
108091bfaeb6Sthorpej
108191bfaeb6Sthorpej CHECK_MODULE();
108291bfaeb6Sthorpej
108391bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ucas_64(&cell, 0xdeadbeef, 0xbeefdead, &actual), 0);
108491bfaeb6Sthorpej ATF_REQUIRE(actual == 0xa5a5a5a5);
108591bfaeb6Sthorpej ATF_REQUIRE(cell == 0xa5a5a5a5);
108691bfaeb6Sthorpej }
ATF_TC_CLEANUP(ucas_64_miscompare,tc)108791bfaeb6Sthorpej ATF_TC_CLEANUP(ucas_64_miscompare, tc)
108891bfaeb6Sthorpej {
108991bfaeb6Sthorpej unload_module();
109091bfaeb6Sthorpej }
109191bfaeb6Sthorpej #endif /* _LP64 */
109291bfaeb6Sthorpej
109391bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ucas_32_null);
ATF_TC_HEAD(ucas_32_null,tc)109491bfaeb6Sthorpej ATF_TC_HEAD(ucas_32_null, tc)
109591bfaeb6Sthorpej {
109691bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
109791bfaeb6Sthorpej "test for correct ucas_32 NULL pointer behavior");
109891bfaeb6Sthorpej }
ATF_TC_BODY(ucas_32_null,tc)109991bfaeb6Sthorpej ATF_TC_BODY(ucas_32_null, tc)
110091bfaeb6Sthorpej {
110191bfaeb6Sthorpej uint32_t actual = 0;
110291bfaeb6Sthorpej
110391bfaeb6Sthorpej CHECK_MODULE();
110491bfaeb6Sthorpej
110591bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ucas_32(NULL, 0xdeadbeef, 0xbeefdead, &actual),
110691bfaeb6Sthorpej EFAULT);
110791bfaeb6Sthorpej }
ATF_TC_CLEANUP(ucas_32_null,tc)110891bfaeb6Sthorpej ATF_TC_CLEANUP(ucas_32_null, tc)
110991bfaeb6Sthorpej {
111091bfaeb6Sthorpej unload_module();
111191bfaeb6Sthorpej }
111291bfaeb6Sthorpej
111391bfaeb6Sthorpej #ifdef _LP64
111491bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ucas_64_null);
ATF_TC_HEAD(ucas_64_null,tc)111591bfaeb6Sthorpej ATF_TC_HEAD(ucas_64_null, tc)
111691bfaeb6Sthorpej {
111791bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
111891bfaeb6Sthorpej "test for correct ucas_64 NULL pointer behavior");
111991bfaeb6Sthorpej }
ATF_TC_BODY(ucas_64_null,tc)112091bfaeb6Sthorpej ATF_TC_BODY(ucas_64_null, tc)
112191bfaeb6Sthorpej {
112291bfaeb6Sthorpej uint64_t actual = 0;
112391bfaeb6Sthorpej
112491bfaeb6Sthorpej CHECK_MODULE();
112591bfaeb6Sthorpej
112691bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ucas_64(NULL, 0xdeadbeef, 0xbeefdead, &actual),
112791bfaeb6Sthorpej EFAULT);
112891bfaeb6Sthorpej }
ATF_TC_CLEANUP(ucas_64_null,tc)112991bfaeb6Sthorpej ATF_TC_CLEANUP(ucas_64_null, tc)
113091bfaeb6Sthorpej {
113191bfaeb6Sthorpej unload_module();
113291bfaeb6Sthorpej }
113391bfaeb6Sthorpej #endif /* _LP64 */
113491bfaeb6Sthorpej
113591bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ucas_32_max);
ATF_TC_HEAD(ucas_32_max,tc)113691bfaeb6Sthorpej ATF_TC_HEAD(ucas_32_max, tc)
113791bfaeb6Sthorpej {
113891bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
113991bfaeb6Sthorpej "test for correct ucas_32 VM_MAX_ADDRESS pointer behavior");
114091bfaeb6Sthorpej }
ATF_TC_BODY(ucas_32_max,tc)114191bfaeb6Sthorpej ATF_TC_BODY(ucas_32_max, tc)
114291bfaeb6Sthorpej {
114391bfaeb6Sthorpej uint32_t actual = 0;
114491bfaeb6Sthorpej
114591bfaeb6Sthorpej CHECK_MODULE();
114691bfaeb6Sthorpej
114791bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ucas_32(vm_max_address(), 0xdeadbeef, 0xbeefdead,
114891bfaeb6Sthorpej &actual), EFAULT);
114991bfaeb6Sthorpej }
ATF_TC_CLEANUP(ucas_32_max,tc)115091bfaeb6Sthorpej ATF_TC_CLEANUP(ucas_32_max, tc)
115191bfaeb6Sthorpej {
115291bfaeb6Sthorpej unload_module();
115391bfaeb6Sthorpej }
115491bfaeb6Sthorpej
115591bfaeb6Sthorpej #ifdef _LP64
115691bfaeb6Sthorpej ATF_TC_WITH_CLEANUP(ucas_64_max);
ATF_TC_HEAD(ucas_64_max,tc)115791bfaeb6Sthorpej ATF_TC_HEAD(ucas_64_max, tc)
115891bfaeb6Sthorpej {
115991bfaeb6Sthorpej atf_tc_set_md_var(tc, "descr",
116091bfaeb6Sthorpej "test for correct ucas_64 VM_MAX_ADDRESS pointer behavior");
116191bfaeb6Sthorpej }
ATF_TC_BODY(ucas_64_max,tc)116291bfaeb6Sthorpej ATF_TC_BODY(ucas_64_max, tc)
116391bfaeb6Sthorpej {
116491bfaeb6Sthorpej uint64_t actual = 0;
116591bfaeb6Sthorpej
116691bfaeb6Sthorpej CHECK_MODULE();
116791bfaeb6Sthorpej
116891bfaeb6Sthorpej ATF_REQUIRE_EQ(do_ucas_64(vm_max_address(), 0xdeadbeef, 0xbeefdead,
116991bfaeb6Sthorpej &actual), EFAULT);
117091bfaeb6Sthorpej }
ATF_TC_CLEANUP(ucas_64_max,tc)117191bfaeb6Sthorpej ATF_TC_CLEANUP(ucas_64_max, tc)
117291bfaeb6Sthorpej {
117391bfaeb6Sthorpej unload_module();
117491bfaeb6Sthorpej }
117591bfaeb6Sthorpej #endif /* _LP64 */
117691bfaeb6Sthorpej
1177*c3061c70Sthorpej ATF_TC_WITH_CLEANUP(ucas_32_nearmax_overflow);
ATF_TC_HEAD(ucas_32_nearmax_overflow,tc)1178*c3061c70Sthorpej ATF_TC_HEAD(ucas_32_nearmax_overflow, tc)
1179*c3061c70Sthorpej {
1180*c3061c70Sthorpej atf_tc_set_md_var(tc, "descr",
1181*c3061c70Sthorpej "test for correct ucas_32 near-VM_MAX_ADDRESS pointer behavior");
1182*c3061c70Sthorpej }
ATF_TC_BODY(ucas_32_nearmax_overflow,tc)1183*c3061c70Sthorpej ATF_TC_BODY(ucas_32_nearmax_overflow, tc)
1184*c3061c70Sthorpej {
1185*c3061c70Sthorpej uint32_t actual = 0;
1186*c3061c70Sthorpej
1187*c3061c70Sthorpej CHECK_MODULE();
1188*c3061c70Sthorpej
1189*c3061c70Sthorpej /*
1190*c3061c70Sthorpej * For no-strict-alignment platforms: address checks must return
1191*c3061c70Sthorpej * EFAULT.
1192*c3061c70Sthorpej *
1193*c3061c70Sthorpej * For strict-alignment platforms: alignment checks must return
1194*c3061c70Sthorpej * EFAULT.
1195*c3061c70Sthorpej */
1196*c3061c70Sthorpej ATF_REQUIRE_EQ(do_ucas_32(vm_max_address_minus(3), 0xdeadbeef,
1197*c3061c70Sthorpej 0xbeefdead, &actual), EFAULT);
1198*c3061c70Sthorpej }
ATF_TC_CLEANUP(ucas_32_nearmax_overflow,tc)1199*c3061c70Sthorpej ATF_TC_CLEANUP(ucas_32_nearmax_overflow, tc)
1200*c3061c70Sthorpej {
1201*c3061c70Sthorpej unload_module();
1202*c3061c70Sthorpej }
1203*c3061c70Sthorpej
1204*c3061c70Sthorpej #ifdef _LP64
1205*c3061c70Sthorpej ATF_TC_WITH_CLEANUP(ucas_64_nearmax_overflow);
ATF_TC_HEAD(ucas_64_nearmax_overflow,tc)1206*c3061c70Sthorpej ATF_TC_HEAD(ucas_64_nearmax_overflow, tc)
1207*c3061c70Sthorpej {
1208*c3061c70Sthorpej atf_tc_set_md_var(tc, "descr",
1209*c3061c70Sthorpej "test for correct ucas_64 near-VM_MAX_ADDRESS pointer behavior");
1210*c3061c70Sthorpej }
ATF_TC_BODY(ucas_64_nearmax_overflow,tc)1211*c3061c70Sthorpej ATF_TC_BODY(ucas_64_nearmax_overflow, tc)
1212*c3061c70Sthorpej {
1213*c3061c70Sthorpej uint64_t actual = 0;
1214*c3061c70Sthorpej
1215*c3061c70Sthorpej CHECK_MODULE();
1216*c3061c70Sthorpej
1217*c3061c70Sthorpej /*
1218*c3061c70Sthorpej * For no-strict-alignment platforms: address checks must return
1219*c3061c70Sthorpej * EFAULT.
1220*c3061c70Sthorpej *
1221*c3061c70Sthorpej * For strict-alignment platforms: alignment checks must return
1222*c3061c70Sthorpej * EFAULT.
1223*c3061c70Sthorpej */
1224*c3061c70Sthorpej ATF_REQUIRE_EQ(do_ucas_64(vm_max_address_minus(7), 0xdeadbeef,
1225*c3061c70Sthorpej 0xbeefdead, &actual), EFAULT);
1226*c3061c70Sthorpej }
ATF_TC_CLEANUP(ucas_64_nearmax_overflow,tc)1227*c3061c70Sthorpej ATF_TC_CLEANUP(ucas_64_nearmax_overflow, tc)
1228*c3061c70Sthorpej {
1229*c3061c70Sthorpej unload_module();
1230*c3061c70Sthorpej }
1231*c3061c70Sthorpej #endif /* _LP64 */
1232*c3061c70Sthorpej
ATF_TP_ADD_TCS(tp)123391bfaeb6Sthorpej ATF_TP_ADD_TCS(tp)
123491bfaeb6Sthorpej {
123591bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_8);
123691bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_16);
123791bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_32);
123891bfaeb6Sthorpej #ifdef _LP64
123991bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_64);
124091bfaeb6Sthorpej #endif
124191bfaeb6Sthorpej
124291bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_8_null);
124391bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_16_null);
124491bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_32_null);
124591bfaeb6Sthorpej #ifdef _LP64
124691bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_64_null);
124791bfaeb6Sthorpej #endif
124891bfaeb6Sthorpej
124991bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_8_max);
125091bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_16_max);
125191bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_32_max);
125291bfaeb6Sthorpej #ifdef _LP64
125391bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ufetch_64_max);
125491bfaeb6Sthorpej #endif
125591bfaeb6Sthorpej
1256*c3061c70Sthorpej ATF_TP_ADD_TC(tp, ufetch_16_nearmax_overflow);
1257*c3061c70Sthorpej ATF_TP_ADD_TC(tp, ufetch_32_nearmax_overflow);
1258*c3061c70Sthorpej #ifdef _LP64
1259*c3061c70Sthorpej ATF_TP_ADD_TC(tp, ufetch_64_nearmax_overflow);
1260*c3061c70Sthorpej #endif
1261*c3061c70Sthorpej
126291bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_8);
126391bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_16);
126491bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_32);
126591bfaeb6Sthorpej #ifdef _LP64
126691bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_64);
126791bfaeb6Sthorpej #endif
126891bfaeb6Sthorpej
126991bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_8_null);
127091bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_16_null);
127191bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_32_null);
127291bfaeb6Sthorpej #ifdef _LP64
127391bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_64_null);
127491bfaeb6Sthorpej #endif
127591bfaeb6Sthorpej
127691bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_8_max);
127791bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_16_max);
127891bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_32_max);
127991bfaeb6Sthorpej #ifdef _LP64
128091bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ustore_64_max);
128191bfaeb6Sthorpej #endif
128291bfaeb6Sthorpej
1283*c3061c70Sthorpej ATF_TP_ADD_TC(tp, ustore_16_nearmax_overflow);
1284*c3061c70Sthorpej ATF_TP_ADD_TC(tp, ustore_32_nearmax_overflow);
1285*c3061c70Sthorpej #ifdef _LP64
1286*c3061c70Sthorpej ATF_TP_ADD_TC(tp, ustore_64_nearmax_overflow);
1287*c3061c70Sthorpej #endif
1288*c3061c70Sthorpej
128991bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ucas_32);
129091bfaeb6Sthorpej #ifdef _LP64
129191bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ucas_64);
129291bfaeb6Sthorpej #endif
129391bfaeb6Sthorpej
129491bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ucas_32_miscompare);
129591bfaeb6Sthorpej #ifdef _LP64
129691bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ucas_64_miscompare);
129791bfaeb6Sthorpej #endif
129891bfaeb6Sthorpej
129991bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ucas_32_null);
130091bfaeb6Sthorpej #ifdef _LP64
130191bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ucas_64_null);
130291bfaeb6Sthorpej #endif
130391bfaeb6Sthorpej
130491bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ucas_32_max);
130591bfaeb6Sthorpej #ifdef _LP64
130691bfaeb6Sthorpej ATF_TP_ADD_TC(tp, ucas_64_max);
130791bfaeb6Sthorpej #endif
130891bfaeb6Sthorpej
1309*c3061c70Sthorpej ATF_TP_ADD_TC(tp, ucas_32_nearmax_overflow);
1310*c3061c70Sthorpej #ifdef _LP64
1311*c3061c70Sthorpej ATF_TP_ADD_TC(tp, ucas_64_nearmax_overflow);
1312*c3061c70Sthorpej #endif
1313*c3061c70Sthorpej
131491bfaeb6Sthorpej return atf_no_error();
131591bfaeb6Sthorpej }
1316