Skip to contentSkip to conversation

Support for SNP_VERIFY_MITIGATION command

PATCH In review Pratik R. Sampat 2 participants 8 messages Jun 30, 2025 – Jul 24, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Support for SNP_VERIFY_MITIGATION command

The SNP_VERIFY_MITIGATION command can be used to query the status of currently supported vulnerability mitigations and to initiate mitigations within the firmware.

The command 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.

Information about supported mitigations is planned to be published as part of AMD Security Bulletins/Notices.

The patch is based on kvm/next and on "crypto/ccp: Fix locking on alloc failure handling"[1]. The latter is required as we invoke this command within sev_ioctl(), which already holds the mutex and does not need to do so again if it has to reclaim snp pages.

Comments and feedback appreciated!

[1]: https://lore.kernel.org/all/[email protected]/

Pratik R. Sampat (1):
crypto: ccp - Add the SNP_VERIFY_MITIGATION command

 Documentation/virt/coco/sev-guest.rst | 13 +++++++
 drivers/crypto/ccp/sev-dev.c          | 55 +++++++++++++++++++++++++++
 include/linux/psp-sev.h               | 30 +++++++++++++++
 include/uapi/linux/psp-sev.h          | 34 +++++++++++++++++
 4 files changed, 132 insertions(+)

base-commit: cf931c83bfc9a33f0b0a91f6fb63a685ffeeb011

Signature · 1 line
2.49.0
#1 lore raw

PATCH 1/1 crypto: ccp - Add the 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.

See SEV-SNP Firmware ABI specifications 1.58, SNP_VERIFY_MITIGATION for more details.

---
 Documentation/virt/coco/sev-guest.rst | 13 +++++++
 drivers/crypto/ccp/sev-dev.c          | 55 +++++++++++++++++++++++++++
 include/linux/psp-sev.h               | 30 +++++++++++++++
 include/uapi/linux/psp-sev.h          | 34 +++++++++++++++++
 4 files changed, 132 insertions(+)
Documentation/virt/coco/sev-guest.rst +13 -0
index 93debceb6eb0..8cc1eb375284 100644
@@ -195,6 +195,19 @@ them into the system after obtaining them from the KDS, and corresponds
 closely to the SNP_VLEK_LOAD firmware command specified in the SEV-SNP
 spec.
 
+2.8 SNP_VERIFY_MITIGATION
+-------------------------
+:Technology: sev-snp
+:Type: hypervisor ioctl cmd
+:Parameters (in): struct sev_user_data_snp_verify_mitigation
+:Returns (out): 0 on success, -negative on error
+
+SNP_VERIFY_MITIGATION enables the host to issue commands to the SEV firmware to
+manage vulnerability mitigations. This command provides two subcommands: VERIFY
+and STATUS. The VERIFY subcommand instructs the firmware to initiate mitigation
+for a specified vulnerability. The STATUS subcommand queries the firmware for
+the currently supported and verified mitigations.
+
 3. SEV-SNP CPUID Enforcement
 ============================
 
drivers/crypto/ccp/sev-dev.c +55 -0

73 lines not on this page · raw message

