process.c (2b0a999ba003ea9b48910d75c318ae63246bc6f3) process.c (f80d034086d5bfcfd3bf4ab6f52b2df78c3ad2fa)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Based on arch/arm/kernel/process.c
4 *
5 * Original Copyright (C) 1995 Linus Torvalds
6 * Copyright (C) 1996-2000 Russell King - Converted to ARM.
7 * Copyright (C) 2012 ARM Ltd.
8 */

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

121 */
122void arch_cpu_idle(void)
123{
124 /*
125 * This should do all the clock switching and wait for interrupt
126 * tricks
127 */
128 cpu_do_idle();
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Based on arch/arm/kernel/process.c
4 *
5 * Original Copyright (C) 1995 Linus Torvalds
6 * Copyright (C) 1996-2000 Russell King - Converted to ARM.
7 * Copyright (C) 2012 ARM Ltd.
8 */

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

121 */
122void arch_cpu_idle(void)
123{
124 /*
125 * This should do all the clock switching and wait for interrupt
126 * tricks
127 */
128 cpu_do_idle();
129 raw_local_irq_enable();
129 local_irq_enable();
130}
131
132#ifdef CONFIG_HOTPLUG_CPU
133void arch_cpu_idle_dead(void)
134{
135 cpu_die();
136}
137#endif

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

417
418 /*
419 * If a TLS pointer was passed to clone, use it for the new
420 * thread.
421 */
422 if (clone_flags & CLONE_SETTLS)
423 p->thread.uw.tp_value = tls;
424 } else {
130}
131
132#ifdef CONFIG_HOTPLUG_CPU
133void arch_cpu_idle_dead(void)
134{
135 cpu_die();
136}
137#endif

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

417
418 /*
419 * If a TLS pointer was passed to clone, use it for the new
420 * thread.
421 */
422 if (clone_flags & CLONE_SETTLS)
423 p->thread.uw.tp_value = tls;
424 } else {
425 /*
426 * A kthread has no context to ERET to, so ensure any buggy
427 * ERET is treated as an illegal exception return.
428 *
429 * When a user task is created from a kthread, childregs will
430 * be initialized by start_thread() or start_compat_thread().
431 */
425 memset(childregs, 0, sizeof(struct pt_regs));
432 memset(childregs, 0, sizeof(struct pt_regs));
426 childregs->pstate = PSR_MODE_EL1h;
427 if (IS_ENABLED(CONFIG_ARM64_UAO) &&
428 cpus_have_const_cap(ARM64_HAS_UAO))
429 childregs->pstate |= PSR_UAO_BIT;
433 childregs->pstate = PSR_MODE_EL1h | PSR_IL_BIT;
430
434
431 spectre_v4_enable_task_mitigation(p);
432
433 if (system_uses_irq_prio_masking())
434 childregs->pmr_save = GIC_PRIO_IRQON;
435
436 p->thread.cpu_context.x19 = stack_start;
437 p->thread.cpu_context.x20 = stk_sz;
438 }
439 p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
440 p->thread.cpu_context.sp = (unsigned long)childregs;
441
442 ptrace_hw_copy_thread(p);
443

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

517 * - enable access when switching from a 32bit task to a 64bit task
518 */
519static void erratum_1418040_thread_switch(struct task_struct *prev,
520 struct task_struct *next)
521{
522 bool prev32, next32;
523 u64 val;
524
435 p->thread.cpu_context.x19 = stack_start;
436 p->thread.cpu_context.x20 = stk_sz;
437 }
438 p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
439 p->thread.cpu_context.sp = (unsigned long)childregs;
440
441 ptrace_hw_copy_thread(p);
442

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

516 * - enable access when switching from a 32bit task to a 64bit task
517 */
518static void erratum_1418040_thread_switch(struct task_struct *prev,
519 struct task_struct *next)
520{
521 bool prev32, next32;
522 u64 val;
523
525 if (!IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040))
524 if (!(IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) &&
525 cpus_have_const_cap(ARM64_WORKAROUND_1418040)))
526 return;
527
528 prev32 = is_compat_thread(task_thread_info(prev));
529 next32 = is_compat_thread(task_thread_info(next));
530
526 return;
527
528 prev32 = is_compat_thread(task_thread_info(prev));
529 next32 = is_compat_thread(task_thread_info(next));
530
531 if (prev32 == next32 || !this_cpu_has_cap(ARM64_WORKAROUND_1418040))
531 if (prev32 == next32)
532 return;
533
534 val = read_sysreg(cntkctl_el1);
535
536 if (!next32)
537 val |= ARCH_TIMER_USR_VCT_ACCESS_EN;
538 else
539 val &= ~ARCH_TIMER_USR_VCT_ACCESS_EN;

--- 209 unchanged lines hidden ---
532 return;
533
534 val = read_sysreg(cntkctl_el1);
535
536 if (!next32)
537 val |= ARCH_TIMER_USR_VCT_ACCESS_EN;
538 else
539 val &= ~ARCH_TIMER_USR_VCT_ACCESS_EN;

--- 209 unchanged lines hidden ---