RE: [PATCH V4 0/9] x86/hyperv: Add AMD sev-snp enlightened guest support on hyperv

From: Dexuan Cui
Date: Sat Aug 05 2023 - 19:37:41 EST


> From: Wei Liu <wei.liu@xxxxxxxxxx>
> Sent: Friday, August 4, 2023 4:35 PM
> To: Tianyu Lan <ltykernel@xxxxxxxxx>
> [...]
> On Fri, Aug 04, 2023 at 11:22:44AM -0400, Tianyu Lan wrote:
> > From: Tianyu Lan <tiala@xxxxxxxxxxxxx>
> [...]
> > Tianyu Lan (9):
[...]
> > x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp ...

Unluckily this commit causes a crash on Intel CPUs (see the below call-trace).

I made a fix here:
https://github.com/dcui/linux/commit/c4db45f6256248435b2a303b264ecbb41320c41d
I guess Wei can squash the fix into Tianyu's commit in the hyperv-next branch?

[ 0.861465] invalid opcode: 0000 [#1] PREEMPT SMP
[ 0.865489] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.5.0-rc4-decui-hcl+ #1
[ 0.869194] Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.1 04/20/2023
[ 0.875049] RIP: 0010:hv_query_ext_cap+0x7a/0x130
[ 0.879626] Code: 83 72 57 48 c7 c6 00 00 00 80 48 2b 35 0f f2 9d 00 48 01 f0 48 8b 35 5d 3e 3d 01 48 85 f6 74 2a b9 01 80 00 00 31 d2 49 89 c0 <0f> 01 d9 c6 05 d4 f2 20 02 01 66 85 c0 74 aa 48 89 c6 48 c7 c7 20
[ 0.897457] RSP: 0000:ffffffff82803e50 EFLAGS: 00010246
[ 0.900194] RAX: 00000000074f72e0 RBX: 0000000000000000 RCX: 0000000000008001
[ 0.903955] RDX: 0000000000000000 RSI: ffffc90000017000 RDI: 0000000000000000
[ 0.908445] RBP: ffffffff82803e60 R08: 00000000074f72e0 R09: 0000000000000001
[ 0.916354] R10: 0720072007200720 R11: 0720072007200720 R12: 0000000000000000
[ 0.924285] R13: 0000000000000000 R14: 0000000000000000 R15: ffffffff8280edb8
[ 0.929481] FS: 0000000000000000(0000) GS:ffff8880f6800000(0000) knlGS:0000000000000000
[ 0.933589] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 0.936526] CR2: ffff888507fff000 CR3: 0000000006036001 CR4: 00000000000200f0
[ 0.942279] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 0.950573] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 0.958417] Call Trace:
[ 0.959827] <TASK>
[ 0.961044] ? show_regs+0x64/0x70
[ 0.962872] ? __die_body+0x20/0x70
[ 0.964741] ? die+0x3e/0x60
[ 0.966273] ? do_trap+0xd7/0x100
[ 0.967922] ? do_error_trap+0x71/0x90
[ 0.970027] ? hv_query_ext_cap+0x7a/0x130
[ 0.974573] ? exc_invalid_op+0x53/0x70
[ 0.978961] ? hv_query_ext_cap+0x7a/0x130
[ 0.983977] ? asm_exc_invalid_op+0x1b/0x20
[ 0.988932] ? hv_query_ext_cap+0x7a/0x130
[ 0.991413] hyperv_init+0x2fe/0x5f0
[ 0.993373] apic_intr_mode_init+0x3e/0x100
[ 0.995655] x86_late_time_init+0x1b/0x30
[ 0.997832] start_kernel+0x617/0xa70
[ 0.999546] x86_64_start_reservations+0x18/0x30
[ 1.003761] x86_64_start_kernel+0xc0/0x110
[ 1.008815] secondary_startup_64_no_verify+0x17e/0x18b
[ Ubuntu
[ *Advanced options for Ubuntu
[ 1.021465] ---[ end trace 0000000000000000 ]---
[ 1.024093] RIP: 0010:hv_query_ext_cap+0x7a/0x130
[ 1.026769] Code: 83 72 57 48 c7 c6 00 00 00 80 48 2b 35 0f f2 9d 00 48 01 f0 48 8b 35 5d 3e 3d 01 48 85 f6 74 2a b9 01 80 00 00 31 d2 49 89 c0 <0f> 01 d9 c6 05 d4 f2 20 02 01 66 85 c0 74 aa 48 89 c6 48 c7 c7 20
[ 1.042358] RSP: 0000:ffffffff82803e50 EFLAGS: 00010246
[ 1.049317] RAX: 00000000074f72e0 RBX: 0000000000000000 RCX: 0000000000008001
[ 1.054740] RDX: 0000000000000000 RSI: ffffc90000017000 RDI: 0000000000000000
[ 1.059058] RBP: ffffffff82803e60 R08: 00000000074f72e0 R09: 0000000000000001
[ 1.062406] R10: 0720072007200720 R11: 0720072007200720 R12: 0000000000000000
[ 1.070915] R13: 0000000000000000 R14: 0000000000000000 R15: ffffffff8280edb8
[ 1.080300] FS: 0000000000000000(0000) GS:ffff8880f6800000(0000) knlGS:0000000000000000
[ 1.086956] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1.090242] CR2: ffff888507fff000 CR3: 0000000006036001 CR4: 00000000000200f0
[ 1.093949] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1.101352] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400