615a631f51fa1bb71ef79f3ea5a748a512ca2387
[linux-2.6-microblaze.git] / Documentation / powerpc / dexcr.rst
1 .. SPDX-License-Identifier: GPL-2.0-or-later
2
3 ==========================================
4 DEXCR (Dynamic Execution Control Register)
5 ==========================================
6
7 Overview
8 ========
9
10 The DEXCR is a privileged special purpose register (SPR) introduced in
11 PowerPC ISA 3.1B (Power10) that allows per-cpu control over several dynamic
12 execution behaviours. These behaviours include speculation (e.g., indirect
13 branch target prediction) and enabling return-oriented programming (ROP)
14 protection instructions.
15
16 The execution control is exposed in hardware as up to 32 bits ('aspects') in
17 the DEXCR. Each aspect controls a certain behaviour, and can be set or cleared
18 to enable/disable the aspect. There are several variants of the DEXCR for
19 different purposes:
20
21 DEXCR
22     A privileged SPR that can control aspects for userspace and kernel space
23 HDEXCR
24     A hypervisor-privileged SPR that can control aspects for the hypervisor and
25     enforce aspects for the kernel and userspace.
26 UDEXCR
27     An optional ultravisor-privileged SPR that can control aspects for the ultravisor.
28
29 Userspace can examine the current DEXCR state using a dedicated SPR that
30 provides a non-privileged read-only view of the userspace DEXCR aspects.
31 There is also an SPR that provides a read-only view of the hypervisor enforced
32 aspects, which ORed with the userspace DEXCR view gives the effective DEXCR
33 state for a process.
34
35
36 Configuration
37 =============
38
39 The DEXCR is currently unconfigurable. All threads are run with the
40 NPHIE aspect enabled.
41
42
43 coredump and ptrace
44 ===================
45
46 The userspace values of the DEXCR and HDEXCR (in this order) are exposed under
47 ``NT_PPC_DEXCR``. These are each 64 bits and readonly, and are intended to
48 assist with core dumps. The DEXCR may be made writable in future. The top 32
49 bits of both registers (corresponding to the non-userspace bits) are masked off.
50
51 If the kernel config ``CONFIG_CHECKPOINT_RESTORE`` is enabled, then
52 ``NT_PPC_HASHKEYR`` is available and exposes the HASHKEYR value of the process
53 for reading and writing. This is a tradeoff between increased security and
54 checkpoint/restore support: a process should normally have no need to know its
55 secret key, but restoring a process requires setting its original key. The key
56 therefore appears in core dumps, and an attacker may be able to retrieve it from
57 a coredump and effectively bypass ROP protection on any threads that share this
58 key (potentially all threads from the same parent that have not run ``exec()``).