Skip to content

Commit c8b06e3

Browse files
James Morsewildea01
authored andcommitted
arm64: Remove useless UAO IPI and describe how this gets enabled
Since its introduction, the UAO enable call was broken, and useless. commit 2a6dcb2 ("arm64: cpufeature: Schedule enable() calls instead of calling them via IPI"), fixed the framework so that these calls are scheduled, so that they can modify PSTATE. Now it is just useless. Remove it. UAO is enabled by the code patching which causes get_user() and friends to use the 'ldtr' family of instructions. This relies on the PSTATE.UAO bit being set to match addr_limit, which we do in uao_thread_switch() called via __switch_to(). All that is needed to enable UAO is patch the code, and call schedule(). __apply_alternatives_multi_stop() calls stop_machine() when it modifies the kernel text to enable the alternatives, (including the UAO code in uao_thread_switch()). Once stop_machine() has finished __switch_to() is called to reschedule the original task, this causes PSTATE.UAO to be set appropriately. An explicit enable() call is not needed. Reported-by: Vladimir Murzin <vladimir.murzin@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
1 parent 510224c commit c8b06e3

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

arch/arm64/include/asm/processor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ static inline void spin_lock_prefetch(const void *ptr)
187187
#endif
188188

189189
int cpu_enable_pan(void *__unused);
190-
int cpu_enable_uao(void *__unused);
191190
int cpu_enable_cache_maint_trap(void *__unused);
192191

193192
#endif /* __ASM_PROCESSOR_H */

arch/arm64/kernel/cpufeature.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,10 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
806806
.sys_reg = SYS_ID_AA64MMFR2_EL1,
807807
.field_pos = ID_AA64MMFR2_UAO_SHIFT,
808808
.min_field_value = 1,
809-
.enable = cpu_enable_uao,
809+
/*
810+
* We rely on stop_machine() calling uao_thread_switch() to set
811+
* UAO immediately after patching.
812+
*/
810813
},
811814
#endif /* CONFIG_ARM64_UAO */
812815
#ifdef CONFIG_ARM64_PAN

arch/arm64/mm/fault.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -691,17 +691,3 @@ int cpu_enable_pan(void *__unused)
691691
return 0;
692692
}
693693
#endif /* CONFIG_ARM64_PAN */
694-
695-
#ifdef CONFIG_ARM64_UAO
696-
/*
697-
* Kernel threads have fs=KERNEL_DS by default, and don't need to call
698-
* set_fs(), devtmpfs in particular relies on this behaviour.
699-
* We need to enable the feature at runtime (instead of adding it to
700-
* PSR_MODE_EL1h) as the feature may not be implemented by the cpu.
701-
*/
702-
int cpu_enable_uao(void *__unused)
703-
{
704-
asm(SET_PSTATE_UAO(1));
705-
return 0;
706-
}
707-
#endif /* CONFIG_ARM64_UAO */

0 commit comments

Comments
 (0)