From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC3F7C43381 for ; Fri, 15 Feb 2019 02:23:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9BFEA20643 for ; Fri, 15 Feb 2019 02:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550197419; bh=3TKFFj+wCctgpdm2UqPxHC8IkD8WwOYKnRGK0Z5NMbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0r9Sr3jbmeFwZsa6VqjeMHmLY2usUA4xxqKmZxFMG6TS5gNsUShKUS6VZZULQKmEQ dOk0V00IR3DfrvndxgMoIqzXDNIbcibW8S6oYgxhRUkxsR7twalePsAC0v3h+8tZV7 rj3WTiQ15hyMrEfp76M67DKuBM2LIyMjiz5uNLd8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391757AbfBOCO3 (ORCPT ); Thu, 14 Feb 2019 21:14:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:54292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391657AbfBOCOX (ORCPT ); Thu, 14 Feb 2019 21:14:23 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 465AE206BA; Fri, 15 Feb 2019 02:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196863; bh=3TKFFj+wCctgpdm2UqPxHC8IkD8WwOYKnRGK0Z5NMbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RznMedWWKc8XL0b/iUlO5K0o6gpeUcer8pRqQs68LZ/DxRBjt41sxIlJKKPVLayp2 NwmMCPdJgkOTSXzvjks+Vi020KidC207gMB0QLVOxdy+zzm2W0yQS7MzYNqCabLM86 a2cE0WCBfp8tgMlX8m7N1yL/4rcTo7CXK2ZxmBC0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Suravee Suthikulpanit , Paolo Bonzini , Sasha Levin , kvm@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 39/40] svm: Fix AVIC incomplete IPI emulation Date: Thu, 14 Feb 2019 21:13:12 -0500 Message-Id: <20190215021313.178476-39-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215021313.178476-1-sashal@kernel.org> References: <20190215021313.178476-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit [ Upstream commit bb218fbcfaaa3b115d4cd7a43c0ca164f3a96e57 ] In case of incomplete IPI with invalid interrupt type, the current SVM driver does not properly emulate the IPI, and fails to boot FreeBSD guests with multiple vcpus when enabling AVIC. Fix this by update APIC ICR high/low registers, which also emulate sending the IPI. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/svm.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 4dc79d139810..187ef94518a6 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4006,25 +4006,14 @@ static int avic_incomplete_ipi_interception(struct vcpu_svm *svm) 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; /* - * 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. + * Update ICR high and low, then emulate sending IPI, + * which is handled when writing APIC_ICR. */ - 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); - } + kvm_lapic_reg_write(apic, APIC_ICR2, icrh); + kvm_lapic_reg_write(apic, APIC_ICR, icrl); break; } case AVIC_IPI_FAILURE_INVALID_TARGET: -- 2.19.1