include/linux/psp-sev.h +30 -0
index 0b3a36bdaa90..ee5d64b0959a 100644
@@ -96,6 +96,7 @@ enum sev_cmd {
 	SEV_CMD_SNP_LAUNCH_FINISH	= 0x0A2,
 	SEV_CMD_SNP_DBG_DECRYPT		= 0x0B0,
 	SEV_CMD_SNP_DBG_ENCRYPT		= 0x0B1,
+	SEV_CMD_SNP_VERIFY_MITIGATION	= 0x0B2,
 	SEV_CMD_SNP_PAGE_SWAP_OUT	= 0x0C0,
 	SEV_CMD_SNP_PAGE_SWAP_IN	= 0x0C1,
 	SEV_CMD_SNP_PAGE_MOVE		= 0x0C2,
@@ -812,6 +813,35 @@ struct sev_data_snp_commit {
 	u32 len;
 } __packed;
 
+/**
+ * struct sev_data_snp_verify_mitigation - SNP_VERIFY_MITIGATION command params
+ *
+ * @length: Length of the command buffer read by the PSP
+ * @subcommand: Mitigation sub-command for the firmware to execute.
+ * @rsvd: Reserved
+ * @vector: Bit specifying the vulnerability mitigation to process
+ * @dst_paddr_en: Destination paddr enabled
+ * @src_paddr_en: Source paddr enabled
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @dst_paddr: Destination address to write the result
+ * @src_paddr: Source address for optional input data
+ * @rsvd3: Reserved
+ */
+struct sev_data_snp_verify_mitigation {
+	u32 length;
+	u16 subcommand;
+	u16 rsvd;
+	u64 vector;
+	u32 dst_paddr_en : 1,
+	    src_paddr_en : 1,
+	    rsvd1 : 30;
+	u8 rsvd2[4];
+	u64 src_paddr;
+	u64 dst_paddr;
+	u8 rsvd3[24];
+} __packed;
+
 #ifdef CONFIG_CRYPTO_DEV_SP_PSP
 
 /**
include/uapi/linux/psp-sev.h +34 -0
index eeb20dfb1fda..ca0f44fef659 100644
@@ -32,6 +32,7 @@ enum {
 	SNP_COMMIT,
 	SNP_SET_CONFIG,
 	SNP_VLEK_LOAD,
+	SNP_VERIFY_MITIGATION,
 
 	SEV_MAX,
 };
@@ -249,6 +250,39 @@ struct sev_user_data_snp_wrapped_vlek_hashstick {
 	__u8 data[432];				/* In */
 } __packed;
 
