Skip to content

[6.6] HYGON: Add new pci device id and modify psp_do_cmd() interface #804

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

Merged
merged 2 commits into from
May 16, 2025

Conversation

chench246
Copy link
Contributor

@chench246 chench246 commented May 15, 2025

  1. add new psp/ccp device id and modify psp_do_cmd() interface to not rely on sev device.

Reference: https://gitee.com/openeuler/kernel/pulls/16281

  1. bugfix: Fix for potential memory Out-of-Bounds access due to insufficient array size in TDM driver.

Summary by Sourcery

Add new Hygon PCI device IDs, decouple PSP command execution from SEV, and correct TDM driver buffer sizing to avoid memory overflows.

New Features:

  • Add support for two new Hygon PCI device IDs (0x14d8 and 0x14c6)

Bug Fixes:

  • Fix potential out-of-bounds access in the TDM driver by using KSYM_NAME_LEN for the symbol buffer size

Enhancements:

  • Refactor PSP command interface to remove dependency on the SEV device by introducing an internal wait queue and psp_wait_cmd_ioc function

chench246 added 2 commits May 15, 2025 14:41
…to not rely on sev device

hygon inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IC7KDI
CVE: NA

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

add new psp/ccp device id and modify psp_do_cmd() interface
to not rely on sev device.

Signed-off-by: chench <[email protected]>
…ufficient array size

In the function 'int sprint_symbol(char *buffer, unsigned long address)',
the buffer variable will undergo a write operation
"namebuf[KSYM_NAME_LEN - 1] = 0;" during the following call chain.

Call Trace:
    tdm_get_cmd_context_hash -> sprint_symbol -> __sprint_symbol ->
    kallsyms_lookup_buildid

Therefore, it is mandatory to ensure the buffer has a minimum size of
KSYM_NAME_LEN.

Signed-off-by: chench <[email protected]>
@deepin-ci-robot deepin-ci-robot requested review from BLumia and Wenlp May 15, 2025 06:43
Copy link

sourcery-ai bot commented May 15, 2025

Reviewer's Guide

This PR decouples PSP command execution from the SEV device by introducing a dedicated wait queue and command-wait helper, updates the IRQ handler and header accordingly, adds two new Hygon PCI device IDs, and fixes an out-of-bounds buffer in the TDM driver.

File-Level Changes

Change Details Files
Refactor PSP command interface off SEV and implement dedicated wait mechanism
  • Define static psp_int_rcvd flag and psp_int_queue wait queue
  • Add psp_wait_cmd_ioc() to wait on psp_int_queue instead of sev_wait_cmd_ioc
  • Update __psp_do_cmd_locked to use psp->io_regs, psp_int_rcvd, psp_cmd_timeout, and invoke psp_wait_cmd_ioc
  • Initialize psp_int_queue in psp_dev_init when vendor is Hygon
  • Declare extern psp_int_queue in hygon/psp-dev.h
drivers/crypto/ccp/hygon/psp-dev.c
drivers/crypto/ccp/psp-dev.c
drivers/crypto/ccp/hygon/psp-dev.h
Extend IRQ handler to signal new PSP wait queue
  • Modify psp_irq_handler_hygon to set psp_int_rcvd and wake psp_int_queue
  • Retain backward compatibility by waking sev->int_queue when sev is non-NULL
drivers/crypto/ccp/hygon/psp-dev.c
Add new Hygon PCI device IDs
  • Introduce PCI_VDEVICE entries for IDs 0x14d8 and 0x14c6
drivers/crypto/ccp/sp-pci.c
Fix potential out-of-bounds in TDM driver
  • Replace fixed 128-byte symbol_buf with KSYM_NAME_LEN to ensure sufficient buffer size
drivers/crypto/ccp/hygon/tdm-dev.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @chench246 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: opsiff

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

The pull request process is described 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

@opsiff opsiff merged commit fa86557 into deepin-community:linux-6.6.y May 16, 2025
5 of 6 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