从内核模块中查找异常向量表的物理地址 [英] Find the physical address of exception vector table from kernel module

查看:23
本文介绍了从内核模块中查找异常向量表的物理地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 android 设备 - 内核版本为 2.6.35.14 (arm cortex a9) 的三星galaxy s2

I have an android device - Samsung galaxy s2 with kernel version 2.6.35.14 (arm cortex a9)

我试图找到异常向量表的物理地址.我知道它位于 0xffff0000 虚拟地址.(我可以通过内核模块打印它的值)

I tried to find the physical address of the exception vector table. I Know that it is at 0xffff0000 virtual address. (i can print its value via kernel module)

我也知道大部分内核虚拟地址(到物理地址)的转换是由值 0x8000000 的变电站完成的.

I also know that the translation of most of the kernel virtual address (to physical) is done by substation of the value 0x8000000.

我有一个可以直接从设备内存读取数据的设备,我想获取异常向量表.

I have a device that can read data directly from devices memory and i want to get the exception vector table.

当我构建内核模块并尝试使用宏 virt_to_phys(0xffff0000) 时,我得到了一些地址,但该表不存在.我以这种方式成功找到了系统调用表,但这里宏给了我错误的地址.

when i built a kernel module and tried to use the macro virt_to_phys(0xffff0000) i have got some address but the table is not there. i succeed to find in this way the system call table but here the macro gave me wrong address.

有谁知道为什么会这样?异常向量表的地址是否驻留在特殊的物理地址中?内核是否以某种特殊方式转换其地址?

Does anyone know why this happens? does the address of the exception vector table resides in a special physical address? Does the kernel translates its address in some special way?

谢谢!!

推荐答案

也可以直接使用 MMU(寄存器 ATS1Cxx 和 PAR)进行 V=>P 转换.请参阅 ARM ARM 的 B4.2.4 部分对于血腥的细节.

It is also possible to use the MMU directly (registers ATS1Cxx and PAR) to perform V=>P translation. See section B4.2.4 of the ARM ARM for the gory details.

如果您以这种方式使用 MMU 寄存器,您可能需要防止与寄存器的其他用途发生竞争.

If you use the MMU registers this way, you might need to protect against races with other uses of the registers.

这可以通过以下代码从任何内核驱动程序访问,

This maybe accessed from any kernel driver with the following code,

 unsigned int pa;
 asm("\t mcr p15, 0, %0, c7, c8, 2\n"
     "\t isb\n"
     "\t mrc p15, 0, %0, c7, c4, 0\n" : "=r" (pa) : "0" (0xffff0000));
 printk("Vector is %x\n", pa & 0xfffff000);

常量是正确的.

  • 0xffff0000 是高向量虚拟地址.
  • 0xfffff000 是 4k 页面的掩码.

这仅适用于后续系列的 ARM 处理器,例如 Cortex 系列.

This works only on later series ARM processors such as the Cortex series.

这篇关于从内核模块中查找异常向量表的物理地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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