Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7224429imu; Tue, 22 Jan 2019 02:26:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ek0RoqCHjZqV8v32p6G8XdsCcyeslu3IcYqPLKG3HUzFeOJvjVqbBCtL+aPKXz6/Gk6XA X-Received: by 2002:a63:314d:: with SMTP id x74mr31210127pgx.10.1548152819246; Tue, 22 Jan 2019 02:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548152819; cv=none; d=google.com; s=arc-20160816; b=UttKyaFHyXkFUzPtT/owZELhNliYillkyTOgSHaTDNjmdHJmUWlCZrwUjK30TIfqj8 6sl3JL13CKJzE2pTbAs2XhT62QQiBmQJn9c1qPMHk9DbpBNVYt3At+VdtHdOXh3nQGtl sakyKKx2XhsmsQyZU4pkGRlOOD+RMu8fEEdQHtFJ8AkfOC4UCrwm8lxqEtmmipV42nh9 IDWr4QyHxLgc5LJ1iHoTZyXbYkPUl9F52Cyi5237jB0810fn3kfLT1u5etItyi8b/dqx z6ePmo4CU0PeA+5YDsOVlm9jo2bJvi8mtfurh2F4haO59j1UG/t1YjFVfg13oUb0Jkr1 pp5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :cc:to:from:dkim-signature; bh=WjzuR9uZjWwsJq1ZM8GejDMp+j7H/Dxpi7qgMHTuDtY=; b=m9Dovn1J3HNyLw6T3aMifUbmKfh14H4eGmGS/SexWYdWX9qoER9d/xpl7+9AcMV/LS MUGe7ZtEIjXAuwH36kgylZY1A82BZaLnWakv9o4iQKSqitQZ0w3+ZKhN0JlOClPU1iRI jPk4Vhpiw7snQAzPasAqvzHwVJvak7G5Ef90LUAepZBNDWSQP7yig57yzrdQKFqIW9PG gsyougvnHrhGb7pxjHu9oolg7E+WcfMS8nGFVegcIMPkbIjOhpE6GtWVWSs704f+lsz0 Mn3E5iVaQMuJcjgq5odn0W/5EkYipXi/cyfm5CWcAB56Z+6UDHyTh2UHKbT2P63KB7A2 d/KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=1k67luOE; 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 p66si338917pfp.144.2019.01.22.02.26.43; Tue, 22 Jan 2019 02:26:59 -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=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=1k67luOE; 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 S1727799AbfAVKZQ (ORCPT + 99 others); Tue, 22 Jan 2019 05:25:16 -0500 Received: from mail-eopbgr750043.outbound.protection.outlook.com ([40.107.75.43]:64896 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726930AbfAVKZQ (ORCPT ); Tue, 22 Jan 2019 05:25:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WjzuR9uZjWwsJq1ZM8GejDMp+j7H/Dxpi7qgMHTuDtY=; b=1k67luOE9HjHEnQmT8fn95JiCNyS3+otaWPXGz9NABAcYG+KzCoerWDpOiwNS+GcbV2mLlW2FT4uRmki0XnTmpwmqdT5MIDXzUZaEyIjCSTXz/cslKxl2z3GOQ91bsxx4lKO2Gk4AHjl8FFRk6RGBHFwSLW1pK9cH0s1t7iJFlw= Received: from DM6PR12MB2844.namprd12.prod.outlook.com (20.176.117.96) by DM6PR12MB3179.namprd12.prod.outlook.com (20.179.104.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.16; Tue, 22 Jan 2019 10:25:14 +0000 Received: from DM6PR12MB2844.namprd12.prod.outlook.com ([fe80::c40:929a:abab:308d]) by DM6PR12MB2844.namprd12.prod.outlook.com ([fe80::c40:929a:abab:308d%3]) with mapi id 15.20.1537.031; Tue, 22 Jan 2019 10:25:13 +0000 From: "Suthikulpanit, Suravee" To: "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "x86@kernel.org" CC: "joro@8bytes.org" , "rkrcmar@redhat.com" , "pbonzini@redhat.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "hpa@zytor.com" , "Suthikulpanit, Suravee" Subject: [PATCH] svm: Fix AVIC incomplete IPI emulation Thread-Topic: [PATCH] svm: Fix AVIC incomplete IPI emulation Thread-Index: AQHUsjzCWuJ1rNsdhEWhrsyeZxFnGA== Date: Tue, 22 Jan 2019 10:25:13 +0000 Message-ID: <20190122102450.125349-1-Suravee.Suthikulpanit@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [171.96.72.83] x-clientproxiedby: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DM6PR12MB2844.namprd12.prod.outlook.com (2603:10b6:5:45::32) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM6PR12MB3179;20:Pt2Y45n5QxAxaW0tduGcodG1VVU/xH9D4BiNiPuGz3WyCshFXilWDtwsVgxziJGfBwjXgBqUbjnbxjISOH4sLz8rUQqiiSpqXdoUeFCXvszDWN3+X7S0ooIGSBBahLpsfxzS34lfoydxiL60pGDHnAoZWJl1pXZOQhs2ZvEBy5OyMSv6oCBOcrj3q23daWqJpU6iokr3RkSC4BUEGsymVP10vGoClMJpQ60tvznWe592839OGIp2JIH2FK7qdeZZ x-ms-office365-filtering-correlation-id: ef3c2e2c-d731-4137-b18a-08d68053e538 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DM6PR12MB3179; x-ms-traffictypediagnostic: DM6PR12MB3179: x-microsoft-antispam-prvs: x-forefront-prvs: 0925081676 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(366004)(376002)(396003)(39860400002)(136003)(189003)(199004)(6506007)(386003)(102836004)(7736002)(2501003)(305945005)(52116002)(14454004)(6512007)(36756003)(7416002)(2906002)(478600001)(14444005)(256004)(53936002)(50226002)(105586002)(72206003)(106356001)(8936002)(1076003)(71190400001)(3846002)(6116002)(86362001)(71200400001)(2616005)(4326008)(2201001)(6486002)(476003)(186003)(66066001)(26005)(6436002)(316002)(68736007)(25786009)(97736004)(99286004)(486006)(54906003)(81166006)(81156014)(110136005)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3179;H:DM6PR12MB2844.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2dYR41l9t7SdcE0HS4vFmUAzAlj2Wj1YEi1XRnSHQTWss2k/ufalNc5BxEB8ssuMwn8QJTI/CnbFuT+JXj2fq31sc43QwD6REFNIJfqsWe1ZIeykZMRpcSe8BYvX/zc7uJyrD4SjGxTqP3LlMos4JUeOiR4YaPg+3hMLbFI/XwnmRWcLiA8xz75t+H8m6WK8PtuJh+KxoYSF6PxptLbqzp+OmtRLsBranNZVfS9gua+DvduOy0hKIiCz7HUQeliWtGXeqYECXTD7XDYff618//eGyOadrtDWkeqdJGprF08+NO8Or06bRVzAOvfWL5/DRpbW3bhKnDF9VoejZ8PZrWKExwANKk5PaEIzb20U6LS15qSpbSWgG48AKiN97ft7JgKPAxXP2L80tXKWNic9wiLjJwLDFYGJxIlX4XZKpis= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef3c2e2c-d731-4137-b18a-08d68053e538 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jan 2019 10:25:10.1928 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3179 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit 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 --- 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 2aff835a65ed..8a0c9a1f6ac8 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4504,25 +4504,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 =3D svm->vcpu.kvm; struct kvm_lapic *apic =3D svm->vcpu.arch.apic; =20 /* - * 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 =3D 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: --=20 2.17.1