禁用L2/L1缓存 [英] Disable L2/L1 caches

查看:110
本文介绍了禁用L2/L1缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试禁用CPU的内部和外部内存缓存,我的配置如上所述: -戴尔精密工作站 -Intel Core 2 Duo E6550 2.33 GHz -Ubuntu 8.10

I am trying to disable the internal and external memory cache of my CPU, my configuration is above: -DELL Precision WorkStation -Intel Core 2 Duo E6550 2.33 GHz -Ubuntu 8.10

我试图通过BIOS禁用它,但它表明DELL计算机不允许用户访问缓存,然后我发现了另一种方法,即以编程方式禁用缓存,《英特尔架构手册》 A.3指出可以通过将bit 30设置为cr0寄存器来禁用高速缓存,然后我编写了上面的代码:

I've tried to disable it through BIOS, but it apears that DELL computers doesn't let users to access cache memory, I found then another way, it is to disable cache programmaticaly, Intel Architecture manual A.3 indicates that cr0 register can be set to disable cache by setting bit 30, i wrote the above code then :

invd

mov eax,cr0

mov eax,cr0

mov eax,40000000H;设置位30

mov eax,40000000H ;set bit 30

mov cr0,eax

mov cr0,eax

该程序已成功编译,但是当我尝试运行exe文件时,它出现了段错误(我正在使用NASM)

The program compiled successfully, but when I try to run exe file,it Seg Faults (i'm using NASM)

有人可以帮助我吗?

推荐答案

请注意,即使由于您位于内核中或以保护模式在DOS上运行您的工具而处于环0中,也会移动 0x40000000 cr0 肯定会造成灾难.您会看到,控制寄存器(cr0)控制着影响处理器运行方式的各种因素,例如启用分页,保护模式(不是直接启用)等.如果取消所有这些位的设置,结果将完全不同如果您先前启用了分页功能,那么在环境和出现分段错误方面就不足为奇了.

Please note that even if you're in ring 0 because you're in the kernel or run your tool on DOS in protected mode etc, moving 0x40000000 to cr0 will definitely cause a disaster. You see, the control register (cr0) controls all sorts of things that effect the way the processor operates, such as enabling paging, protected mode (not directly) etc. If you unset all those bits, you will end up in a totally different environment and getting a segmentation fault is not surprising at all if you had paging enabled previously.

您应该改为这样做:

mov eax,cr0
or eax, 40000000H ;set bit 30 without clearing the others
mov cr0,eax

这篇关于禁用L2/L1缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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