1 /*
2 * Check decoding of prctl PR_SVE_SET_VL/PR_SVE_GET_VL operations.
3 *
4 * Copyright (c) 2021-2023 The strace developers.
5 * All rights reserved.
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10 #include "tests.h"
11 #include "scno.h"
12 #include <stdio.h>
13 #include <unistd.h>
14 #include <linux/prctl.h>
15
16 int
17 main(void)
18 {
19 long rc;
20
21 prctl_marker();
22
23 rc = syscall(__NR_prctl, PR_SVE_SET_VL, 0xf);
24 printf("prctl(PR_SVE_SET_VL, %#lx) = %s\n", (unsigned long) 0xf,
25 sprintrc(rc));
26
27 rc = syscall(__NR_prctl, PR_SVE_SET_VL, 0xff);
28 printf("prctl(PR_SVE_SET_VL, %#lx) = %s\n", (unsigned long) 0xff,
29 sprintrc(rc));
30
31 rc = syscall(__NR_prctl, PR_SVE_SET_VL, PR_SVE_SET_VL_ONEXEC | 0xff);
32 printf("prctl(PR_SVE_SET_VL, PR_SVE_SET_VL_ONEXEC|%#lx) = %s\n",
33 (unsigned long) 0xff, sprintrc(rc));
34
35 rc = syscall(__NR_prctl, PR_SVE_SET_VL, PR_SVE_VL_INHERIT | 0xff);
36 printf("prctl(PR_SVE_SET_VL, PR_SVE_VL_INHERIT|%#lx) = %s\n",
37 (unsigned long) 0xff, sprintrc(rc));
38
39 rc = syscall(__NR_prctl, PR_SVE_SET_VL,
40 PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT | 0xff);
41 printf("prctl(PR_SVE_SET_VL, "
42 "PR_SVE_SET_VL_ONEXEC|PR_SVE_VL_INHERIT|%#lx) = %s\n",
43 (unsigned long) 0xff, sprintrc(rc));
44
45 rc = syscall(__NR_prctl, PR_SVE_GET_VL);
46 printf("prctl(PR_SVE_GET_VL) = ");
47 if (rc >= 0) {
48 printf("%#lx", rc);
49 if (rc > 0xffff) {
50 printf(" (");
51 if (rc & PR_SVE_SET_VL_ONEXEC)
52 printf("PR_SVE_SET_VL_ONEXEC");
53 if (rc & PR_SVE_VL_INHERIT) {
54 printf("%sPR_SVE_VL_INHERIT",
55 rc & PR_SVE_SET_VL_ONEXEC ? "|" : "");
56 }
57 if (rc & ~0x6ffffU) {
58 printf("%s%#lx",
59 rc & 0x60000 ? "|" : "", rc & ~0x6ffffU);
60 }
61 printf("|%#lx)\n", rc & 0xffffU);
62 } else {
63 puts("");
64 }
65 } else {
66 puts(sprintrc(rc));
67 }
68
69 puts("+++ exited with 0 +++");
70 return 0;
71 }