Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751965AbdILPna (ORCPT ); Tue, 12 Sep 2017 11:43:30 -0400 Received: from mail-bl2nam02on0080.outbound.protection.outlook.com ([104.47.38.80]:8448 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751782AbdILPnJ (ORCPT ); Tue, 12 Sep 2017 11:43:09 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; From: Suravee Suthikulpanit To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, joro@8bytes.org, Suravee Suthikulpanit Subject: [PATCH v2 3/3] KVM: SVM: Add irqchip_split() checks before enabling AVIC Date: Tue, 12 Sep 2017 10:42:42 -0500 Message-Id: <1505230962-86304-4-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505230962-86304-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1505230962-86304-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: BN6PR2001CA0014.namprd20.prod.outlook.com (10.172.112.152) To CY4PR12MB1733.namprd12.prod.outlook.com (10.175.62.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a3931ff-676f-49ed-ebac-08d4f9f4f39f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY4PR12MB1733; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1733;3:Eolg8thO5VxK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30YMh9/W4qMO1FbMWM8amkbU4JUH03dF5kvDmsLqojC3ZmUUvUKMTTThJTSBVTEmTD+nLDnWIBQP3XxoSdmRQDoUywtf7gqEzL42IDSyclbT8kfkf9fnHYVbmqUo5zyPXj851ybQWTq8J7D/RGe73juKb9liB842KDftNl4q4sByAGPYtiyyd/5RZUb5IxkqCnPmgTGIpAI7q+WN37zrC92LFDNxDSO33L+WQbFDW/RDCBiAlzqkZc4ZbGJLYelxFqH3uhZM+X4Tco0YaQvq7sP+9org7FnY7lOsmjtK8n/2mQ8gE/G48C3RsVphi4GuoOX0gDuFKrKP7S+w0hiuoe7WduW;4:e3xsx0rY6ZYNot1tFLVuxoFVwwyYv4RF7C+oU4qfJ4DsuKUAICnxPqaYuD8pMPRXSTZu6XGe1MY+Vj7RRH82UMO2jpcscn4jyWGw9Vo5emp+9pKu3eoNY+kBq+6f3JQLEA7MgqdhHJyNCaMcOEVpvQ1XaKYIkFphBPwY/a+W2TRgfVnRemTB/SMBk7/SJ6BZbCKzSnEt4x4SFSHXk76Rsw7QPRZ8jKreTErAgSjHuugfG/tDJh/j0ntzjWFIbzSwGpE+NFonKfPvsdlgeJ0Na1dQ4/BycVc6oo+8DVubcfc= X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123555025)(20161123560025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR12MB1733;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR12MB1733; X-Forefront-PRVS: 042857DBB5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(199003)(189002)(305945005)(5660300001)(53416004)(7736002)(72206003)(2950100002)(25786009)(76176999)(2906002)(50986999)(106356001)(189998001)(4326008)(316002)(478600001)(33646002)(105586002)(101416001)(6486002)(48376002)(81166006)(36756003)(8936002)(47776003)(68736007)(3846002)(6116002)(81156014)(110136004)(42186005)(6666003)(97736004)(53936002)(50226002)(5003940100001)(8676002)(4720700003)(86362001)(66066001)(50466002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1733;H:dave-rhel73-ethanol.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR12MB1733;23:jAEnbv5JXByCR1vwjs4QaFQxHhYxA7p7VWIg9+kKP?= =?us-ascii?Q?Dn+U1YyCNIl4u8Rp0huo1GXgQtYK5ejd7McJL7rK0NW3I197EuPDyomM8OIC?= =?us-ascii?Q?g+nhQVTtQPID5ZS5Zaokhe4kAnNAYYcD3OFFhEOjJMaYGixLTYcJ4FsMAoSI?= =?us-ascii?Q?bXfO/FdfgAtb9EJdbBEM7jEnepuCB3VwRyqYY9yafa3nktM2pUtgSBQ2nXOj?= =?us-ascii?Q?MNbaDA/7xHHRFf51a7FTG53ABdtROv5II3GBEp+RGv/GrmAmhf0UBy5xtISB?= =?us-ascii?Q?EeMHj4bigM4KJ5BUI2FUFmx/R6o2YbB+k/B/oqFyxapL9TeC2Dn5q94d/VLM?= =?us-ascii?Q?PsBz/Z+uR6R3Xe8cAE8Ke/A5qRppTJWOUocXrp0a5wnt28St02fXPY+bUKlN?= =?us-ascii?Q?o+bpeTnLyilLKBKqz4WD6pLSNSQ7HoVXdxMr4fNM/7bSiC8b0zndok3O8bkK?= =?us-ascii?Q?JsTUqDziSa3lvORK2w3LYtJPcfK+j9UolXesC3Ld4EO7VIj3SS6z8PE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Sj9nHOjJAKb+hpFg==;5:lRoa+DsWQ5yKJXX3zJxC0xh1wV5qx+9McZ+dBnnR3Y2jvPg3buUdlUObKp+jahYFjAY0TeE4W7uGHT8bRWIM73BidpbtXo6h1xTtGiwYEGRRdUkAPDrZW8A0e2Fam0TlqQT8lUTLw+lvxg9vYJt9zg==;24:/D5XI3XDYOs48U7E3yhOf7ad6yyfejSR9lCctVlkosPk+IpkOLE6yUQoBMd6s47vGu5YtNKO1IWAw8/wGJJn+q9nE09byYL96MVMbDFgWfY=;7:qxx6hOTa8sk5NP0Lii7C4re2jTBODNy6V9//mn/KOTybHgqcJHhtcCdiCKAoR8bePTvEA4fzs16wPP3N7lTHdhn3zFCWzxmhrpByYrkrANsQ6jwV/uQezAfhl2fHORRLCRyMKPxwoqHr88lHCgAqCypm6/VSdIm+2ZcNtzkk6bN9oN4+eSjmUorFTydi8/fDLJcWr3bNYYCPZmBUbCPYMbJQSBnIC9lLtFtkgtMOQQE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1733;20:XyCnbSX6kzVSyB7dV8NoXXmtvD/SjCHNOjT4KzZ28TSP4VC6/w1GTtleWQ+43DLKHScTB8LU3/ixl+jfUlcWQAjBawpwcaWcdQ+4qHPtnzrxERuCVq0AFzw6aEQsznDcF8TTakfYqfAo+Pf0pOPyPAGovGZK3nxxvGPh2EbcMpdwk/8CPzbrxfk6UTXytSR3frOYyUM+C30Hl8F00QBSWH0CRTCDKFEt+pbFf1KzJbiowFK2h/pQoBqkBwKROnMV X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2017 15:43:01.1544 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1733 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2004 Lines: 66 SVM AVIC hardware accelerates guest write to APIC_EOI register (for edge-trigger interrupt), which means it does not trap to KVM. So, only enable SVM AVIC only in split irqchip mode. (e.g. launching qemu w/ option '-machine kernel_irqchip=split'). Suggested-by: Paolo Bonzini Signed-off-by: Suravee Suthikulpanit --- arch/x86/kvm/svm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index d1b3eb4..a7b96e7 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1176,7 +1176,6 @@ static void avic_init_vmcb(struct vcpu_svm *svm) vmcb->control.avic_physical_id = ppa & AVIC_HPA_MASK; vmcb->control.avic_physical_id |= AVIC_MAX_PHYSICAL_ID_COUNT; vmcb->control.int_ctl |= AVIC_ENABLE_MASK; - svm->vcpu.arch.apicv_active = true; } static void init_vmcb(struct vcpu_svm *svm) @@ -1292,7 +1291,7 @@ static void init_vmcb(struct vcpu_svm *svm) set_intercept(svm, INTERCEPT_PAUSE); } - if (avic) + if (kvm_vcpu_apicv_active(&svm->vcpu)) avic_init_vmcb(svm); /* @@ -1594,6 +1593,12 @@ static int avic_init_vcpu(struct vcpu_svm *svm) if (!avic) return 0; + if (!kvm_vcpu_apicv_active(&svm->vcpu)) { + pr_debug("%s: Disable AVIC due to non-split irqchip.\n", + __func__); + return 0; + } + ret = avic_init_backing_page(&svm->vcpu); if (ret) return ret; @@ -4388,7 +4393,7 @@ static void svm_set_virtual_x2apic_mode(struct kvm_vcpu *vcpu, bool set) static bool svm_get_enable_apicv(struct kvm_vcpu *vcpu) { - return avic; + return avic && irqchip_split(vcpu->kvm); } static void svm_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr) @@ -4405,7 +4410,7 @@ static void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) struct vcpu_svm *svm = to_svm(vcpu); struct vmcb *vmcb = svm->vmcb; - if (!avic) + if (!kvm_vcpu_apicv_active(&svm->vcpu)) return; vmcb->control.int_ctl &= ~AVIC_ENABLE_MASK; -- 1.8.3.1