-
Notifications
You must be signed in to change notification settings - Fork 35
fix: update shmbridge testcase #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,143 @@ | ||
| Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| SPDX-License-Identifier: BSD-3-Clause | ||
| # shmbridge Validation test | ||
| # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| # shmbridge Validation Test | ||
|
|
||
| ## Overview | ||
|
|
||
| This test case validates the presence and initialization of the Qualcomm Secure Channel Manager (QCOM_SCM) interface on the device. It ensures that: | ||
| This test validates the presence, registration, and correct runtime state of the | ||
| Qualcomm Secure Channel Manager (`qcom_scm`) driver on the target device. The | ||
| `qcom_scm` driver is the kernel-side interface to TrustZone / Secure World and is | ||
| a hard dependency for shared-memory bridge (shmbridge), SMMU, Crypto, and many | ||
| other Qualcomm subsystem drivers. | ||
|
|
||
| --- | ||
|
|
||
| - The kernel is configured with QCOM_SCM support | ||
| - The dmesg logs contain expected `qcom_scm` entries | ||
| - There are no "probe failure" messages in the logs | ||
| ## Checks Performed | ||
|
|
||
| ## Usage | ||
| | # | Check | Path / Interface | Mandatory | | ||
| |---|-------|-----------------|-----------| | ||
| | 1 | **sysfs module presence** | `/sys/module/qcom_scm` | Yes | | ||
| | 2 | **Device Tree firmware/scm node** | `/sys/firmware/devicetree/base/firmware/scm` | Yes | | ||
| | 3 | **Platform driver registration** | `/sys/bus/platform/drivers/qcom_scm` | Yes | | ||
| | 4 | **Driver-to-device binding** | Symlinks under `/sys/bus/platform/drivers/qcom_scm/` | Yes | | ||
| | 5 | **sysfs attribute readability** | `/sys/module/qcom_scm/parameters/*` | Yes | | ||
| | 6 | **Device uevent / modalias** | `<bound_device>/uevent` | Informational | | ||
| | 7 | **TEE / TrustZone device node** | `/dev/tee0`, `/dev/teepriv0` | Yes | | ||
|
|
||
| > **Informational checks** log their findings but do not cause the test to WARN | ||
| > when the path is absent. This handles platforms where `CONFIG_TEE` or runtime | ||
| > PM exposure is optional. | ||
|
vnarapar marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sentence is confusing. Informational checks do not cause the test to fail, but they may log a warning. The current script logs log_warn for missing TEE nodes. Impact: The README wording contradicts the script and is hard to understand. Recommended fix:
|
||
|
|
||
| ### Check details | ||
|
|
||
| 1. **sysfs module presence** — Confirms the `qcom_scm` driver was compiled into | ||
| the kernel (or loaded as a module) and is visible under `/sys/module`. | ||
|
|
||
| 2. **Device Tree firmware/scm node** — The `qcom_scm` driver requires a | ||
| `firmware/scm` node in the Device Tree to probe successfully. Uses the | ||
| `check_dt_nodes()` helper from `functestlib.sh`. | ||
|
|
||
| Instructions: | ||
| 3. **Platform driver registration** — Confirms the driver called | ||
| `platform_driver_register()` successfully and is listed on the platform bus. | ||
|
|
||
| 4. **Driver-to-device binding** — Confirms `probe()` completed without error by | ||
| checking that at least one symlink (bound device) exists under the driver | ||
| directory. | ||
|
|
||
| 5. **sysfs attribute readability** — Iterates all files under | ||
| `/sys/module/qcom_scm/parameters/` and verifies each can be read without an | ||
| I/O error. Logs the name and current value of each parameter (e.g. | ||
| `download_mode`). | ||
|
|
||
| 6. **Device uevent / modalias** — Reads the `uevent` file of the bound device and | ||
| validates that a `MODALIAS` entry is present, confirming correct udev/hotplug | ||
| registration. | ||
|
|
||
| 7. **TEE / TrustZone device node** — Checks for the character devices `/dev/tee0` | ||
| and `/dev/teepriv0`. These are created by the TEE subsystem when `CONFIG_TEE` | ||
| is enabled and `qcom_scm` has successfully initialised the TrustZone interface. | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. **Copy repo to Target Device**: Use `scp` to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device. | ||
| 2. **Verify Transfer**: Ensure that the repo has been successfully copied to the target device. | ||
| 3. **Run Scripts**: Navigate to the directory where these files are copied on the target device and execute the scripts as needed. | ||
| | Requirement | Notes | | ||
| |-------------|-------| | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: This describes the check but does not state that absence is warning-only. Impact: Users may still assume missing TEE nodes fail the test. Recommended fix:
|
||
| | `CONFIG_QCOM_SCM=y` or `CONFIG_QCOM_SCM=m` | Test is **failed** if this config is absent | | ||
| | `grep`, `find` | Test is **skipped** if these utilities are missing | | ||
| | `/proc/config.gz` readable | Required by `check_kernel_config()` | | ||
| | Root access | Required to read some sysfs power and uevent paths | | ||
|
|
||
| Run the SHM Bridge test using: | ||
| --- | ||
| #### Quick Example | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Quick start | ||
|
|
||
| ```sh | ||
| git clone <this-repo> | ||
| cd <this-repo> | ||
| scp -r common Runner user@target_device_ip:<Path in device> | ||
| ssh user@target_device_ip | ||
| cd <Path in device>/Runner && ./run-test.sh shmbridge | ||
| scp -r Runner user@<target_ip>:<path_on_device> | ||
| ssh user@<target_ip> | ||
| cd <path_on_device>/Runner && ./run-test.sh shmbridge | ||
| ``` | ||
|
|
||
| ### Run directly on the device | ||
|
|
||
| ```sh | ||
| cd Runner | ||
| ./run-test.sh shmbridge | ||
| ``` | ||
|
|
||
| --- | ||
| ## Prerequisites | ||
| 1. zcat, grep, and dmesg must be available. | ||
| 2. Root access may be required to write to read kernel logs. | ||
| --- | ||
| ## Result Format | ||
| Test result will be saved in `shmbridge.res` as: | ||
| ## Output | ||
| A .res file is generated in the same directory: | ||
|
|
||
| `shmbridge PASS` OR `shmbridge FAIL` | ||
|
|
||
| ## Sample Log | ||
|
|
||
| ### PASS output | ||
| ``` | ||
| Output | ||
|
|
||
| [INFO] 1970-01-01 01:10:01 - ----------------------------------------------------------------------------------------- | ||
| [INFO] 1970-01-01 01:10:01 - -------------------Starting shmbridge Testcase---------------------------- | ||
| [INFO] 1970-01-01 01:10:01 - ==== Test Initialization ==== | ||
| [INFO] 1970-01-01 01:10:01 - Checking if required tools are available | ||
| [INFO] 1970-01-01 01:10:01 - Checking kernel config for QCOM_SCM support... | ||
| [PASS] 1970-01-01 01:10:01 - Kernel config CONFIG_QCOM_SCM is enabled | ||
| [INFO] 1970-01-01 01:10:01 - Scanning dmesg logs for qcom_scm initialization | ||
| [PASS] 1970-01-01 01:10:01 - shmbridge : Test Passed (qcom_scm present and no probe failures) | ||
| [INFO] 1970-01-01 01:10:01 - -------------------Completed shmbridge Testcase---------------------------- | ||
| [INFO] 2026-05-08 05:07:27 - ----------------------------------------------------------------------------------------- | ||
| [INFO] 2026-05-08 05:07:27 - -------------------Starting shmbridge Testcase---------------------------- | ||
| [INFO] 2026-05-08 05:07:27 - ==== Test Initialization ==== | ||
| [INFO] 2026-05-08 05:07:27 - Checking if required tools are available... | ||
| [INFO] 2026-05-08 05:07:27 - Checking kernel config for CONFIG_QCOM_SCM support... | ||
| [PASS] 2026-05-08 05:07:27 - Kernel config CONFIG_QCOM_SCM is enabled | ||
| [INFO] 2026-05-08 05:07:27 - --- qcom_scm sysfs module presence --- | ||
| [PASS] 2026-05-08 05:07:27 - qcom_scm module directory exists under /sys/module. | ||
| [INFO] 2026-05-08 05:07:27 - --- Device Tree firmware/scm node --- | ||
| [INFO] 2026-05-08 05:07:27 - /sys/firmware/devicetree/base/firmware/scm | ||
| [INFO] 2026-05-08 05:07:27 - /sys/firmware/devicetree/base/firmware/scm | ||
| [PASS] 2026-05-08 05:07:27 - Device tree node exists: /sys/firmware/devicetree/base/firmware/scm | ||
| [PASS] 2026-05-08 05:07:27 - Device Tree firmware/scm node is present. | ||
| [INFO] 2026-05-08 05:07:27 - --- qcom_scm platform driver registration --- | ||
| [PASS] 2026-05-08 05:07:27 - qcom_scm platform driver is registered on the platform bus. | ||
| [INFO] 2026-05-08 05:07:27 - --- qcom_scm driver-to-device binding --- | ||
| [PASS] 2026-05-08 05:07:27 - qcom_scm driver is bound to device: firmware:scm | ||
| [INFO] 2026-05-08 05:07:28 - --- qcom_scm sysfs attribute readability --- | ||
| [PASS] 2026-05-08 05:07:28 - qcom_scm sysfs attribute readable: download_mode = full | ||
| [INFO] 2026-05-08 05:07:28 - --- qcom_scm device uevent/modalias --- | ||
| [PASS] 2026-05-08 05:07:28 - qcom_scm device uevent is valid: MODALIAS=of:NscmT(null)Cqcom,scm-sa8775pCqcom,scm | ||
| [INFO] 2026-05-08 05:07:28 - --- TEE/TrustZone device node presence --- | ||
| [PASS] 2026-05-08 05:07:28 - TEE device node is present: /dev/tee0 | ||
| [INFO] 2026-05-08 05:07:28 - ----------------------------------------------------------------------------------------- | ||
| [PASS] 2026-05-08 05:07:28 - shmbridge : PASS - qcom_scm driver validated successfully across all checks. | ||
| [INFO] 2026-05-08 05:07:28 - -------------------Completed shmbridge Testcase---------------------------- | ||
| [PASS] 2026-05-08 05:07:28 - shmbridge passed | ||
|
|
||
| [INFO] 2026-05-08 05:07:28 - ========== Test Summary ========== | ||
| PASSED: | ||
| shmbridge | ||
|
|
||
| FAILED: | ||
| None | ||
|
|
||
| SKIPPED: | ||
| None | ||
| [INFO] 2026-05-08 05:07:28 - ================================== | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| SPDX-License-Identifier: BSD-3-Clause | ||
| Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Locate and source init_env | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| INIT_ENV="" | ||
| SEARCH="$SCRIPT_DIR" | ||
|
|
@@ -34,50 +34,138 @@ log_info "---------------------------------------------------------------------- | |
| log_info "-------------------Starting $TESTNAME Testcase----------------------------" | ||
| log_info "==== Test Initialization ====" | ||
|
|
||
| log_info "Checking if required tools are available" | ||
|
|
||
| if ! check_dependencies grep; then | ||
| log_skip "$TESTNAME SKIP - missing required grep utility" | ||
| echo "$TESTNAME SKIP" >"$res_file" | ||
| log_info "Checking if required tools are available..." | ||
| if ! check_dependencies grep find basename cat readlink head; then | ||
| log_skip "$TESTNAME SKIP - missing required grep/find utility" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dependency list is now fixed, but the log message still only says grep/find. If basename, cat, readlink, or head is missing, the skip message will be misleading. |
||
| echo "$TESTNAME SKIP" > "$res_file" | ||
| exit 0 | ||
| fi | ||
|
|
||
| log_info "Checking kernel config for QCOM_SCM support..." | ||
| log_info "Checking kernel config for CONFIG_QCOM_SCM support..." | ||
| if ! check_kernel_config "CONFIG_QCOM_SCM"; then | ||
| log_skip "$TESTNAME : CONFIG_QCOM_SCM not enabled, test Skipped" | ||
| echo "$TESTNAME SKIP" > "$res_file" | ||
| log_fail "$TESTNAME : CONFIG_QCOM_SCM not enabled, test Skipped" | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| exit 0 | ||
| fi | ||
|
|
||
| log_info "Checking qcom_scm presence using sysfs/current-boot kernel log" | ||
| fail_flag=0 | ||
|
|
||
|
|
||
| log_info "--- qcom_scm sysfs module presence ---" | ||
| if [ -d /sys/module/qcom_scm ]; then | ||
| log_pass "qcom_scm driver is present in sysfs." | ||
| elif get_kernel_log 2>/dev/null | grep -qi '\bqcom_scm\b'; then | ||
| log_pass "qcom_scm present in current-boot kernel log." | ||
| log_pass "qcom_scm module directory exists under /sys/module." | ||
| else | ||
| log_fail "FAIL: qcom_scm not found in sysfs or current-boot kernel log." | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| exit 0 | ||
| log_fail "qcom_scm module directory NOT found under /sys/module." | ||
| fail_flag=1 | ||
| fi | ||
|
|
||
| log_info "--- Device Tree firmware/scm node ---" | ||
| if check_dt_nodes "/sys/firmware/devicetree/base/firmware/scm"; then | ||
| log_pass "Device Tree firmware/scm node is present." | ||
| else | ||
| log_fail "Device Tree /sys/firmware/devicetree/base/firmware/scm node is missing." | ||
| fail_flag=1 | ||
| fi | ||
|
|
||
| log_info "--- qcom_scm platform driver registration ---" | ||
| if [ -d /sys/bus/platform/drivers/qcom_scm ]; then | ||
|
vnarapar marked this conversation as resolved.
|
||
| log_pass "qcom_scm platform driver is registered on the platform bus." | ||
| else | ||
| log_fail "qcom_scm platform driver is NOT registered on the platform bus." | ||
| fail_flag=1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hard check is fine, but if it fails, it still does not print available SCM-like platform drivers. If the driver name/path changes across kernel versions, the failure will not show enough context. |
||
| fi | ||
|
|
||
| log_info "--- qcom_scm driver-to-device binding ---" | ||
| if [ -d /sys/bus/platform/drivers/qcom_scm ]; then | ||
| bound_devices=$(find /sys/bus/platform/drivers/qcom_scm -maxdepth 1 -type l 2>/dev/null) | ||
| if [ -n "$bound_devices" ]; then | ||
| for dev in $bound_devices; do | ||
| dev_name=$(basename "$dev") | ||
| log_pass "qcom_scm driver is bound to device: $dev_name" | ||
| done | ||
| else | ||
| log_fail "qcom_scm driver is registered but NOT bound to any platform device." | ||
|
vnarapar marked this conversation as resolved.
|
||
| log_info "[DIAG] Contents of /sys/bus/platform/drivers/qcom_scm:" | ||
| for entry in /sys/bus/platform/drivers/qcom_scm/*; do | ||
| [ -e "$entry" ] || continue | ||
| log_info "[DIAG] $(ls -ld "$entry" 2>/dev/null)" | ||
| done | ||
| log_info "[DIAG] All platform devices (to check for path mismatch):" | ||
| for dev in /sys/bus/platform/devices/*scm*; do | ||
| [ -e "$dev" ] || continue | ||
| log_info "[DIAG] $dev" | ||
| done | ||
| log_info "[DIAG] Deferred probe list (if available):" | ||
| if [ -r /sys/kernel/debug/devices_deferred ]; then | ||
| grep -i "scm" /sys/kernel/debug/devices_deferred 2>/dev/null | while IFS= read -r line; do | ||
| log_info "[DIAG] $line" | ||
| done | ||
| else | ||
| log_info "[DIAG] /sys/kernel/debug/devices_deferred not available." | ||
| fi | ||
| fail_flag=1 | ||
| fi | ||
| else | ||
| log_info "Skipping driver binding check (platform driver not registered)." | ||
| fi | ||
|
|
||
| log_info "--- qcom_scm sysfs attribute readability ---" | ||
| scm_attrs_ok=0 | ||
| for attr in /sys/module/qcom_scm/parameters/*; do | ||
| [ -f "$attr" ] || continue | ||
| attr_name=$(basename "$attr") | ||
| if attr_val=$(cat "$attr" 2>/dev/null); then | ||
|
vnarapar marked this conversation as resolved.
|
||
| log_pass "qcom_scm sysfs attribute readable: $attr_name = $attr_val" | ||
| scm_attrs_ok=1 | ||
| else | ||
| log_fail "qcom_scm sysfs attribute NOT readable: $attr_name" | ||
| fail_flag=1 | ||
| fi | ||
| done | ||
| if [ "$scm_attrs_ok" -eq 0 ]; then | ||
| log_info "No qcom_scm module parameters found (may be expected for built-in config)." | ||
| fi | ||
|
|
||
| log_info "--- qcom_scm device uevent/modalias ---" | ||
| scm_uevent_found=0 | ||
| for dev_link in /sys/bus/platform/drivers/qcom_scm/*; do | ||
| [ -L "$dev_link" ] || continue | ||
| dev_path=$(readlink -f "$dev_link" 2>/dev/null) | ||
|
vnarapar marked this conversation as resolved.
|
||
| if [ -f "$dev_path/uevent" ]; then | ||
| modalias=$(grep "^MODALIAS=" "$dev_path/uevent" 2>/dev/null | head -n 1) | ||
|
vnarapar marked this conversation as resolved.
|
||
| if [ -n "$modalias" ]; then | ||
| log_pass "qcom_scm device uevent is valid: $modalias" | ||
| else | ||
| log_pass "qcom_scm device uevent file is present (no MODALIAS entry)." | ||
| fi | ||
| scm_uevent_found=1 | ||
| break | ||
| fi | ||
| done | ||
| if [ "$scm_uevent_found" -eq 0 ]; then | ||
| log_info "qcom_scm device uevent not found (may be expected if driver is not bound)." | ||
| fi | ||
|
|
||
| scm_log="./qcom_scm_kernel.log" | ||
| scm_err="./qcom_scm_errors.log" | ||
| err_patterns='probe failed|fail(ed)?|error|timed out|not found|invalid|corrupt|abort|panic|oops|unhandled' | ||
|
|
||
| log_info "Scanning current-boot kernel log for qcom_scm-related errors" | ||
| get_kernel_log > "$scm_log" 2>/dev/null || true | ||
| grep -iE "qcom_scm.*($err_patterns)" "$scm_log" > "$scm_err" || true | ||
| log_info "--- TEE/TrustZone device node presence ---" | ||
|
vnarapar marked this conversation as resolved.
|
||
| tee_found=0 | ||
| for tee_node in /dev/tee0 /dev/teepriv0; do | ||
| if [ -c "$tee_node" ]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. README still says TEE node presence is mandatory. Impact: Script behavior and documentation disagree. Recommended fix: Update README table and note. See README comment below. |
||
| log_pass "TEE device node is present: $tee_node" | ||
| tee_found=1 | ||
| fi | ||
| done | ||
| if [ "$tee_found" -eq 0 ]; then | ||
| log_warn "No TEE device node found (/dev/tee0, /dev/teepriv0)." | ||
| fi | ||
|
|
||
|
|
||
| if [ -s "$scm_err" ]; then | ||
| while IFS= read -r line; do | ||
| [ -n "$line" ] || continue | ||
| log_info "[kernel] $line" | ||
| done < "$scm_err" | ||
| log_fail "FAIL: qcom_scm-related errors detected in current-boot kernel log." | ||
| log_info "-----------------------------------------------------------------------------------------" | ||
| if [ "$fail_flag" -eq 1 ]; then | ||
| log_fail "$TESTNAME : FAIL - One or more qcom_scm validation checks failed." | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| else | ||
| log_pass "$TESTNAME : Test Passed (qcom_scm present and no qcom_scm-related kernel errors)" | ||
| log_pass "$TESTNAME : PASS - qcom_scm driver validated successfully across all checks." | ||
| echo "$TESTNAME PASS" > "$res_file" | ||
| fi | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current script treats missing TEE nodes as WARN, not FAIL.
Impact: Documentation gives the wrong test expectation.
Recommended fix:
| 7 | TEE / TrustZone device node |
/dev/tee0,/dev/teepriv0| Informational |or:
| 7 | TEE / TrustZone device node |
/dev/tee0,/dev/teepriv0| Warning only |