Kernel error: IRQ remapping doesn't support X2APIC mode, disabled x2apic
Kernel error: IRQ remapping doesn't support X2APIC mode, disabled x2apic
我需要在 Intel(R) Xeon(R) CPU E3-1225 v5 @ 3.30GHz 上启用 x2apic,我发现 cpuinfo 支持 x2apic:
但是当内核启动时,我发现错误信息:
[0.138328]IRQ 重映射不支持 X2APIC 模式,禁用 x2apic。
我检查了我的内核配置:
CONFIG_X86_X2APIC=y
我该怎么做才能解决这个问题?
/proc/cpuinfo 中的 x2apic 显示了您的 CPU 芯片的功能。
当存在无法为所需模式启用 x2apic 模式的环境时,内核函数 `try_to_enable_x2apic() 会生成消息 "IRQ remapping doesn't support X2APIC mode, disable x2apic"。当前代码是
static __init void try_to_enable_x2apic(int remap_mode)
{
if (x2apic_state == X2APIC_DISABLED)
return;
if (remap_mode != IRQ_REMAP_X2APIC_MODE) {
/* IR is required if there is APIC ID > 255 even when running
* under KVM
*/
if (max_physical_apicid > 255 ||
!x86_init.hyper.x2apic_available()) {
pr_info("x2apic: IRQ remapping doesn't support X2APIC mode\n");
x2apic_disable();
return;
}
/*
* without IR all CPUs can be addressed by IOAPIC/MSI
* only in physical mode
*/
x2apic_phys = 1;
}
x2apic_enable();
}
从 arch/x86/kernel/apic/apic.c 文件的 enable_IR_x2apic(void)
中调用:
ir_stat = irq_remapping_prepare();
if (ir_stat < 0 && !x2apic_supported())
return;
...
/* If irq_remapping_prepare() succeeded, try to enable it */
if (ir_stat >= 0)
ir_stat = irq_remapping_enable();
/* ir_stat contains the remap mode or an error code */
try_to_enable_x2apic(ir_stat);
2015年`try_to_enable_x2apic()功能有一些补丁https://lore.kernel.org/patchwork/patch/533651/和 https://lore.kernel.org/patchwork/patch/533496/; 2013 年引入代码路径 https://groups.google.com/forum/#!msg/fa.linux 时,有大量邮件列表 theread。 kernel/uD28wv9Inhg/KHgAvvkA0d4J
x86/apic: Only disable CPU x2apic mode when necessary
When interrupt remapping hardware is not in X2APIC, CPU X2APIC mode
will be disabled if:
- 1) Maximum CPU APIC ID is bigger than 255
- 2) hypervisior doesn't support x2apic mode.
您应该检查您的管理程序(如果使用)和 irq 重新映射方法。可以有来自 intel_enable_irq_remapping - https://elixir.bootlin.com/linux/latest/source/drivers/iommu/intel_irq_remapping.c#L827
的 "Enabled IRQ remapping in" pr_info 消息
我个人认为此错误消息具有误导性。
内容:IRQ remapping doesn't support X2APIC mode, disable x2apic.
实际含义:IRQ remapping isn't enabled, so x2APIC was disabled.
解决方法是开启IRQ重映射。在内核配置中设置 CONFIG_IRQ_REMAP=y
并重新编译它。
x2APIC 要求启用 IOMMU 并启用 IRQ 重新映射。
- 在 BIOS 中启用 IOMMU。 (它在许多系统上默认被禁用。即使在我全新的(2020 年 7 月)配备 EPYC 7742 CPU 的技嘉 R282-Z93 上也是如此!)
- 在 BIOS 中启用 x2APIC。
- 在内核中启用 IOMMU 支持:
- 对于英特尔 CPU:
CONFIG_INTEL_IOMMU=y
- 对于 AMD CPU:
CONFIG_AMD_IOMMU=y
和 CONFIG_AMD_IOMMU_V2=y
- 在内核中启用 x2APIC 支持:
CONFIG_X86_X2APIC=y
- 在内核中启用 IRQ 重新映射:
CONFIG_IRQ_REMAP=y
因此,如果 x2APIC 需要 IRQ 重新映射,那么究竟如何才能得到一个具有 x2APIC 支持但没有 IRQ 重新映射的内核?好吧,如果您查看 CONFIG_X86_X2APIC 的依赖项,您会发现它需要 X86_LOCAL_APIC && X86_64 && (IRQ_REMAP || HYPERVISOR_GUEST)
因此,如果您的内核构建为在管理程序下支持 运行,那么您很可能无法启用 IRQ 重新映射选项。 (我正是这样做的。糟糕!在我为“IRQ 重新映射不支持 X2APIC 模式,禁用 x2apic”消息搜索内核源代码之前,弄清楚出了什么问题是非常令人困惑的,此时它变得相对简单明了解决问题。)
我需要在 Intel(R) Xeon(R) CPU E3-1225 v5 @ 3.30GHz 上启用 x2apic,我发现 cpuinfo 支持 x2apic:
但是当内核启动时,我发现错误信息:
[0.138328]IRQ 重映射不支持 X2APIC 模式,禁用 x2apic。
我检查了我的内核配置:
CONFIG_X86_X2APIC=y
我该怎么做才能解决这个问题?
x2apic 显示了您的 CPU 芯片的功能。 当存在无法为所需模式启用 x2apic 模式的环境时,内核函数 `try_to_enable_x2apic() 会生成消息 "IRQ remapping doesn't support X2APIC mode, disable x2apic"。当前代码是
static __init void try_to_enable_x2apic(int remap_mode)
{
if (x2apic_state == X2APIC_DISABLED)
return;
if (remap_mode != IRQ_REMAP_X2APIC_MODE) {
/* IR is required if there is APIC ID > 255 even when running
* under KVM
*/
if (max_physical_apicid > 255 ||
!x86_init.hyper.x2apic_available()) {
pr_info("x2apic: IRQ remapping doesn't support X2APIC mode\n");
x2apic_disable();
return;
}
/*
* without IR all CPUs can be addressed by IOAPIC/MSI
* only in physical mode
*/
x2apic_phys = 1;
}
x2apic_enable();
}
从 arch/x86/kernel/apic/apic.c 文件的 enable_IR_x2apic(void)
中调用:
ir_stat = irq_remapping_prepare();
if (ir_stat < 0 && !x2apic_supported())
return;
...
/* If irq_remapping_prepare() succeeded, try to enable it */
if (ir_stat >= 0)
ir_stat = irq_remapping_enable();
/* ir_stat contains the remap mode or an error code */
try_to_enable_x2apic(ir_stat);
2015年`try_to_enable_x2apic()功能有一些补丁https://lore.kernel.org/patchwork/patch/533651/和 https://lore.kernel.org/patchwork/patch/533496/; 2013 年引入代码路径 https://groups.google.com/forum/#!msg/fa.linux 时,有大量邮件列表 theread。 kernel/uD28wv9Inhg/KHgAvvkA0d4J
x86/apic: Only disable CPU x2apic mode when necessary
When interrupt remapping hardware is not in X2APIC, CPU X2APIC mode will be disabled if:
- 1) Maximum CPU APIC ID is bigger than 255
- 2) hypervisior doesn't support x2apic mode.
您应该检查您的管理程序(如果使用)和 irq 重新映射方法。可以有来自 intel_enable_irq_remapping - https://elixir.bootlin.com/linux/latest/source/drivers/iommu/intel_irq_remapping.c#L827
的 "Enabled IRQ remapping in" pr_info 消息我个人认为此错误消息具有误导性。
内容:IRQ remapping doesn't support X2APIC mode, disable x2apic.
实际含义:IRQ remapping isn't enabled, so x2APIC was disabled.
解决方法是开启IRQ重映射。在内核配置中设置 CONFIG_IRQ_REMAP=y
并重新编译它。
x2APIC 要求启用 IOMMU 并启用 IRQ 重新映射。
- 在 BIOS 中启用 IOMMU。 (它在许多系统上默认被禁用。即使在我全新的(2020 年 7 月)配备 EPYC 7742 CPU 的技嘉 R282-Z93 上也是如此!)
- 在 BIOS 中启用 x2APIC。
- 在内核中启用 IOMMU 支持:
- 对于英特尔 CPU:
CONFIG_INTEL_IOMMU=y
- 对于 AMD CPU:
CONFIG_AMD_IOMMU=y
和CONFIG_AMD_IOMMU_V2=y
- 对于英特尔 CPU:
- 在内核中启用 x2APIC 支持:
CONFIG_X86_X2APIC=y
- 在内核中启用 IRQ 重新映射:
CONFIG_IRQ_REMAP=y
因此,如果 x2APIC 需要 IRQ 重新映射,那么究竟如何才能得到一个具有 x2APIC 支持但没有 IRQ 重新映射的内核?好吧,如果您查看 CONFIG_X86_X2APIC 的依赖项,您会发现它需要 X86_LOCAL_APIC && X86_64 && (IRQ_REMAP || HYPERVISOR_GUEST)
因此,如果您的内核构建为在管理程序下支持 运行,那么您很可能无法启用 IRQ 重新映射选项。 (我正是这样做的。糟糕!在我为“IRQ 重新映射不支持 X2APIC 模式,禁用 x2apic”消息搜索内核源代码之前,弄清楚出了什么问题是非常令人困惑的,此时它变得相对简单明了解决问题。)