dexcr.h (5bfa66bf86d792bbcc76bc09cf99a2ae9d6e0eec) dexcr.h (f88723a609787254f7645eb6ac261b8363e8a5bc)
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * POWER Dynamic Execution Control Facility (DEXCR)
4 *
5 * This header file contains helper functions and macros
6 * required for all the DEXCR related test cases.
7 */
8#ifndef _SELFTESTS_POWERPC_DEXCR_DEXCR_H
9#define _SELFTESTS_POWERPC_DEXCR_DEXCR_H
10
11#include <stdbool.h>
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * POWER Dynamic Execution Control Facility (DEXCR)
4 *
5 * This header file contains helper functions and macros
6 * required for all the DEXCR related test cases.
7 */
8#ifndef _SELFTESTS_POWERPC_DEXCR_DEXCR_H
9#define _SELFTESTS_POWERPC_DEXCR_DEXCR_H
10
11#include <stdbool.h>
12#include <sys/prctl.h>
12#include <sys/types.h>
13
14#include "reg.h"
15
16#define DEXCR_PR_BIT(aspect) __MASK(63 - (32 + (aspect)))
17#define DEXCR_PR_SBHE DEXCR_PR_BIT(0)
18#define DEXCR_PR_IBRTPD DEXCR_PR_BIT(3)
19#define DEXCR_PR_SRAPD DEXCR_PR_BIT(4)
20#define DEXCR_PR_NPHIE DEXCR_PR_BIT(5)
21
22#define PPC_RAW_HASH_ARGS(b, i, a) \
23 ((((i) >> 3) & 0x1F) << 21 | (a) << 16 | (b) << 11 | (((i) >> 8) & 0x1))
24#define PPC_RAW_HASHST(b, i, a) \
25 str(.long (0x7C0005A4 | PPC_RAW_HASH_ARGS(b, i, a));)
26#define PPC_RAW_HASHCHK(b, i, a) \
27 str(.long (0x7C0005E4 | PPC_RAW_HASH_ARGS(b, i, a));)
28
13#include <sys/types.h>
14
15#include "reg.h"
16
17#define DEXCR_PR_BIT(aspect) __MASK(63 - (32 + (aspect)))
18#define DEXCR_PR_SBHE DEXCR_PR_BIT(0)
19#define DEXCR_PR_IBRTPD DEXCR_PR_BIT(3)
20#define DEXCR_PR_SRAPD DEXCR_PR_BIT(4)
21#define DEXCR_PR_NPHIE DEXCR_PR_BIT(5)
22
23#define PPC_RAW_HASH_ARGS(b, i, a) \
24 ((((i) >> 3) & 0x1F) << 21 | (a) << 16 | (b) << 11 | (((i) >> 8) & 0x1))
25#define PPC_RAW_HASHST(b, i, a) \
26 str(.long (0x7C0005A4 | PPC_RAW_HASH_ARGS(b, i, a));)
27#define PPC_RAW_HASHCHK(b, i, a) \
28 str(.long (0x7C0005E4 | PPC_RAW_HASH_ARGS(b, i, a));)
29
30struct dexcr_aspect {
31 const char *name; /* Short display name */
32 const char *opt; /* Option name for chdexcr */
33 const char *desc; /* Expanded aspect meaning */
34 unsigned int index; /* Aspect bit index in DEXCR */
35 unsigned long prctl; /* 'which' value for get/set prctl */
36};
37
38static const struct dexcr_aspect aspects[] = {
39 {
40 .name = "SBHE",
41 .opt = "sbhe",
42 .desc = "Speculative branch hint enable",
43 .index = 0,
44 .prctl = PR_PPC_DEXCR_SBHE,
45 },
46 {
47 .name = "IBRTPD",
48 .opt = "ibrtpd",
49 .desc = "Indirect branch recurrent target prediction disable",
50 .index = 3,
51 .prctl = PR_PPC_DEXCR_IBRTPD,
52 },
53 {
54 .name = "SRAPD",
55 .opt = "srapd",
56 .desc = "Subroutine return address prediction disable",
57 .index = 4,
58 .prctl = PR_PPC_DEXCR_SRAPD,
59 },
60 {
61 .name = "NPHIE",
62 .opt = "nphie",
63 .desc = "Non-privileged hash instruction enable",
64 .index = 5,
65 .prctl = PR_PPC_DEXCR_NPHIE,
66 },
67 {
68 .name = "PHIE",
69 .opt = "phie",
70 .desc = "Privileged hash instruction enable",
71 .index = 6,
72 .prctl = -1,
73 },
74};
75
29bool dexcr_exists(void);
30
31bool pr_dexcr_aspect_supported(unsigned long which);
32
33bool pr_dexcr_aspect_editable(unsigned long which);
34
35int pr_get_dexcr(unsigned long pr_aspect);
36

--- 23 unchanged lines hidden ---
76bool dexcr_exists(void);
77
78bool pr_dexcr_aspect_supported(unsigned long which);
79
80bool pr_dexcr_aspect_editable(unsigned long which);
81
82int pr_get_dexcr(unsigned long pr_aspect);
83

--- 23 unchanged lines hidden ---