Commit 4544db3f authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 fixes from Catalin Marinas:

 - Ensure context synchronisation after a write to APIAKey.

 - Fix bullet list formatting in Documentation/arm64/amu.rst to
   eliminate doc warnings.

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  Documentation: arm64: fix amu.rst doc warnings
  arm64: sync kernel APIAKey when installing
parents b9916af7 59bff30a
...@@ -23,13 +23,14 @@ optional external memory-mapped interface. ...@@ -23,13 +23,14 @@ optional external memory-mapped interface.
Version 1 of the Activity Monitors architecture implements a counter group Version 1 of the Activity Monitors architecture implements a counter group
of four fixed and architecturally defined 64-bit event counters. of four fixed and architecturally defined 64-bit event counters.
- CPU cycle counter: increments at the frequency of the CPU.
- Constant counter: increments at the fixed frequency of the system - CPU cycle counter: increments at the frequency of the CPU.
clock. - Constant counter: increments at the fixed frequency of the system
- Instructions retired: increments with every architecturally executed clock.
instruction. - Instructions retired: increments with every architecturally executed
- Memory stall cycles: counts instruction dispatch stall cycles caused by instruction.
misses in the last level cache within the clock domain. - Memory stall cycles: counts instruction dispatch stall cycles caused by
misses in the last level cache within the clock domain.
When in WFI or WFE these counters do not increment. When in WFI or WFE these counters do not increment.
...@@ -57,11 +58,12 @@ counters, only the presence of the extension. ...@@ -57,11 +58,12 @@ counters, only the presence of the extension.
Firmware (code running at higher exception levels, e.g. arm-tf) support is Firmware (code running at higher exception levels, e.g. arm-tf) support is
needed to: needed to:
- Enable access for lower exception levels (EL2 and EL1) to the AMU
registers. - Enable access for lower exception levels (EL2 and EL1) to the AMU
- Enable the counters. If not enabled these will read as 0. registers.
- Save/restore the counters before/after the CPU is being put/brought up - Enable the counters. If not enabled these will read as 0.
from the 'off' power state. - Save/restore the counters before/after the CPU is being put/brought up
from the 'off' power state.
When using kernels that have this feature enabled but boot with broken When using kernels that have this feature enabled but boot with broken
firmware the user may experience panics or lockups when accessing the firmware the user may experience panics or lockups when accessing the
...@@ -78,10 +80,11 @@ are not trapped in EL2/EL3. ...@@ -78,10 +80,11 @@ are not trapped in EL2/EL3.
The fixed counters of AMUv1 are accessible though the following system The fixed counters of AMUv1 are accessible though the following system
register definitions: register definitions:
- SYS_AMEVCNTR0_CORE_EL0
- SYS_AMEVCNTR0_CONST_EL0 - SYS_AMEVCNTR0_CORE_EL0
- SYS_AMEVCNTR0_INST_RET_EL0 - SYS_AMEVCNTR0_CONST_EL0
- SYS_AMEVCNTR0_MEM_STALL_EL0 - SYS_AMEVCNTR0_INST_RET_EL0
- SYS_AMEVCNTR0_MEM_STALL_EL0
Auxiliary platform specific counters can be accessed using Auxiliary platform specific counters can be accessed using
SYS_AMEVCNTR1_EL0(n), where n is a value between 0 and 15. SYS_AMEVCNTR1_EL0(n), where n is a value between 0 and 15.
...@@ -93,9 +96,10 @@ Userspace access ...@@ -93,9 +96,10 @@ Userspace access
---------------- ----------------
Currently, access from userspace to the AMU registers is disabled due to: Currently, access from userspace to the AMU registers is disabled due to:
- Security reasons: they might expose information about code executed in
secure mode. - Security reasons: they might expose information about code executed in
- Purpose: AMU counters are intended for system management use. secure mode.
- Purpose: AMU counters are intended for system management use.
Also, the presence of the feature is not visible to userspace. Also, the presence of the feature is not visible to userspace.
...@@ -105,8 +109,9 @@ Virtualization ...@@ -105,8 +109,9 @@ Virtualization
Currently, access from userspace (EL0) and kernelspace (EL1) on the KVM Currently, access from userspace (EL0) and kernelspace (EL1) on the KVM
guest side is disabled due to: guest side is disabled due to:
- Security reasons: they might expose information about code executed
by other guests or the host. - Security reasons: they might expose information about code executed
by other guests or the host.
Any attempt to access the AMU registers will result in an UNDEFINED Any attempt to access the AMU registers will result in an UNDEFINED
exception being injected into the guest. exception being injected into the guest.
...@@ -47,7 +47,7 @@ static inline void ptrauth_keys_init_user(struct ptrauth_keys_user *keys) ...@@ -47,7 +47,7 @@ static inline void ptrauth_keys_init_user(struct ptrauth_keys_user *keys)
get_random_bytes(&keys->apga, sizeof(keys->apga)); get_random_bytes(&keys->apga, sizeof(keys->apga));
} }
#define __ptrauth_key_install(k, v) \ #define __ptrauth_key_install_nosync(k, v) \
do { \ do { \
struct ptrauth_key __pki_v = (v); \ struct ptrauth_key __pki_v = (v); \
write_sysreg_s(__pki_v.lo, SYS_ ## k ## KEYLO_EL1); \ write_sysreg_s(__pki_v.lo, SYS_ ## k ## KEYLO_EL1); \
...@@ -62,8 +62,11 @@ static __always_inline void ptrauth_keys_init_kernel(struct ptrauth_keys_kernel ...@@ -62,8 +62,11 @@ static __always_inline void ptrauth_keys_init_kernel(struct ptrauth_keys_kernel
static __always_inline void ptrauth_keys_switch_kernel(struct ptrauth_keys_kernel *keys) static __always_inline void ptrauth_keys_switch_kernel(struct ptrauth_keys_kernel *keys)
{ {
if (system_supports_address_auth()) if (!system_supports_address_auth())
__ptrauth_key_install(APIA, keys->apia); return;
__ptrauth_key_install_nosync(APIA, keys->apia);
isb();
} }
extern int ptrauth_prctl_reset_keys(struct task_struct *tsk, unsigned long arg); extern int ptrauth_prctl_reset_keys(struct task_struct *tsk, unsigned long arg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment