<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/arch/mips/include/asm/processor.h, branch v4.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.9</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-08-02T07:28:53Z</updated>
<entry>
<title>MIPS: Use per-mm page to execute branch delay slot instructions</title>
<updated>2016-08-02T07:28:53Z</updated>
<author>
<name>Paul Burton</name>
<email>paul.burton@imgtec.com</email>
</author>
<published>2016-07-08T10:06:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=432c6bacbd0c16ec210c43da411ccc3855c4c010'/>
<id>urn:sha1:432c6bacbd0c16ec210c43da411ccc3855c4c010</id>
<content type='text'>
In some cases the kernel needs to execute an instruction from the delay
slot of an emulated branch instruction. These cases include:

  - Emulated floating point branch instructions (bc1[ft]l?) for systems
    which don't include an FPU, or upon which the kernel is run with the
    "nofpu" parameter.

  - MIPSr6 systems running binaries targeting older revisions of the
    architecture, which may include branch instructions whose encodings
    are no longer valid in MIPSr6.

Executing instructions from such delay slots is done by writing the
instruction to memory followed by a trap, as part of an "emuframe", and
executing it. This avoids the requirement of an emulator for the entire
MIPS instruction set. Prior to this patch such emuframes are written to
the user stack and executed from there.

This patch moves FP branch delay emuframes off of the user stack and
into a per-mm page. Allocating a page per-mm leaves userland with access
to only what it had access to previously, and compared to other
solutions is relatively simple.

When a thread requires a delay slot emulation, it is allocated a frame.
A thread may only have one frame allocated at any one time, since it may
only ever be executing one instruction at any one time. In order to
ensure that we can free up allocated frame later, its index is recorded
in struct thread_struct. In the typical case, after executing the delay
slot instruction we'll execute a break instruction with the BRK_MEMU
code. This traps back to the kernel &amp; leads to a call to do_dsemulret
which frees the allocated frame &amp; moves the user PC back to the
instruction that would have executed following the emulated branch.
In some cases the delay slot instruction may be invalid, such as a
branch, or may trigger an exception. In these cases the BRK_MEMU break
instruction will not be hit. In order to ensure that frames are freed
this patch introduces dsemul_thread_cleanup() and calls it to free any
allocated frame upon thread exit. If the instruction generated an
exception &amp; leads to a signal being delivered to the thread, or indeed
if a signal simply happens to be delivered to the thread whilst it is
executing from the struct emuframe, then we need to take care to exit
the frame appropriately. This is done by either rolling back the user PC
to the branch or advancing it to the continuation PC prior to signal
delivery, using dsemul_thread_rollback(). If this were not done then a
sigreturn would return to the struct emuframe, and if that frame had
meanwhile been used in response to an emulated branch instruction within
the signal handler then we would execute the wrong user code.

Whilst a user could theoretically place something like a compact branch
to self in a delay slot and cause their thread to become stuck in an
infinite loop with the frame never being deallocated, this would:

  - Only affect the users single process.

  - Be architecturally invalid since there would be a branch in the
    delay slot, which is forbidden.

  - Be extremely unlikely to happen by mistake, and provide a program
    with no more ability to harm the system than a simple infinite loop
    would.

If a thread requires a delay slot emulation &amp; no frame is available to
it (ie. the process has enough other threads that all frames are
currently in use) then the thread joins a waitqueue. It will sleep until
a frame is freed by another thread in the process.

Since we now know whether a thread has an allocated frame due to our
tracking of its index, the cookie field of struct emuframe is removed as
we can be more certain whether we have a valid frame. Since a thread may
only ever have a single frame at any given time, the epc field of struct
emuframe is also removed &amp; the PC to continue from is instead stored in
struct thread_struct. Together these changes simplify &amp; shrink struct
emuframe somewhat, allowing twice as many frames to fit into the page
allocated for them.

The primary benefit of this patch is that we are now free to mark the
user stack non-executable where that is possible.

Signed-off-by: Paul Burton &lt;paul.burton@imgtec.com&gt;
Cc: Leonid Yegoshin &lt;leonid.yegoshin@imgtec.com&gt;
Cc: Maciej Rozycki &lt;maciej.rozycki@imgtec.com&gt;
Cc: Faraz Shahbazker &lt;faraz.shahbazker@imgtec.com&gt;
Cc: Raghu Gandham &lt;raghu.gandham@imgtec.com&gt;
Cc: Matthew Fortune &lt;matthew.fortune@imgtec.com&gt;
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/13764/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS64: Support of at least 48 bits of SEGBITS</title>
<updated>2016-05-13T12:02:16Z</updated>
<author>
<name>Leonid Yegoshin</name>
<email>Leonid.Yegoshin@imgtec.com</email>
</author>
<published>2015-05-15T01:34:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1e321fa917fb2d30d39ff1c6ea89d6f1cf4f34a5'/>
<id>urn:sha1:1e321fa917fb2d30d39ff1c6ea89d6f1cf4f34a5</id>
<content type='text'>
SEGBITS is 40 bits or more, depending on CPU type.  Introduces optional
support for 48 bits of application virtual address space.  Only 16K and
64K pages are supported.

