如题,多核浸染代码如下:
// 多核浸染
KeGenericCallDpc(synchronization_infection, NULL);
BOOLEAN
synchronization_infection(KDPC* dpc,
PVOID
deferred_context,
system_arg1,
system_arg2)
{
ULONG
cpu_id = KeGetCurrentProcessorIndex();
struct
__vcpu* vcpu = (
__vcpu*)(&vcpu_info.vcpu_info_table[cpu_id]);
// 初始化vmcs并执行vmlaunch
init_vcpu(vcpu, cpu_id);
// Wait for all DPCs to synchronize at this point
KeSignalCallDpcSynchronize(system_arg2);
// Mark the DPC as being complete
KeSignalCallDpcDone(system_arg1);
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL,
"[ok] cpu-%d synchronization infection completed.\n"
, vcpu->cpu_id);
return
TRUE;
}
经过测试发现,1/2/3/6核时可正常实现多核浸染,但当核心数为4/8时卡死。
处理器核心数为2时,正常实现虚拟化。
处理器核心数为4时,执行init_vcpu卡死。
当前物理机CPU为4核8线程,使用VMware® Workstation 17 Pro。为什么会出现这样的问题?懂的大牛指点一下,谢谢!
[培训]《冰与火的战歌:Windows内核攻防实战》!从零到实战,融合AI与Windows内核攻防全技术栈,打造具备自动化能力的内核开发高手。
是不是内存对齐的问题,你的init_vcpu内部分配VMCS时是不是使用了ExAllocatePool2导致内存没有4K对齐,导致vmlaunch行为异常,如果是的话,建议使用MmAllocateContiguousMemory,建议把init_vcpu详细代码给出来,附注是intel sdm