Re: KCSAN + KVM = host reset

From: Sean Christopherson
Date: Fri Apr 10 2020 - 12:06:09 EST


On Fri, Apr 10, 2020 at 11:50:10AM -0400, Qian Cai wrote:
>
> This works,
>
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -3278,7 +3278,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
>
> bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);
>
> -static void svm_vcpu_run(struct kvm_vcpu *vcpu)
> +static __no_kcsan void svm_vcpu_run(struct kvm_vcpu *vcpu)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
>
> Does anyone has any idea why svm_vcpu_run() would be a problem for
> KCSAN_INTERRUPT_WATCHER=y?
>
> I can only see there are a bunch of assembly code in __svm_vcpu_run() that
> might be related?

svm_vcpu_run() does all kinds of interrupt toggling, e.g. the sequence is:

1. EFLAGS.IF == 0, from caller
2. clgi()
3. EFLAGS.IF <= 1
4. __svm_vcpu_run(), i.e. enter guest
5. EFLAGS == 0, from VM-Exit
6. EFLAGS.IF <= 1
7. stgi()