Received: by 10.223.185.116 with SMTP id b49csp7494155wrg; Thu, 1 Mar 2018 06:29:06 -0800 (PST) X-Google-Smtp-Source: AG47ELsLRhhqVm9lGggSDImOW6cOHCM1cRBphvVyRBAZJrIk1sUrMg+VfkAijs8kqvmXekoCrBqr X-Received: by 2002:a17:902:2843:: with SMTP id e61-v6mr2096663plb.437.1519914546837; Thu, 01 Mar 2018 06:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519914546; cv=none; d=google.com; s=arc-20160816; b=SkFhpFtgZ4G+5EeOLCOZTOzrwYxKUm3aL3tNuEN5j+3LMn+xxU/xeTnpp7dgnEdmW9 49qHkPj8v69PleWxkyFcRO8VjYspbo8GYVdyLI9LvBLEf9CQF9BO3jNuI/4pvYU9MQs0 8233+d1/He7wYkuboq8LuIheOkOG5T+iqCxvjhcr2BrWMoP3oe+OlTIN4POX5uOVo7B4 CbdArU53DLFiJ3XPYJ/LeTJ1YNvW75/Ro5jqqhgFulG5i/X5dVkFqyYxN+ULLXkKDG+8 Z/Ek/79c+EeTafixf/YS3YIPpbo6eKxe5wLRdV2pgmRtoclxUdcGCol6QdYo6dMSNiGP pqng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=DeKJfDR20HE2tMNUTCDNP1m2fXJ7hpEHZl8IipYDJBM=; b=A0NGcXSYNyEnPu5Uj+I0wJCcfAAWkKWF8IOG6PTQmxzZBfdOxyh7LtTqM9RdDd+26B 2kf3lwFWuJUvTJGIFG3Vl6Roc+Wz7H4+9pLCIdRVDxgryCb16B+kdsFMX0RFNPjeZ8N9 b8SABy1Vrm/33F0rNOD+/C1DlGX7SfJIWTGDR/yZKs3odAXvcgZzIwdPetOYDktbAi09 +9AcFKBcfRpDNF05R14DwT3MbSLflrvckWk0l2TWskK5RXeOwzf5sWcvxYEZRyjngXrz PahdnTmj45GTM9U0f8BE27yJVeAUeiJjoQPRy2bKpcw5A69F25sQ2Wqvti7fPLAxwhBH Pl9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vCxaRLpq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h91-v6si3053172pld.202.2018.03.01.06.28.52; Thu, 01 Mar 2018 06:29:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vCxaRLpq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031531AbeCAO1x (ORCPT + 99 others); Thu, 1 Mar 2018 09:27:53 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34022 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031518AbeCAO1t (ORCPT ); Thu, 1 Mar 2018 09:27:49 -0500 Received: by mail-pg0-f67.google.com with SMTP id m19so2370885pgn.1 for ; Thu, 01 Mar 2018 06:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=DeKJfDR20HE2tMNUTCDNP1m2fXJ7hpEHZl8IipYDJBM=; b=vCxaRLpq/uIyLepeG98r29+rAEDgFbzE5bgJyIX1lMkI5AKYWak21tOg3AAMVPHA8R WXDeZxXxl9nV5EZqcDgPJhhdikjtHRd9G6va5MwnYsjJEJZ7BBPpFu0uHCsDfbI43fZP YYB2FRDtOfTSjkm8wi8Fkk/1HLTI/OUyddT7ay+OjghU8mjoQ7+rpjdB+2R4nCRH8zDL tx/M4SL/xkjyOfb1oOO/ZccJkD8I+V1zP7w1okMeeFXS2aLfGg3RtRfi2eRfJTHlhWtu 7CVvwmme1gofFJMyqJVOiJfaAU6tLz+lJg5JeJilGAbHX5JCmPvqHM+ypgAZb51007R4 509Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=DeKJfDR20HE2tMNUTCDNP1m2fXJ7hpEHZl8IipYDJBM=; b=c8toZiNsSSpWjA5TBTW33EuZ4kjhvb+ZaWI6e1De1Dn0+7/CAcM6O1v32cgSYmpCM4 +YdSRoy2SEdfAn0q+TvB1qQjH+HTIAf3aaVB1W30Ld9Dj0sKvI8XIuXHiSGKjmtp8wFo 7r0AjxEotGkObIBbYhQIFzpI9mz13o0q/zD65SnTRNiiePD6aidUjDn5AVyL4ceuCIrP 6mi06AnBDKNVs2vXWlFMUfQFWaLfqmWwYSf+WUJZz5uM7UDe20IQ5xrwEqh12F7tA/51 K7kxlhu3Xc5VTp4hr+smTMbbnc/9Vv1ClkYO5+rHNIBhOcNfgX1CBF+jUPHlg6JARajw NxKA== X-Gm-Message-State: APf1xPD9rqdCW/XT8D+AzW3Pxyi5VEURDcjcnRReiEMdyaEFYFrH2Jgn AFIWn7ty9sOnf0aPnigP8JVJvfr2GVdOl3hBhTeThicwCkk= X-Received: by 10.99.139.199 with SMTP id j190mr1722615pge.334.1519914468552; Thu, 01 Mar 2018 06:27:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.140.151 with HTTP; Thu, 1 Mar 2018 06:27:28 -0800 (PST) In-Reply-To: <20180301142425.18550-1-rkrcmar@redhat.com> References: <20180301142425.18550-1-rkrcmar@redhat.com> From: Dmitry Vyukov Date: Thu, 1 Mar 2018 15:27:28 +0100 Message-ID: Subject: Re: [PATCH] KVM: x86: fix vcpu initialization with userspace lapic To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: LKML , KVM list , Paolo Bonzini , stable Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 1, 2018 at 3:24 PM, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > Moving the code around broke this rare configuration. > Use this opportunity to finally call lapic reset from vcpu reset. > > Reported-by: Dmitry Vyukov This was reported by syzbot: https://groups.google.com/d/msg/syzkaller-bugs/QrDXoM_mQRk/mT2cebykBQAJ Please add the Reported-by: syzbot+fb7a33a4b6c35007a72b@syzkaller.appspotmail.com tag so that syzbot will know when it's fixed. > Suggested-by: Paolo Bonzini > Fixes: 0b2e9904c159 ("KVM: x86: move LAPIC initialization after VMCS crea= tion") > Cc: stable@vger.kernel.org > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > --- > arch/x86/kvm/lapic.c | 10 ++++------ > arch/x86/kvm/x86.c | 3 ++- > 2 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index cc5fe7a50dde..391dda8d43b7 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -2002,14 +2002,13 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u6= 4 value) > > void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event) > { > - struct kvm_lapic *apic; > + struct kvm_lapic *apic =3D vcpu->arch.apic; > int i; > > - apic_debug("%s\n", __func__); > + if (!apic) > + return; > > - ASSERT(vcpu); > - apic =3D vcpu->arch.apic; > - ASSERT(apic !=3D NULL); > + apic_debug("%s\n", __func__); > > /* Stop the timer in case it's a reset to an active apic */ > hrtimer_cancel(&apic->lapic_timer.timer); > @@ -2568,7 +2567,6 @@ void kvm_apic_accept_events(struct kvm_vcpu *vcpu) > > pe =3D xchg(&apic->pending_events, 0); > if (test_bit(KVM_APIC_INIT, &pe)) { > - kvm_lapic_reset(vcpu, true); > kvm_vcpu_reset(vcpu, true); > if (kvm_vcpu_is_bsp(apic->vcpu)) > vcpu->arch.mp_state =3D KVM_MP_STATE_RUNNABLE; > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 1a3ed81031f1..3f96b51d0495 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8123,7 +8123,6 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) > kvm_vcpu_mtrr_init(vcpu); > vcpu_load(vcpu); > kvm_vcpu_reset(vcpu, false); > - kvm_lapic_reset(vcpu, false); > kvm_mmu_setup(vcpu); > vcpu_put(vcpu); > return 0; > @@ -8166,6 +8165,8 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) > > void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) > { > + kvm_lapic_reset(vcpu, init_event); > + > vcpu->arch.hflags =3D 0; > > vcpu->arch.smi_pending =3D 0; > -- > 2.15.1 >