• [轉]关于CR0.WP


    关于CR0.WP

    我们知道CR0的WP位可以关闭内核写保护。他和页表的R/W位有关。Intel手册中的描述绕来绕去似乎一直没有说到重点。

    When the processor is in supervisor mode and the WP flag in register CR0 is clear (its 
    state following reset initialization), all pages are both readable and writable (write-
    protection is ignored). When the processor is in user mode, it can write only to user-
    mode pages that are read/write accessible. User-mode pages which are read/write or 
    read-only are readable; supervisor-mode pages are neither readable nor writable 
    from user mode. A page-fault exception is generated on any attempt to violate the 
    protection rules.
    Starting with the P6 family, Intel processors allow user-mode pages to be write-
    protected against supervisor-mode access. Setting CR0.WP = 1 enables supervisor-
    mode sensitivity to user-mode, write protected pages. Supervisor pages which are 
    read-only are not writable from any privilege level (if CR0.WP = 1). This supervisor 
    write-protect feature is useful for implementing a “copy-on-write” strategy used by 
    some operating systems, such as UNIX*, for task creation (also called forking or 
    spawning). When a new task is created, it is possible to copy the entire address space 
    of the parent task. This gives the child task a complete, duplicate set of the parent's 
    segments and pages. An alternative copy-on-write strategy saves memory space and 
    time by mapping the child's segments and pages to the same segments and pages 
    used by the parent task. A private copy of a page gets created only when one of the 
    tasks writes to the page. By using the WP flag and marking the shared pages as read-
    only, the supervisor can detect an attempt to write to a user-level page, and can copy 
    the page at that time.

    经过试验明白了WP位的作用。

    WP位是Supervisor的写保护位 (CPL < 3是Supervisor)

    当WP = 1时,Supervisor不能写R/W没有置位的页。

    WP = 0时,Supervisor可以写任何页。

    对于User (CPL = 3), 无论WP是什么,都不能写R/W没有置位的页。所以User无论怎么样都是二等公民。

  • 相关阅读:
    实现ls(课上作业)
    20181217 (2)
    20181217 (1)
    ubuntu开启远程ssh登陆本机功能
    解决ubuntu下Could not get lock的问题
    博客园生成目录结构
    np.mean以及np.std用法
    解决 Could not find a version that satisfies the requirement torch==1.4.0
    github下载ocr模型 windows直接解压出问题
    centos7 连接不上网络解决办法
  • 原文地址:https://www.cnblogs.com/bittorrent/p/3328238.html
Copyright © 2020-2023  润新知