Skip to content

Commit e221804

Browse files
aikbp3tk0v
authored andcommitted
x86/sev: Do not handle #VC for DR7 read/write
With MSR_AMD64_SEV_DEBUG_SWAP enabled, the guest is not expected to receive a #VC for reads or writes of DR7. Update the SNP_FEATURES_PRESENT mask with MSR_AMD64_SNP_DEBUG_SWAP so an SNP guest doesn't gracefully terminate during SNP feature negotiation if MSR_AMD64_SEV_DEBUG_SWAP is enabled. Since a guest is not expected to receive a #VC on DR7 accesses when MSR_AMD64_SEV_DEBUG_SWAP is enabled, return an error from the #VC handler in this situation. Signed-off-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Carlos Bilbao <[email protected]> Reviewed-by: Tom Lendacky <[email protected]> Reviewed-by: Pankaj Gupta <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2ccdd1b commit e221804

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

arch/x86/boot/compressed/sev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ static void enforce_vmpl0(void)
365365
* by the guest kernel. As and when a new feature is implemented in the
366366
* guest kernel, a corresponding bit should be added to the mask.
367367
*/
368-
#define SNP_FEATURES_PRESENT (0)
368+
#define SNP_FEATURES_PRESENT MSR_AMD64_SNP_DEBUG_SWAP
369369

370370
void snp_check_features(void)
371371
{

arch/x86/kernel/sev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,9 @@ static enum es_result vc_handle_dr7_write(struct ghcb *ghcb,
15751575
long val, *reg = vc_insn_get_rm(ctxt);
15761576
enum es_result ret;
15771577

1578+
if (sev_status & MSR_AMD64_SNP_DEBUG_SWAP)
1579+
return ES_VMM_ERROR;
1580+
15781581
if (!reg)
15791582
return ES_DECODE_FAILED;
15801583

@@ -1612,6 +1615,9 @@ static enum es_result vc_handle_dr7_read(struct ghcb *ghcb,
16121615
struct sev_es_runtime_data *data = this_cpu_read(runtime_data);
16131616
long *reg = vc_insn_get_rm(ctxt);
16141617

1618+
if (sev_status & MSR_AMD64_SNP_DEBUG_SWAP)
1619+
return ES_VMM_ERROR;
1620+
16151621
if (!reg)
16161622
return ES_DECODE_FAILED;
16171623

0 commit comments

Comments
 (0)