Commit d94afc6c authored by mark gross's avatar mark gross Committed by Linus Torvalds

intel-iommu: fault_reason index cleanup

Fix an off by one bug in the fault reason string reporting function, and
clean up some of the code around this buglet.

[akpm@linux-foundation.org: cleanup]
Signed-off-by: default avatarmark gross <mgross@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f8bab735
...@@ -745,7 +745,7 @@ static int iommu_disable_translation(struct intel_iommu *iommu) ...@@ -745,7 +745,7 @@ static int iommu_disable_translation(struct intel_iommu *iommu)
/* iommu interrupt handling. Most stuff are MSI-like. */ /* iommu interrupt handling. Most stuff are MSI-like. */
static char *fault_reason_strings[] = static const char *fault_reason_strings[] =
{ {
"Software", "Software",
"Present bit in root entry is clear", "Present bit in root entry is clear",
...@@ -760,14 +760,13 @@ static char *fault_reason_strings[] = ...@@ -760,14 +760,13 @@ static char *fault_reason_strings[] =
"non-zero reserved fields in RTP", "non-zero reserved fields in RTP",
"non-zero reserved fields in CTP", "non-zero reserved fields in CTP",
"non-zero reserved fields in PTE", "non-zero reserved fields in PTE",
"Unknown"
}; };
#define MAX_FAULT_REASON_IDX (ARRAY_SIZE(fault_reason_strings) - 1) #define MAX_FAULT_REASON_IDX (ARRAY_SIZE(fault_reason_strings) - 1)
char *dmar_get_fault_reason(u8 fault_reason) const char *dmar_get_fault_reason(u8 fault_reason)
{ {
if (fault_reason >= MAX_FAULT_REASON_IDX) if (fault_reason > MAX_FAULT_REASON_IDX)
return fault_reason_strings[MAX_FAULT_REASON_IDX - 1]; return "Unknown";
else else
return fault_reason_strings[fault_reason]; return fault_reason_strings[fault_reason];
} }
...@@ -825,7 +824,7 @@ void dmar_msi_read(int irq, struct msi_msg *msg) ...@@ -825,7 +824,7 @@ void dmar_msi_read(int irq, struct msi_msg *msg)
static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type, static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type,
u8 fault_reason, u16 source_id, u64 addr) u8 fault_reason, u16 source_id, u64 addr)
{ {
char *reason; const char *reason;
reason = dmar_get_fault_reason(fault_reason); reason = dmar_get_fault_reason(fault_reason);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#ifdef CONFIG_DMAR #ifdef CONFIG_DMAR
struct intel_iommu; struct intel_iommu;
extern char *dmar_get_fault_reason(u8 fault_reason); extern const char *dmar_get_fault_reason(u8 fault_reason);
/* Can't use the common MSI interrupt functions /* Can't use the common MSI interrupt functions
* since DMAR is not a pci device * since DMAR is not a pci device
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment