亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3375 | 回復(fù): 5
打印 上一主題 下一主題

x86_64究竟有幾個ring? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2012-05-23 17:49 |只看該作者 |倒序瀏覽

看到很多地方都說x86_64只有兩個ring:ring 0和ring 3
比如:
1、 http://wiki.osdev.org/Security 提到"However, many architectures have only two rings (e.g. x86_64), corresponding to ring 0 and 3 in this description."


2、Prentice.Hall.The.Definitive.Guide.to.the.Xen.Hypervisor.Nov.2007.pdf 一本講虛擬化的書
     1.7.1 The Hypervisor, the OS, and the Applications 提到 When AMD tidied up the IA32 architecture as part of the process of creating x86-64, one of the things it did was reduce the number of rings.


但是我翻遍了 《Intel 64 and IA_32 Architectures Software Developer's Manual》也沒有找到說x86_64只有2個ring的地方

于是自己寫了一段代碼:
對 arch/x86/boot/compressed/head_64.S 做了修改

選擇這個文件沒有別的意思,只是因為bzImage內(nèi)核啟動過程中,在這個文件中,進(jìn)入了long mode。

在剛進(jìn)入(ring0)long mode之后,利用iret依次切換到ring1 ring2 ring3 然后在ring3中死循環(huán)。

在每一個ring中在屏幕上輸出一個表示當(dāng)前ring number的數(shù)字,
(在物理機DELL R710和KVM虛擬機中驗證的)結(jié)果表明,輸出了0123

這應(yīng)該改說明x86_64是有4個ring吧?

另外還測試了不同ring的代碼對不同ring的數(shù)據(jù)訪問能力,如下表
  1.             data level   0    1     2    3
  2. code level
  3. 0                        Y    Y     Y    Y
  4. 1                        N    Y     Y    Y
  5. 2                        N    N     Y    Y
  6. 3                        N    N     N    Y
復(fù)制代碼
這應(yīng)該說明,四個ring確實是不同的吧?

有沒有懂這方面的兄弟,科普一下!

論壇徽章:
0
2 [報告]
發(fā)表于 2012-05-23 17:50 |只看該作者
回復(fù) 1# sanbiangongzi


   
對arch/x86/boot/compressed/head_64.S 修改內(nèi)容如下:
  1. 140c140,141
  2. <       movl    $0x00000183, %eax
  3. ---
  4. > /*    movl    $0x00000183, %eax */
  5. >       movl    $0x00000187, %eax /* assign RING3 access right */
  6. 214a216,323
  7. > #define __KERNEL_CS_RING1  (6 * 8 + 1)
  8. > #define __KERNEL_DS_RING1  (7 * 8 + 1)
  9. > #define __KERNEL_CS_RING2  (8 * 8 + 2)
  10. > #define __KERNEL_DS_RING2  (9 * 8 + 2)
  11. > #define __KERNEL_CS_RING3  (10 * 8 + 3)
  12. > #define __KERNEL_DS_RING3  (11 * 8 + 3)
  13. >
  14. > .global ring_test
  15. > ring_test:
  16. >       # ring 0 print
  17. >       movw $(0x0500 + '0'), %ax
  18. >       movw %ax, 0xb80a0
  19. >
  20. >
  21. >       # to higher ring
  22. >       push    $__KERNEL_DS_RING1
  23. >       push    %rsp
  24. >         pushf
  25. >         pop     %rax
  26. >         or      $0x1000, %rax
  27. >         push    %rax
  28. >       push    $__KERNEL_CS_RING1
  29. >       lea     1f(%rbp), %rax
  30. >       push    %rax
  31. >       iretq
  32. > 1:
  33. >       xorl    %eax, %eax
  34. >       movl    $__KERNEL_DS_RING1, %eax
  35. >       movl    %eax, %ds
  36. >       # print
  37. >       movw $(0x0500 + '1'), %ax
  38. >       movw %ax, 0xb80a0 + 2 * 1
  39. >
  40. >       /*
  41. >       movl $__KERNEL_DS, %eax
  42. >       movl %eax, %es
  43. >       movl %es:(0x100000), %eax
  44. >       */
  45. >
  46. >       movl $__KERNEL_DS_RING2, %eax
  47. >       movl %eax, %es
  48. >       movl %es:(0x100000), %eax
  49. >
  50. >       movl $__KERNEL_DS_RING3, %eax
  51. >       movl %eax, %es
  52. >       movl %es:(0x100000), %eax
  53. >
  54. >       # to higher ring
  55. >       push    $__KERNEL_DS_RING2
  56. >       push    %rsp
  57. >         pushf
  58. >         pop     %rax
  59. >         or      $0x2000, %rax
  60. >         push    %rax
  61. >       push    $__KERNEL_CS_RING2
  62. >       lea     1f(%rbp), %rax
  63. >       push    %rax
  64. >       iretq
  65. > 1:
  66. >       xorl    %eax, %eax
  67. >       movl    $__KERNEL_DS_RING2, %eax
  68. >       movl    %eax, %ds
  69. >       # print
  70. >       movw $(0x0500 + '2'), %ax
  71. >       movw %ax, 0xb80a0 + 2 * 2
  72. >
  73. >       /*
  74. >       movl $__KERNEL_DS_RING1, %eax
  75. >       movl %eax, %es
  76. >       movl %es:(0x100000), %eax
  77. >       */
  78. >
  79. >       movl $__KERNEL_DS_RING3, %eax
  80. >       movl %eax, %es
  81. >       movl %es:(0x100000), %eax
  82. >
  83. >       # to higher ring
  84. >       push    $__KERNEL_DS_RING3
  85. >       push    %rsp
  86. >         pushf
  87. >         pop     %rax
  88. >         or      $0x3000, %rax
  89. >         push    %rax
  90. >       push    $__KERNEL_CS_RING3
  91. >       lea     1f(%rbp), %rax
  92. >       push    %rax
  93. >       iretq
  94. > 1:
  95. >       xorl    %eax, %eax
  96. >       movl    $__KERNEL_DS_RING3, %eax
  97. >       movl    %eax, %ds
  98. >       # print
  99. >       movw $(0x0500 + '3'), %ax
  100. >       movw %ax, 0xb80a0 + 2 * 3
  101. >
  102. >       /*
  103. >       movl $__KERNEL_DS_RING1, %eax
  104. >       movl %eax, %es
  105. >       movl %es:(0x100000), %eax
  106. >
  107. >       movl $__KERNEL_DS_RING2, %eax
  108. >       movl %eax, %es
  109. >       movl %es:(0x100000), %eax
  110. >       */
  111. >
  112. >       jmp .
  113. >
  114. >
  115. 299a409,410
  116. >
  117. >         
  118. 309a421,427
  119. >
  120. >       .quad   0x00afba000000ffff      /* __KERNEL_CS_RING1 */
  121. >       .quad   0x00cfb2000000ffff      /* __KERNEL_DS_RING1 */
  122. >       .quad   0x00afda000000ffff      /* __KERNEL_CS_RING2 */
  123. >       .quad   0x00cfd2000000ffff      /* __KERNEL_DS_RING2 */
  124. >       .quad   0x00affa000000ffff      /* __KERNEL_CS_RING3 */
  125. >       .quad   0x00cff2000000ffff      /* __KERNEL_DS_RING3 */
