Skip to content

Commit

Permalink
x86/hyperv: Fix a crash on Intel CPUs caused by a recent hypercall ch…
Browse files Browse the repository at this point in the history
…ange

Commit 5f4eadd confuses the oldinstr and the newinstr, and causes a
invalid opcode crash on Intel CPUs, which don't know vmmcall.

Fixes: 5f4eadd ("x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp enlightened guest")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
  • Loading branch information
dcui committed Aug 5, 2023
1 parent 3a5274c commit c4db45f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/x86/include/asm/mshyperv.h
Expand Up @@ -72,7 +72,7 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
return U64_MAX;

__asm__ __volatile__("mov %[output], %%r8\n"
ALTERNATIVE("vmmcall", CALL_NOSPEC, X86_FEATURE_SEV_ES)
ALTERNATIVE(CALL_NOSPEC, "vmmcall", X86_FEATURE_SEV_ES)
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
"+c" (control), "+d" (input_address)
: [output] "r" (output_address),
Expand Down Expand Up @@ -113,7 +113,7 @@ static inline u64 _hv_do_fast_hypercall8(u64 control, u64 input1)
#ifdef CONFIG_X86_64
{
__asm__ __volatile__("mov %[thunk_target], %%r8\n"
ALTERNATIVE("vmmcall", CALL_NOSPEC, X86_FEATURE_SEV_ES)
ALTERNATIVE(CALL_NOSPEC, "vmmcall", X86_FEATURE_SEV_ES)
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
"+c" (control), "+d" (input1)
: THUNK_TARGET(hv_hypercall_pg)
Expand Down Expand Up @@ -159,7 +159,7 @@ static inline u64 _hv_do_fast_hypercall16(u64 control, u64 input1, u64 input2)
#ifdef CONFIG_X86_64
{
__asm__ __volatile__("mov %[output], %%r8\n"
ALTERNATIVE("vmmcall", CALL_NOSPEC, X86_FEATURE_SEV_ES)
ALTERNATIVE(CALL_NOSPEC, "vmmcall", X86_FEATURE_SEV_ES)
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
"+c" (control), "+d" (input1)
: [output] "r" (input2),
Expand Down

0 comments on commit c4db45f

Please sign in to comment.