Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp842976yba; Wed, 24 Apr 2019 10:29:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9v52w6ic5zsUxfUVosmLkFecbkUz3UAJ4mN7g4arfGYOUNrF5Fee2Ixh8wb7TnN9mOzDk X-Received: by 2002:a63:945:: with SMTP id 66mr32044654pgj.128.1556126952178; Wed, 24 Apr 2019 10:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556126952; cv=none; d=google.com; s=arc-20160816; b=pum1WVgLLMcupA8bRYysz9FfY49hgzAz6Z4XxaPXwMZithbIKjmhe9d1v49MWDYSm4 P4dc+WTGnu4C6PAfZUcuivWx6j0Boj3ugOE/Crd78roeJjfJw0SMAoko180mU/04bxET NUuTxCyHyn1Nwx9wSm/wXQj3QNm2lW2YpML6aTIAptsHf67dD1DS40cjMGpADq3XoEYP UhQMrbTb1SKWhrsVZL7LJcv17iD50Ip4/blo7X2rarqfkK9y40lnMJAbnjGy7VPMLB3B Y4wNTxZRbpAU230U5Fd3h5dyXW8kX+O7ZOBnjDFb21vhHasLQNxZQW6JB1BPza4mn7zI VGvQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4kaPHexbkguKlRkhSwAvwaReZREOYqDBah/5WS4/kvg=; b=ojwEBMKu9Ad0ZiXms1j4eQ/9Vpp1CdE8No3SCkfmHuRWkGmkfQ0FaWXeCw+ocnPPmS u0fhDi+3Op6T/qMwEnPtQSd451rvjzp0069SF9LNyravSKvRL6jgxg/V8GYarapRppH9 MhtAM6S+EoV0EvOH5SuL1QNZfrMfjUsgUng8fs/q30usAV0+rrVnPzT5ko6cbHFmbFpJ 61z8cvOeKPzzVSwumAuiMlKywkSckYjjq4iu9CCEaeulqgcMvdLeYzfDXv3V/D7grDpC l86qHBa5L2V1izeheDzWr+7vZVLzMwNlWFMF2jbUtrM/WeSKeGaFxosTmRTr4c4dLvxb JlXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yze8bKfX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13si17724533pgs.341.2019.04.24.10.28.57; Wed, 24 Apr 2019 10:29:12 -0700 (PDT) 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=@kernel.org header.s=default header.b=Yze8bKfX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389479AbfDXR1V (ORCPT + 99 others); Wed, 24 Apr 2019 13:27:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:53302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390417AbfDXR1S (ORCPT ); Wed, 24 Apr 2019 13:27:18 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2D2DB2054F; Wed, 24 Apr 2019 17:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126837; bh=+PVdPFLFopSrQN7q0kTmy89xWb7SJI450oZr/gdKq94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yze8bKfXUA1Vrx5yiuJGY6+PX4EskteaigVOxVu3L5lZLSyygTh1hDewhTOKAf1+J vDHwctuVXBvuWqPQcxowQ8B73Fs6bvRPKja2cOuFzygcX6dkDGApqh8Rc+y6Utdw8B 6KuNQPZfUDN+4fTfMIAhX4XtW+XTDqRIIxJlAGL4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini , Oren Twaig , Suravee Suthikulpanit Subject: [PATCH 4.14 35/70] Revert "svm: Fix AVIC incomplete IPI emulation" Date: Wed, 24 Apr 2019 19:09:55 +0200 Message-Id: <20190424170911.953072633@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170906.751869122@linuxfoundation.org> References: <20190424170906.751869122@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suthikulpanit, Suravee commit 4a58038b9e420276157785afa0a0bbb4b9bc2265 upstream. This reverts commit bb218fbcfaaa3b115d4cd7a43c0ca164f3a96e57. As Oren Twaig pointed out the old discussion: https://patchwork.kernel.org/patch/8292231/ that the change coud potentially cause an extra IPI to be sent to the destination vcpu because the AVIC hardware already set the IRR bit before the incomplete IPI #VMEXIT with id=1 (target vcpu is not running). Since writting to ICR and ICR2 will also set the IRR. If something triggers the destination vcpu to get scheduled before the emulation finishes, then this could result in an additional IPI. Also, the issue mentioned in the commit bb218fbcfaaa was misdiagnosed. Cc: Radim Krčmář Cc: Paolo Bonzini Reported-by: Oren Twaig Signed-off-by: Suravee Suthikulpanit Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4017,14 +4017,25 @@ static int avic_incomplete_ipi_intercept kvm_lapic_reg_write(apic, APIC_ICR, icrl); break; case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: { + int i; + struct kvm_vcpu *vcpu; + struct kvm *kvm = svm->vcpu.kvm; struct kvm_lapic *apic = svm->vcpu.arch.apic; /* - * Update ICR high and low, then emulate sending IPI, - * which is handled when writing APIC_ICR. + * At this point, we expect that the AVIC HW has already + * set the appropriate IRR bits on the valid target + * vcpus. So, we just need to kick the appropriate vcpu. */ - kvm_lapic_reg_write(apic, APIC_ICR2, icrh); - kvm_lapic_reg_write(apic, APIC_ICR, icrl); + kvm_for_each_vcpu(i, vcpu, kvm) { + bool m = kvm_apic_match_dest(vcpu, apic, + icrl & KVM_APIC_SHORT_MASK, + GET_APIC_DEST_FIELD(icrh), + icrl & KVM_APIC_DEST_MASK); + + if (m && !avic_vcpu_is_running(vcpu)) + kvm_vcpu_wake_up(vcpu); + } break; } case AVIC_IPI_FAILURE_INVALID_TARGET: