2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994 - 2000, 2001, 2003 Ralf Baechle
|
|
|
|
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
|
|
|
|
* Copyright (C) 2001 MIPS Technologies, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/asm.h>
|
|
|
|
#include <asm/asmmacro.h>
|
2015-03-04 02:48:49 +08:00
|
|
|
#include <asm/compiler.h>
|
2017-03-04 07:26:05 +08:00
|
|
|
#include <asm/irqflags.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/regdef.h>
|
|
|
|
#include <asm/mipsregs.h>
|
|
|
|
#include <asm/stackframe.h>
|
|
|
|
#include <asm/isadep.h>
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
#include <asm/war.h>
|
|
|
|
|
2019-10-16 03:17:59 +08:00
|
|
|
#ifndef CONFIG_PREEMPTION
|
2005-04-17 06:20:36 +08:00
|
|
|
#define resume_kernel restore_all
|
2007-02-13 21:50:18 +08:00
|
|
|
#else
|
|
|
|
#define __ret_from_irq ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
.text
|
|
|
|
.align 5
|
2019-10-16 03:17:59 +08:00
|
|
|
#ifndef CONFIG_PREEMPTION
|
2005-04-17 06:20:36 +08:00
|
|
|
FEXPORT(ret_from_exception)
|
2007-02-13 21:50:18 +08:00
|
|
|
local_irq_disable # preempt stop
|
|
|
|
b __ret_from_irq
|
2006-10-09 00:24:23 +08:00
|
|
|
#endif
|
2007-02-13 21:50:18 +08:00
|
|
|
FEXPORT(ret_from_irq)
|
|
|
|
LONG_S s0, TI_REGS($28)
|
|
|
|
FEXPORT(__ret_from_irq)
|
2012-04-06 02:37:34 +08:00
|
|
|
/*
|
|
|
|
* We can be coming here from a syscall done in the kernel space,
|
|
|
|
* e.g. a failed kernel_execve().
|
|
|
|
*/
|
|
|
|
resume_userspace_check:
|
2005-04-17 06:20:36 +08:00
|
|
|
LONG_L t0, PT_STATUS(sp) # returning to kernel mode?
|
|
|
|
andi t0, t0, KU_USER
|
|
|
|
beqz t0, resume_kernel
|
|
|
|
|
2004-12-10 20:56:33 +08:00
|
|
|
resume_userspace:
|
|
|
|
local_irq_disable # make sure we dont miss an
|
2005-04-17 06:20:36 +08:00
|
|
|
# interrupt setting need_resched
|
|
|
|
# between sampling and return
|
|
|
|
LONG_L a2, TI_FLAGS($28) # current->work
|
2004-12-10 20:56:33 +08:00
|
|
|
andi t0, a2, _TIF_WORK_MASK # (ignoring syscall_trace)
|
|
|
|
bnez t0, work_pending
|
2005-04-17 06:20:36 +08:00
|
|
|
j restore_all
|
|
|
|
|
2019-10-16 03:17:59 +08:00
|
|
|
#ifdef CONFIG_PREEMPTION
|
2004-12-10 20:56:33 +08:00
|
|
|
resume_kernel:
|
2005-02-07 10:54:29 +08:00
|
|
|
local_irq_disable
|
2005-04-17 06:20:36 +08:00
|
|
|
lw t0, TI_PRE_COUNT($28)
|
|
|
|
bnez t0, restore_all
|
|
|
|
LONG_L t0, TI_FLAGS($28)
|
|
|
|
andi t1, t0, _TIF_NEED_RESCHED
|
|
|
|
beqz t1, restore_all
|
|
|
|
LONG_L t0, PT_STATUS(sp) # Interrupts off?
|
|
|
|
andi t0, 1
|
|
|
|
beqz t0, restore_all
|
2019-03-16 00:31:33 +08:00
|
|
|
PTR_LA ra, restore_all
|
|
|
|
j preempt_schedule_irq
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2012-10-10 04:27:45 +08:00
|
|
|
FEXPORT(ret_from_kernel_thread)
|
|
|
|
jal schedule_tail # a0 = struct task_struct *prev
|
|
|
|
move a0, s1
|
|
|
|
jal s0
|
2012-10-12 04:01:20 +08:00
|
|
|
j syscall_exit
|
2012-10-10 04:27:45 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
FEXPORT(ret_from_fork)
|
2006-07-03 15:25:41 +08:00
|
|
|
jal schedule_tail # a0 = struct task_struct *prev
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
FEXPORT(syscall_exit)
|
2018-06-15 01:20:54 +08:00
|
|
|
#ifdef CONFIG_DEBUG_RSEQ
|
|
|
|
move a0, sp
|
|
|
|
jal rseq_syscall
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
local_irq_disable # make sure need_resched and
|
|
|
|
# signals dont change between
|
|
|
|
# sampling and return
|
|
|
|
LONG_L a2, TI_FLAGS($28) # current->work
|
|
|
|
li t0, _TIF_ALLWORK_MASK
|
|
|
|
and t0, a2, t0
|
|
|
|
bnez t0, syscall_exit_work
|
|
|
|
|
2012-05-06 04:11:35 +08:00
|
|
|
restore_all: # restore full frame
|
2005-04-17 06:20:36 +08:00
|
|
|
.set noat
|
|
|
|
RESTORE_TEMP
|
|
|
|
RESTORE_AT
|
|
|
|
RESTORE_STATIC
|
2012-05-06 04:11:35 +08:00
|
|
|
restore_partial: # restore partial frame
|
2006-07-07 21:07:18 +08:00
|
|
|
#ifdef CONFIG_TRACE_IRQFLAGS
|
|
|
|
SAVE_STATIC
|
|
|
|
SAVE_AT
|
|
|
|
SAVE_TEMP
|
|
|
|
LONG_L v0, PT_STATUS(sp)
|
2007-03-26 21:47:06 +08:00
|
|
|
#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
|
|
|
|
and v0, ST0_IEP
|
|
|
|
#else
|
|
|
|
and v0, ST0_IE
|
|
|
|
#endif
|
2006-07-07 21:07:18 +08:00
|
|
|
beqz v0, 1f
|
|
|
|
jal trace_hardirqs_on
|
|
|
|
b 2f
|
|
|
|
1: jal trace_hardirqs_off
|
|
|
|
2:
|
|
|
|
RESTORE_TEMP
|
|
|
|
RESTORE_AT
|
|
|
|
RESTORE_STATIC
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
RESTORE_SOME
|
|
|
|
RESTORE_SP_AND_RET
|
|
|
|
.set at
|
|
|
|
|
2004-12-10 20:56:33 +08:00
|
|
|
work_pending:
|
|
|
|
andi t0, a2, _TIF_NEED_RESCHED # a2 is preloaded with TI_FLAGS
|
2005-04-17 06:20:36 +08:00
|
|
|
beqz t0, work_notifysig
|
|
|
|
work_resched:
|
2017-03-04 07:26:05 +08:00
|
|
|
TRACE_IRQS_OFF
|
2005-04-17 06:20:36 +08:00
|
|
|
jal schedule
|
|
|
|
|
2004-12-10 20:56:33 +08:00
|
|
|
local_irq_disable # make sure need_resched and
|
2005-04-17 06:20:36 +08:00
|
|
|
# signals dont change between
|
|
|
|
# sampling and return
|
|
|
|
LONG_L a2, TI_FLAGS($28)
|
|
|
|
andi t0, a2, _TIF_WORK_MASK # is there any work to be done
|
|
|
|
# other than syscall tracing?
|
|
|
|
beqz t0, restore_all
|
|
|
|
andi t0, a2, _TIF_NEED_RESCHED
|
|
|
|
bnez t0, work_resched
|
|
|
|
|
|
|
|
work_notifysig: # deal with pending signals and
|
|
|
|
# notify-resume requests
|
|
|
|
move a0, sp
|
|
|
|
li a1, 0
|
|
|
|
jal do_notify_resume # a2 already loaded
|
2012-04-06 02:37:34 +08:00
|
|
|
j resume_userspace_check
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-05-06 04:11:35 +08:00
|
|
|
FEXPORT(syscall_exit_partial)
|
2018-06-15 01:20:54 +08:00
|
|
|
#ifdef CONFIG_DEBUG_RSEQ
|
|
|
|
move a0, sp
|
|
|
|
jal rseq_syscall
|
|
|
|
#endif
|
2012-05-06 04:11:35 +08:00
|
|
|
local_irq_disable # make sure need_resched doesn't
|
|
|
|
# change between and return
|
|
|
|
LONG_L a2, TI_FLAGS($28) # current->work
|
|
|
|
li t0, _TIF_ALLWORK_MASK
|
|
|
|
and t0, a2
|
|
|
|
beqz t0, restore_partial
|
2005-04-17 06:20:36 +08:00
|
|
|
SAVE_STATIC
|
2004-12-10 20:56:33 +08:00
|
|
|
syscall_exit_work:
|
2012-05-03 09:45:12 +08:00
|
|
|
LONG_L t0, PT_STATUS(sp) # returning to kernel mode?
|
|
|
|
andi t0, t0, KU_USER
|
|
|
|
beqz t0, resume_kernel
|
2011-05-19 16:21:28 +08:00
|
|
|
li t0, _TIF_WORK_SYSCALL_EXIT
|
2004-12-10 20:56:33 +08:00
|
|
|
and t0, a2 # a2 is preloaded with TI_FLAGS
|
|
|
|
beqz t0, work_pending # trace bit set?
|
2011-05-19 16:21:29 +08:00
|
|
|
local_irq_enable # could let syscall_trace_leave()
|
2005-04-17 06:20:36 +08:00
|
|
|
# call schedule() instead
|
2017-03-04 07:26:05 +08:00
|
|
|
TRACE_IRQS_ON
|
2005-04-17 06:20:36 +08:00
|
|
|
move a0, sp
|
2011-05-19 16:21:29 +08:00
|
|
|
jal syscall_trace_leave
|
2005-04-17 06:20:36 +08:00
|
|
|
b resume_userspace
|
2006-04-05 16:45:45 +08:00
|
|
|
|
mips: Add MIPS Release 5 support
There are five MIPS32/64 architecture releases currently available:
from 1 to 6 except fourth one, which was intentionally skipped.
Three of them can be called as major: 1st, 2nd and 6th, that not only
have some system level alterations, but also introduced significant
core/ISA level updates. The rest of the MIPS architecture releases are
minor.
Even though they don't have as much ISA/system/core level changes
as the major ones with respect to the previous releases, they still
provide a set of updates (I'd say they were intended to be the
intermediate releases before a major one) that might be useful for the
kernel and user-level code, when activated by the kernel or compiler.
In particular the following features were introduced or ended up being
available at/after MIPS32/64 Release 5 architecture:
+ the last release of the misaligned memory access instructions,
+ virtualisation - VZ ASE - is optional component of the arch,
+ SIMD - MSA ASE - is optional component of the arch,
+ DSP ASE is optional component of the arch,
+ CP0.Status.FR=1 for CP1.FIR.F64=1 (pure 64-bit FPU general registers)
must be available if FPU is implemented,
+ CP1.FIR.Has2008 support is required so CP1.FCSR.{ABS2008,NAN2008} bits
are available.
+ UFR/UNFR aliases to access CP0.Status.FR from user-space by means of
ctc1/cfc1 instructions (enabled by CP0.Config5.UFR),
+ CP0.COnfig5.LLB=1 and eretnc instruction are implemented to without
accidentally clearing LL-bit when returning from an interrupt,
exception, or error trap,
+ XPA feature together with extended versions of CPx registers is
introduced, which needs to have mfhc0/mthc0 instructions available.
So due to these changes GNU GCC provides an extended instructions set
support for MIPS32/64 Release 5 by default like eretnc/mfhc0/mthc0. Even
though the architecture alteration isn't that big, it still worth to be
taken into account by the kernel software. Finally we can't deny that
some optimization/limitations might be found in future and implemented
on some level in kernel or compiler. In this case having even
intermediate MIPS architecture releases support would be more than
useful.
So the most of the changes provided by this commit can be split into
either compile- or runtime configs related. The compile-time related
changes are caused by adding the new CONFIG_CPU_MIPS32_R5/CONFIG_CPU_MIPSR5
configs and concern the code activating MIPSR2 or MIPSR6 already
implemented features (like eretnc/LLbit, mthc0/mfhc0). In addition
CPU_HAS_MSA can be now freely enabled for MIPS32/64 release 5 based
platforms as this is done for CPU_MIPS32_R6 CPUs. The runtime changes
concerns the features which are handled with respect to the MIPS ISA
revision detected at run-time by means of CP0.Config.{AT,AR} bits. Alas
these fields can be used to detect either r1 or r2 or r6 releases.
But since we know which CPUs in fact support the R5 arch, we can manually
set MIPS_CPU_ISA_M32R5/MIPS_CPU_ISA_M64R5 bit of c->isa_level and then
use cpu_has_mips32r5/cpu_has_mips64r5 where it's appropriate.
Since XPA/EVA provide too complex alterationss and to have them used with
MIPS32 Release 2 charged kernels (for compatibility with current platform
configs) they are left to be setup as a separate kernel configs.
Co-developed-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-05-21 22:07:14 +08:00
|
|
|
#if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR5) || \
|
|
|
|
defined(CONFIG_CPU_MIPSR6) || defined(CONFIG_MIPS_MT)
|
2006-04-05 16:45:45 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* MIPS32R2 Instruction Hazard Barrier - must be called
|
|
|
|
*
|
|
|
|
* For C code use the inline version named instruction_hazard().
|
|
|
|
*/
|
|
|
|
LEAF(mips_ihb)
|
2015-03-04 02:48:49 +08:00
|
|
|
.set MIPS_ISA_LEVEL_RAW
|
2006-04-05 16:45:45 +08:00
|
|
|
jr.hb ra
|
|
|
|
nop
|
|
|
|
END(mips_ihb)
|
|
|
|
|
mips: Add MIPS Release 5 support
There are five MIPS32/64 architecture releases currently available:
from 1 to 6 except fourth one, which was intentionally skipped.
Three of them can be called as major: 1st, 2nd and 6th, that not only
have some system level alterations, but also introduced significant
core/ISA level updates. The rest of the MIPS architecture releases are
minor.
Even though they don't have as much ISA/system/core level changes
as the major ones with respect to the previous releases, they still
provide a set of updates (I'd say they were intended to be the
intermediate releases before a major one) that might be useful for the
kernel and user-level code, when activated by the kernel or compiler.
In particular the following features were introduced or ended up being
available at/after MIPS32/64 Release 5 architecture:
+ the last release of the misaligned memory access instructions,
+ virtualisation - VZ ASE - is optional component of the arch,
+ SIMD - MSA ASE - is optional component of the arch,
+ DSP ASE is optional component of the arch,
+ CP0.Status.FR=1 for CP1.FIR.F64=1 (pure 64-bit FPU general registers)
must be available if FPU is implemented,
+ CP1.FIR.Has2008 support is required so CP1.FCSR.{ABS2008,NAN2008} bits
are available.
+ UFR/UNFR aliases to access CP0.Status.FR from user-space by means of
ctc1/cfc1 instructions (enabled by CP0.Config5.UFR),
+ CP0.COnfig5.LLB=1 and eretnc instruction are implemented to without
accidentally clearing LL-bit when returning from an interrupt,
exception, or error trap,
+ XPA feature together with extended versions of CPx registers is
introduced, which needs to have mfhc0/mthc0 instructions available.
So due to these changes GNU GCC provides an extended instructions set
support for MIPS32/64 Release 5 by default like eretnc/mfhc0/mthc0. Even
though the architecture alteration isn't that big, it still worth to be
taken into account by the kernel software. Finally we can't deny that
some optimization/limitations might be found in future and implemented
on some level in kernel or compiler. In this case having even
intermediate MIPS architecture releases support would be more than
useful.
So the most of the changes provided by this commit can be split into
either compile- or runtime configs related. The compile-time related
changes are caused by adding the new CONFIG_CPU_MIPS32_R5/CONFIG_CPU_MIPSR5
configs and concern the code activating MIPSR2 or MIPSR6 already
implemented features (like eretnc/LLbit, mthc0/mfhc0). In addition
CPU_HAS_MSA can be now freely enabled for MIPS32/64 release 5 based
platforms as this is done for CPU_MIPS32_R6 CPUs. The runtime changes
concerns the features which are handled with respect to the MIPS ISA
revision detected at run-time by means of CP0.Config.{AT,AR} bits. Alas
these fields can be used to detect either r1 or r2 or r6 releases.
But since we know which CPUs in fact support the R5 arch, we can manually
set MIPS_CPU_ISA_M32R5/MIPS_CPU_ISA_M64R5 bit of c->isa_level and then
use cpu_has_mips32r5/cpu_has_mips64r5 where it's appropriate.
Since XPA/EVA provide too complex alterationss and to have them used with
MIPS32 Release 2 charged kernels (for compatibility with current platform
configs) they are left to be setup as a separate kernel configs.
Co-developed-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-05-21 22:07:14 +08:00
|
|
|
#endif /* CONFIG_CPU_MIPSR2 - CONFIG_CPU_MIPSR6 or CONFIG_MIPS_MT */
|