Skip to content

Commit

Permalink
Fix a BSOD triggered by Windows 10 20H1.
Browse files Browse the repository at this point in the history
The bugcheck is caused by an APC interrupt delivered in the middle of fastop
emulation, where original KVM will overwrite host eflags. With SMAP on, AC
of eflags is very sensitive.
  • Loading branch information
Taogle2018 committed Apr 30, 2020
1 parent 8db1a4a commit 587ee91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion arch/x86/kvm/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5213,7 +5213,7 @@ extern void __asm_fastop(size_t *flags,void *fop,
struct x86_emulate_ctxt *ctxt);
static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *))
{
size_t flags = (ctxt->eflags & EFLAGS_MASK) | X86_EFLAGS_IF;
size_t flags = ctxt->eflags & EFLAGS_MASK;
char *__fop = (char *)fop;

if (!(ctxt->d & ByteOp))
Expand Down
16 changes: 8 additions & 8 deletions assembly/x64/assembly.asm
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,17 @@ __asm_fastop proc frame

; save host eflags
pushfq
push qword ptr[rdi]
mov r10, qword ptr[rdi]
mov r9, qword ptr[rsp]
and r9d, 0fffff72ah
or r10, r9
push r10
popfq
call rsi
pushfq
pop qword ptr[rdi]
pop r10
and r10, 8D5h ; keep status flags
mov qword ptr[rdi], r10
popfq

mov qword ptr CXT_TO_DST[r8], rax
Expand All @@ -646,12 +652,6 @@ __asm_fastop proc frame
ret
__asm_fastop endp

public kvm_fastop_exception
kvm_fastop_exception proc
xor esi, esi
ret
kvm_fastop_exception endp

; ---------------------------------------------------------------------------
align 8

Expand Down

0 comments on commit 587ee91

Please sign in to comment.