Skip to content
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

Support running Hygon TKM in CSV virtual machine #443

Merged
merged 5 commits into from
Oct 18, 2024

Conversation

Amannix
Copy link

@Amannix Amannix commented Oct 17, 2024

Verification steps:

  1. Create a vtkm vid and use a supported version of QEMU to launch a CSV virtual machine. Add the options -mem2 base=512G,size=32M -device psp,vid= to the startup parameters. This will map 16 host-shared 2MB huge pages within the specified address range and bind them to the corresponding TKM key space.
    1729174714782
  2. After entering the virtual machine OS, use dmesg to check that the BIOS-e820 address range includes the [512G, 512G+32M) interval, indicating that the BIOS has provided the memory space set by the mem2 option to the kernel.
    1729174873570
  3. Modify the GRUB options and set memmap=32M$512G to ensure that the kernel reserves the [512G, 512G+32M) memory range.
    1729175132929
  4. Execute any TKM command
    1729175216779

Related QEMU PR: deepin-community/qemu#24

xiongmengbiao and others added 5 commits October 17, 2024 21:54
hygon inclusion
category: feature

---------------------------

The data of the CSV VM is encrypted, so the ciphertext
data of the CSV VM cannot be copied to the host kernel
space for processing.

This patch removes the old copy-based processing.

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

---------------------------

The CSV virtual machine puts the tkm command data
into an encrypted 2MB hugepage space,
then submits the command address GPA to the host kernel,
then the host kernel converts the GPA to HPA,
and finally submits the HPA to the PSP hardware.

During the entire command forwarding process,
since the data of the CSV virtual machine is encrypted,
the host kernel cannot access the real TKM command data submitted by CSV.

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

---------------------------

CSV guests can run without SME enabled.
Regardless of the host's SME status,
the C-bit must be set for the physical address.
Memory will be encrypted with a different key than SME.

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

---------------------------

When accessing the TKM from the host user space,
DMA operations are performed using hugepages of memory,
which are expected to be permanently fixed in the system.

This patch provides a set of ioctl interfaces to
pin memory pages to prevent migration.

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

hygon inclusion
category: bugfix

---------------------------

gfn_to_pfn causes the refcount to increment atomically by one,
which needs to be released.

Signed-off-by: niuyongwen <niuyongwen@hygon.cn>
@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 avenger-285714 for approval. For more information see the Code Review Process.

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

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

@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.

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.

@Avenger-285714 Avenger-285714 merged commit 92c940f into deepin-community:linux-6.6.y Oct 18, 2024
2 of 4 checks passed
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