head_32.S中的“stack_start”的定义是不是有问题?
时间:2011-02-27
来源:互联网
本帖最后由 JackyBsh 于 2011-02-27 22:58 编辑
(内核版本:2.6.35.4)
文件 arch/x86/kernel/head_32.S 中,设置0号进程的堆栈时,有如下相关语句:
----------------------------------------------------
lss stack_start,%esp
......
ENTRY(stack_start)
.long init_thread_union+THREAD_SIZE
.long __BOOT_DS
----------------------------------------------------
针对汇编指令 lss, 根据Intel的手册“Software Developer’s Manual,Volume 2A:Instruction Set Reference, A-M”,其中有说明如下:
------------------------------------------------------------------------------------------------------------
Loads a far pointer (segment selector and offset) from the second operand (source
operand) into a segment register and the first operand (destination operand). The
source operand specifies a 48-bit or a 32-bit pointer in memory depending on the
current setting of the operand-size attribute (32 bits or 16 bits, respectively). The
instruction opcode and the destination operand specify a segment register/general-
purpose register pair. The 16-bit segment selector from the source operand is loaded
into the segment register specified with the opcode (DS, SS, ES, FS, or GS). The
32-bit or 16-bit offset is loaded into the register specified with the destination
operand.
------------------------------------------------------------------------------------------------------------
根据上面的说明,源操作数 stack_start 是否应该定义为48位的:
--------------------------------------------
ENTRY(stack_start)
.long init_thread_union+THREAD_SIZE
.word __BOOT_DS
--------------------------------------------
但是现在内核中定义为2个long,是64位的,是否有问题?
(内核版本:2.6.35.4)
文件 arch/x86/kernel/head_32.S 中,设置0号进程的堆栈时,有如下相关语句:
----------------------------------------------------
lss stack_start,%esp
......
ENTRY(stack_start)
.long init_thread_union+THREAD_SIZE
.long __BOOT_DS
----------------------------------------------------
针对汇编指令 lss, 根据Intel的手册“Software Developer’s Manual,Volume 2A:Instruction Set Reference, A-M”,其中有说明如下:
------------------------------------------------------------------------------------------------------------
Loads a far pointer (segment selector and offset) from the second operand (source
operand) into a segment register and the first operand (destination operand). The
source operand specifies a 48-bit or a 32-bit pointer in memory depending on the
current setting of the operand-size attribute (32 bits or 16 bits, respectively). The
instruction opcode and the destination operand specify a segment register/general-
purpose register pair. The 16-bit segment selector from the source operand is loaded
into the segment register specified with the opcode (DS, SS, ES, FS, or GS). The
32-bit or 16-bit offset is loaded into the register specified with the destination
operand.
------------------------------------------------------------------------------------------------------------
根据上面的说明,源操作数 stack_start 是否应该定义为48位的:
--------------------------------------------
ENTRY(stack_start)
.long init_thread_union+THREAD_SIZE
.word __BOOT_DS
--------------------------------------------
但是现在内核中定义为2个long,是64位的,是否有问题?
作者: JackyBsh 发布时间: 2011-02-27
回复 JackyBsh
难道是地址对齐?
难道是地址对齐?
作者: cluter 发布时间: 2011-02-28
回复 JackyBsh
lss 只会取用stack_start地址向后48bit,并且x86是little-endian, 所以第二个.long的高16bit没被用到
看下内核extern出的stack_start
42 /* Static state in head.S used to set up a CPU */
43 extern struct {
44 void *sp;
45 unsigned short ss;
46 } stack_start;
lss 只会取用stack_start地址向后48bit,并且x86是little-endian, 所以第二个.long的高16bit没被用到
看下内核extern出的stack_start
42 /* Static state in head.S used to set up a CPU */
43 extern struct {
44 void *sp;
45 unsigned short ss;
46 } stack_start;
作者: chobit_s 发布时间: 2011-02-28
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28