Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp857090yba; Wed, 24 Apr 2019 10:43:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeBoQXX6InAnaddFahQiZY/1pAEPgBt2GUScRtICWjJZcaCDVmNDVj3t0MRkYTdTqDATDq X-Received: by 2002:a65:6541:: with SMTP id a1mr30722154pgw.233.1556127787436; Wed, 24 Apr 2019 10:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556127787; cv=none; d=google.com; s=arc-20160816; b=e22XJX/ehzPRQLnr4czEC8cczmQY09Bh86zoZUzT57hA67x26BK3JlfREabeWdQV5T RCbOSDm9CWpvWzqUM4UDs8EqSZfSpOPbc+hYylc8e7UiExTurC1iv2qaUfkyDAzB2vc1 BqzHmNpPP75Gpfn2ikt7V4IngUNEXPGIqwi6pMvS8WZosh0Gre6pYFWR8GRqw19aJmTf q7u0bXYzZyCAJtnk9x1M1qtdZHvabi2Ynv+NgwcX9z3feqL7Op/cVGDglrF/PIO/T+aN 1QwH2TL3jiMfq0rFc6ZtNZXqLD4fzl6dMvfBydnQdPXfEd+1K/x9Wkd93DjOkepN6ckP /f+Q== 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=yRBOp45JOM+GlmZclzranP/IX3a0Lc7vr8ebQAP6ovk=; b=kGNJv1UYPcofBohwNiCNpJlbHRI4WT0zoSXvF1BXa4Ou6sJ8ZZUPRhl645RtsOGZkw 9YfHqORQNKMPOn31n1j4Jz4Y09e4+NHOoQ524R6I5nHtqZresRkB3BCe5QFH7SjsW9dG CkBMvamzSWskFE1gp7RvGJBJZ5zlyH0UgTg69xKkp2BCaKQKcpOCPE8YhE+Fy+xfDY2x bU546e8Ob0NKqWijZIFuLBbejiO5BL35sPKCBM8ZQgETzUVjbB12PynBMCeVC7nOIQW3 xjxEx9OdrI6iLBLIdJRqSMpqdt7e1cLGYQhewWcYDOfLxDqqjU3gW6f9GH01sXsoLDaX h9aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wTtwzA67; 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 n8si18794560plk.108.2019.04.24.10.42.52; Wed, 24 Apr 2019 10:43:07 -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=wTtwzA67; 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 S2403964AbfDXRlY (ORCPT + 99 others); Wed, 24 Apr 2019 13:41:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:35638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392161AbfDXRgq (ORCPT ); Wed, 24 Apr 2019 13:36:46 -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 BFB852054F; Wed, 24 Apr 2019 17:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556127405; bh=y/0aG/HlXwylPub4CXxvzD6seuHsVyZ2rZPp/lGFBoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wTtwzA67PvfbVI5Nq9IwrOCNsdM8ZnW3e/ewbx45yRjwFnVHZt/JETm0XuEO4tzpo a8UJMnWmXx0L1RFHEB37bcnO8QoHZVdROVTy9sNgZQZfkiQyOqlC8ODGHrntMyY8zp JJ0Z2AnOEyJyMB4UqehXAin/9AvlOaYwooFi0xYk= 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 5.0 080/115] Revert "svm: Fix AVIC incomplete IPI emulation" Date: Wed, 24 Apr 2019 19:10:16 +0200 Message-Id: <20190424170929.659823680@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170924.797924502@linuxfoundation.org> References: <20190424170924.797924502@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 @@ -4515,14 +4515,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: