强制Linux在4G上仅使用内存? [英] Force Linux to use only memory over 4G?

查看:185
本文介绍了强制Linux在4G上仅使用内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Linux设备驱动程序,该设备连接到一个理论上可以使用64位地址执行DMA的设备.我想测试一下是否可以正常工作.

I have a Linux device driver that interfaces to a device that, in theory, can perform DMA using 64-bit addresses. I'd like to test to see that this actually works.

是否有一种简单的方法可以强制Linux机器不使用物理地址4G以下的任何内存?如果内核映像在内存不足的情况下就可以了.我只想能够强制我知道所有动态分配的缓冲区,而为我分配的任何内核或用户缓冲区都无法以32位寻址的情况.这是蛮力的,但是比我能想到的任何东西都要全面.

Is there a simple way that I can force a Linux machine not to use any memory below physical address 4G? It's OK if the kernel image is in low memory; I just want to be able to force a situation where I know all my dynamically allocated buffers, and any kernel or user buffers allocated for me are not addressable in 32 bits. This is a little brute force, but would be more comprehensive than anything else I can think of.

这应该可以帮助我捕获(1)未正确配置或未加载完整地址(或只是普通损坏)的硬件,以及(2)意外和不必要地使用退回缓冲区(因为无处退回) ).

This should help me catch (1) hardware that wasn't configured correctly or loaded with the full address (or is just plain broken) as well as (2) accidental and unnecessary use of bounce buffers (because there's nowhere to bounce to).

说明:我正在运行x86_64,所以我不关心大多数旧的32位寻址问题.我只想测试驱动程序可以使用64位物理地址正确地与众多缓冲区接口.

clarification: I'm running x86_64, so I don't care about most of the old 32-bit addressing issues. I just want to test that a driver can correctly interface with multitudes of buffers using 64-bit physical addresses.

推荐答案

/usr /src/linux/Documentation/kernel-parameters.txt

        memmap=exactmap [KNL,X86] Enable setting of an exact
                        E820 memory map, as specified by the user.
                        Such memmap=exactmap lines can be constructed based on
                        BIOS output or other requirements. See the memmap=nn@ss
                        option description.

        memmap=nn[KMG]@ss[KMG]
                        [KNL] Force usage of a specific region of memory
                        Region of memory to be used, from ss to ss+nn.

        memmap=nn[KMG]#ss[KMG]
                        [KNL,ACPI] Mark specific memory as ACPI data.
                        Region of memory to be used, from ss to ss+nn.

        memmap=nn[KMG]$ss[KMG]
                        [KNL,ACPI] Mark specific memory as reserved.
                        Region of memory to be used, from ss to ss+nn.
                        Example: Exclude memory from 0x18690000-0x1869ffff
                                 memmap=64K$0x18690000
                                 or
                                 memmap=0x10000$0x18690000

如果将memmap=4G$0添加到内核的引导参数,则将无法再访问较低的4GB物理内存.另外,您的系统将不再引导...但是其中的一些变化(memmap=3584M$512M?)可能会允许4GB以下的足够内存供系统引导,但不足以在其中分配驱动程序的DMA缓冲区.

If you add memmap=4G$0 to the kernel's boot parameters, the lower 4GB of physical memory will no longer be accessible. Also, your system will no longer boot... but some variation hereof (memmap=3584M$512M?) may allow for enough memory below 4GB for the system to boot but not enough that your driver's DMA buffers will be allocated there.

这篇关于强制Linux在4G上仅使用内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