aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/x86/include/asm/mshyperv.h
diff options
context:
space:
mode:
authorTianyu Lan <tiala@microsoft.com>2023-08-18 06:29:15 -0400
committerWei Liu <wei.liu@kernel.org>2023-08-22 00:38:20 +0000
commit48b1f68372ca93ff67812d99c8d7351aaee62a2a (patch)
treefa302d83e638241c413556f9a5c5fa48c64ca3ce /arch/x86/include/asm/mshyperv.h
parentdrivers: hv: Mark percpu hvcall input arg page unencrypted in SEV-SNP enlightened guest (diff)
downloadwireguard-linux-48b1f68372ca93ff67812d99c8d7351aaee62a2a.tar.xz
wireguard-linux-48b1f68372ca93ff67812d99c8d7351aaee62a2a.zip
x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp enlightened guest
In sev-snp enlightened guest, Hyper-V hypercall needs to use vmmcall to trigger vmexit and notify hypervisor to handle hypercall request. Signed-off-by: Tianyu Lan <tiala@microsoft.com> Reviewed-by: Dexuan Cui <decui@microsoft.com> Signed-off-by: Wei Liu <wei.liu@kernel.org> Link: https://lore.kernel.org/r/20230818102919.1318039-6-ltykernel@gmail.com
Diffstat (limited to 'arch/x86/include/asm/mshyperv.h')
-rw-r--r--arch/x86/include/asm/mshyperv.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 9f11f0495950..8660d6bca6f2 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -48,6 +48,8 @@ extern u64 hv_current_partition_id;
extern union hv_ghcb * __percpu *hv_ghcb_pg;
+extern bool hv_isolation_type_en_snp(void);
+
int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages);
int hv_call_add_logical_proc(int node, u32 lp_index, u32 acpi_id);
int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags);
@@ -59,6 +61,16 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
u64 hv_status;
#ifdef CONFIG_X86_64
+ if (hv_isolation_type_en_snp()) {
+ __asm__ __volatile__("mov %4, %%r8\n"
+ "vmmcall"
+ : "=a" (hv_status), ASM_CALL_CONSTRAINT,
+ "+c" (control), "+d" (input_address)
+ : "r" (output_address)
+ : "cc", "memory", "r8", "r9", "r10", "r11");
+ return hv_status;
+ }
+
if (!hv_hypercall_pg)
return U64_MAX;
@@ -102,7 +114,13 @@ static inline u64 _hv_do_fast_hypercall8(u64 control, u64 input1)
u64 hv_status;
#ifdef CONFIG_X86_64
- {
+ if (hv_isolation_type_en_snp()) {
+ __asm__ __volatile__(
+ "vmmcall"
+ : "=a" (hv_status), ASM_CALL_CONSTRAINT,
+ "+c" (control), "+d" (input1)
+ :: "cc", "r8", "r9", "r10", "r11");
+ } else {
__asm__ __volatile__(CALL_NOSPEC
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
"+c" (control), "+d" (input1)
@@ -147,7 +165,14 @@ static inline u64 _hv_do_fast_hypercall16(u64 control, u64 input1, u64 input2)
u64 hv_status;
#ifdef CONFIG_X86_64
- {
+ if (hv_isolation_type_en_snp()) {
+ __asm__ __volatile__("mov %4, %%r8\n"
+ "vmmcall"
+ : "=a" (hv_status), ASM_CALL_CONSTRAINT,
+ "+c" (control), "+d" (input1)
+ : "r" (input2)
+ : "cc", "r8", "r9", "r10", "r11");
+ } else {
__asm__ __volatile__("mov %4, %%r8\n"
CALL_NOSPEC
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
@@ -240,7 +265,6 @@ static inline void hv_vtom_init(void) {}
#endif
extern bool hv_isolation_type_snp(void);
-extern bool hv_isolation_type_en_snp(void);
static inline bool hv_is_synic_reg(unsigned int reg)
{