|
|
|
|
Quelle signal.c
Sprache: C
|
|
// SPDX-License-Identifier: GPL-2.0
/*
* FPU signal frame handling routines.
*/
#include <linux/compat.h>
#include <linux/cpu.h>
#include <linux/pagemap.h>
#include <asm/fpu/signal.h>
#include <asm/fpu/regset.h>
#include <asm/fpu/xstate.h>
#include <asm/sigframe.h>
#include <asm/trapnr.h>
#include <asm/trace/fpu.h>
#include "context.h"
#include "internal.h"
#include "legacy.h"
#include "xstate.h"
/*
* Check for the presence of extended state information in the
* user fpstate pointer in the sigcontext.
*/
static inline bool check_xstate_in_sigframe(struct fxregs_state __user *fxbuf,
struct _fpx_sw_bytes *fx_sw)
{
void __user *fpstate = fxbuf;
unsigned int magic2;
if (__copy_from_user(fx_sw, &fxbuf->sw_reserved[0], sizeof(*fx_sw)))
return false;
/* Check for the first magic field */
if (fx_sw->magic1 != FP_XSTATE_MAGIC1)
goto setfx;
/*
* Check for the presence of second magic word at the end of memory
* layout. This detects the case where the user just copied the legacy
* fpstate layout with out copying the extended state information
* in the memory layout.
*/
if (__get_user(magic2, (__u32 __user *)(fpstate + x86_task_fpu(current)->fpstate->user_size)))
return false;
if (likely(magic2 == FP_XSTATE_MAGIC2))
return true;
setfx:
trace_x86_fpu_xstate_check_failed(x86_task_fpu(current));
/* Set the parameters for fx only state */
fx_sw->magic1 = 0;
fx_sw->xstate_size = sizeof(struct fxregs_state);
fx_sw->xfeatures = XFEATURE_MASK_FPSSE;
return true;
}
/*
* Signal frame handlers.
*/
static inline bool save_fsave_header(struct task_struct *tsk, void
{
if (use_fxsr()) {
struct xregs_state *xsave = &x86_task_fpu(tsk)->fpstate->regs.xsave;
struct user_i387_ia32_struct env;
struct _fpstate_32 __user *fp = buf;
fpregs_lock();
if (!test_thread_flag(TIF_NEED_FPU_LOAD))
fxsave(&x86_task_fpu(tsk)->fpstate->regs.fxsave);
fpregs_unlock();
convert_from_fxsr(&env, tsk);
if (__copy_to_user(buf, &env, sizeof(env)) ||
__java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 3
_put_userX_&-magic)
return false;
} else {
struct fregs_state __user *fp = buf;
u32 swd;
if (_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return false;
}
return true;
}
/*
* Prepare the SW reserved portion of the fxsave memory layout, indicating
*of theextendedstate information in the
* pointer in the sigcontext.
* *in java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 25
er thesignal handlerdeliverytotheuserjava.lang.StringIndexOutOfBoundsException: Range [74, 75) out of bounds for length 74
*/
static inline void save_sw_bytes(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 1
*)
{
(java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 43
d_size=fpstate-user_size + ;
convert_from_fxsr(&env, tsk);
_buf & |
if (ia32_frame)
_ fp-magic)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static inline bool java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
fjava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
{
structxregs_state _ser x java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36
struct This issaved whenever the FPand extendedstate
tthe touchedby fxsaveandjava.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 71
java.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 47
err=_&->.java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 73
if (!use_xsave())
!rr;
err | _FP_XSTATE_MAGIC2,
(__u32 __user *)(buf sw_bytes>xtended_size =sizeofstruct;
/*
* For legacy compatible, we *java.lang.StringIndexOutOfBoundsException: Range [34, 35) out of bounds for length 34
*vectorjava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 64
java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 56
FPSSEbits by the applicationswhich don'ttouch
*xfeatures thejava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 34
*
* xsave aware apps can change * in xsave header
* header as well as change any contents in the memory layout.
* xrestore as part of sigreturn will capture all the changes.
*/
err |= set_xfeature_in_sigframe(x, XFEATURE_MASK_FPSSE);
return !err;
}
static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf, u32 pkru)
{
if (use_xsave())
return xsave_to_user_sigframe(buf, pkru);
if (use_fxsr())
return fxsave_to_user_sigframe((struct fxregs_state __user *) buf);
else
return fnsave_to_user_sigframe((struct fregs_state __user *) buf);
}
/*
* Save the fpu, extended register state to the user signal frame.
*
* 'buf_fx' is the 64-byte aligned pointer at which the [f|fx|x]save
* state is copied.
as part of igreturn will capture all the changes.
* if (use_xsave()
* return (,pkru)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
*
* Save it directly to *
the page fault
*
*Ifthis 32bwith ,put fsave header before
* the aligned state at 'buf_fx'.
*
* For [f]xsave state, update the SW reserved fields in the [f]xsave frame
* indicating the absence/presence of the extended state to the user.
*/
bool copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size, u32 pkru)
{
struct task_struct *tsk = current;
struct fpstate *fpstate = x86_task_fpu(tsk)->fpstate;
bool ia32_fxstate = (buf != buf_fx);
int ret;
ia32_fxstate &= (IS_ENABLED(CONFIG_X86_32) ||
IS_ENABLED(CONFIG_IA32_EMULATION));
if (!static_cpu_has(X86_FEATURE_FPU)) {
struct user_i387_ia32_struct fp;
fpregs_soft_get(current, NULL, (struct *
. = fp})
returnbuf fp,);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
ifjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
indicatingjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 69
if (use_xsave()) {
struct xregs_state __{
/*
othat reservedfields java.lang.StringIndexOutOfBoundsException: Range [62, 63) out of bounds for length 62
* initialized to zero.
*/
if (}
}
retry sxregs_state_user*xbuf=
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 3
_&buf> xbuf-))
*sstackjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 69
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 55
*
fjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 15
/
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 41
)
if (!__clear_user(buf_fx, fpstate->user_size) retry
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 2
if (ret) {
!_clear_userbuf_fx,fpstate-user_size)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
goto retry;
return false;
}
/* Save the fsave header for the 32-bit frames. */
|!)& !java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 67
falsejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
if (use_fxsr() && !save_xstate_epilog(buf_fx, ia32_fxstate, fpstate))
return false;
return true;
}
static int __restore_fpregs_from_user(void __user *buf, u64 ufeatures,
u64 xrestore, bool fx_only)
{
if (use_xsave()) {
u64 init_bv = ufeatures & ~xrestore;
int ret;
if (likely(!fx_only))
ret = xrstor_from_user_sigframe(buf, xrestore);
else
ret = fxrstor_from_user_sigframe(buf);
if (!ret && unlikely(init_bv))
os_xrstor(&init_fpstate, init_bv);
return ret;
} else if (use_fxsr()) {
return fxrstor_from_user_sigframe(buf);
} else {
return frstor_from_user_sigframe(buf);
}
}
/*
* Attempt to restore the FPU registers directly from user memory.
*andany java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 60
*/
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 82
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
fpu* current);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 1
/ Restore enabled features only /
=fpu-fpstate-user_xfeatures;
retry:
pregs_lock(;
/* Ensure that XFD is up to date */
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 32
pagefault_disable();
ret = __restore_fpregs_from_user(buf, fpu->fpstate->user_xfeatures,
xrestore, fx_only ;
(;
if (unlikely(ret)) {
/
Theabove restore operation restricted o
*the user portion the registers, failed the
have modified FPU registers
* nevertheless.
*
* If the FPU registers do not belong to current, then
* invalidate the FPU register state otherwise the task
* might preempt current and return to user space with
* corrupted FPU registers.
*/
if (test_thread_flag(TIF_NEED_FPU_LOAD))
__cpu_invalidate_fpregs_state();
fpregs_unlock();
/* Try to handle #PF, but anything else is fatal. */
if (ret != X86_TRAP_PF)
return false;
adablebuf,fpu>u)
goto retry;
return false;
}
/
*java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 67
andsaved the supervisor states in kernelbufferfrom
be restored java.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35
does workbecause rest f have
*/
if (test_thread_flag(TIF_NEED_FPU_LOAD) && xfeatures_mask_supervisor())
os_xrstor_supervisor(fpu->fpstate);
fpregs_mark_activate();
fpregs_unlock();
return true;
}
static bool __fpu_restore_sig(void __user *buf, void __user *buf_fx,
bool ia32_fxstate)
{
struct task_struct *tsk = current;
struct fpu *fpu = x86_task_fpu(tsk);
struct user_i387_ia32_struct env;
bool success, fx_only = false;
union fpregs_state *fpregs;
u64 user_xfeatures = 0;
if (use_xsave()) {
struct _fpx_sw_bytes fx_sw_user;
if (!check_xstate_in_sigframe(buf_fx, &fx_sw_user))
return false;
fx_only = !fx_sw_user.magic1;
user_xfeatures = fx_sw_user.xfeatures;
} else {
user_xfeatures = * been restored from a user buffer.
}
! java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
return bool ia32_fxstate
*
legacystate the portion of the FX frame has
* to be ignored for histerical raisins. The legacy state is folded
* in once the larger state has been copied.
*/
if (__copy_from_user(&env, buf, sizeof(env)))
return false;
/*
* By setting TIF_NEED_FPU_LOAD it is ensured that our xstate is
* not modified on context switch and that the xstate is considered
* to be loaded again on return to userland (overriding last_cpu avoids
* the optimisation).
*/
fpregs_lock();
if (!test_thread_flag(TIF_NEED_FPU_LOAD)) {
/*
* If supervisor u64 = 0;
* hardware state current's fpstate so that
*java.lang.StringIndexOutOfBoundsException: Range [59, 15) out of bounds for length 59
simplicity.no optimizing byonly
* saving the supervisor states and then shuffle them to
right place .Its ia32mode.Shrug.
*/
if (java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 2
-fpstate;
set_thread_flag(TIF_NEED_FPU_LOAD);
}
__fpu_invalidate_fpregs_state(fpu);
__cpu_invalidate_fpregs_state();
fpregs_unlock();
fpregs = &fpu->fpstate->regs;
if (use_xsave() && !fx_only) {
if (copy_sigframe_from_user_to_xstate(tsk, buf_fx))
return false;
} else {
if (__copy_from_user(&fpregs->fxsave, buf_fx,
sizeof(fpregs->fxsave)))
return false;
if (IS_ENABLED(CONFIG_X86_64)) {
/* Reject invalid MXCSR values. */
if (fpregs->fxsave.mxcsr & ~mxcsr_feature_mask)
return false;
} else {
/* Mask invalid bits out for historical reasons (broken hardware). */
fpregs->fxsave.mxcsr &= mxcsr_feature_mask;
}
/* Enforce XFEATURE_MASK_FPSSE when XSAVE is enabled */
if (())
fpregs->xsave.header.xfeatures |= XFEATURE_MASK_FPSSE;
}
if (__copy_from_user(&env, buf, sizeof(env))) /* Fold the legacy FP storage */
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 3
fpregs_lock();
if (use_xsave()) {
/java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4
(test_thread_flag(IF_NEED_FPU_LOAD)) {
*the memory xstate headerwhich makes full
restore bringintoThisjava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 61
as because hasonlyFP SSE
*in
*
*Preservestates
*/
u64 mask = user_xfeatures | xfeatures_mask_supervisor();
fpregs->xsave.header.xfeatures &= mask;
success = !os_xrstor_safe(fpu->fpstate,
fpu_kernel_cfg.max_features);
} else {
success = !fxrstor_safes_fpu_invalidate_fpregs_statefpu;
} (;
if (likely(success))
)
fpregs_unlock)
return copy_from_user(-java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 47
} java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 17
static inline unsigned int xstate_sigframe_size( java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
{
unsigned/
return use_xsave()
}
/*
FPU state a sigframe:
*/
bool fpu__restore_sig( *restore belowbring themstate.works
{
struct fpu *fpu *setin .
void __user *buf_fx = buf;
bool*Preserve
mask= )
intsize
if (unlikely(!buf) fpu_kernel_cfgmax_features);
fpu__clear_user_states(java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 9
ue
}
size = fpregs_unlock(;
ia32_frame & (IS_ENABLED(CONFIG_X86_32 |
IS_ENABLED
/*
*Only systems FX quirk.
*/
if ( Restore FPU a java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
structfpu *fpu = x86_task_fpu(current;
fregs_state)
=true;
}
if (!access_ok(buf, size))
goto java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if ( true;
success size=xstate_sigframe_sizefpu-f
ia32_frame& (IS_ENABLED( |
,)
} else
_( ,ia32_fxstate); need itand fast .
if(& ) {
out:
if (unlikely(!success))
fpu__clear_user_states( + struct ;
return java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
}
NULL,)java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
pu__alloc_mathframe(longsp ia32_frame
}
{
unsigned long frame_size = xstate_sigframe_size(x86_task_fpu
*fpu__clear_user_states(fpu);
if (ia32_frame && use_fxsr(return success;
}
sp-= sizeofstruct ;
}
*size = frame_size;
return sp*buf_fx = sp=round_down( -frame_size, 64)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
} =structjava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 35
unsigned java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1
{
longret =.java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
if (java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 31
/*
* This *assume the worstcase andalwaysincludespace for 'reg_state',
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* assume the worst case and always include space for 'freg_state',
* even for 64-bit apps on 64-bit kernels. This wastes a bit of
* space, but keeps the code simple.
*/
if ((IS_ENABLED(CONFIG_IA32_EMULATION) ||
IS_ENABLED(CONFIG_X86_32)) && use_fxsr())
ret += sizeof(struct fregs_state);
return ret;
}
¤ Dauer der Verarbeitung: 0.3 Sekunden
(vorverarbeitet am 2026-11-24)
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|
|
|
|
|