+#define SNP_MIT_SUBCMD_REQ_STATUS	0x0
+#define SNP_MIT_SUBCMD_REQ_VERIFY	0x1
+
+/**
+ * struct sev_user_data_snp_verify_mitigation - vulnerability mitigation op
+ *
+ * @subcommand: Mitigation sub-command for the firmware to execute.
+ *              REQ_STATUS: 0x0 - Request status about currently supported and
+ *                                verified mitigations
+ *              REQ_VERIFY: 0x1 - Request to initiate verification mitigation
+ *                                operation on a specific mitigation
+ * @vector: A single bit to specify the mitigation to process
+ * @dst_uaddr: Destination addr to write the result
+ */
+struct sev_user_data_snp_verify_mitigation {
+	u16 subcommand;				/* In */
+	u64 vector;				/* In */
+	u64 dst_uaddr;				/* In */
+} __packed;
+
+/**
+ * struct snp_verify_mitigation_dst - mitigation result vectors
+ *
+ * @mit_verified_vector: Bit vector of vulnerability mitigations verified
+ * @mit_supported_vector: Bit vector of vulnerability mitigations supported
+ * @mit_failure_status: Status of the verification operation
+ */
+struct snp_verify_mitigation_dst {
+	u64 mit_verified_vector;		/* OUT */
+	u64 mit_supported_vector;		/* OUT */
+	u32 mit_failure_status;			/* OUT */
+} __packed;
+
 /**
  * struct sev_issue_cmd - SEV ioctl parameters
  *
Signature · 1 line
2.49.0
#2 lore raw

Re: [PATCH 1/1] crypto: ccp - Add the SNP_VERIFY_MITIGATION command

Quoted 6 lines · Pratik R. Sampat

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.

See SEV-SNP Firmware ABI specifications 1.58, SNP_VERIFY_MITIGATION for more details.

Nothing here explains why this needs to be exposed directly to userspace.

#3 lore raw

Re: [PATCH 1/1] crypto: ccp - Add the SNP_VERIFY_MITIGATION command

Hi Sean,

Quoted 9 lines · Sean Christopherson
Quoted 6 lines · Pratik R. Sampat

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.

See SEV-SNP Firmware ABI specifications 1.58, SNP_VERIFY_MITIGATION for more details.

Nothing here explains why this needs to be exposed directly to userspace.

The general idea is that not all mitigations may/can be applied immediately, for ex: some mitigations may require all the guest to be shutdown before they can be applied. So a host userspace interface to query+apply mitigations can be useful for that coordination before attempting to apply the mitigation.

I also realized that I could use SNP_FEATURE_INFO's cached results from Ashish's CipherTextHiding series[1] to save us a firmware call if the verify mitigation in the ECX vector is unsupported.

[1]: https://lore.kernel.org/kvm/[email protected]/

Thanks,
Pratik

#4 lore raw

Re: [PATCH 1/1] crypto: ccp - Add the SNP_VERIFY_MITIGATION command

Quoted 11 lines · Pratik R. Sampat

Hi Sean,

Quoted 8 lines · Sean Christopherson
Quoted 6 lines · Pratik R. Sampat

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.

See SEV-SNP Firmware ABI specifications 1.58, SNP_VERIFY_MITIGATION for more details.

Quoted 7 lines
Quoted 1 line

Nothing here explains why this needs to be exposed directly to userspace.

The general idea is that not all mitigations may/can be applied immediately, for ex: some mitigations may require all the guest to be shutdown before they can be applied. So a host userspace interface to query+apply mitigations can be useful for that coordination before attempting to apply the mitigation.

But why expose ioctls to effectively give userspace direct access to firmware? E.g. why not configure firmware mitigations via the kernel's upcoming Attack Vector Controls.

https://lore.kernel.org/all/[email protected]

#5 lore raw

Re: [PATCH 1/1] crypto: ccp - Add the SNP_VERIFY_MITIGATION command

Quoted 20 lines · Sean Christopherson
Quoted 11 lines · Pratik R. Sampat

Hi Sean,

Quoted 8 lines · Sean Christopherson
Quoted 6 lines · Pratik R. Sampat

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.

See SEV-SNP Firmware ABI specifications 1.58, SNP_VERIFY_MITIGATION for more details.

Quoted 7 lines
Quoted 1 line

Nothing here explains why this needs to be exposed directly to userspace.

The general idea is that not all mitigations may/can be applied immediately, for ex: some mitigations may require all the guest to be shutdown before they can be applied. So a host userspace interface to query+apply mitigations can be useful for that coordination before attempting to apply the mitigation.

Quoted 5 lines

But why expose ioctls to effectively give userspace direct access to firmware? E.g. why not configure firmware mitigations via the kernel's upcoming Attack Vector Controls.

https://lore.kernel.org/all/[email protected]

Something like Attack Vector Controls may not work in our case, since those are designed to protect the kernel from userspace and guests, whereas SEV firmware mitigations are focused on protecting guests from the hypervisor. Additionally, Attack Vector Controls are managed via boot command-line parameters, but maybe we could potentially change that by introducing RW interfaces for our case within /sys/devices/system/cpu/vector_vulnerabilities (or what the final form of this interface ends up being).

Another option could be to expose this functionality in a subdirectory under /sys/firmware/?

However, with any of these approaches, we would still be giving userspace the ability to access and alter the firmware, similar to the interfaces that expose features such as Download Firmware EX also allow, right?

Thanks!
Pratik

#6 lore raw

Re: [PATCH 1/1] crypto: ccp - Add the SNP_VERIFY_MITIGATION command

Quoted 38 lines · Pratik R. Sampat
Quoted 20 lines · Sean Christopherson
Quoted 11 lines · Pratik R. Sampat

Hi Sean,

Quoted 8 lines · Sean Christopherson
Quoted 6 lines · Pratik R. Sampat

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.

See SEV-SNP Firmware ABI specifications 1.58, SNP_VERIFY_MITIGATION for more details.

Quoted 7 lines
Quoted 1 line

Nothing here explains why this needs to be exposed directly to userspace.

The general idea is that not all mitigations may/can be applied immediately, for ex: some mitigations may require all the guest to be shutdown before they can be applied. So a host userspace interface to query+apply mitigations can be useful for that coordination before attempting to apply the mitigation.

Quoted 5 lines

But why expose ioctls to effectively give userspace direct access to firmware? E.g. why not configure firmware mitigations via the kernel's upcoming Attack Vector Controls.

https://lore.kernel.org/all/[email protected]

Something like Attack Vector Controls may not work in our case, since those are designed to protect the kernel from userspace and guests, whereas SEV firmware mitigations are focused on protecting guests from the hypervisor. Additionally, Attack Vector Controls are managed via boot command-line parameters, but maybe we could potentially change that by introducing RW interfaces for our case within /sys/devices/system/cpu/vector_vulnerabilities (or what the final form of this interface ends up being).

Quoted 7 lines

Another option could be to expose this functionality in a subdirectory under /sys/firmware/?

However, with any of these approaches, we would still be giving userspace the ability to access and alter the firmware, similar to the interfaces that expose features such as Download Firmware EX also allow, right?

Not all userspace is created equal, e.g. init_ex_path is a module param, and (un)loading modules requires CAP_SYS_MODULE. The expected/desired use cases also matter, e.g. if there's no use case for toggling mitigations after initial setup, then the interface presented to userspace could likely be much different than if there's a "need" to make mitigations fully runtime configurable.

#7 lore raw

Re: [PATCH 1/1] crypto: ccp - Add the SNP_VERIFY_MITIGATION command

Quoted 47 lines · Sean Christopherson
Quoted 38 lines · Pratik R. Sampat
Quoted 20 lines · Sean Christopherson
Quoted 11 lines · Pratik R. Sampat

Hi Sean,

Quoted 8 lines · Sean Christopherson
Quoted 6 lines · Pratik R. Sampat

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.

See SEV-SNP Firmware ABI specifications 1.58, SNP_VERIFY_MITIGATION for more details.

Quoted 7 lines
Quoted 1 line

Nothing here explains why this needs to be exposed directly to userspace.

The general idea is that not all mitigations may/can be applied immediately, for ex: some mitigations may require all the guest to be shutdown before they can be applied. So a host userspace interface to query+apply mitigations can be useful for that coordination before attempting to apply the mitigation.

Quoted 5 lines

But why expose ioctls to effectively give userspace direct access to firmware? E.g. why not configure firmware mitigations via the kernel's upcoming Attack Vector Controls.

https://lore.kernel.org/all/[email protected]

Something like Attack Vector Controls may not work in our case, since those are designed to protect the kernel from userspace and guests, whereas SEV firmware mitigations are focused on protecting guests from the hypervisor. Additionally, Attack Vector Controls are managed via boot command-line parameters, but maybe we could potentially change that by introducing RW interfaces for our case within /sys/devices/system/cpu/vector_vulnerabilities (or what the final form of this interface ends up being).

Quoted 7 lines

Another option could be to expose this functionality in a subdirectory under /sys/firmware/?

However, with any of these approaches, we would still be giving userspace the ability to access and alter the firmware, similar to the interfaces that expose features such as Download Firmware EX also allow, right?

Quoted 5 lines

Not all userspace is created equal, e.g. init_ex_path is a module param, and (un)loading modules requires CAP_SYS_MODULE. The expected/desired use cases also matter, e.g. if there's no use case for toggling mitigations after initial setup, then the interface presented to userspace could likely be much different than if there's a "need" to make mitigations fully runtime configurable.

That’s certainly true.
I believe in our case, runtime configurability may be necessary when we support live firmware updates. These updates can introduce new supported mitigations, some of which may require guests to be shut down before they can be applied.

With the ioctl approach, we use the writable flag to check if we can apply mitigations, rather than just reading those that are supported. Alternatively, we could create a /sys/firmware/vulnerabilities/ directory containing a read-only supported_mitigations file and a read-write verified_mitigations interface.

Thanks!
Pratik