On Thu, Aug 01, 2024 at 01:06:48PM +0100, Mark Brown wrote:
Implement the architecture neutral prtctl() interface for setting the
s/prtctl/prctl/
+int arch_set_shadow_stack_status(struct task_struct *task, unsigned long arg) +{
- unsigned long gcs, size;
- int ret;
- if (!system_supports_gcs())
return -EINVAL;- if (is_compat_thread(task_thread_info(task)))
return -EINVAL;- /* Reject unknown flags */
- if (arg & ~PR_SHADOW_STACK_SUPPORTED_STATUS_MASK)
return -EINVAL;- ret = gcs_check_locked(task, arg);
- if (ret != 0)
return ret;- /* If we are enabling GCS then make sure we have a stack */
- if (arg & PR_SHADOW_STACK_ENABLE) {
if (!task_gcs_el0_enabled(task)) {/* Do not allow GCS to be reenabled */if (task->thread.gcs_base)return -EINVAL;if (task != current)return -EBUSY;size = gcs_size(0);gcs = alloc_gcs(0, size);if (!gcs)return -ENOMEM;task->thread.gcspr_el0 = gcs + size - sizeof(u64);task->thread.gcs_base = gcs;task->thread.gcs_size = size;if (task == current)write_sysreg_s(task->thread.gcspr_el0,SYS_GCSPR_EL0);}- }
Nitpick: use a single 'if' instead of nesting (unless subsequent patches add more to the first block).
Otherwise it looks fine.
Reviewed-by: Catalin Marinas catalin.marinas@arm.com