Documentation/x86/pat.txt
2013-10-18 10:45
316 查看
Chinese translated version of Documentation/x86/pat.txt
If you have any comment or update to the content, please contact the
original document maintainer directly. However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help. Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.
Chinese maintainer: 尹娇萍 1072986620@qq.com
---------------------------------------------------------------------
Documentation/x86/pat.txt 的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 尹娇萍 1072986620@qq.com
中文版翻译者: 尹娇萍 1072986620@qq.com
中文版校译者: 尹娇萍 1072986620@qq.com
以下为正文
---------------------------------------------------------------------
PAT (Page Attribute Table)
PAT(页面属性表)
x86 Page Attribute Table (PAT) allows for setting the memory attribute at the
page level granularity. PAT is complementary to the MTRR settings which allows
for setting of memory types over physical address ranges. However, PAT is
more flexible than MTRR due to its capability to set attributes at page level
and also due to the fact that there are no hardware limitations on number of
such attribute settings allowed. Added flexibility comes with guidelines for
not having memory type aliasing for the same physical memory with multiple
virtual addresses.
x86的页面属性表(PAT)允许设置页面粒度级别的内存属性。PAT是MTRR设置的互补,允许
设置在物理地址范围内的内存类型。然而,PAT设置属性比MTRR更灵活,因为它能够在页面
级设置,还由于它允许任何数目的硬件限制的属性设置这样的事实。增加的灵活性是指引
那些没有内存类型别名的相同的物理内存到多个虚拟地址。
PAT allows for different types of memory attributes. The most commonly used
ones that will be supported at this time are Write-back, Uncached,
Write-combined and Uncached Minus.
PAT允许用于不同类型的存储器属性。在目前最常用可支持的是写回,未缓存,
写结合和未缓存的减。
PAT APIs
PAT的APIs
--------
There are many different APIs in the kernel that allows setting of memory
attributes at the page level. In order to avoid aliasing, these interfaces
should be used thoughtfully. Below is a table of interfaces available,
their intended usage and their memory attribute relationships. Internally,
these APIs use a reserve_memtype()/free_memtype() interface on the physical
address range to avoid any aliasing.
有许多不同的API在内核中,允许在页级别设置存储器属性。为了避免混淆,应谨慎使
用这些接口。下面是一说明其用途和内存属性的接口关系表。在内部,这些API使用在
物理地址范围内的reserve_memtype()/free_memtype()接口,以避免任何别名。
-------------------------------------------------------------------
API | RAM | ACPI,... | Reserved/Holes |
-----------------------|----------|------------|------------------|
| | | |
ioremap | -- | UC- | UC- |
| | | |
ioremap_cache | -- | WB | WB |
| | | |
ioremap_nocache | -- | UC- | UC- |
| | | |
ioremap_wc | -- | -- | WC |
| | | |
set_memory_uc | UC- | -- | -- |
set_memory_wb | | | |
| | | |
set_memory_wc | WC | -- | -- |
set_memory_wb | | | |
| | | |
pci sysfs resource | -- | -- | UC- |
| | | |
pci sysfs resource_wc | -- | -- | WC |
is IORESOURCE_PREFETCH| | | |
| | | |
pci proc | -- | -- | UC- |
!PCIIOC_WRITE_COMBINE | | | |
| | | |
pci proc | -- | -- | WC |
PCIIOC_WRITE_COMBINE | | | |
| | | |
/dev/mem | -- | WB/WC/UC- | WB/WC/UC- |
read-write | | | |
| | | |
/dev/mem | -- | UC- | UC- |
mmap SYNC flag | | | |
| | | |
/dev/mem | -- | WB/WC/UC- | WB/WC/UC- |
mmap !SYNC flag | |(from exist-| (from exist- |
and | | ing alias)| ing alias) |
any alias to this area| | | |
| | | |
/dev/mem | -- | WB | WB |
mmap !SYNC flag | | | |
no alias to this area | | | |
and | | | |
MTRR says WB | | | |
| | | |
/dev/mem | -- | -- | UC- |
mmap !SYNC flag | | | |
no alias to this area | | | |
and | | | |
MTRR says !WB | | | |
| | | |
-------------------------------------------------------------------
Advanced APIs for drivers
驱动程序的高级API
-------------------------
A. Exporting pages to users with remap_pfn_range, io_remap_pfn_range,
vm_insert_pfn
A.出口页面用户提供remap_pfn_range, io_remap_pfn_range,
vm_insert_pfn
Drivers wanting to export some pages to userspace do it by using mmap
interface and a combination of
1) pgprot_noncached()
2) io_remap_pfn_range() or remap_pfn_range() or vm_insert_pfn()
希望某些页面导出到用户空间的驱动程序使用mmap的界面的组合以及
1) pgprot_noncached()
2) io_remap_pfn_range() or remap_pfn_range() or vm_insert_pfn()
With PAT support, a new API pgprot_writecombine is being added. So, drivers can
continue to use the above sequence, with either pgprot_noncached() or
pgprot_writecombine() in step 1, followed by step 2.
在PAT支持的下,一个新的API被添加pgprot_writecombine。因此,驱动可以继续使用上述
的序列,要么pgprot_noncached()或 pgprot_writecombine()在步骤1中,随后由步骤2。
In addition, step 2 internally tracks the region as UC or WC in memtype
list in order to ensure no conflicting mapping.
此外,第2步内部跟踪区域UC或WC在mem类型列表中,以确保没有冲突的映射。
Note that this set of APIs only works with IO (non RAM) regions. If driver
wants to export a RAM region, it has to do set_memory_uc() or set_memory_wc()
as step 0 above and also track the usage of those pages and use set_memory_wb()
before the page is freed to free pool.
请注意,这组API仅与IO(non RAM)区域有关。如果驱动程序要导出RAM区域,它必须做
set_memory_uc()或set_memory_wc()作为上述步骤0和跟踪使用这些网页使用
set_memory_wb(),在页面被释放到空闲池中之前。
Notes:
注释:
-- in the above table mean "Not suggested usage for the API". Some of the --'s
are strictly enforced by the kernel. Some others are not really enforced
today, but may be enforced in future.
- 上述表格的意思是“不建议使用的API”。 - 是被内核严格执行。有些在现在已经不被真
正执行了,但可能会在今后被强制执行。
For ioremap and pci access through /sys or /proc - The actual type returned
can be more restrictive, in case of any existing aliasing for that address.
For example: If there is an existing uncached mapping, a new ioremap_wc can
return uncached mapping in place of write-combine requested.
对于的ioremap和PCI,通过访问/ sys目录或者/ proc - 在该地址有现有别名情况下返
回的实际类型要更严格。例如:如果有一个现有的未缓存的映射,一个新的ioremap_wc的
返回未缓存映射取代写相结合的要求。
set_memory_[uc|wc] and set_memory_wb should be used in pairs, where driver will
first make a region uc or wc and switch it back to wb after use.
设置内存[UC| WC] set_memory_wb应成对使用,在驱动程序会先做出一个地区UC或WC和使用
后切换回WB。
Over time writes to /proc/mtrr will be deprecated in favor of using PAT based
interfaces. Users writing to /proc/mtrr are suggested to use above interfaces.
随着时间的推移被写入到/ proc/ mtrr以有利于使用PAT基础的接口将不赞成使用。建议
用户写入到/ proc/ mtrr以使用上述接口。
Drivers should use ioremap_[uc|wc] to access PCI BARs with [uc|wc] access
types.
驱动程序应使用ioremap_[UC| WC],访问PCI BARs[UC| WC]访问类型。
Drivers should use set_memory_[uc|wc] to set access type for RAM ranges.
驱动程序应使用set_memory_[UC| WC]来设置RAM范围的访问类型。
PAT debugging
PAT调试
-------------
With CONFIG_DEBUG_FS enabled, PAT memtype list can be examined by
随着CONFIG_DEBUG_FS启用,PAT memtype列表可以被检查根据
# mount -t debugfs debugfs /sys/kernel/debug
# cat /sys/kernel/debug/x86/pat_memtype_list
PAT memtype list:
uncached-minus @ 0x7fadf000-0x7fae0000
uncached-minus @ 0x7fb19000-0x7fb1a000
uncached-minus @ 0x7fb1a000-0x7fb1b000
uncached-minus @ 0x7fb1b000-0x7fb1c000
uncached-minus @ 0x7fb1c000-0x7fb1d000
uncached-minus @ 0x7fb1d000-0x7fb1e000
uncached-minus @ 0x7fb1e000-0x7fb25000
uncached-minus @ 0x7fb25000-0x7fb26000
uncached-minus @ 0x7fb26000-0x7fb27000
uncached-minus @ 0x7fb27000-0x7fb28000
uncached-minus @ 0x7fb28000-0x7fb2e000
uncached-minus @ 0x7fb2e000-0x7fb2f000
uncached-minus @ 0x7fb2f000-0x7fb30000
uncached-minus @ 0x7fb31000-0x7fb32000
uncached-minus @ 0x80000000-0x90000000
This list shows physical address ranges and various PAT settings used to
access those physical address ranges.
此列表显示物理地址范围和用于访问这些物理地址范围的各种PAT设置。
Another, more verbose way of getting PAT related debug messages is with
"debugpat" boot parameter. With this parameter, various debug messages are
printed to dmesg log.
另外,更详细的方式是得到PAT相关的调试消息的“debugpat”启动参数。使用此参数,
各种调试消息被打印在名为dmesg的日志中。
If you have any comment or update to the content, please contact the
original document maintainer directly. However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help. Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.
Chinese maintainer: 尹娇萍 1072986620@qq.com
---------------------------------------------------------------------
Documentation/x86/pat.txt 的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 尹娇萍 1072986620@qq.com
中文版翻译者: 尹娇萍 1072986620@qq.com
中文版校译者: 尹娇萍 1072986620@qq.com
以下为正文
---------------------------------------------------------------------
PAT (Page Attribute Table)
PAT(页面属性表)
x86 Page Attribute Table (PAT) allows for setting the memory attribute at the
page level granularity. PAT is complementary to the MTRR settings which allows
for setting of memory types over physical address ranges. However, PAT is
more flexible than MTRR due to its capability to set attributes at page level
and also due to the fact that there are no hardware limitations on number of
such attribute settings allowed. Added flexibility comes with guidelines for
not having memory type aliasing for the same physical memory with multiple
virtual addresses.
x86的页面属性表(PAT)允许设置页面粒度级别的内存属性。PAT是MTRR设置的互补,允许
设置在物理地址范围内的内存类型。然而,PAT设置属性比MTRR更灵活,因为它能够在页面
级设置,还由于它允许任何数目的硬件限制的属性设置这样的事实。增加的灵活性是指引
那些没有内存类型别名的相同的物理内存到多个虚拟地址。
PAT allows for different types of memory attributes. The most commonly used
ones that will be supported at this time are Write-back, Uncached,
Write-combined and Uncached Minus.
PAT允许用于不同类型的存储器属性。在目前最常用可支持的是写回,未缓存,
写结合和未缓存的减。
PAT APIs
PAT的APIs
--------
There are many different APIs in the kernel that allows setting of memory
attributes at the page level. In order to avoid aliasing, these interfaces
should be used thoughtfully. Below is a table of interfaces available,
their intended usage and their memory attribute relationships. Internally,
these APIs use a reserve_memtype()/free_memtype() interface on the physical
address range to avoid any aliasing.
有许多不同的API在内核中,允许在页级别设置存储器属性。为了避免混淆,应谨慎使
用这些接口。下面是一说明其用途和内存属性的接口关系表。在内部,这些API使用在
物理地址范围内的reserve_memtype()/free_memtype()接口,以避免任何别名。
-------------------------------------------------------------------
API | RAM | ACPI,... | Reserved/Holes |
-----------------------|----------|------------|------------------|
| | | |
ioremap | -- | UC- | UC- |
| | | |
ioremap_cache | -- | WB | WB |
| | | |
ioremap_nocache | -- | UC- | UC- |
| | | |
ioremap_wc | -- | -- | WC |
| | | |
set_memory_uc | UC- | -- | -- |
set_memory_wb | | | |
| | | |
set_memory_wc | WC | -- | -- |
set_memory_wb | | | |
| | | |
pci sysfs resource | -- | -- | UC- |
| | | |
pci sysfs resource_wc | -- | -- | WC |
is IORESOURCE_PREFETCH| | | |
| | | |
pci proc | -- | -- | UC- |
!PCIIOC_WRITE_COMBINE | | | |
| | | |
pci proc | -- | -- | WC |
PCIIOC_WRITE_COMBINE | | | |
| | | |
/dev/mem | -- | WB/WC/UC- | WB/WC/UC- |
read-write | | | |
| | | |
/dev/mem | -- | UC- | UC- |
mmap SYNC flag | | | |
| | | |
/dev/mem | -- | WB/WC/UC- | WB/WC/UC- |
mmap !SYNC flag | |(from exist-| (from exist- |
and | | ing alias)| ing alias) |
any alias to this area| | | |
| | | |
/dev/mem | -- | WB | WB |
mmap !SYNC flag | | | |
no alias to this area | | | |
and | | | |
MTRR says WB | | | |
| | | |
/dev/mem | -- | -- | UC- |
mmap !SYNC flag | | | |
no alias to this area | | | |
and | | | |
MTRR says !WB | | | |
| | | |
-------------------------------------------------------------------
Advanced APIs for drivers
驱动程序的高级API
-------------------------
A. Exporting pages to users with remap_pfn_range, io_remap_pfn_range,
vm_insert_pfn
A.出口页面用户提供remap_pfn_range, io_remap_pfn_range,
vm_insert_pfn
Drivers wanting to export some pages to userspace do it by using mmap
interface and a combination of
1) pgprot_noncached()
2) io_remap_pfn_range() or remap_pfn_range() or vm_insert_pfn()
希望某些页面导出到用户空间的驱动程序使用mmap的界面的组合以及
1) pgprot_noncached()
2) io_remap_pfn_range() or remap_pfn_range() or vm_insert_pfn()
With PAT support, a new API pgprot_writecombine is being added. So, drivers can
continue to use the above sequence, with either pgprot_noncached() or
pgprot_writecombine() in step 1, followed by step 2.
在PAT支持的下,一个新的API被添加pgprot_writecombine。因此,驱动可以继续使用上述
的序列,要么pgprot_noncached()或 pgprot_writecombine()在步骤1中,随后由步骤2。
In addition, step 2 internally tracks the region as UC or WC in memtype
list in order to ensure no conflicting mapping.
此外,第2步内部跟踪区域UC或WC在mem类型列表中,以确保没有冲突的映射。
Note that this set of APIs only works with IO (non RAM) regions. If driver
wants to export a RAM region, it has to do set_memory_uc() or set_memory_wc()
as step 0 above and also track the usage of those pages and use set_memory_wb()
before the page is freed to free pool.
请注意,这组API仅与IO(non RAM)区域有关。如果驱动程序要导出RAM区域,它必须做
set_memory_uc()或set_memory_wc()作为上述步骤0和跟踪使用这些网页使用
set_memory_wb(),在页面被释放到空闲池中之前。
Notes:
注释:
-- in the above table mean "Not suggested usage for the API". Some of the --'s
are strictly enforced by the kernel. Some others are not really enforced
today, but may be enforced in future.
- 上述表格的意思是“不建议使用的API”。 - 是被内核严格执行。有些在现在已经不被真
正执行了,但可能会在今后被强制执行。
For ioremap and pci access through /sys or /proc - The actual type returned
can be more restrictive, in case of any existing aliasing for that address.
For example: If there is an existing uncached mapping, a new ioremap_wc can
return uncached mapping in place of write-combine requested.
对于的ioremap和PCI,通过访问/ sys目录或者/ proc - 在该地址有现有别名情况下返
回的实际类型要更严格。例如:如果有一个现有的未缓存的映射,一个新的ioremap_wc的
返回未缓存映射取代写相结合的要求。
set_memory_[uc|wc] and set_memory_wb should be used in pairs, where driver will
first make a region uc or wc and switch it back to wb after use.
设置内存[UC| WC] set_memory_wb应成对使用,在驱动程序会先做出一个地区UC或WC和使用
后切换回WB。
Over time writes to /proc/mtrr will be deprecated in favor of using PAT based
interfaces. Users writing to /proc/mtrr are suggested to use above interfaces.
随着时间的推移被写入到/ proc/ mtrr以有利于使用PAT基础的接口将不赞成使用。建议
用户写入到/ proc/ mtrr以使用上述接口。
Drivers should use ioremap_[uc|wc] to access PCI BARs with [uc|wc] access
types.
驱动程序应使用ioremap_[UC| WC],访问PCI BARs[UC| WC]访问类型。
Drivers should use set_memory_[uc|wc] to set access type for RAM ranges.
驱动程序应使用set_memory_[UC| WC]来设置RAM范围的访问类型。
PAT debugging
PAT调试
-------------
With CONFIG_DEBUG_FS enabled, PAT memtype list can be examined by
随着CONFIG_DEBUG_FS启用,PAT memtype列表可以被检查根据
# mount -t debugfs debugfs /sys/kernel/debug
# cat /sys/kernel/debug/x86/pat_memtype_list
PAT memtype list:
uncached-minus @ 0x7fadf000-0x7fae0000
uncached-minus @ 0x7fb19000-0x7fb1a000
uncached-minus @ 0x7fb1a000-0x7fb1b000
uncached-minus @ 0x7fb1b000-0x7fb1c000
uncached-minus @ 0x7fb1c000-0x7fb1d000
uncached-minus @ 0x7fb1d000-0x7fb1e000
uncached-minus @ 0x7fb1e000-0x7fb25000
uncached-minus @ 0x7fb25000-0x7fb26000
uncached-minus @ 0x7fb26000-0x7fb27000
uncached-minus @ 0x7fb27000-0x7fb28000
uncached-minus @ 0x7fb28000-0x7fb2e000
uncached-minus @ 0x7fb2e000-0x7fb2f000
uncached-minus @ 0x7fb2f000-0x7fb30000
uncached-minus @ 0x7fb31000-0x7fb32000
uncached-minus @ 0x80000000-0x90000000
This list shows physical address ranges and various PAT settings used to
access those physical address ranges.
此列表显示物理地址范围和用于访问这些物理地址范围的各种PAT设置。
Another, more verbose way of getting PAT related debug messages is with
"debugpat" boot parameter. With this parameter, various debug messages are
printed to dmesg log.
另外,更详细的方式是得到PAT相关的调试消息的“debugpat”启动参数。使用此参数,
各种调试消息被打印在名为dmesg的日志中。
相关文章推荐
- 最大子序列的查找的python 实现
- 关于IBM ServeRaid阵列卡配置的思考
- ubuntu和windows时间不同步的问题解决 双系统安装
- 腾讯软件开发笔试题 武汉
- 我的备份脚本
- 2013年工作中遇到的20个问题:241-260
- 2013年工作中遇到的20个问题:241-260
- 我希望在软件开发生涯初期就知道的 4 件事
- 小项目
- How to detect when the client closes the connection?
- 求助大神:Could not find the main class:
- centos6.0下Error: Connection activation failed: Device not managed by NetworkManager解决办法
- Webview使用总结
- 2013年工作中遇到的20个问题:241-260
- 数据库:SQL Server自增长列的编号
- 最少插入字符
- 动态规划之钢条切割
- android 随手记 170多个示例demo源码
- WPF 4 DataGrid 控件(基本功能篇)
- There is no Action mapped for namespace [] and action name [] associated with context path []