Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/os-tests/tests/xsave/xregs_set.c
+++ new/usr/src/test/os-tests/tests/xsave/xregs_set.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright 2023 Oxide Computer Company
14 14 */
15 15
16 16 /*
17 17 * This is a program that is meant to be used as a target for libproc and mdb.
18 18 * It uses a CLI-based seed and sets its FPU to a set of known values. After
19 19 * that, we call a function that can be used as a no-op target to dump the FPU
20 20 * state, attempting to minimize the number of instructions inbetween
21 21 * operations. We use the 'yield(2)' system call and library function in libc
22 22 * for that as it's something that'll not really do much and it is very unlikely
23 23 * the compiler will use the FPU between function calls.
24 24 */
25 25
26 26 #include <err.h>
27 27 #include <stdlib.h>
28 28 #include <unistd.h>
29 29 #include <errno.h>
30 30
31 31 #include "xsave_util.h"
32 32
33 33 static xsu_fpu_t fpu;
34 34
35 35 int
36 36 main(int argc, char *argv[])
37 37 {
38 38 uint32_t hwsup;
39 39 char *eptr;
40 40 unsigned long ul;
41 41
42 42 if (argc != 2) {
43 43 errx(EXIT_FAILURE, "missing required seed");
44 44 }
45 45
46 46 errno = 0;
47 47 ul = strtoul(argv[1], &eptr, 0);
48 48 if (errno != 0 || *eptr != '\0') {
49 49 errx(EXIT_FAILURE, "seed value is bad: %s", argv[3]);
50 50 }
51 51
52 52 hwsup = xsu_hwsupport();
53 53 xsu_fill(&fpu, hwsup, (uint32_t)ul);
54 54 xsu_setfpu(&fpu, hwsup);
55 55
56 56 yield();
57 57 return (EXIT_SUCCESS);
58 58 }
|
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX