Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes in the virtio-SCMI clock protocol implementation:
fix(virtio-scmi): correct CLOCK_NAME_GET message id—CLOCK_NAME_GETis 0x8 (SCMI/Linux), not 0x9; the mis-numberedCLOCK_CONFIG_GETmoves to 0xB.fix(virtio-scmi): report v3.1 clock attributes and extended names— return the 24-byteCLOCK_ATTRIBUTESpayload withclock_enable_latency = 0and setBIT(29)(SUPPORTS_EXTENDED_NAMES), so Linux >= 5.19 fetches the full clock name throughCLOCK_NAME_GET.Fixes #453.
Motivation
hvisor-tool reported only the 16-byte SCMI short name, so every guest clock name was truncated to 15 characters. On RK3588,
clk_i2s0_8ch_tx_srcandclk_i2s0_8ch_tx_fracboth becomeclk_i2s0_8ch_tx. The guest clock core rejects the second registration of that name, so the guest does not merely show duplicates: it loses the second clock (-EEXIST, see Verification).Fixing that exposed two defects in the same path:
SCMI_CLOCK_MSG_NAME_GETwas declared as 0x9 while SCMI and Linux use 0x8. EnablingBIT(29)alone would send 0x8 intohandle_clock_config_get(), whose 12-byte request check rejects the 8-byte name request and returnsSCMI_ERR_PARAMSwithout writing a response. The guest would then see a zero-length completion and waitVIRTIO_MAX_RX_TIMEOUT_MS(60 s) per clock. Measured through the real dispatcher before the id fix:Linux 5.19+ reads
clock_enable_latencyfromCLOCK_ATTRIBUTESwhenever the protocol major version is >= 2. hvisor-tool sent 20 bytes instead of 24, so the kernel copied 20 bytes and used the remaining 4 bytes of its receive buffer as the latency value.Verification
Host harness: the real
scmi/clock.candscmi_core.care compiled together, onlyioctl()andlog_log()are stubbed, and requests go throughvirtio_scmi_clock_handle_req()so the dispatcher is exercised. The ioctl stub mirrors the kernel module, which always reportsparent_id = -1.rc=-2,written=0rc=0,written=76CLOCK_ATTRIBUTESpayloadattributes(production)0x000000010x20000001clock_enable_latency0CLOCK_NAME_GETresultclk_i2s0_8ch_tx_srcCaptured frame after the fix:
Commands:
make -C hvisor-tool/tools ARCH=arm64 VIRTIO_SCMI=y ...make -C hvisor-tool/tools ARCH=arm64 VIRTIO_SCMI=n ...clang-format 23.1.5 --dry-run --Werror(format workflow pin)typos --config _typos.tomlqemu-gicv3zone lifecycle regressionclk_summarycheck-EEXIST, clock droppedThe zone0 run adds two
fixed-clocknodes with longclock-output-namesto thehvisor_virtio_devicenode of the QEMU zone0 DT, then queries the kernel moduledirectly with a small static aarch64 tool:
This confirms the name source end to end up to the kernel module: the DT clocks are enumerated and their full names are returned. It also confirms that
parent_idis always-1, i.e. the short-name path never sets bit 28.QEMU run (hvisor built from this branch, guest kernel and zone0 DT from the standard
qemu-gicv3image,hvisor.ko+hvisorfrom this branch):The guest-side
clk_summarycheck ran on a QEMUqemu-gicv3zone1 guest (Linux 7.3.5,CONFIG_ARM_SCMI_TRANSPORT_VIRTIO=y), with the two fixed-clock nodes from the zone0 DT exposed through the zone1 device tree:The zone1 guest also needs the per-queue virtio-console workers: the single-threaded console on
devstalls this guest before user space, which is why the earlier zone0-only probe could not be extended to a guest. The extra SCMI IRQ also had to move off 79 (any IRQ other than the three the guest'svirtio-mmionodes use works here); both are fixture issues, not part of this change.Risks and Limitations
CLOCK_ATTRIBUTESpayload grows from 20 to 24 bytes.msg_fetch_response()copiesmin(requested, available), so the extra 4 bytes are ignored.SUPPORTS_EXTENDED_NAMESin the clock protocol). Older guests keep the 15-character name; they are not made worse.