mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 07:35:36 -05:00
Luigi reported that retriggering a posted MSI interrupt does not work
correctly.
The reason is that the retrigger happens at the vector domain by sending an
IPI to the actual vector on the target CPU. That works correctly exactly
once because the posted MSI interrupt chip does not issue an EOI as that's
only required for the posted MSI notification vector itself.
As a consequence the vector becomes stale in the ISR, which not only
affects this vector but also any lower priority vector in the affected
APIC because the ISR bit is not cleared.
Luigi proposed to set the vector in the remap PIR bitmap and raise the
posted MSI notification vector. That works, but that still does not cure a
related problem:
If there is ever a stray interrupt on such a vector, then the related
APIC ISR bit becomes stale due to the lack of EOI as described above.
Unlikely to happen, but if it happens it's not debuggable at all.
So instead of playing games with the PIR, this can be actually solved
for both cases by:
1) Keeping track of the posted interrupt vector handler state
2) Implementing a posted MSI specific irq_ack() callback which checks that
state. If the posted vector handler is inactive it issues an EOI,
otherwise it delegates that to the posted handler.
This is correct versus affinity changes and concurrent events on the posted
vector as the actual handler invocation is serialized through the interrupt
descriptor lock.
Fixes: ed1e48ea43 ("iommu/vt-d: Enable posted mode for device MSIs")
Reported-by: Luigi Rizzo <lrizzo@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Luigi Rizzo <lrizzo@google.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20251125214631.044440658@linutronix.de
Closes: https://lore.kernel.org/lkml/20251124104836.3685533-1-lrizzo@google.com
98 lines
2.5 KiB
C
98 lines
2.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2012 Advanced Micro Devices, Inc.
|
|
* Author: Joerg Roedel <joerg.roedel@amd.com>
|
|
*
|
|
* This header file contains the interface of the interrupt remapping code to
|
|
* the x86 interrupt management code.
|
|
*/
|
|
|
|
#ifndef __X86_IRQ_REMAPPING_H
|
|
#define __X86_IRQ_REMAPPING_H
|
|
|
|
#include <asm/irqdomain.h>
|
|
#include <asm/hw_irq.h>
|
|
#include <asm/io_apic.h>
|
|
|
|
struct msi_msg;
|
|
struct irq_alloc_info;
|
|
|
|
enum irq_remap_cap {
|
|
IRQ_POSTING_CAP = 0,
|
|
};
|
|
|
|
enum {
|
|
IRQ_REMAP_XAPIC_MODE,
|
|
IRQ_REMAP_X2APIC_MODE,
|
|
};
|
|
|
|
/*
|
|
* This is mainly used to communicate information back-and-forth
|
|
* between SVM and IOMMU for setting up and tearing down posted
|
|
* interrupt
|
|
*/
|
|
struct amd_iommu_pi_data {
|
|
u64 vapic_addr; /* Physical address of the vCPU's vAPIC. */
|
|
u32 ga_tag;
|
|
u32 vector; /* Guest vector of the interrupt */
|
|
int cpu;
|
|
bool ga_log_intr;
|
|
bool is_guest_mode;
|
|
void *ir_data;
|
|
};
|
|
|
|
struct intel_iommu_pi_data {
|
|
u64 pi_desc_addr; /* Physical address of PI Descriptor */
|
|
u32 vector; /* Guest vector of the interrupt */
|
|
};
|
|
|
|
#ifdef CONFIG_IRQ_REMAP
|
|
|
|
extern raw_spinlock_t irq_2_ir_lock;
|
|
|
|
extern bool irq_remapping_cap(enum irq_remap_cap cap);
|
|
extern void set_irq_remapping_broken(void);
|
|
extern int irq_remapping_prepare(void);
|
|
extern int irq_remapping_enable(void);
|
|
extern void irq_remapping_disable(void);
|
|
extern int irq_remapping_reenable(int);
|
|
extern int irq_remap_enable_fault_handling(void);
|
|
extern void panic_if_irq_remap(const char *msg);
|
|
|
|
/* Get parent irqdomain for interrupt remapping irqdomain */
|
|
static inline struct irq_domain *arch_get_ir_parent_domain(void)
|
|
{
|
|
return x86_vector_domain;
|
|
}
|
|
|
|
extern bool enable_posted_msi;
|
|
|
|
static inline bool posted_msi_supported(void)
|
|
{
|
|
return enable_posted_msi && irq_remapping_cap(IRQ_POSTING_CAP);
|
|
}
|
|
|
|
#else /* CONFIG_IRQ_REMAP */
|
|
|
|
static inline bool irq_remapping_cap(enum irq_remap_cap cap) { return 0; }
|
|
static inline void set_irq_remapping_broken(void) { }
|
|
static inline int irq_remapping_prepare(void) { return -ENODEV; }
|
|
static inline int irq_remapping_enable(void) { return -ENODEV; }
|
|
static inline void irq_remapping_disable(void) { }
|
|
static inline int irq_remapping_reenable(int eim) { return -ENODEV; }
|
|
static inline int irq_remap_enable_fault_handling(void) { return -ENODEV; }
|
|
|
|
static inline void panic_if_irq_remap(const char *msg)
|
|
{
|
|
}
|
|
|
|
#endif /* CONFIG_IRQ_REMAP */
|
|
|
|
#ifdef CONFIG_X86_POSTED_MSI
|
|
void intel_ack_posted_msi_irq(struct irq_data *irqd);
|
|
#else
|
|
#define intel_ack_posted_msi_irq NULL
|
|
#endif
|
|
|
|
#endif /* __X86_IRQ_REMAPPING_H */
|