Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp864578yba; Wed, 24 Apr 2019 10:50:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxe4LkL2nZOYuGxyurGbjitPEmGJlwjA2H+WgOWrMdZAvqP4RVfklDHSnkr+gZVHjjZ+IQT X-Received: by 2002:a63:6a44:: with SMTP id f65mr30918849pgc.354.1556128255986; Wed, 24 Apr 2019 10:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556128255; cv=none; d=google.com; s=arc-20160816; b=QjnIyw9sEsZLuhWjRqHWY7Y9n5S2uWsBp/p6MP0KOWdibHRcoT2qQaczyK8j9wJr9B gpGvQ0QIIgCvPot+UZJHr4EErIJk7NukkAN017FoZOkDTfCrYM4dfbsbxx0pWNwSzBna r5YI/m3iw6AEaPWFkRh/5PEl4cpszOsBhgsBoaIuz5jmkcArX+O3HUUPkcVQuu++luH/ iEzd/o3nexkpW3W0KhKn17tl1oLUrPqpsvtAOANXLhadASIt4nJk7EVAYm9dw9Ai2+ja aVBexTNFMgaDhyq4yMO48PwCL6bqaVDg3291PwEfO/V7ziDVfntLhhCeGGPIksfDrHrB D5BQ== 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=CWiJ+5VrakAZDA1+MXxH2HFVQwgt0TWNOCTNwbdYjxA=; b=E4EjkIw2NIBkHUkJi9/eVGjEXBwdnG/Cf2Nep07OigqvdovnhmLKdouksyz1AmB7fR IiNK5X8SnwkMNDsDOLKb2WTcwZjWLRmqK7pFqyu+9FCNQ2uqA8B0i2//wxkE0iz3vuRV ayq8VYBdbNxCRyoMl1Wfg6lWAH2ciXvtbL6Dlu0B+cnzsuIJoV4xKeHXxn0lDD+Dmmvg eBdxvdHGrJ/wQnrOGTR5Xg6w7cvWC5Oyf9laRNdL/1vOi1vUnnuAkfUeFLFKkzqNO9li vvi0nnCwlbvcSBrffqv8jhmpD+0CqF1FiCmvdZ6d7gNPv7Q3tPWwXDULx6ZyB7GeqVir 9lyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jvJV5jqN; 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 d14si19069116pgb.26.2019.04.24.10.50.40; Wed, 24 Apr 2019 10:50:55 -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=jvJV5jqN; 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 S2391537AbfDXRr6 (ORCPT + 99 others); Wed, 24 Apr 2019 13:47:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:58088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390616AbfDXRbd (ORCPT ); Wed, 24 Apr 2019 13:31:33 -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 D050321909; Wed, 24 Apr 2019 17:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556127093; bh=k3Nl2xS4dRU+G45FUZtiPfxcemDK0yk1GmtDZOpfK5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jvJV5jqNDjbDZhkq438E8OfXFKTYtMM9ZVh1SbfbR1Dc3mrpLx/qnnR3C2cSLfWra W7dJAhC/YyRvxqpNWS6Z9dKPqgIjNEaNOn6wmjjP7tAUqUz7nonxuAVNz0+MFRIu1R 6vvGoB8n/Xx7ZAfOnELr9b1yEJATyvytscFHIqa0= 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.19 60/96] Revert "svm: Fix AVIC incomplete IPI emulation" Date: Wed, 24 Apr 2019 19:10:05 +0200 Message-Id: <20190424170923.786207075@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170919.829037226@linuxfoundation.org> References: <20190424170919.829037226@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 @@ -4496,14 +4496,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: