Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp205474imj; Thu, 14 Feb 2019 18:39:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IasCfvv3AKGy18ikhqXij3m6DMt9JSnjEbYqNjNluQgwIKNGT+biE8+/t49bp8E3hHIoJBH X-Received: by 2002:a63:ff60:: with SMTP id s32mr6883361pgk.266.1550198382256; Thu, 14 Feb 2019 18:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198382; cv=none; d=google.com; s=arc-20160816; b=Pfy879xsEkjNSqzmjXfexrBmMOmpcbKCl6mJ8Xsva8Vy6X32iK7qPXaj0udCBw79Di ZXo2eKNwT7GAB67YJyEGBA1gEJb4ugHfcR3hsZMPBRctr1RtLm2FsRd8y6SIxFmWMng3 gfqrS9ePZxW+uYp1MFoOsF7eA0AAxJLeMlNsXFd7YJpJgJI55TeYevc5szr/8NTkhnGC lIHNzUuB50Q4K0vbWc5yq4lOQpHbVRRpTrOtKgx0Cn+3g0yVtN2wMeJqbRpGTd+1EWWV IiaVvp+b+1UCA1ACMUKcNJ6I4BygwhXoz9mjfVGqPn8F2FjemSm4wzKZledgh3rGD1dn Lzww== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LNshFqS+zFl/RRytU7M6sGS6EXWxOSd5irRRF6oqOUU=; b=ESXRW1+dfLo4xAdADtwGeLRxrFcwRXrqrt7f58ccHrwDFrxIaPy64A9WYFeUCtQAgo rzSFnSsryoSlDq2P/dE7yuK/Y5dxFkTX89RMZER3T/NDaYO5ERGweXoHsHJuyUQsRAcO CCii9BZSGSF28s1G/fAlJoERkgc3PkazaA+aouefg3SwapND1kXYRG3Px5xN8XYvwzYQ Qzu38p6mKhRq6jcEuaUi7YktBT4PzTjERUNk9xONTULdE1Hfk9V7CQX12mfdLSgndoFk 50gSZs5bCrt6XWJphw/RqvQ2diRdjgB59Vz9ehqpoDPU1g6BBo30a6wM+1t5Mmuhwlt3 pV6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GVlOdPxH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si4851898plk.300.2019.02.14.18.39.18; Thu, 14 Feb 2019 18:39:42 -0800 (PST) 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=GVlOdPxH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732628AbfBOCfb (ORCPT + 99 others); Thu, 14 Feb 2019 21:35:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:51164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732138AbfBOCLF (ORCPT ); Thu, 14 Feb 2019 21:11:05 -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 B9A8021B68; Fri, 15 Feb 2019 02:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196664; bh=aaJVp55CTXuaXx9jliqdiG47J4cyVZSwbncctg49O/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVlOdPxHlOlli0+3+Xebty1xYNTEFYTe9rEhykYSmF8eG7hUVmAKPXhR0pi30LkLN kh+dCMt7K2hNN98WGULbtlIu9sJse0MpO+BPwKU1oTvNEAEsgsSMGVp9vO4NrBTNGb N2XjvsybZ14Rw/eKfyHwcJ3C1vPKvmWgLKF+TJ5c= 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.20 73/77] svm: Fix AVIC incomplete IPI emulation Date: Thu, 14 Feb 2019 21:08:51 -0500 Message-Id: <20190215020855.176727-73-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-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 101f53ccf571..cea8f8c03e8c 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4486,25 +4486,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