Skip to content

Commit

Permalink
x86/hyperv: Do not move the original assembly code in hv_do_hypercall()
Browse files Browse the repository at this point in the history
Add a return for hv_isolation_type_en_snp() to avoid moving the code unnecessarily

Fixes: 21ff4de070a7 ("x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp enlightened guest")
Link: lantianyu/linux@21ff4de
Signed-off-by: Dexuan Cui <decui@microsoft.com>
  • Loading branch information
dcui committed Aug 16, 2023
1 parent 2b3bbc1 commit f810135
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions arch/x86/include/asm/mshyperv.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,19 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
"+c" (control), "+d" (input_address)
: "r" (output_address)
: "cc", "memory", "r8", "r9", "r10", "r11");
} else {
if (!hv_hypercall_pg)
return U64_MAX;

__asm__ __volatile__("mov %4, %%r8\n"
CALL_NOSPEC
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
"+c" (control), "+d" (input_address)
: "r" (output_address),
THUNK_TARGET(hv_hypercall_pg)
: "cc", "memory", "r8", "r9", "r10", "r11");
return hv_status;
}

if (!hv_hypercall_pg)
return U64_MAX;

__asm__ __volatile__("mov %4, %%r8\n"
CALL_NOSPEC
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
"+c" (control), "+d" (input_address)
: "r" (output_address),
THUNK_TARGET(hv_hypercall_pg)
: "cc", "memory", "r8", "r9", "r10", "r11");
#else
u32 input_address_hi = upper_32_bits(input_address);
u32 input_address_lo = lower_32_bits(input_address);
Expand Down

0 comments on commit f810135

Please sign in to comment.