iommu/amd: Add IOMMU event log injection interface for testing event flag decoding logic
PATCH 2/3 iommu/amd: Add IOMMU event log injection interface for testing event flag decoding logic
From: Suravee Suthikulpanit <[email protected]>
Add IOMMU event log injection interface for testing event flag decoding logic. This interface allows users to specify device id, event flag, and event types via debugfs.
echo 0x300 > /sys/kernel/debug/amd-iommu-evninj/devid // (e.g. Bus:Dev.fun 3:0.0) echo 0xfff > /sys/kernel/debug/amd-iommu-evninj/flags // (e.g. Specify flag value)
echo 2 > /sys/kernel/debug/amd-iommu-evninj/type // (e.g. for IO_PAGE_FAULT event)
Once the event is injected, IOMMU driver will parse and print out the event information in kernel log (dmesg) with the various information depending on the types of event and flag specified.
--- drivers/iommu/Kconfig | 9 ++++ drivers/iommu/Makefile | 1 + drivers/iommu/amd_iommu.c | 7 ++- drivers/iommu/amd_iommu_inject.c | 99 ++++++++++++++++++++++++++++++++++++++ drivers/iommu/amd_iommu_proto.h | 9 ++++ 5 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 drivers/iommu/amd_iommu_inject.c
drivers/iommu/Kconfig +9 -0
@@ -64,6 +64,15 @@ config AMD_IOMMU_STATS information to userspace via debugfs. If unsure, say N. +config AMD_IOMMU_EVENT_LOG_INJ + bool "Enable AMID IOMMU event injection interface via debugfs" + depends on AMD_IOMMU + select DEBUG_FS + ---help--- + This option enables code in the AMD IOMMU driver to allow event log + injection for testing IOMMU event log decoding logic via debugfs + If unsure, say N. + config AMD_IOMMU_V2 tristate "AMD IOMMU Version 2 driver" depends on AMD_IOMMU && PROFILING
drivers/iommu/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_OF_IOMMU) += of_iommu.o obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o msm_iommu_dev.o obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o obj-$(CONFIG_AMD_IOMMU_V2) += amd_iommu_v2.o +obj-$(CONFIG_AMD_IOMMU_EVENT_LOG_INJ) += amd_iommu_inject.o obj-$(CONFIG_DMAR_TABLE) += dmar.o obj-$(CONFIG_INTEL_IOMMU) += iova.o intel-iommu.o obj-$(CONFIG_IRQ_REMAP) += intel_irq_remapping.o irq_remapping.o
drivers/iommu/amd_iommu.c +5 -2
@@ -711,7 +711,7 @@ static void dump_command(unsigned long phys_addr)pr_err ("AMD-Vi: CMD[%d]: %08x\n" , i, cmd->data[i]); } -static void iommu_print_event (int type,int devid,int domid, +void amd_iommu_print_event (int type,int devid,int domid,int flags,u64 address) {pr_err ("AMD-Vi: Event logged [" );
@@ -799,7 +799,7 @@ retry: goto retry; } -iommu_print_event (type, devid, domid, flags, address); +amd_iommu_print_event (type, devid, domid, flags, address);memset (__evt,0 ,4 *sizeof (u32)); }
@@ -3288,6 +3288,9 @@ int __init amd_iommu_init_dma_ops(void)else pr_info ("AMD-Vi: Lazy IO/TLB flushing enabled\n" ); +#ifdef CONFIG_AMD_IOMMU_EVENT_LOG_INJ +amd_iommu_evninj_init (); +#endif return 0 ; free_domains:
drivers/iommu/amd_iommu_inject.c new file +99 -0
99 lines not on this page · raw message
drivers/iommu/amd_iommu_proto.h +9 -0
@@ -31,6 +31,9 @@ extern int amd_iommu_init_devices(void);extern void amd_iommu_uninit_devices (void );extern void amd_iommu_init_notifier (void );extern void amd_iommu_init_api (void ); +extern void amd_iommu_print_event (int type,int devid, +int domid,int flags,u64 address); +/* Needed for interrupt remapping */ extern int amd_iommu_supported (void );
@@ -69,6 +72,12 @@ static inline void amd_iommu_stats_init(void) { }#endif /* !CONFIG_AMD_IOMMU_STATS */ +#ifdef CONFIG_AMD_IOMMU_EVENT_LOG_INJ + +extern int amd_iommu_evninj_init (void ); + +#endif /* CONFIG_AMD_IOMMU_EVENT_LOG_INJ */ +static inline bool is_rd890_iommu (struct pci_dev *pdev) { return (pdev->vendor == PCI_VENDOR_ID_ATI) &&
Signature · 1 line
1.7.10.4
Joerg Roedel
maintainerQuoted 5 lines · On Wed, Mar 27, 2013 at 06:51:34PM -0500…
From: Suravee Suthikulpanit <[email protected]>
Add IOMMU event log injection interface for testing event flag decoding logic. This interface allows users to specify device id, event flag, and event types via debugfs.
Quoted 7 lines
echo
0x300>/sys/kernel/debug/amd-iommu-evninj/devid// (e.g. Bus:Dev.fun 3:0.0) echo0xfff>/sys/kernel/debug/amd-iommu-evninj/flags// (e.g. Specify flag value)
echo 2 >/sys/kernel/debug/amd-iommu-evninj/type// (e.g. forIO_PAGE_FAULTevent)Once the event is injected, IOMMU driver will parse and print out the event information in kernel log (dmesg) with the various information depending on the types of event and flag specified.
Why is this needed? I think the risk of regressions in the event-handling code is to low to justify the need for an event-injection mechanism.
Joerg
Quoted 10 lines · Joerg Roedel
Quoted 9 lines · On Wed, Mar 27, 2013 at 06:51:34PM -0500…
From: Suravee Suthikulpanit <[email protected]>
Add IOMMU event log injection interface for testing event flag decoding logic. This interface allows users to specify device id, event flag, and event types via debugfs.
echo
0x300>/sys/kernel/debug/amd-iommu-evninj/devid// (e.g. Bus:Dev.fun 3:0.0) echo0xfff>/sys/kernel/debug/amd-iommu-evninj/flags// (e.g. Specify flag value)
echo 2 >/sys/kernel/debug/amd-iommu-evninj/type// (e.g. forIO_PAGE_FAULTevent)
Quoted 6 lines
Quoted 3 lines
Once the event is injected, IOMMU driver will parse and print out the event information in kernel log (dmesg) with the various information depending on the types of event and flag specified.
Why is this needed? I think the risk of regressions in the event-handling code is to low to justify the need for an event-injection mechanism.
You are right, it is not needed. I create this interface to provide a way for reviewers to test out how the report will be generated for each type of events/errors.
Suravee
Quoted 5 lines
Joerg