crypto/ccp: Introduce SNP_VERIFY_MITIGATION command
Subsystems (3)
RFC v2 1/1 crypto/ccp: Introduce SNP_VERIFY_MITIGATION command
The SEV-SNP firmware provides the SNP_VERIFY_MITIGATION command, which can be used to query the status of currently supported vulnerability mitigations and to initiate mitigations within the firmware.
This command is an explicit mechanism to ascertain if a firmware mitigation is applied without needing a full RMP re-build, which is most useful in a live firmware update scenario.
The firmware supports two subcommands: STATUS and VERIFY. The STATUS subcommand is used to query the supported and verified mitigation bits. The VERIFY subcommand initiates the mitigation process within the FW for the specified vulnerability.Expose a userspace interface under:/sys/firmware/vulnerabilities/
- supported_mitigations (read-only): supported mitigation vector mask
- verified_mitigations (read/write): current verified mask; write a vector to request VERIFY for that bit
- failed_status (read-only): firmware-reported failure status from the last operation, as returned alongside the status vectors
The behavior of SNP_VERIFY_MITIGATION and the pre-requisites for using it are bug-specific. Information about supported mitigations and it's corresponding vector is to be published as part of the AMD Security Bulletin.
See SEV-SNP Firmware ABI specifications 1.58, SNP_VERIFY_MITIGATION for more details.
---
RFC v2:
* Intrdouce /sys/firmware/vulnerabilities sysfs interface instead of
an ioctl interface - Boris
* Reword commit message to focus on need for a userspace interface - Sean
* Since download_firmware_ex is the primary usecase of this feature,
posting this patch in parallel to those discussions[1].
Link to RFC: https://lore.kernel.org/linux-crypto/[email protected]/
[1]: https://lore.kernel.org/linux-crypto/[email protected]/
--- .../testing/sysfs-firmware-vulnerabilities | 20 +++ drivers/crypto/ccp/sev-dev.c | 152 ++++++++++++++++++ drivers/crypto/ccp/sev-dev.h | 2 + include/linux/psp-sev.h | 51 ++++++ 4 files changed, 225 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-firmware-vulnerabilities
Documentation/ABI/testing/sysfs-firmware-vulnerabilities new file +20 -0
@@ -0,0 +1,20 @@ +What: /sys/firmware/vulnerabilities + /sys/firmware/vulnerabilities/supported_mitigations + /sys/firmware/vulnerabilities/verified_mitigations + /sys/firmware/vulnerabilities/failed_status +Date: May 2026 +Contact: [email protected] +Description: Information about SEV-SNP firmware vulnerabilities + + supported_mitigations: Read only interface that reports the + vector of mitigations supported by the + firmware + verified_mitigations: Read/write interface that allows applying + a firmware mitigation and reports + already verified mitigations. + failed_status: Read only interface that reports the status of + the verification operation. + + The list of supported mitigations, their applications are both + platform and bug specific posted as part of the AMD Security + Bulletin.
drivers/crypto/ccp/sev-dev.c +152 -0
176 lines not on this page · raw message
drivers/crypto/ccp/sev-dev.h +2 -0
@@ -59,6 +59,8 @@ struct sev_device {bool snp_initialized; +struct kobject *verify_mit; +struct sev_user_data_status sev_plat_status;struct sev_user_data_snp_status snp_plat_status;
include/linux/psp-sev.h +51 -0
67 lines not on this page · raw message
Signature · 1 line
2.53.0
Quoted 2 lines · Pratik R. Sampat
-
failed_status(read-only): firmware-reported failure status from the last operation, as returned alongside the status vectors
"from the last operation" is not quite right here, it looks like it re-runs the STATUS command and reports that error?
Documentation/ABI/testing/sysfs-firmware-vulnerabilities line 16
Quoted 2 lines
Documentation/ABI/testing/sysfs-firmware-vulnerabilities new file +2
-0+ failed_status: Read only interface that reports the status of + the verification operation.
This should probably also note that it runs a fresh operation.
I was trying to think of a nice way to report the status of the last operation short of caching it, but I didn't come up with anything good. I don't think it's important enough to cache, the failure codes right now are all for things that would persist across runs.
Tycho
Hi Tycho,
Missed this one in my mailbox. Thanks for the review!
Quoted 6 lines · Tycho Andersen
Quoted 2 lines · Pratik R. Sampat
-
failed_status(read-only): firmware-reported failure status from the last operation, as returned alongside the status vectors"from the last operation" is not quite right here, it looks like it re-runs the STATUS command and reports that error?
That is correct. It runs the STATUS command and reports the status of the verification operation. Probably better to phrase it as the "last verification operation" instead?
Quoted 6 lines
Documentation/ABI/testing/sysfs-firmware-vulnerabilities line 16
Quoted 3 lines
Documentation/ABI/testing/sysfs-firmware-vulnerabilities new file +2
-0+ failed_status: Read only interface that reports the status of + the verification operation.This should probably also note that it runs a fresh operation.
Ack.
Quoted 5 lines
I was trying to think of a nice way to report the status of the last operation short of caching it, but I didn't come up with anything good. I don't think it's important enough to cache, the failure codes right now are all for things that would persist across runs.
Right, I didn't want to leave room for any ambiguity so avoided caching it for one additional call.
If the failure status is set, we do fail the VERIFY op as well, but I wasn't too sure how to report that failure without an additional interface like this.
--Pratik
Quoted 9 lines · Pratik R. Sampat
Hi Tycho,
Missed this one in my mailbox. Thanks for the review!
Quoted 4 lines · Tycho Andersen
Quoted 2 lines · Pratik R. Sampat
-
failed_status(read-only): firmware-reported failure status from the last operation, as returned alongside the status vectors
Quoted 6 lines
Quoted 2 lines
"from the last operation" is not quite right here, it looks like it re-runs the STATUS command and reports that error?
That is correct. It runs the STATUS command and reports the status of the verification operation. Probably better to phrase it as the "last verification operation" instead?
Hmm, I'm not sure what you mean here. The FW spec 1.58 table 132 says:
Command to request the firmware to return information regarding the currently supported (available) mitigations, and then the verified (processed and completed) mitigations. If DST_PADDR_EN is set, DST_PADDR will be populated with the SNP_VERIFY_MITIGATION_DST_PADDR structure.
so I don't think it has anything to do with the last VERIFY operation?
The spec is a bit messy here, though. Table 131 mentions a MIT_REQ_CHECK operation, which I assume should really be _STATUS. It describes what the output VECTOR should be for VERIFY in table 131, but not what it is for STATUS. Table 132 suggests the output VECTOR is the list of supported mitigations, which matches what I was seeing when I played with this.
Tycho
Quoted 19 lines · Tycho Andersen
Quoted 9 lines · Pratik R. Sampat
Hi Tycho,
Missed this one in my mailbox. Thanks for the review!
Quoted 4 lines · Tycho Andersen
Quoted 2 lines · Pratik R. Sampat
-
failed_status(read-only): firmware-reported failure status from the last operation, as returned alongside the status vectorsQuoted 6 lines
Quoted 2 lines
"from the last operation" is not quite right here, it looks like it re-runs the STATUS command and reports that error?
That is correct. It runs the STATUS command and reports the status of the verification operation. Probably better to phrase it as the "last verification operation" instead?
Hmm, I'm not sure what you mean here. The FW spec 1.58 table 132 says:
Quoted 8 lines
Command to request the firmware to return information regarding the currently supported (available) mitigations, and then the verified (processed and completed) mitigations. If
DST_PADDR_ENis set,DST_PADDRwill be populated with theSNP_VERIFY_MITIGATION_DST_PADDRstructure.so I don't think it has anything to do with the last VERIFY operation?
Right, I had missed that. Table 133 says failure_status is the status of the verification operation. It also looks like calling STATUS repopulates SNP_VERIFY_MITIGATION_DST_PADDR anyway.
I am not keen on caching the result either though. For simplicity, we could just drop the failed_status interface, log failure_status with pr_[err|warn](), and return -EIO?
Quoted 7 lines
The spec is a bit messy here, though. Table 131 mentions a
MIT_REQ_CHECKoperation, which I assume should really be_STATUS. It describes what the output VECTOR should be for VERIFY in table 131, but not what it is for STATUS. Table 132 suggests the output VECTOR is the list of supported mitigations, which matches what I was seeing when I played with this.
That is a good catch! We should get that changed in spec.
--Pratik
Quoted 3 lines · Pratik R. Sampat
I am not keen on caching the result either though. For simplicity, we could just drop the
failed_statusinterface, logfailure_statuswith pr_[err|warn](), and return-EIO?
Yeah, that sounds reasonable to me.
Quoted 9 lines
Quoted 7 lines
The spec is a bit messy here, though. Table 131 mentions a
MIT_REQ_CHECKoperation, which I assume should really be_STATUS. It describes what the output VECTOR should be for VERIFY in table 131, but not what it is for STATUS. Table 132 suggests the output VECTOR is the list of supported mitigations, which matches what I was seeing when I played with this.That is a good catch! We should get that changed in spec.
Yep, I pinged our spec maintainer, hopefully it'll be resolved Real Soon.
Thanks,
Tycho