Skip to content

Add throttling detection to sev-guest

Dionna Glaze lkml 15 versions – Applied

Status from this message: The following commit has been merged into the x86/urgent branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v15 Latest4 patches 0 repliesApplied
  2. v143 patches 3 repliesSuperseded
  3. v134 patches 8 repliesSuperseded
Earlier versions · 12
VersionPostedPatchesRepliesStatus
v123 patches5 repliesSuperseded
v117 patches3 repliesSuperseded
v104 patches0 repliesSuperseded
v94 patches3 repliesApplied
v84 patches18 repliesSuperseded
v74 patches3 repliesSuperseded
v64 patches0 repliesSuperseded
v54 patches4 repliesSuperseded
v44 patches8 repliesSuperseded
v34 patches2 repliesSuperseded
v22 patches0 repliesSuperseded
v12 patches2 repliesSuperseded

Changes in v15 from the cover letter

* Split double-buffering into its own patch.
* Changed cond_resched to schedule_timeout_killable.

Patches in v15 Applied

#Subject and filesSizeRepliesApplied
1/4virt/coco/sev-guest: Add throttling awarenessarch/x86/include/asm/sev-common.h arch/x86/kernel/sev.c drivers/virt/coco/sev-guest/sev-guest.c+34 -60 replies
2/4virt/coco/sev-guest: Double-buffer messagesdrivers/virt/coco/sev-guest/sev-guest.c+21 -40 replies
3/4crypto: ccp - Name -1 return value as SEV_RET_NO_FW_CALLDocumentation/virt/coco/sev-guest.rst drivers/crypto/ccp/sev-dev.c include/uapi/linux/psp-sev.h+22 -90 replies
4/4x86/sev: Change snp_guest_issue_request's fw_errDocumentation/virt/coco/sev-guest.rst arch/x86/include/asm/sev-common.h arch/x86/include/asm/sev.h +3 more+62 -440 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v15 yet.

Read the v15 thread

Cover letter [PATCH v15 0/4] Add throttling detection to sev-guest

The guest request synchronous API from SEV-SNP VMs to the host's security processor consumes a global resource. For this reason, AMD's docs recommend that the host implements a throttling mechanism. In order for the guest to know it's been throttled and should try its request again, we need some good-faith communication from the host that the request has been throttled.

These patches work with the existing /dev/sev-guest ABI to detect a throttling code.

Changes from v14:
* Split double-buffering into its own patch.
* Changed cond_resched to schedule_timeout_killable.
Changes from v13:
* Added double-buffering fix to the "Fixes" patch to address a secondary concern of zero trust with respect to host access to intermediate cryptographic computations in shared memory.
* Removed module parameters and rate limiting in favor of just cond_resched.
* Removed possible infinite loop of retries by giving up with an erased VMPCK and -ETIMEDOUT error after 60 seconds of retries.
Changes from v12:
* Reordered fix patch to the beginning and kept it minimal.
* Changed documentation in same patch as the respective change to the header.
* Changed exitinfo2 in dev_alert to print in hex.
Changes from v11:
* Squashed all type changing patches into 1 that modifies both sev-guest

    and x86/kernel/sev.c.

* Removed fw_err field from sev-guest command struct (renamed exitinfo2).
Changes from v10:
* Added sev_guestreq_err_t typedef early in chain to change a signature acress x86/sev and virt/coco/sev-guest in a single change. This makes all patches build. I have 3 cleanup patches to change the type and subsequently remove the typedef.
* Changed exitinfo2 initial undefined value back to 0xff since Thomas indicated that a firmware error is only 16 bits.
Changes from v9:
* Rebased on v6.2-rc3
Changes from v8:
* Added documentation changes.
* Changed commit messages to use passive voice.
* Simplified control flow for __sev_platform_init_locked.
Changes from v7:
* Replaced handle_guest_request arguments msg_ver and fw_err with a pointer to the snp_guest_request_ioctl argument struct.
Changes from v6:
* Rebased on the IV reuse fix patch
* renamed rate_hz to rate_s and fixed its MODULE_PARM_DESC to use the correct variable name.
* Changed sleep_timeout_interrutible (not defined) to schedule_timeout_interruptible.
Changes from v5:
* Fixed commit prefix text
* Added all get_maintainers.pl folks to commits' Cc tags
* Changed SET_RET_NO_FW_CALL commit's metadata to show pgonda signs off and is the author.
Changes from v4:
* Clarified comment on SEV_RET_NO_FW_CALL
* Changed ratelimit loop to use sleep_timeout_interruptible
Changes from v3:
* sev-guest ratelimits itself to one request twice a second.
* Fixed a type signature to use u64 instead of unsigned int
* Set *exitinfo2 unconditionally after the ghcb_hv_call.
Changes from v2:
* Codified the non-firmware-call firmware error code as (u32)-1.
* Changed sev_issue_guest_request unsigned long *fw_err argument to u64 *exitinfo2 to more accurately and type-safely describe the value that it outputs.
* Changed sev_issue_guest_request to always set its exitinfo2 argument to either the non-firmware-call error code, the EXIT_INFO_2 returned from the VMM if the request failed, or 0 on success. This fixes a bug that returned uninitialized kernel stack memory to the user when there is no error.
* Changed the throttle behavior to retry in the driver instead of returning -EAGAIN, due to possible message sequence number reuse on different message contents.

Changes from v1:
* Changed throttle error code to 2

Cc Tom Lendacky <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Peter Gonda <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Venu Busireddy <[email protected]>
Cc Michael Roth <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Cc Michael Sterritt <[email protected]>

Dionna Glaze (3):
virt/coco/sev-guest: Add throttling awareness virt/coco/sev-guest: Double-buffer messages x86/sev: Change snp_guest_issue_request's fw_err

Peter Gonda (1):
crypto: ccp - Name -1 return value as SEV_RET_NO_FW_CALL

 Documentation/virt/coco/sev-guest.rst   |  21 +++--
 arch/x86/include/asm/sev-common.h       |   3 -
 arch/x86/include/asm/sev.h              |   4 +-
 arch/x86/kernel/sev.c                   |  13 +--
 drivers/crypto/ccp/sev-dev.c            |  22 ++++--
 drivers/virt/coco/sev-guest/sev-guest.c | 100 +++++++++++++++++-------
 include/uapi/linux/psp-sev.h            |   7 ++
 include/uapi/linux/sev-guest.h          |  18 ++++-
 8 files changed, 132 insertions(+), 56 deletions(-)
Signature · 1 line
2.39.1.637.g21b0678d19-goog