函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\tls.c Create Date:2022-07-27 08:52:21
Last Modify:2022-05-18 16:59:10 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Set a given TLS descriptor:

函数原型:int do_set_thread_area(struct task_struct *p, int idx, struct user_desc __user *u_info, int can_allocate)

返回类型:int

参数:

类型参数名称
struct task_struct *p
intidx
struct user_desc __user *u_info
intcan_allocate
119  unsigned short __maybe_unused sel, modified_sel
121  如果copy_from_user( & info, u_info, info的长度)则返回:负EFAULT
124  如果非tls_desc_okay( & info)则返回:负EINVAL
127  如果idx恒等于负1则idx等于entry_number
134  如果idx恒等于负1且can_allocate
135  idx等于sys_alloc_thread_area: get a yet unused TLS descriptor index.
136  如果idx小于0则返回:idx
138  如果put_user - Write a simple value into user space(idx, & entry_number)则返回:负EFAULT
142  如果idx小于The layout of the per-CPU GDT under Linux:* 0 - null <=== cacheline #1* 1 - reserved* 2 - reserved* 3 - reserved* 4 - unused <=== cacheline #2* 5 - unused* ------- start of TLS (Thread-Local Storage) segments:* 6 - TLS segment #1 [ glibc's TLS segment ]* idx大于GDT_ENTRY_TLS_MAX则返回:负EINVAL
145  set_tls_desc(p, idx, & info, 1)
152  modified_sel等于idx左移3位按位或3
154  如果p恒等于当前进程
156  Save a segment register away:(取寄存器值(ds), sel)
157  如果sel恒等于modified_selloadsegment(取寄存器值(ds), sel)
160  Save a segment register away:(es, sel)
161  如果sel恒等于modified_selloadsegment(es, sel)
164  Save a segment register away:(取寄存器值(fs), sel)
165  如果sel恒等于modified_selloadsegment(取寄存器值(fs), sel)
168  Save a segment register away:(取寄存器值(gs), sel)
169  如果sel恒等于modified_selload_gs_index(sel)
178  否则
180  如果fsindex恒等于modified_selfsbase等于base_addr
183  如果gsindex恒等于modified_selgsbase等于base_addr
188  返回:0
调用者
名称描述
arch_ptrace
set_new_tls