Add support for OCP protocol - #20
Open
n-ramacciotti wants to merge 4 commits into
Open
Conversation
n-ramacciotti
force-pushed
the
ocp_module
branch
from
June 24, 2026 11:15
9beee2d to
0e23e44
Compare
Author
|
v2:
|
n-ramacciotti
force-pushed
the
ocp_module
branch
8 times, most recently
from
July 8, 2026 11:48
7c5394b to
1b7a412
Compare
n-ramacciotti
force-pushed
the
ocp_module
branch
from
July 22, 2026 13:17
1b7a412 to
b34b176
Compare
Author
|
v3:
TODO:
|
n-ramacciotti
force-pushed
the
ocp_module
branch
from
July 24, 2026 10:50
b34b176 to
84b0b7f
Compare
Author
|
v4:
Tested locally (without SNP, but with fake replies and a very basic userspace application) TODO:
|
n-ramacciotti
force-pushed
the
ocp_module
branch
4 times, most recently
from
July 28, 2026 10:03
9b25fc1 to
8326c56
Compare
Author
|
v5:
|
n-ramacciotti
force-pushed
the
ocp_module
branch
4 times, most recently
from
July 30, 2026 14:03
0c38f34 to
749b2ba
Compare
n-ramacciotti
force-pushed
the
ocp_module
branch
from
August 6, 2026 11:38
749b2ba to
5149032
Compare
Author
|
v6:
|
n-ramacciotti
force-pushed
the
ocp_module
branch
from
August 7, 2026 16:09
5149032 to
c4b5655
Compare
n-ramacciotti
marked this pull request as ready for review
August 7, 2026 16:09
Author
|
v7:
It's ready for review now |
kraxel
reviewed
Aug 12, 2026
n-ramacciotti
force-pushed
the
ocp_module
branch
from
August 13, 2026 13:17
c4b5655 to
6bd8133
Compare
Author
|
v8:
TODO:
|
Add four new functionalities to interact with the SVSM Observability and Configuration Protocol (OCP). They are based on the specifications draft. Expose them so they can be used by a driver. Signed-off-by: Nicola Ramacciotti <[email protected]>
Add a driver for the OCP defined by the spec. For now, it only supports open. Additional file operations will be added later. The device cannot be hot-plugged as it is emulated by the platform, so we can use platform_driver_probe(). The module needs to create a class and obtain a range of device numbers. These actions are not strictly related to driver probing. Therefore, avoid the use of module_platform_driver_probe() and use module_init/exit to take care of them. The device will be registered by the platform only when it's available, so probe() needs to initialize the cdev, allocate the buffer for SVSM-kernel communications and create the device node for userspace. Since the platform device cannot be hot-plugged, the driver has no unbind attribute and the driver can be removed only with rmmod, which can only be called when there are no file descriptors open. Therefore, the allocated data can be removed directly in remove() and there is no need to have the struct cdev and the struct device as member of the same structure with lifetime managed by the struct device, with a custom release operation that frees the data. Signed-off-by: Nicola Ramacciotti <[email protected]>
n-ramacciotti
force-pushed
the
ocp_module
branch
from
August 18, 2026 15:15
6bd8133 to
6f2ad00
Compare
Author
|
v9:
|
n-ramacciotti
force-pushed
the
ocp_module
branch
2 times, most recently
from
August 18, 2026 17:10
6f2ad00 to
d4f2585
Compare
Reserve a range of codes from the ioctl documentation. For now, only four are needed, but some are left for growth. Introduce the ioctl interface, which uses the API exposed by x86/sev to send commands and receive responses from SVSM as defined in the spec. Share the interface with uapi to make it available also for userspace. The ioctl returns a positive integer to userspace to number of bytes. This is done to avoid an additional copy_to_user(). Signed-off-by: Nicola Ramacciotti <[email protected]>
Add `ocp-svsm` device that can be handled by the platform driver added in the previous commits in `drivers/char/ocp_svsm.c` TODO: Register the platform device only when SVSM is available and it supports OCP calls. Signed-off-by: Nicola Ramacciotti <[email protected]>
n-ramacciotti
force-pushed
the
ocp_module
branch
from
August 18, 2026 17:11
d4f2585 to
29c7af7
Compare
kraxel
reviewed
Aug 19, 2026
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| *bytes_read = call.r8_out; |
There was a problem hiding this comment.
Some calls return the bytes transfered in rcx, some in r8.
I think we should pick one register and use that everywhere.
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.
RFC PR for observability and configuration protocol
This is the linux-side handler.
It contains the platform device and driver registration + all the ocp calls implementation.
This contains a [test] commit with a module that can be loaded and will do a single call to SVSM_OCP_LIST during initialization. The parameter of this call can be changed based on a configuration parameter that can be specified when inserting the module. This can be inserted and removed multiple times.see PR coconut-svsm/svsm#1138 and n-ramacciotti/svsm-tools#1