Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754511AbdIFDk5 (ORCPT ); Tue, 5 Sep 2017 23:40:57 -0400 Received: from mail-dm3nam03on0065.outbound.protection.outlook.com ([104.47.41.65]:48544 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753735AbdIFDkN (ORCPT ); Tue, 5 Sep 2017 23:40:13 -0400 From: Suravee Suthikulpanit To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, joro@8bytes.org, Suravee Suthikulpanit Subject: [PATCH 3/3] KVM: SVM: Add irqchip_split() checks before enabling AVIC Date: Tue, 5 Sep 2017 22:39:29 -0500 Message-Id: <1504669169-4919-4-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1504669169-4919-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1504669169-4919-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [114.109.128.54] X-ClientProxiedBy: SG2PR06CA0102.apcprd06.prod.outlook.com (10.170.138.28) To DM5PR12MB1737.namprd12.prod.outlook.com (10.175.89.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0350cc5f-5297-4b8c-69ed-08d4f4d8fa7e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DM5PR12MB1737; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1737;3:vyxy2ME4ftYA1au/rLceH/hkbqcrrDxNf5fVmDDD7hzFI187EZ+JVC2gGG36uDmUsJtzjp7M0NN4Q5vafjsjeemsPvOKGz5brp+syRsQO2eXFT4/4wvEQLZCGiLxfvl/II71q8bcbSjQjcKDHSOkIsTfJiF+8F4u81+69+gR2RgFqbA4CnY6arWJXl4Ukfk/IgEL09ZvgeIFwufSEUhW4XfKbNY8Eyf6QcZvWuR/FfzuqwzMoGn3Lf3VBHbhB/bE;25:qu4UY1O8XzBetmcoCyEHu5RhUTeC2spP1hmSiAauCYqP7OF27olkCTynQdrkIhlLvDj1TMQCAkGknPnf0P1wx9Z16/0Qe/zQXu9XMP4eBFNDWvTUPoNAKx6n55f73pepTUmPeJeQGSb1Z4BhBp3jX1XTZWzqL3r/QFn8dhoZvw8wwaWNJrnmJQHBCpeSBojzS80oDbn4MVmmmS62UfHoXetCmC0xmvEvCaZlba5xreUVl6i6KLT3zZkcU4N0DBLp3TfGg98jovd1DHFnD8da9YrTTrmAgMjq7PAZySCwaiiRXrpkGuxZfrLhPZkF5CUy8gWZgIpcSvZcJrN5arvfrA==;31:6trz2kuLMFu+qc3p2DsmCqjrj1fVONMe0k2C+71aovboqCrtf464Op058jt1hMI8d69f2MgyMOXtflKrM+P8e4zoYzLKrwhex8+5AdrhT5xVEh8sNHcKmvoOQRN9hDJLfG6FddTRuyt7jDq3hh2hR3wEJ4teehrBtIHB9SIVup0WdbVw7qtJZLHXeTQBLs9LkZZgU5FOxy7+mDjrTxltltEJeBUzkQ+WSR+nW8QeVk4= X-MS-TrafficTypeDiagnostic: DM5PR12MB1737: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1737;20:NkQlOxkP0zfrVw7iTUyPV9aalG4Ihp5UbDf13l2ZsMRZz+PZiLgBwm6GR/9otL/r++04XavXl8AOjJaGHkd/fE9//9guWUCr4Tmhd+Q+fQhV7X/aXCG+c2isCwRMJCuKtlR3f1bjwPW8T3pSf3auXgjufsXOQ2XjMkdTQyL5gOqUnQRrHLZz6pmP1EI2QX5WaVbwiKGSiWrftc6/hviekLUVDVPooH+uEwq8BKsqnnO7zQMlorYg7xhx0+Vdc4YLxMU5Ryn5ZYgKWYC6GDWLSDR/hWkh2spFwY9Gt4C+xMk6PkfnuFzgxYEJZpGKwHfpN7m8iqiyASoM9OHjPjBAM+MhIj36A1p8+Q2L9eCQQJr02DgCsGiQEvahvD5pLtFab59QWC9ZVKT1wz7PmCJJVxT8kvjLIfbNRrFpSlfyI2NtKPfHylpOOc+8/a83dD45Ie8nZmSt9VxgsGkof1pc9ZOjJ+hrcr3VAtzEmGkLeT1rAXF6FZZ/62TCzafM53uj;4:CHl5YXSOBtdSXUzTXuVPJeZ92DHgWkGXVHIvadIkIxaHSJy7LcHXrKuy5PpmJl2E0FEUYLAgulz6wxYDXB6oai1dcrdd+9DD3NA6T5xeIrr1+7tIeaBnK9/QExabu7IMp8AEGtU+7lBMrTzU+5zXG6jkXkbj/ZuI8PD9eVxkhmtk6O8WNt5vGBEAKbu0HOsMjEZFjlZNtrS/5OID9CXwI4Q0cXx4M9byn5npLUodQSyhkvmACh4K+CELK1zzn+gY7o5RLCGFOHIGWkQbo3p9VkS4IkrBPhScnTL/RiZ4GWU= 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR12MB1737;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR12MB1737; X-Forefront-PRVS: 0422860ED4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(199003)(189002)(8936002)(6666003)(2950100002)(6116002)(86362001)(53936002)(4720700003)(101416001)(6486002)(42186005)(106356001)(5660300001)(5003940100001)(105586002)(3846002)(110136004)(305945005)(4326008)(6506006)(72206003)(7736002)(76176999)(66066001)(47776003)(478600001)(25786009)(2906002)(8676002)(97736004)(50986999)(68736007)(50226002)(36756003)(81166006)(33646002)(81156014)(50466002)(189998001)(48376002)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1737;H:ssuthiku-rhel73-zp.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM5PR12MB1737;23:ARc6gjFd7gwIWSJSjo8yjmbt08Ik6AvlmS0hAPvt0?= =?us-ascii?Q?fs9QKO3z4Ilfto2AhAvfAV9+ZSwJYd9WJp6zT93+pmj7WyCqJ963f7vQmEb9?= =?us-ascii?Q?V5Mt/c6OklrXtPPe5yQbya141IR2ieGK53325aakwukZC1qlo0VZSJaMfThl?= =?us-ascii?Q?yWq2gqeZJqRSy7iS1R6D9tcHRbmxKLSiU192Krb2Ll8CF1UwhNYi+DFxNUGf?= =?us-ascii?Q?/Fn1cNMyDqzt3ogOhdgbjyMZhXigvvlAPU/UtlqWo0I9+d9FCKoaaMCqm85a?= =?us-ascii?Q?dpt4qXs0PUFDYE8Rc5siJzKEsCPW+W2Z6zKWxmtYHB8P+DoQNn/OzxrznAyz?= =?us-ascii?Q?vpvIIFX8/F321GFbtFRJQGrS0BmKp9lHoQ8evflciRp30lxhwVElCMAovmEQ?= =?us-ascii?Q?973we0YFclmqeMrUt674YvCPA1odxUV/ruoC+EjU59U3vOuVHPGf078ESQmx?= =?us-ascii?Q?rIwWHGb8e7tj0yZL3gk4QBty94+Q6jRVPt1d2PNRqFpjGfMsWljByPC1EopN?= =?us-ascii?Q?02pWAYYvAX+nyU9SAgCFC7OwzlHwvkJITMnwwLmaMIIWidxD17nLqErRVgAy?= =?us-ascii?Q?iiEuBMA67jQURN24WzvAk5iRHa7Y1byYgWYG8kYtCrCbWN9CaY/wDY/DxawJ?= =?us-ascii?Q?JoJl1J/xkRmTfjRoFqaxr1fmjreQLZby1+9Dzh5hfyYm/EksRwelCNtm6UsJ?= =?us-ascii?Q?kq2hh72iFRe5Ia+8Fod7jS95EGgi+kKLRxTXpq0FQrNK0RZKTAdaiB0Rv6C8?= =?us-ascii?Q?ZpGyVQcGtnMBqlej05FXIM/vy3kBoI+lb6QC34pCGs7aYXcGVCBXbNrwQlVu?= =?us-ascii?Q?gN8XWdylx4kEUAsg+QgNfjswBeEVrRcT5GyugzdNZet4RXDguJSSA6YHmZzQ?= =?us-ascii?Q?5gBo3oKIzrG0439jjEageta0VPfA8ExnepytzJu15kx1gLrQhev06n6lnykk?= =?us-ascii?Q?fu9ClUyib68iWg3a9TGoMTUO/veRO9NCKMVl4E8greZW3xLfuVoVDQPOv2zr?= =?us-ascii?Q?lSG0NwLAFAgdccEn+usXiCDC0ON55g/nLoqbSJhDxGl8UBtgReFa94Bj5A6b?= =?us-ascii?Q?ompWHpZqCYAzeeZ5IQ4TJmrGvTV?= X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1737;6:xr+4Hqi/ehZLZo1MxAJqKGWKNnVOK5tCdCV9xACYNkFa6qvTSENktOZ5u+eeagAqMC5GzPZGOx/IdSXG34o29+N696VYTcRkvXLs4vR29Jv7LOLavP4FX+T4SvuWtUzBGkjPqADR0AO+sIm8/D8PXiqO0oWo839GLLP5aLEm34OJAbsUVJH5mXLXN5WQiGBfVtPIesOwXB3Xk49/X3pdp+VtLuaxLTyZn/cV2mCrfCFsO2INqkbcxyypRUOkvwhLntPygqzpdYmFDi9G/CsH3jQpFzN3o0PYewQDxpTsutUGlwU6x4RGFVofD9pAw7FDNtNwpOMIz+KiMKMKesO48A==;5:2gAIYb5C4nGYOC2Y91oBH47NCzvXAreRXlZ8Zqsm2ksWNOenvLCDp445MY8VeriOkw5gcVAlR29FfuzQDFrzHmpGVRb0ttLtdoa9VPQK+SyqmQE9OyW4gXrbw6+RaTD6gWz9SiVMN1XpjV04EPAedA==;24:8X4IVhd3yf4/4xWHNOvc1h7wOqLgqiOaobsltRM4+brx1DvdTarphtRxDscDO6Lznl+1ZIGxVGyXZS/nPQX4uzt2tJB3h4DwyJTMVlbOJPM=;7:r09DnxPG1dfmizkBL6JyPQuGX7/+cz+HcSLcIlD85aDO9HmwXEr7a8DaqCI7KAZjuY09Q3byJFf6aS1BHGiOv7zf5LHW5ryKJtUtrZNwF/Ruuyo36XxUAmP2blPL5AXKB/3KchsXC8XHyuDae821MIZEp+9fpaGEIiePJBM7SYAsZmn0/raZWIcbvAreR6XEsDvgIuePuIoqhf7UWBLBJWcQ+7ZK2HL88glHHiAWrw8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1737;20:/qvksIbZ0kII0zKcPPbbpk+6K+CP9KhuFa22deEtRH5inypXe33oPELaK95u5QGi6BfFGRH2J2VlKPVL/e4BfN6Y2obR7BTyXpBCcjgdGZ9rOWTMr78qKebp9C4RNGGD3zlz8u0Ze/aw17ycv+Jr9jdMk5wSPpP8aYoYt6zqVNuPEUG8bN3dk1FdQTkQvbplAiRANXLpQzws28X9oUA9Azib3YBg3KpIfk1hPANiLoq2K2cDiAcM8kgJX3trfTal X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2017 03:40:09.8158 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1737 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1998 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..7ce191b 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 (!irqchip_split(svm->vcpu.kvm)) { + 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 (!avic || !irqchip_split(svm->vcpu.kvm)) return; vmcb->control.int_ctl &= ~AVIC_ENABLE_MASK; -- 1.8.3.1