Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Tianyu Lan and committed by
Wei Liu
4754ec7f 44676bb9

+21
+21
arch/x86/kernel/cpu/mshyperv.c
··· 32 32 #include <asm/nmi.h> 33 33 #include <clocksource/hyperv_timer.h> 34 34 #include <asm/numa.h> 35 + #include <asm/svm.h> 35 36 36 37 /* Is Linux running as the root partition? */ 37 38 bool hv_root_partition; ··· 575 574 return eax & HYPERV_VS_PROPERTIES_EAX_EXTENDED_IOAPIC_RTE; 576 575 } 577 576 577 + #ifdef CONFIG_AMD_MEM_ENCRYPT 578 + static void hv_sev_es_hcall_prepare(struct ghcb *ghcb, struct pt_regs *regs) 579 + { 580 + /* RAX and CPL are already in the GHCB */ 581 + ghcb_set_rcx(ghcb, regs->cx); 582 + ghcb_set_rdx(ghcb, regs->dx); 583 + ghcb_set_r8(ghcb, regs->r8); 584 + } 585 + 586 + static bool hv_sev_es_hcall_finish(struct ghcb *ghcb, struct pt_regs *regs) 587 + { 588 + /* No checking of the return state needed */ 589 + return true; 590 + } 591 + #endif 592 + 578 593 const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = { 579 594 .name = "Microsoft Hyper-V", 580 595 .detect = ms_hyperv_platform, ··· 598 581 .init.x2apic_available = ms_hyperv_x2apic_available, 599 582 .init.msi_ext_dest_id = ms_hyperv_msi_ext_dest_id, 600 583 .init.init_platform = ms_hyperv_init_platform, 584 + #ifdef CONFIG_AMD_MEM_ENCRYPT 585 + .runtime.sev_es_hcall_prepare = hv_sev_es_hcall_prepare, 586 + .runtime.sev_es_hcall_finish = hv_sev_es_hcall_finish, 587 + #endif 601 588 };