- 论坛徽章:
- 0
|
回复 1# sanbiangongzi
对arch/x86/boot/compressed/head_64.S 修改内容如下:- 140c140,141
- < movl $0x00000183, %eax
- ---
- > /* movl $0x00000183, %eax */
- > movl $0x00000187, %eax /* assign RING3 access right */
- 214a216,323
- > #define __KERNEL_CS_RING1 (6 * 8 + 1)
- > #define __KERNEL_DS_RING1 (7 * 8 + 1)
- > #define __KERNEL_CS_RING2 (8 * 8 + 2)
- > #define __KERNEL_DS_RING2 (9 * 8 + 2)
- > #define __KERNEL_CS_RING3 (10 * 8 + 3)
- > #define __KERNEL_DS_RING3 (11 * 8 + 3)
- >
- > .global ring_test
- > ring_test:
- > # ring 0 print
- > movw $(0x0500 + '0'), %ax
- > movw %ax, 0xb80a0
- >
- >
- > # to higher ring
- > push $__KERNEL_DS_RING1
- > push %rsp
- > pushf
- > pop %rax
- > or $0x1000, %rax
- > push %rax
- > push $__KERNEL_CS_RING1
- > lea 1f(%rbp), %rax
- > push %rax
- > iretq
- > 1:
- > xorl %eax, %eax
- > movl $__KERNEL_DS_RING1, %eax
- > movl %eax, %ds
- > # print
- > movw $(0x0500 + '1'), %ax
- > movw %ax, 0xb80a0 + 2 * 1
- >
- > /*
- > movl $__KERNEL_DS, %eax
- > movl %eax, %es
- > movl %es:(0x100000), %eax
- > */
- >
- > movl $__KERNEL_DS_RING2, %eax
- > movl %eax, %es
- > movl %es:(0x100000), %eax
- >
- > movl $__KERNEL_DS_RING3, %eax
- > movl %eax, %es
- > movl %es:(0x100000), %eax
- >
- > # to higher ring
- > push $__KERNEL_DS_RING2
- > push %rsp
- > pushf
- > pop %rax
- > or $0x2000, %rax
- > push %rax
- > push $__KERNEL_CS_RING2
- > lea 1f(%rbp), %rax
- > push %rax
- > iretq
- > 1:
- > xorl %eax, %eax
- > movl $__KERNEL_DS_RING2, %eax
- > movl %eax, %ds
- > # print
- > movw $(0x0500 + '2'), %ax
- > movw %ax, 0xb80a0 + 2 * 2
- >
- > /*
- > movl $__KERNEL_DS_RING1, %eax
- > movl %eax, %es
- > movl %es:(0x100000), %eax
- > */
- >
- > movl $__KERNEL_DS_RING3, %eax
- > movl %eax, %es
- > movl %es:(0x100000), %eax
- >
- > # to higher ring
- > push $__KERNEL_DS_RING3
- > push %rsp
- > pushf
- > pop %rax
- > or $0x3000, %rax
- > push %rax
- > push $__KERNEL_CS_RING3
- > lea 1f(%rbp), %rax
- > push %rax
- > iretq
- > 1:
- > xorl %eax, %eax
- > movl $__KERNEL_DS_RING3, %eax
- > movl %eax, %ds
- > # print
- > movw $(0x0500 + '3'), %ax
- > movw %ax, 0xb80a0 + 2 * 3
- >
- > /*
- > movl $__KERNEL_DS_RING1, %eax
- > movl %eax, %es
- > movl %es:(0x100000), %eax
- >
- > movl $__KERNEL_DS_RING2, %eax
- > movl %eax, %es
- > movl %es:(0x100000), %eax
- > */
- >
- > jmp .
- >
- >
- 299a409,410
- >
- >
- 309a421,427
- >
- > .quad 0x00afba000000ffff /* __KERNEL_CS_RING1 */
- > .quad 0x00cfb2000000ffff /* __KERNEL_DS_RING1 */
- > .quad 0x00afda000000ffff /* __KERNEL_CS_RING2 */
- > .quad 0x00cfd2000000ffff /* __KERNEL_DS_RING2 */
- > .quad 0x00affa000000ffff /* __KERNEL_CS_RING3 */
- > .quad 0x00cff2000000ffff /* __KERNEL_DS_RING3 */
复制代码 |
|