Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\fpu\signal.c Create Date:2022-07-28 07:50:10
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:__fpu__restore_sig

Proto:static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)

Type:int

Parameter:

TypeParameterName
void __user *buf
void __user *buf_fx
intsize
274  struct user_i387_ia32_struct * envp = NULL
275  state_size = Size of the FPU context state. All tasks in the system use the* same context size, regardless of what portion they use.* This is inherent to the XSAVE architecture which puts all state* components into a single, continuous memory block:
276  ia32_fxstate = buf != buf_fx
277  tsk = current process
278  fpu = Floating point and extended processor state
280  xfeatures = 0
281  fx_only = 0
282  ret = 0
284  ia32_fxstate &= IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_X86_32) || IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_IA32_EMULATION)
287  If Not buf Then
288  Clear the FPU state back to init state.* Called by sys_execve(), by the signal handler code and by various* error paths.
289  Return 0
292  If Not access_ok - Checks if a user space pointer is valid*@addr: User space pointer to start of block to check*@size: Size of block to check* Context: User context only. This function may sleep if pagefaults are* enabled.(buf, size) Then Return -EACCES
295  If Not static_cpu_has(Onboard FPU ) Then Return fpregs_soft_set(current process, NULL, 0, sizeof(structuser_i387_ia32_struct), NULL, buf) != 0
300  If use_xsave() Then
308  state_size = sizeof(structfxregs_state)
309  fx_only = 1
311  Else
324  set_thread_flag(load FPU on return to userspace )
325  __fpu_invalidate_fpregs_state(fpu)
327  If buf_fx % 64 Then fx_only = 1
333  If ia32_fxstate Then
334  ret = __copy_from_user( & env, buf, size of env )
335  If ret Then Go to err_out
337  envp = env
338  Else
346  Use fpregs_lock() while editing CPU's FPU registers or fpu->state.* A context switch will (and softirq might) save CPU's FPU registers to* fpu->state and set TIF_NEED_FPU_LOAD leaving CPU's FPU registers in* a random state.
347  These routines enable/disable the pagefault handler. If disabled, it will* not take any locks and go straight to the fixup table.* User access methods will not sleep when called from a pagefault_disabled()* environment.
348  ret = Restore the extended state if present. Otherwise, restore the FP/SSE state.
349  pagefault_enable()
350  If Not ret Then
352  fpregs_unlock()
353  Return 0
355  These generally need preemption protection to work,* do try to avoid using these on their own:
356  fpregs_unlock()
360  If use_xsave() && Not fx_only Then
361  init_bv = xfeatures_mask & ~xfeatures
363  If using_compacted_format() Then
365  Else
371  If ret Then Go to err_out
374  sanitize_restored_xstate( & @state:* In-memory copy of all FPU registers that we save/restore* over context switches. If the task is using the FPU then* the registers in the FPU are more recent than this state* copy. If the task context-switches away then they get, envp, xfeatures, fx_only)
376  Use fpregs_lock() while editing CPU's FPU registers or fpu->state.* A context switch will (and softirq might) save CPU's FPU registers to* fpu->state and set TIF_NEED_FPU_LOAD leaving CPU's FPU registers in* a random state.
377  If Value for the false possibility is greater at compile time(init_bv) Then Restore processor xstate from xsave area.
379  ret = Restore xstate from kernel space xsave area, return an error code instead of* an exception.
381  Else if use_fxsr() Then
382  ret = __copy_from_user( & fxsave, buf_fx, state_size)
383  If ret Then
384  ret = -EFAULT
385  Go to err_out
388  sanitize_restored_xstate( & @state:* In-memory copy of all FPU registers that we save/restore* over context switches. If the task is using the FPU then* the registers in the FPU are more recent than this state* copy. If the task context-switches away then they get, envp, xfeatures, fx_only)
390  Use fpregs_lock() while editing CPU's FPU registers or fpu->state.* A context switch will (and softirq might) save CPU's FPU registers to* fpu->state and set TIF_NEED_FPU_LOAD leaving CPU's FPU registers in* a random state.
391  If use_xsave() Then
396  ret = copy_kernel_to_fxregs_err( & fxsave)
397  Else
398  ret = __copy_from_user( & fsave, buf_fx, state_size)
399  If ret Then Go to err_out
402  Use fpregs_lock() while editing CPU's FPU registers or fpu->state.* A context switch will (and softirq might) save CPU's FPU registers to* fpu->state and set TIF_NEED_FPU_LOAD leaving CPU's FPU registers in* a random state.
403  ret = copy_kernel_to_fregs_err( & fsave)
405  If Not ret Then fpregs_mark_activate()
407  Else These generally need preemption protection to work,* do try to avoid using these on their own:
409  fpregs_unlock()
411  err_out :
412  If ret Then Clear the FPU state back to init state.* Called by sys_execve(), by the signal handler code and by various* error paths.
414  Return ret
Caller
NameDescribe
fpu__restore_sigRestore FPU state from a sigframe: