dexcr.c (cdd5b5a9761fd66d17586e4f4ba6588c70e640ea) dexcr.c (5bfa66bf86d792bbcc76bc09cf99a2ae9d6e0eec)
1// SPDX-License-Identifier: GPL-2.0+
2
3#include <errno.h>
4#include <setjmp.h>
5#include <signal.h>
1// SPDX-License-Identifier: GPL-2.0+
2
3#include <errno.h>
4#include <setjmp.h>
5#include <signal.h>
6#include <sys/prctl.h>
6#include <sys/types.h>
7#include <sys/wait.h>
8
9#include "dexcr.h"
10#include "reg.h"
11#include "utils.h"
12
13static jmp_buf generic_signal_jump_buf;

--- 24 unchanged lines hidden (view full) ---

38 mfspr(SPRN_DEXCR_RO);
39 exists = true;
40
41out:
42 pop_signal_handler(SIGILL, old);
43 return exists;
44}
45
7#include <sys/types.h>
8#include <sys/wait.h>
9
10#include "dexcr.h"
11#include "reg.h"
12#include "utils.h"
13
14static jmp_buf generic_signal_jump_buf;

--- 24 unchanged lines hidden (view full) ---

39 mfspr(SPRN_DEXCR_RO);
40 exists = true;
41
42out:
43 pop_signal_handler(SIGILL, old);
44 return exists;
45}
46
47unsigned int pr_which_to_aspect(unsigned long which)
48{
49 switch (which) {
50 case PR_PPC_DEXCR_SBHE:
51 return DEXCR_PR_SBHE;
52 case PR_PPC_DEXCR_IBRTPD:
53 return DEXCR_PR_IBRTPD;
54 case PR_PPC_DEXCR_SRAPD:
55 return DEXCR_PR_SRAPD;
56 case PR_PPC_DEXCR_NPHIE:
57 return DEXCR_PR_NPHIE;
58 default:
59 FAIL_IF_EXIT_MSG(true, "unknown PR aspect");
60 }
61}
62
63int pr_get_dexcr(unsigned long which)
64{
65 return prctl(PR_PPC_GET_DEXCR, which, 0UL, 0UL, 0UL);
66}
67
68int pr_set_dexcr(unsigned long which, unsigned long ctrl)
69{
70 return prctl(PR_PPC_SET_DEXCR, which, ctrl, 0UL, 0UL);
71}
72
73bool pr_dexcr_aspect_supported(unsigned long which)
74{
75 if (pr_get_dexcr(which) == -1)
76 return errno == ENODEV;
77
78 return true;
79}
80
81bool pr_dexcr_aspect_editable(unsigned long which)
82{
83 return pr_get_dexcr(which) & PR_PPC_DEXCR_CTRL_EDITABLE;
84}
85
46/*
47 * Just test if a bad hashchk triggers a signal, without checking
48 * for support or if the NPHIE aspect is enabled.
49 */
50bool hashchk_triggers(void)
51{
52 struct sigaction old;
53 volatile bool triggers;

--- 79 unchanged lines hidden ---
86/*
87 * Just test if a bad hashchk triggers a signal, without checking
88 * for support or if the NPHIE aspect is enabled.
89 */
90bool hashchk_triggers(void)
91{
92 struct sigaction old;
93 volatile bool triggers;

--- 79 unchanged lines hidden ---