Skip to content

Commit 4754ec7

Browse files
tialaliuw
authored andcommitted
x86/hyperv: Add hyperv-specific handling for VMMCALL under SEV-ES
Add Hyperv-specific handling for faults caused by VMMCALL instructions. 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-9-ltykernel@gmail.com
1 parent 44676bb commit 4754ec7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <asm/nmi.h>
3333
#include <clocksource/hyperv_timer.h>
3434
#include <asm/numa.h>
35+
#include <asm/svm.h>
3536

3637
/* Is Linux running as the root partition? */
3738
bool hv_root_partition;
@@ -574,11 +575,31 @@ static bool __init ms_hyperv_msi_ext_dest_id(void)
574575
return eax & HYPERV_VS_PROPERTIES_EAX_EXTENDED_IOAPIC_RTE;
575576
}
576577

578+
#ifdef CONFIG_AMD_MEM_ENCRYPT
579+
static void hv_sev_es_hcall_prepare(struct ghcb *ghcb, struct pt_regs *regs)
580+
{
581+
/* RAX and CPL are already in the GHCB */
582+
ghcb_set_rcx(ghcb, regs->cx);
583+
ghcb_set_rdx(ghcb, regs->dx);
584+
ghcb_set_r8(ghcb, regs->r8);
585+
}
586+
587+
static bool hv_sev_es_hcall_finish(struct ghcb *ghcb, struct pt_regs *regs)
588+
{
589+
/* No checking of the return state needed */
590+
return true;
591+
}
592+
#endif
593+
577594
const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
578595
.name = "Microsoft Hyper-V",
579596
.detect = ms_hyperv_platform,
580597
.type = X86_HYPER_MS_HYPERV,
581598
.init.x2apic_available = ms_hyperv_x2apic_available,
582599
.init.msi_ext_dest_id = ms_hyperv_msi_ext_dest_id,
583600
.init.init_platform = ms_hyperv_init_platform,
601+
#ifdef CONFIG_AMD_MEM_ENCRYPT
602+
.runtime.sev_es_hcall_prepare = hv_sev_es_hcall_prepare,
603+
.runtime.sev_es_hcall_finish = hv_sev_es_hcall_finish,
604+
#endif
584605
};

0 commit comments

Comments
 (0)