File Index
Files and directories
Sign in
FILE

dexcr.h

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/powerpc/dexcr/dexcr.h C
  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>
 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
 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
 84int pr_set_dexcr(unsigned long pr_aspect, unsigned long ctrl);
 85
 86unsigned int pr_which_to_aspect(unsigned long which);
 87
 88bool hashchk_triggers(void);
 89
 90enum dexcr_source {
 91	DEXCR,		/* Userspace DEXCR value */
 92	HDEXCR,		/* Hypervisor enforced DEXCR value */
 93	EFFECTIVE,	/* Bitwise OR of UDEXCR and ENFORCED DEXCR bits */
 94};
 95
 96unsigned int get_dexcr(enum dexcr_source source);
 97
 98void await_child_success(pid_t pid);
 99
100void hashst(unsigned long lr, void *sp);
101
102void hashchk(unsigned long lr, void *sp);
103
104void do_bad_hashchk(void);
105
106#endif  /* _SELFTESTS_POWERPC_DEXCR_DEXCR_H */
~/ Read-only file preview.