Re: [PATCH] iommu/vt-d: Fix modify_irte NULL pointer
From: Wanpeng Li
Date: Mon Aug 22 2016 - 09:33:37 EST
2016-08-22 20:38 GMT+08:00 Thomas Gleixner <tglx@xxxxxxxxxxxxx>:
> On Mon, 22 Aug 2016, Wanpeng Li wrote:
>
>> From: Wanpeng Li <wanpeng.li@xxxxxxxxxxx>
>>
>> native_smp_prepare_cpus
>> -> default_setup_apic_routing
>> -> enable_IR_x2apic
>> -> irq_remapping_prepare
>> -> intel_prepare_irq_remapping
>> -> parse_ioapics_under_ir => return 0
>> -> ir_parse_ioapic_hpet_scope
>> -> ir_parse_one_ioapic_scope
>> -> intel_setup_irq_remapping
>
>> IR table is setup even if noapic boot parameter is added.
>> index ac59692..f1cb7c6 100644
>> --- a/drivers/iommu/intel_irq_remapping.c
>> +++ b/drivers/iommu/intel_irq_remapping.c
>> @@ -854,6 +854,9 @@ static int ir_parse_one_ioapic_scope(struct acpi_dmar_device_scope *scope,
>> count = (scope->length - sizeof(struct acpi_dmar_device_scope))
>> / sizeof(struct acpi_dmar_pci_path);
>>
>> + if (skip_ioapic_setup)
>> + return -ENODEV;
>
> Why are you adding this in the iommu code? We should not call any of the apic
> functions when apic is disabled.
Good point, how about something like this(untested, I will test it tomorrow):
diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
index 7c43e71..152d627 100644
--- a/arch/x86/kernel/apic/probe_32.c
+++ b/arch/x86/kernel/apic/probe_32.c
@@ -154,6 +154,9 @@ void __init default_setup_apic_routing(void)
{
int version = apic_version[boot_cpu_physical_apicid];
+ if (skip_ioapic_setup)
+ return;
+
if (num_possible_cpus() > 8) {
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_INTEL:
diff --git a/arch/x86/kernel/apic/probe_64.c b/arch/x86/kernel/apic/probe_64.c
index c303054..ffc3ae2 100644
--- a/arch/x86/kernel/apic/probe_64.c
+++ b/arch/x86/kernel/apic/probe_64.c
@@ -29,6 +29,9 @@ void __init default_setup_apic_routing(void)
{
struct apic **drv;
+ if (skip_ioapic_setup)
+ return;
+
enable_IR_x2apic();
Regards,
Wanpeng Li