Enabling will result in a memory overhead of a small number of pages for
small applications.  For 64K pages a 3rd level of page tables is required
which has some impact during software TLB refill.

[ralf@linux-mips.org: Fixed things raised in the review of the version
posted and changed kconfig to be a bit more userfriendly.]

Signed-off-by: Leonid Yegoshin &lt;Leonid.Yegoshin@imgtec.com&gt;
Cc: aleksey.makarov@auriga.com
Cc: james.hogan@imgtec.com
Cc: paul.burton@imgtec.com
Cc: david.daney@cavium.com
Cc: peterz@infradead.org
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Cc: davidlohr@hp.com
Cc: kirill@shutemov.name
Cc: akpm@linux-foundation.org
Cc: mingo@kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10051/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Make flush_thread</title>
<updated>2016-05-13T12:01:54Z</updated>
<author>
<name>Ralf Baechle</name>
<email>ralf@linux-mips.org</email>
</author>
<published>2016-03-26T23:07:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=04cc89d120f94131de89a6e20da27016db4782ce'/>
<id>urn:sha1:04cc89d120f94131de89a6e20da27016db4782ce</id>
<content type='text'>
Avoids function calls to an empty function.

Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Fix 64k page support for 32 bit kernels.</title>
<updated>2016-02-04T00:24:40Z</updated>
<author>
<name>Ralf Baechle</name>
<email>ralf@linux-mips.org</email>
</author>
<published>2016-02-04T00:24:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d7de413475f443957a0c1d256e405d19b3a2cb22'/>
<id>urn:sha1:d7de413475f443957a0c1d256e405d19b3a2cb22</id>
<content type='text'>
TASK_SIZE was defined as 0x7fff8000UL which for 64k pages is not a
multiple of the page size.  Somewhere further down the math fails
such that executing an ELF binary fails.

Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
Tested-by: Joshua Henderson &lt;joshua.henderson@microchip.com&gt;
</content>
</entry>
<entry>
<title>MIPS: Initial implementation of a VDSO</title>
<updated>2015-11-11T07:36:36Z</updated>
<author>
<name>Alex Smith</name>
<email>alex.smith@imgtec.com</email>
</author>
<published>2015-10-21T08:54:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ebb5e78cc63417a35254a791de66e1cc84f963cc'/>
<id>urn:sha1:ebb5e78cc63417a35254a791de66e1cc84f963cc</id>
<content type='text'>
Add an initial implementation of a proper (i.e. an ELF shared library)
VDSO. With this commit it does not export any symbols, it only replaces
the current signal return trampoline page. A later commit will add user
implementations of gettimeofday()/clock_gettime().

To support both new toolchains and old ones which don't generate ABI
flags section, we define its content manually and then use a tool
(genvdso) to patch up the section to have the correct name and type.
genvdso also extracts symbol offsets ({,rt_}sigreturn) needed by the
kernel, and generates a C file containing a "struct mips_vdso_image"
containing both the VDSO data and these offsets. This C file is
compiled into the kernel.

On 64-bit kernels we require a different VDSO for each supported ABI,
so we may build up to 3 different VDSOs. The VDSO to use is selected by
the mips_abi structure.

A kernel/user shared data page is created and mapped below the VDSO
image. This is currently empty, but will be used by the user time
function implementations which are added later.

[markos.chandras@imgtec.com:
- Add more comments
- Move abi detection in genvdso.h since it's the get_symbol function
that needs it.
- Add an R6 specific way to calculate the base address of VDSO in order
to avoid the branch instruction which affects performance.
- Do not patch .gnu.attributes since it's not needed for dynamic linking.
- Simplify Makefile a little bit.
- checkpatch fixes
- Restrict VDSO support for binutils &lt; 2.25 for pre-R6
- Include atomic64.h for O32 variant on MIPS64]

Signed-off-by: Alex Smith &lt;alex.smith@imgtec.com&gt;
Signed-off-by: Markos Chandras &lt;markos.chandras@imgtec.com&gt;
Cc: Matthew Fortune &lt;matthew.fortune@imgtec.com&gt;
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11337/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Set trap_no field in thread_struct on exception.</title>
<updated>2015-09-03T10:08:04Z</updated>
<author>
<name>Ralf Baechle</name>
<email>ralf@linux-mips.org</email>
</author>
<published>2015-07-28T18:37:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e3b28831c18c6c95c51b6bb717fa116d2b658ba9'/>
<id>urn:sha1:e3b28831c18c6c95c51b6bb717fa116d2b658ba9</id>
<content type='text'>
This reverts commit 7281cd22973008a782860e48ed8d85d00204168c and adds
actual functionality to use the field.
</content>
</entry>
<entry>
<title>MIPS: MSA: Fix big-endian FPR_IDX implementation</title>
<updated>2015-03-27T18:42:48Z</updated>
<author>
<name>James Hogan</name>
<email>james.hogan@imgtec.com</email>
</author>
<published>2015-01-30T12:09:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1f3a2c6e229ccb8df8115b04d16ad4832767cf3a'/>
<id>urn:sha1:1f3a2c6e229ccb8df8115b04d16ad4832767cf3a</id>
<content type='text'>
The maximum word size is 64-bits since MSA state is saved using st.d
which stores two 64-bit words, therefore reimplement FPR_IDX using xor,
and only within each 64-bit word.

Signed-off-by: James Hogan &lt;james.hogan@imgtec.com&gt;
Signed-off-by: Paul Burton &lt;paul.burton@imgtec.com&gt;
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9169/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: OCTEON: Save and restore CP2 SHA3 state</title>
<updated>2015-02-20T14:29:08Z</updated>
<author>
<name>David Daney</name>
<email>david.daney@cavium.com</email>
</author>
<published>2015-01-15T13:11:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6b3a287e6351b00df6624b41c160e1c0817f40e2'/>
<id>urn:sha1:6b3a287e6351b00df6624b41c160e1c0817f40e2</id>
<content type='text'>
Allocate new save space, and then save/restore the registers if
OCTEON III.

Signed-off-by: David Daney &lt;david.daney@cavium.com&gt;
Signed-off-by: Aleksey Makarov &lt;aleksey.makarov@auriga.com&gt;
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/8935/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Remove unneeded #ifdef __KERNEL__ from asm/processor.h</title>
<updated>2015-02-20T13:14:52Z</updated>
<author>
<name>David Daney</name>
<email>david.daney@cavium.com</email>
</author>
<published>2014-12-18T10:59:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=151f9148d1af9ed3b5e29ab49800b0669bfe6a6a'/>
<id>urn:sha1:151f9148d1af9ed3b5e29ab49800b0669bfe6a6a</id>
<content type='text'>
Signed-off-by: David Daney &lt;david.daney@cavium.com&gt;
Signed-off-by: Aleksey Makarov &lt;aleksey.makarov@auriga.com&gt;
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/8737/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS</title>
<updated>2015-02-12T11:30:29Z</updated>
<author>
<name>Paul Burton</name>
<email>paul.burton@imgtec.com</email>
</author>
<published>2015-01-08T12:17:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9791554b45a2acc28247f66a5fd5bbc212a6b8c8'/>
<id>urn:sha1:9791554b45a2acc28247f66a5fd5bbc212a6b8c8</id>
<content type='text'>
Userland code may be built using an ABI which permits linking to objects
that have more restrictive floating point requirements. For example,
userland code may be built to target the O32 FPXX ABI. Such code may be
linked with other FPXX code, or code built for either one of the more
restrictive FP32 or FP64. When linking with more restrictive code, the
overall requirement of the process becomes that of the more restrictive
code. The kernel has no way to know in advance which mode the process
will need to be executed in, and indeed it may need to change during
execution. The dynamic loader is the only code which will know the
overall required mode, and so it needs to have a means to instruct the
kernel to switch the FP mode of the process.

This patch introduces 2 new options to the prctl syscall which provide
such a capability. The FP mode of the process is represented as a
simple bitmask combining a number of mode bits mirroring those present
in the hardware. Userland can either retrieve the current FP mode of
the process:

  mode = prctl(PR_GET_FP_MODE);

or modify the current FP mode of the process:

  err = prctl(PR_SET_FP_MODE, new_mode);

Signed-off-by: Paul Burton &lt;paul.burton@imgtec.com&gt;
Cc: Matthew Fortune &lt;matthew.fortune@imgtec.com&gt;
Cc: Markos Chandras &lt;markos.chandras@imgtec.com&gt;
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/8899/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
</feed>
