Skip to content

iommu/arm-smmu-v3: Parse out event records

Pranjal Shrivastava linux-iommu 6 versions – Applied

Status from this message: Applied to will (for-joerg/arm-smmu/updates), thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest2 patches 3 repliesApplied
  2. v53 patches 23 repliesSuperseded
  3. v43 patches 43 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v32 patches25 repliesSuperseded
v22 patches16 repliesSuperseded
v11 patch2 repliesSuperseded

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/2iommu/arm-smmu-v3: Introduce struct arm_smmu_eventdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h+54 -190 replies
2/2iommu/arm-smmu-v3: Log better event recordsdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h+115 -130 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [PATCH v6 0/2] iommu/arm-smmu-v3: Parse out event records

Enhance the arm-smmu-v3 driver to parse out useful information from event records into a structure for better event handling & logging.

Some sample events, powered by QEMU:

1. Bad StreamID:

[   10.940765] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x02 received:
[   10.941260] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000800000002
[   10.941735] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[   10.942211] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[   10.942706] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[   10.943357] arm-smmu-v3 arm-smmu-v3.0.auto: event: C_BAD_STREAMID client: 0000:00:01.0 sid: 0x8 ssid: 0x0

2. Permission Fault:

[    7.477618] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x13 received:
[    7.478185] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000800000013
[    7.478666] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000020000000000
[    7.479443] arm-smmu-v3 arm-smmu-v3.0.auto:  0x00000000fffff040
[    7.479929] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.480410] arm-smmu-v3 arm-smmu-v3.0.auto: event: F_PERMISSION client: 0000:00:01.0 sid: 0x8 ssid: 0x0 iova: 0xfffff040 ipa: 0x0
[    7.481258] arm-smmu-v3 arm-smmu-v3.0.auto: unpriv data write s1 "Input address caused fault" stag: 0x0

3. STE Fetch Fault:

[    7.548667] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x03 received:
[    7.549304] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000800000003
[    7.549800] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.550298] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.550780] arm-smmu-v3 arm-smmu-v3.0.auto:  0x00000000000001e0
[    7.551568] arm-smmu-v3 arm-smmu-v3.0.auto: event: F_STE_FETCH client: 0000:00:01.0 sid: 0x8 ssid: 0x0 fetch_addr: 0x1e0

5. Unknown / Implementation-defined Fault:

[   13.517857] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x0b received:
[   13.518339] arm-smmu-v3 arm-smmu-v3.0.auto:  0x000000080000000b
[   13.518814] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000028800000000
[   13.519311] arm-smmu-v3 arm-smmu-v3.0.auto:  0x00000000ffffe004
[   13.519789] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[   13.520294] arm-smmu-v3 arm-smmu-v3.0.auto: event: UNKNOWN client: 0000:00:01.0 sid: 0x8 ssid: 0x0

v6
* Re-structured the logs in 2 lines with prefixes as suggested.
* Masked address fields appropriately to avoid issues with RES0
* Added a member for fetch_address to demarcate it separately.
* Used FIELD_GET where required instead of masking.
* Renamed raw_evt to evt and evt to event as suggested.
* Renamed arm_smmu_handle_evt to arm_smmu_handle_event.

v5
https://lore.kernel.org/all/[email protected]/
* Replaced strings with used macros to conserve stack space
* Fixed IPA log truncation,(e.g. logged 0xfffff instead of 0xfffff040)
* Bounded evt->id by ARRAY_SIZE to avoid inflating event_str
* Restored the original raw dump format
* Decoupled "raw" event from struct arm_smmu_event
* Moved the raw event log before the decoded/pretty log
* Improved the sid.ssid format to be more readable
* Zero-initialized the arm_smmu_event var in arm_smmu_handle_evt
* Refactored struct arm_smmu_events to use bitfields instead of bools
* Removed struct arm_smmu_device field from struct arm_smmu_event
* Removed master_name field to use dev_name(event->dev) instead
* Pahole reports a total of 3-byte holes & struct size = 40 bytes
* Moved most constant parts of the log to the fmt string
* Moved the event decoding within arm_smmu_handle_evt
* Renamed arm_smmu_get_event_from_raw => arm_smmu_decode_event
* Renamed a few EVT_IDs for consistency as per Daniel's suggestions
* Renamed "master" to "client" in the logs as suggested in reviews
* Corrected "F_VMS_FAULT" => "F_VMS_FETCH"
* Re-ordered event strings in event_str as they appear in the spec
* Removed less useful comments

