diff options
author | 2022-02-09 12:10:10 -0600 | |
---|---|---|
committer | 2022-04-06 13:14:24 +0200 | |
commit | 87294bdb7b4b73555b0fba45da1cdecdc6a0d5a8 (patch) | |
tree | 1a9da8387cd9b30e1ac28ca1992f45659e6d467b /arch/x86/kernel/sev-shared.c | |
parent | x86/compressed: Add helper for validating pages in the decompression stage (diff) | |
download | linux-87294bdb7b4b73555b0fba45da1cdecdc6a0d5a8.tar.gz linux-87294bdb7b4b73555b0fba45da1cdecdc6a0d5a8.tar.bz2 linux-87294bdb7b4b73555b0fba45da1cdecdc6a0d5a8.zip |
x86/compressed: Register GHCB memory when SEV-SNP is active
The SEV-SNP guest is required by the GHCB spec to register the GHCB's
Guest Physical Address (GPA). This is because the hypervisor may prefer
that a guest use a consistent and/or specific GPA for the GHCB associated
with a vCPU. For more information, see the GHCB specification section
"GHCB GPA Registration".
If hypervisor can not work with the guest provided GPA then terminate the
guest boot.
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Venu Busireddy <venu.busireddy@oracle.com>
Link: https://lore.kernel.org/r/20220307213356.2797205-17-brijesh.singh@amd.com
Diffstat (limited to 'arch/x86/kernel/sev-shared.c')
-rw-r--r-- | arch/x86/kernel/sev-shared.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86/kernel/sev-shared.c b/arch/x86/kernel/sev-shared.c index 4a876e684f67..e9ff13cd90b0 100644 --- a/arch/x86/kernel/sev-shared.c +++ b/arch/x86/kernel/sev-shared.c @@ -68,6 +68,22 @@ static u64 get_hv_features(void) return GHCB_MSR_HV_FT_RESP_VAL(val); } +static void __maybe_unused snp_register_ghcb_early(unsigned long paddr) +{ + unsigned long pfn = paddr >> PAGE_SHIFT; + u64 val; + + sev_es_wr_ghcb_msr(GHCB_MSR_REG_GPA_REQ_VAL(pfn)); + VMGEXIT(); + + val = sev_es_rd_ghcb_msr(); + + /* If the response GPA is not ours then abort the guest */ + if ((GHCB_RESP_CODE(val) != GHCB_MSR_REG_GPA_RESP) || + (GHCB_MSR_REG_GPA_RESP_VAL(val) != pfn)) + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_REGISTER); +} + static bool sev_es_negotiate_protocol(void) { u64 val; |