Skip to content

Conversation

@Amannix
Copy link
Contributor

@Amannix Amannix commented Aug 26, 2024

Description:

When qemu is started, it can access different key spaces by specifying vid (virtual ID).
When the guest accesses the TKM, it will notify KVM through hypercall call, and KVM will send the guest's command data to the PSP for processing.

Related qemu PR: 支持海光可信密钥管理(TKM)的密钥隔离功能

xiongmengbiao and others added 8 commits August 21, 2024 16:55
…rnel space

hygon inclusion
category: feature
---------------------------

Add a self-defined mutex to support concurrent psp access between kernel
space and user space.

Signed-off-by: xiongmengbiao <xiongmengbiao@hygon.cn>
hygon inclusion
category: feature
---------------------------

Add ioctl interface to control the state of self-defined
mutex in user and kernel space.

By default, when psp user-mode driver is not used,
the self-defined mutex is disabled, and the kernel's native
private lock is utilized instead.

Signed-off-by: xiongmengbiao <xiongmengbiao@hygon.cn>
hygon inclusion
category: feature
---------------------------

Support the PSP virtualization basic framework.

The guest uses the vmmcall instruction to
interact with KVM, which then forwards
the data to the PSP device driver and sends
it to the PSP hardware.

Signed-off-by: niuyongwen <niuyongwen@hygon.cn>
hygon inclusion
category: feature
---------------------------

Allow the guest to execute Trusted Key Management (TKM)
commands in user mode.

Each TKM command data block is transferred to KVM using
the vmmcall instruction and processed through the following
three steps:

1. Obtain the VM command and preprocess the pointer
   mapping table information in the command buffer
2. The command that has been converted will interact
   with the channel of the psp through the driver and
   try to obtain the execution result
3. The executed command data is recovered according to
   the multilevel pointer of the mapping table, and then returned to the VM

Signed-off-by: niuyongwen <niuyongwen@hygon.cn>
hygon inclusion
category: feature
---------------------------

Add `vpsp_add_vid` and `vpsp_del_vid` to receive
VID information in host user mode.
Generally, these ioctl calls should be initiated from the QEMU process.

When sending data to the PSP hardware,
place the VID in the bit 56 to bit 63 range of the physical address.
The PSP hardware will then access different key spaces based on the VID.

Signed-off-by: xiongmengbiao <xiongmengbiao@hygon.cn>
hygon inclusion
category: feature
---------------------------

If the guest does not explicitly specify a VID
via `vpsp_add_vid`, VID 0 will be used by default,
sharing the key space with the host.

A `vpsp_set_default_vid_permission` ioctl call
has been added to control the behavior of the default VID.
If the default VID permission is set to "not allowed,"
any guest that does not explicitly specify a VID
will be denied access to the TKM function.

Signed-off-by: xiongmengbiao <xiongmengbiao@hygon.cn>
… module

hygon inclusion
category: feature
---------------------------

Because the KVM module calls certain interfaces from the ccp module,
such as vpsp_try_do_cmd, it is necessary to load the ccp module
before loading kvm.

However, on CPUs other than Hygon, the ccp module might not be loaded,
which would prevent the kvm module from loading.

Therefore, we use function hooks to call functions from the ccp module.
Now the module dependencies are as follows:

[root@centos-7-8 ~]# lsmod | grep kvm
kvm_amd               200704  0
kvm                  1339392  1 kvm_amd
ccp                   352256  1 kvm_amd
irqbypass              12288  2 vfio_pci_core,kvm

Signed-off-by: xiongmengbiao <xiongmengbiao@hygon.cn>
…emmory for tkm

hygon inclusion
category: bugfix
---------------------------

When deleting a VID, `memcpy` is used to move
data within the array and overwrite the deleted VID entry.

However, `memcpy` does not handle overlapping
memory regions correctly within the array.

Therefore, `memmove` should be used instead.

Signed-off-by: niuyongwen <niuyongwen@hygon.cn>
@deepin-ci-robot
Copy link

Hi @Amannix. Thanks for your PR. 😃

@deepin-ci-robot
Copy link

Hi @Amannix. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign opsiff for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants