From 1012e254ccdf816ecea16accef3f4a8dc5a48041 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Wed, 6 Jan 2021 21:16:24 +0100 Subject: [PATCH] arch/x86: PCIE MSI address and data may be out of remapping In fact, in case of VT-D being enabled, it will require to get an address and data for its own MSI based interrupts which cannot be remapped (i.e.: will directly go to the relevant APIC). This is necessary to get the Fault event supported in VT-D. Signed-off-by: Tomasz Bursztyka --- arch/x86/core/pcie.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/x86/core/pcie.c b/arch/x86/core/pcie.c index 290e6a4a8d2..add79e3009d 100644 --- a/arch/x86/core/pcie.c +++ b/arch/x86/core/pcie.c @@ -187,24 +187,28 @@ uint32_t pcie_msi_map(unsigned int irq, ARG_UNUSED(irq); #if defined(CONFIG_INTEL_VTD_ICTL) - return vtd_remap_msi(vtd, vector, n_vector); -#else - return 0xFEE00000U; /* standard delivery to BSP local APIC */ + if (vector != NULL && n_vector > 0) { + return vtd_remap_msi(vtd, vector, n_vector); + } #endif + return 0xFEE00000U; /* standard delivery to BSP local APIC */ } uint16_t pcie_msi_mdr(unsigned int irq, msi_vector_t *vector) { - if (IS_ENABLED(CONFIG_INTEL_VTD_ICTL)) { - return 0; - } + if (vector != NULL) { + if (IS_ENABLED(CONFIG_INTEL_VTD_ICTL)) { + return 0; + } #if defined(CONFIG_PCIE_MSI_X) - if (vector->msix) { - return 0x4000U | vector->arch.vector; - } + if (vector->msix) { + return 0x4000U | vector->arch.vector; + } #endif + } + return 0x4000U | Z_IRQ_TO_INTERRUPT_VECTOR(irq); }