All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/2] iommu/arm-smmu-v3: Parse out event records
@ 2024-12-03 18:49 Pranjal Shrivastava
  2024-12-03 18:49 ` [PATCH v6 1/2] iommu/arm-smmu-v3: Introduce struct arm_smmu_event Pranjal Shrivastava
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pranjal Shrivastava @ 2024-12-03 18:49 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Robin Murphy
  Cc: Mostafa Saleh, Nicolin Chen, iommu, Jason Gunthorpe, Daniel Mentz,
	Pranjal Shrivastava

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/20241112083018.1662104-1-praan@google.com/
 * 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/20241018180022.807928-1-praan@google.com/
 * 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/20240928005143.2378938-1-praan@google.com/
 * 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/20240827193026.3993039-1-praan@google.com/
 * 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/20240816211722.1404070-1-praan@google.com/

 * 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/20241018180022.807928-1-praan@google.com/
 * 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/20240928005143.2378938-1-praan@google.com/
 * 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/20240827193026.3993039-1-praan@google.com/
 * 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/20240816211722.1404070-1-praan@google.com/

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(-)

-- 
2.47.0.338.g60cca15819-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-01-07 13:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 18:49 [PATCH v6 0/2] iommu/arm-smmu-v3: Parse out event records Pranjal Shrivastava
2024-12-03 18:49 ` [PATCH v6 1/2] iommu/arm-smmu-v3: Introduce struct arm_smmu_event Pranjal Shrivastava
2024-12-03 18:49 ` [PATCH v6 2/2] iommu/arm-smmu-v3: Log better event records Pranjal Shrivastava
2024-12-10  0:17 ` [PATCH v6 0/2] iommu/arm-smmu-v3: Parse out " Will Deacon
2025-01-06 11:29   ` Pranjal Shrivastava
2025-01-07 13:00     ` Will Deacon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.