arch/x86: Fix MSI MAP destination

When Zephyr runs directly on actual hardware, it will be always
directing MSI messages to BSP (BootStrap Processor). This was fine until
Zephyr could be ran on virtualizor that may NOT run it on BSP.

So directing MSI messages on current processor. If Zephyr runs on actual
hardware, it will be BSP since such setup is always made at boot time by
the BSP. On other use case it will be whatever is relevant at that time.

Fixes #43853

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2022-02-04 10:28:13 +01:00 committed by Christopher Friedt
parent a807fff085
commit 063dbecb23
1 changed files with 15 additions and 2 deletions

View File

@ -16,6 +16,8 @@
#include <kernel_arch_func.h>
#include <device.h>
#include <drivers/pcie/msi.h>
#include <drivers/interrupt_controller/sysapic.h>
#include <arch/x86/cpuid.h>
#endif
/* PCI Express Extended Configuration Mechanism (MMIO) */
@ -179,12 +181,15 @@ static bool get_vtd(void)
/* these functions are explained in include/drivers/pcie/msi.h */
#define MSI_MAP_DESTINATION_ID_SHIFT 12
#define MSI_RH BIT(3)
uint32_t pcie_msi_map(unsigned int irq,
msi_vector_t *vector)
{
uint32_t map;
ARG_UNUSED(irq);
#if defined(CONFIG_INTEL_VTD_ICTL)
#if !defined(CONFIG_PCIE_MSI_X)
if (vector != NULL) {
@ -197,7 +202,15 @@ uint32_t pcie_msi_map(unsigned int irq,
#endif
#endif
{
map = 0xFEE00000U; /* standard delivery to BSP local APIC */
uint32_t dest_id;
dest_id = z_x86_cpuid_get_current_physical_apic_id() <<
MSI_MAP_DESTINATION_ID_SHIFT;
/* Directing to current physical CPU (may not be BSP)
* Destination ID - RH 1 - DM 0
*/
map = 0xFEE00000U | dest_id | MSI_RH;
}
return map;