v4
https://lore.kernel.org/all/[email protected]/
* Re-arranged the series to first introduce struct arm_smmu_event
* Improved the complex ternary expression that prints TTRnW info
* Added consistent spacing to the logs & resized log strings
* Moved ratelimiting within arm_smmu_dump_event
* Refactored master_name printing by getting a ref to the device
* Refactored arm_smmu_handle_evt to avoid redundant master lookup

v3
https://lore.kernel.org/all/[email protected]/
* Fixed a potential race and null pointer deref for arm_smmu_master
* Improved the logging approach by using multiple strings
* Added logs for STAG & STALL fields for relevant events
* Invoked the log function within arm_smmu_handle_evt routine
* Rebased the changes

v2
https://lore.kernel.org/linux-iommu/[email protected]/
* Addressed review comments
* Introduced struct arm_smmu_event to hold relevant event fields
* Broke out helper functions to populate & dump event info
* Modified the event handler routines to use struct arm_smmu_event

v1
https://lore.kernel.org/linux-iommu/[email protected]/

* Replaced strings with used macros to conserve stack space
* Fixed IPA log truncation,(e.g. logged 0xfffff instead of 0xfffff040)
* Bounded evt->id by ARRAY_SIZE to avoid inflating event_str
* Restored the original raw dump format
* Decoupled "raw" event from struct arm_smmu_event
* Moved the raw event log before the decoded/pretty log
* Improved the sid.ssid format to be more readable
* Zero-initialized the arm_smmu_event var in arm_smmu_handle_evt
* Refactored struct arm_smmu_events to use bitfields instead of bools
* Removed struct arm_smmu_device field from struct arm_smmu_event
* Removed master_name field to use dev_name(event->dev) instead
* Pahole reports a total of 3-byte holes & struct size = 40 bytes
* Moved most constant parts of the log to the fmt string
* Moved the event decoding within arm_smmu_handle_evt
* Renamed arm_smmu_get_event_from_raw => arm_smmu_decode_event
* Renamed a few EVT_IDs for consistency as per Daniel's suggestions
* Renamed "master" to "client" in the logs as suggested in reviews
* Corrected "F_VMS_FAULT" => "F_VMS_FETCH"
* Re-ordered event strings in event_str as they appear in the spec
* Removed less useful comments

v4
https://lore.kernel.org/all/[email protected]/
* Re-arranged the series to first introduce struct arm_smmu_event
* Improved the complex ternary expression that prints TTRnW info
* Added consistent spacing to the logs & resized log strings
* Moved ratelimiting within arm_smmu_dump_event
* Refactored master_name printing by getting a ref to the device
* Refactored arm_smmu_handle_evt to avoid redundant master lookup

v3
https://lore.kernel.org/all/[email protected]/
* Fixed a potential race and null pointer deref for arm_smmu_master
* Improved the logging approach by using multiple strings
* Added logs for STAG & STALL fields for relevant events
* Invoked the log function within arm_smmu_handle_evt routine
* Rebased the changes

v2
https://lore.kernel.org/linux-iommu/[email protected]/
* Addressed review comments
* Introduced struct arm_smmu_event to hold relevant event fields
* Broke out helper functions to populate & dump event info
* Modified the event handler routines to use struct arm_smmu_event

v1
https://lore.kernel.org/linux-iommu/[email protected]/

Pranjal Shrivastava (2):
iommu/arm-smmu-v3: Introduce struct arm_smmu_event iommu/arm-smmu-v3: Log better event records

 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 157 ++++++++++++++++----
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h |  30 ++++
 2 files changed, 162 insertions(+), 25 deletions(-)
Signature · 1 line
2.47.0.338.g60cca15819-goog