2017-11-01 10:08:43 -04:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
2012-10-09 04:47:43 -04:00
|
|
|
/*
|
|
|
|
* System calls under the Sparc.
|
|
|
|
*
|
|
|
|
* Don't be scared by the ugly clobbers, it is the only way I can
|
|
|
|
* think of right now to force the arguments into fixed registers
|
|
|
|
* before the trap into the system call with gcc 'asm' statements.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995, 2007 David S. Miller (davem@davemloft.net)
|
|
|
|
*
|
|
|
|
* SunOS compatibility based upon preliminary work which is:
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu)
|
|
|
|
*/
|
|
|
|
#ifndef _UAPI_SPARC_UNISTD_H
|
|
|
|
#define _UAPI_SPARC_UNISTD_H
|
|
|
|
|
|
|
|
#ifndef __32bit_syscall_numbers__
|
|
|
|
#ifndef __arch64__
|
|
|
|
#define __32bit_syscall_numbers__
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-11-14 00:26:31 -05:00
|
|
|
#ifdef __arch64__
|
|
|
|
#include <asm/unistd_64.h>
|
2012-10-09 04:47:43 -04:00
|
|
|
#else
|
2018-11-14 00:26:31 -05:00
|
|
|
#include <asm/unistd_32.h>
|
2018-11-14 00:26:29 -05:00
|
|
|
#endif
|
sparc64: Make montmul/montsqr/mpmul usable in 32-bit threads.
The Montgomery Multiply, Montgomery Square, and Multiple-Precision
Multiply instructions work by loading a combination of the floating
point and multiple register windows worth of integer registers
with the inputs.
These values are 64-bit. But for 32-bit userland processes we only
save the low 32-bits of each integer register during a register spill.
This is because the register window save area is in the user stack and
has a fixed layout.
Therefore, the only way to use these instruction in 32-bit mode is to
perform the following sequence:
1) Load the top-32bits of a choosen integer register with a sentinel,
say "-1". This will be in the outer-most register window.
The idea is that we're trying to see if the outer-most register
window gets spilled, and thus the 64-bit values were truncated.
2) Load all the inputs for the montmul/montsqr/mpmul instruction,
down to the inner-most register window.
3) Execute the opcode.
4) Traverse back up to the outer-most register window.
5) Check the sentinel, if it's still "-1" store the results.
Otherwise retry the entire sequence.
This retry is extremely troublesome. If you're just unlucky and an
interrupt or other trap happens, it'll push that outer-most window to
the stack and clear the sentinel when we restore it.
We could retry forever and never make forward progress if interrupts
arrive at a fast enough rate (consider perf events as one example).
So we have do limited retries and fallback to software which is
extremely non-deterministic.
Luckily it's very straightforward to provide a mechanism to let
32-bit applications use a 64-bit stack. Stacks in 64-bit mode are
biased by 2047 bytes, which means that the lowest bit is set in the
actual %sp register value.
So if we see bit zero set in a 32-bit application's stack we treat
it like a 64-bit stack.
Runtime detection of such a facility is tricky, and cumbersome at
best. For example, just trying to use a biased stack and seeing if it
works is hard to recover from (the signal handler will need to use an
alt stack, plus something along the lines of longjmp). Therefore, we
add a system call to report a bitmask of arch specific features like
this in a cheap and less hairy way.
With help from Andy Polyakov.
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-10-26 18:18:37 -04:00
|
|
|
|
|
|
|
/* Bitmask values returned from kern_features system call. */
|
|
|
|
#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001
|
2012-10-09 04:47:43 -04:00
|
|
|
|
|
|
|
#endif /* _UAPI_SPARC_UNISTD_H */
|