Add virtio-scmi backend and comprehensive documentation#84
Add virtio-scmi backend and comprehensive documentation#84Inquisitor-201 wants to merge 16 commits into
Conversation
a1cde9a to
2818939
Compare
| /* Forward declarations from core.c */ | ||
| extern struct mutex reset_list_mutex; | ||
| extern struct list_head reset_controller_list; | ||
| extern struct reset_control * | ||
| __reset_control_get_internal(struct reset_controller_dev *rcdev, | ||
| unsigned int index, bool shared, bool acquired); |
There was a problem hiding this comment.
With the header issue worked around (by providing the missing reset-domains.h locally), the compilation now passes, but the module fails at modpost with three undefined symbols:
ERROR: modpost: "reset_controller_list" [hvisor.ko] undefined!
ERROR: modpost: "__reset_control_get_internal" [hvisor.ko] undefined!
ERROR: modpost: "reset_list_mutex" [hvisor.ko] undefined!
I noticed that reset-domains.c declares them as extern:
extern struct mutex reset_list_mutex;
extern struct list_head reset_controller_list;
extern struct reset_control *
__reset_control_get_internal(struct reset_controller_dev *rcdev,
unsigned int index, bool shared, bool acquired);but they don't appear to be defined anywhere in the module. These also aren't exported by either the 6.1 SDK kernel or upstream 7.1-rc2:
# SDK kernel 6.1
$ grep -E "EXPORT_SYMBOL.*(reset_controller_list|__reset_control_get_internal|reset_list_mutex)" drivers/reset/core.c
(empty)
# Upstream 7.1-rc2
$ grep -E "EXPORT_SYMBOL.*(reset_controller_list|__reset_control_get_internal|reset_list_mutex)" drivers/reset/core.c
(empty)Just wanted to check — were these symbols meant to be provided by a local implementation (perhaps in reset-domains.c itself or another file) that didn't make it into this PR because of the
missing header? Or were you thinking of exporting them from the SDK kernel?
Happy to help sort it out either way — let me know what you think!
There was a problem hiding this comment.
Thanks for looking into this! I've investigated the issue across multiple kernel versions (5.10, 6.1, 6.6), and you're right —
reset_list_mutex, reset_controller_list, and __reset_control_get_internal are all declared as static in drivers/reset/core.c
and are never exported via EXPORT_SYMBOL in any upstream kernel.
Since we need to access these internal reset controller symbols from an out-of-tree module, the fix I'm using is to manually
add EXPORT_SYMBOL_GPL for these three symbols in the kernel's drivers/reset/core.c, as part of the SDK kernel patch set.
Specifically:
// In drivers/reset/core.c, after each definition:
EXPORT_SYMBOL_GPL(reset_list_mutex);
EXPORT_SYMBOL_GPL(reset_controller_list);
EXPORT_SYMBOL_GPL(__reset_control_get_internal);f6ccb52 to
2818939
Compare
|
@agicy Fixed. It should be OK now |
| } | ||
|
|
||
| // Update used ring with total length (request + response) | ||
| update_used_ring(vq, desc_idx, iov[0].iov_len + iov[1].iov_len); |
There was a problem hiding this comment.
There is a logical error in the call to update_used_ring of virtq_tx_handle_one_request.
Implementation
In virtq_tx_handle_one_request, &iov[0] is passed as req_iov (request, device-readable) and &iov[1] is passed as resp_iov (response, device-writable).
// tools/virtio/devices/scmi/virtio_scmi.c:70-72
// Dispatch request to protocol handler
int status =
scmi_handle_message(dev, protocol_id, msg_id, token, &iov[0], &iov[1]);int scmi_handle_message(SCMIDev *dev, uint8_t protocol_id, uint8_t msg_id,
uint16_t token, const struct iovec *req_iov,
struct iovec *resp_iov);Specifications
This confirms that iov[0] represents the Request sent by the guest, and iov[1] is the Response written by the device.
Device reports the number of bytes it has written to memory for each buffer it uses. This is referred to as "used length".
References: Virtual I/O Device (VIRTIO) Version 1.2 - 2.6 Virtqueues
The virtio_scmi_response fields are interpreted as follows:
- hdr: (device-writable) contains the SCMI message header
- ret_values: (device-writable) comprises the SCMI message return values
References: Virtual I/O Device (VIRTIO) Version 1.2 - 5.17.6.1 cmdq Operation
Conclusion
The device only writes data into iov[1] (the device-writable response buffer). Including iov[0].iov_len in used_len reports uninitialized bytes to the guest, causing the guest SCMI driver to see a response larger than the actual payload. This triggers the "Malformed reply" warning on every message exchange.
The fix is straightforward: pass only iov[1].iov_len to update_used_ring.
Results
Before the fix, the guest SCMI driver saw a 124-byte response for a message whose payload is only 4 bytes:
[ 134.973615] arm-scmi firmware:scmi: Malformed reply - real_sz:124 calc_sz:4 (loop_num_ret:3)
There was a problem hiding this comment.
Thanks for catching this! The fix has been applied in commit 76e3113 — now passing only iov[1].iov_len to update_used_ring.
Introduces a comprehensive guide for deploying virtio-scmi on hvisor. Key sections include: - ZoneU Device Tree configuration (SCMI protocols, VirtIO nodes). - SoC device re-mapping for clock and reset providers. - Hvisor configuration requirements (config.json & virtio_cfg.json). - Linux kernel backporting instructions for versions < 5.15. - Current status: rebased to stable hvisor-tool (pre-refactor version). Note: Added warnings regarding incompatibility with the latest hvisor-tool device-based architecture.
… SCMI configuration
…O-SCMI framework, including architecture, configuration, and usage examples
This header was from an out-of-tree kernel patch and is no longer needed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The device only writes data into iov[1] (response buffer). Including iov[0].iov_len (request header) in used_len made the guest see a response larger than the actual payload, triggering a "Malformed reply" warning on every message exchange. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
76e3113 to
c24cba5
Compare
ProblemResponse
|
- Replace CCF enumeration in scmi_clock_get_count with config value clock_max_num - Rename "invalid_clock_" prefix to "inv_" to shorten clock name - Remove unused cached_clock_count and related cache logic
修复:时钟数量获取方式与命名1. 时钟数量不再枚举 CCF
2. 缩短无效时钟名前缀
|
PR: Implement VirtIO-SCMI Virtualization Feature
Feature Overview
This PR implements the VirtIO-SCMI virtualization framework, allowing virtual machines (ZoneU) to securely access hardware resources on the host (Zone0) through the VirtIO transport layer, including:
Implementation Details
Core Changes
Build System:
Kernel Driver:
User Space Tools:
Configuration System:
Technical Architecture
The VirtIO-SCMI system is divided into three layers:
Key Features
Configuration Guide
Device Tree Configuration
ZoneU device tree needs to define:
JSON Configuration
Configure in virtio_cfg.json:
Testing Instructions
Build Testing
Runtime Testing
Examples
Complete RK3588 example configuration is provided:
examples/rk3588-aarch64/with_virtio_scmi/README.md: Detailed configuration and usage instructionsDependencies
This implementation adds complete VirtIO-SCMI support to the hvisor project, enabling virtual machines to securely access and manage hardware resources.