在内核初始化期间写入 per-cpu 变量物理地址
Writing per-cpu variables physical address during kernel initialization
我有以下代码:
static DEFINE_PER_CPU_ALIGNED(cpu_clock_t, cpu_clock);
static void func(void *info)
{
uint64_t cpu_clock_pa = per_cpu_ptr_to_phys(get_cpu_ptr(&cpu_clock));
__asm__ __volatile__ ... //Giving the PA to VMware kernel which is supposed to write something to there
put_cpu_ptr(cpu_clock);
}
问题是,当这段代码作为内核初始化的一部分运行时,我在 VMware 工作站 "The CPU is disabled on the guest operating system" 中收到一条消息,这意味着发生了一些内核崩溃,当我在内核启动后使用相同的代码时(调用它作为模块初始化的一部分)它工作正常...
正如 a3f 指出的那样,我的代码是 运行 在 setup_per_cpu_areas
之前。
我有以下代码:
static DEFINE_PER_CPU_ALIGNED(cpu_clock_t, cpu_clock);
static void func(void *info)
{
uint64_t cpu_clock_pa = per_cpu_ptr_to_phys(get_cpu_ptr(&cpu_clock));
__asm__ __volatile__ ... //Giving the PA to VMware kernel which is supposed to write something to there
put_cpu_ptr(cpu_clock);
}
问题是,当这段代码作为内核初始化的一部分运行时,我在 VMware 工作站 "The CPU is disabled on the guest operating system" 中收到一条消息,这意味着发生了一些内核崩溃,当我在内核启动后使用相同的代码时(调用它作为模块初始化的一部分)它工作正常...
正如 a3f 指出的那样,我的代码是 运行 在 setup_per_cpu_areas
之前。