復(fù)制代碼

論壇徽章:
0
3 [報告]
發(fā)表于 2012-05-23 17:51 |只看該作者
回復(fù) 2# sanbiangongzi


    忘了說兩次測試 CPU分別是
Intel(R) Xeon(R) CPU           E5506  @ 2.13GHz 物理機

Intel(R) Xeon(R) CPU           E5540  @ 2.53GHz 虛擬機

論壇徽章:
59
2015年亞洲杯之約旦
日期:2015-01-27 21:27:392015年亞洲杯之日本
日期:2015-02-06 22:09:41拜羊年徽章
日期:2015-03-03 16:15:432015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015元宵節(jié)徽章
日期:2015-03-06 15:50:392015年亞洲杯之阿聯(lián)酋
日期:2015-03-19 17:39:302015年亞洲杯之中國
日期:2015-03-23 18:52:23巳蛇
日期:2014-12-14 22:44:03雙子座
日期:2014-12-10 21:39:16處女座
日期:2014-12-02 08:03:17天蝎座
日期:2014-07-21 19:08:47
4 [報告]
發(fā)表于 2012-05-23 20:47 |只看該作者
However, many architectures have only two rings (e.g. x86_64), corresponding to ring 0 and 3 in this description."


However, many architectures have only two rings (e.g. x86_64), corresponding to ring 0 and 3 in this description."
x86 has ring 0,1,2,3, but for portable, linux (windows too) just use two: ring 0 & ring 3.

good luck

論壇徽章:
0
5 [報告]
發(fā)表于 2012-05-24 09:06 |只看該作者
回復(fù) 4# folklore


    However, many architectures have only two rings (e.g. x86_64), corresponding to ring 0 and 3 in this description.
x86 has ring 0,1,2,3, but for portable, linux (windows too) just use two: ring 0 & ring 3.



謝謝這位兄臺的回復(fù),但是好像還是沒有弄明白,我想知道的CPU究竟總共有幾個RING,這與操作系統(tǒng)使用了其中的幾個RING是,兩個不同的問題。


上面提到的文檔是說,x86_64減少了ring的數(shù)量,但是我的測試代碼,證實了ring1/2的存在

我想知道,這些文檔提到”x86_64減少了ring的數(shù)量“是出于什么樣的背景呢?應(yīng)該不是亂說吧。

論壇徽章:
0
6 [報告]
發(fā)表于 2012-05-24 11:32 |只看該作者
本帖最后由 atz0001 于 2012-05-24 11:55 編輯

老大,當(dāng)然以 Intel 的手冊為準(zhǔn)啦,何況你在真實的 CPU 上驗證過。

我看你水平很高啊,至少比我高很多。自信點。

又看了下手冊,感覺 ring/Privilege-level 這個概念是 Segment protection 的,
現(xiàn)在推薦用  page protection 的,那么 ring 這個概念基本不相干了.

猜的.
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP