Skip to content

Commit b131035

Browse files
tialaliuw
authored andcommitted
x86/hyperv: Mark Hyper-V vp assist page unencrypted in SEV-SNP enlightened guest
hv vp assist page needs to be shared between SEV-SNP guest and Hyper-V. So mark the page unencrypted in the SEV-SNP guest. Reviewed-by: Dexuan Cui <decui@microsoft.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Signed-off-by: Tianyu Lan <tiala@microsoft.com> Signed-off-by: Wei Liu <wei.liu@kernel.org> Link: https://lore.kernel.org/r/20230818102919.1318039-4-ltykernel@gmail.com
1 parent 8387ce0 commit b131035

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

arch/x86/hyperv/hv_init.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <asm/hyperv-tlfs.h>
1919
#include <asm/mshyperv.h>
2020
#include <asm/idtentry.h>
21+
#include <asm/set_memory.h>
2122
#include <linux/kexec.h>
2223
#include <linux/version.h>
2324
#include <linux/vmalloc.h>
@@ -106,8 +107,21 @@ static int hv_cpu_init(unsigned int cpu)
106107
* in hv_cpu_die(), otherwise a CPU may not be stopped in the
107108
* case of CPU offlining and the VM will hang.
108109
*/
109-
if (!*hvp)
110+
if (!*hvp) {
110111
*hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL | __GFP_ZERO);
112+
113+
/*
114+
* Hyper-V should never specify a VM that is a Confidential
115+
* VM and also running in the root partition. Root partition
116+
* is blocked to run in Confidential VM. So only decrypt assist
117+
* page in non-root partition here.
118+
*/
119+
if (*hvp && hv_isolation_type_en_snp()) {
120+
WARN_ON_ONCE(set_memory_decrypted((unsigned long)(*hvp), 1));
121+
memset(*hvp, 0, PAGE_SIZE);
122+
}
123+
}
124+
111125
if (*hvp)
112126
msr.pfn = vmalloc_to_pfn(*hvp);
113127

0 commit comments

Comments
 (0)