Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760281AbdCVQtt (ORCPT ); Wed, 22 Mar 2017 12:49:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53150 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759304AbdCVQtj (ORCPT ); Wed, 22 Mar 2017 12:49:39 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B6030C3A79 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=rkrcmar@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B6030C3A79 Date: Wed, 22 Mar 2017 17:49:33 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: David Hildenbrand Cc: kvm@vger.kernel.org, Paolo Bonzini , Dmitry Vyukov , stable@vger.kernel.org, LKML Subject: Re: [PATCH v1] KVM: x86: fix illegal MP_STATE when in/entering SMM Message-ID: <20170322164932.GA1992@potion> References: <20170322155354.18436-1-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170322155354.18436-1-david@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 22 Mar 2017 16:49:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1405 Lines: 37 2017-03-22 16:53+0100, David Hildenbrand: > If we already entered/are about to enter SMM, don't allow > switching to INIT/SIPI_RECEIVED, otherwise the next call to > kvm_apic_accept_events() will report a warning. > > Fixes: cd7764fe9f73 ("KVM: x86: latch INITs while in system management mode") > Cc: stable@vger.kernel.org # 4.2+ > Reported-by: Dmitry Vyukov > Signed-off-by: David Hildenbrand > --- > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 1faf620..7d0ec1b 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -7355,6 +7355,12 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, > mp_state->mp_state != KVM_MP_STATE_RUNNABLE) > return -EINVAL; > > + /* INITs are latched while in SMM */ > + if ((is_smm(vcpu) || vcpu->arch.smi_pending) && I think that userspace can still set the mpstate first and then enter SMM with KVM_SET_VCPU_EVENTS, which would result in the same warning ... Don't we need a similar check in kvm_vcpu_ioctl_x86_set_vcpu_events()? Thanks. > + (mp_state->mp_state == KVM_MP_STATE_SIPI_RECEIVED || > + mp_state->mp_state == KVM_MP_STATE_INIT_RECEIVED)) > + return -EINVAL; > + > if (mp_state->mp_state == KVM_MP_STATE_SIPI_RECEIVED) { > vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; > set_bit(KVM_APIC_SIPI, &vcpu->arch.apic->pending_events); > -- > 2.9.3 >