From patchwork Wed Mar 20 10:07:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 10861263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A62A217E0 for ; Wed, 20 Mar 2019 10:08:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87CD129AB2 for ; Wed, 20 Mar 2019 10:08:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77D0829B10; Wed, 20 Mar 2019 10:08:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1564A29AB2 for ; Wed, 20 Mar 2019 10:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727997AbfCTKIB (ORCPT ); Wed, 20 Mar 2019 06:08:01 -0400 Received: from mx60.baidu.com ([61.135.168.60]:38051 "EHLO tc-sys-mailedm05.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727732AbfCTKIA (ORCPT ); Wed, 20 Mar 2019 06:08:00 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm05.tc.baidu.com (Postfix) with ESMTP id 3A0081EBA00D; Wed, 20 Mar 2019 18:07:46 +0800 (CST) From: Li RongQing To: x86@kernel.org, kvm@vger.kernel.org, vkuznets@redhat.com, sean.j.christopherson@intel.com, bp@alien8.de Subject: [PATCH][V3] KVM: svm: merge incomplete IPI emulation handling Date: Wed, 20 Mar 2019 18:07:46 +0800 Message-Id: <1553076466-29446-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Invalid int type emulation and target not running emulation have same codes, which update APIC ICR high/low registers, and emulate sending the IPI. so fall through this switch cases to reduce duplicate codes and wide the comment out to 80 columns Co-developed-by: Zhang Yu Suggested-by: Sean Christopherson Signed-off-by: Li RongQing Signed-off-by: Zhang Yu Signed-off-by: Li RongQing --- v2->v3: use Co-developed-by, instead of Signed-off-by v1->v2: make cases statements are back-to-back and wide the comment out to 80 columns as suggested by Sean Christopherson arch/x86/kvm/svm.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index c6613d1dfa75..db6946791663 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4498,26 +4498,18 @@ static int avic_incomplete_ipi_interception(struct vcpu_svm *svm) switch (id) { case AVIC_IPI_FAILURE_INVALID_INT_TYPE: - /* - * AVIC hardware handles the generation of - * IPIs when the specified Message Type is Fixed - * (also known as fixed delivery mode) and - * the Trigger Mode is edge-triggered. The hardware - * also supports self and broadcast delivery modes - * specified via the Destination Shorthand(DSH) - * field of the ICRL. Logical and physical APIC ID - * formats are supported. All other IPI types cause - * a #VMEXIT, which needs to emulated. - */ - kvm_lapic_reg_write(apic, APIC_ICR2, icrh); - kvm_lapic_reg_write(apic, APIC_ICR, icrl); - break; case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: { - struct kvm_lapic *apic = svm->vcpu.arch.apic; - /* - * Update ICR high and low, then emulate sending IPI, - * which is handled when writing APIC_ICR. + * AVIC hardware handles the generation of IPIs when the + * specified Message Type is Fixed (also known as fixed + * delivery mode) and the Trigger Mode is edge-triggered. + * The hardware also supports self and broadcast delivery + * modes specified via the Destination Shorthand(DSH) field + * of the ICRL. Logical and physical APIC ID formats are + * supported. All other IPI types cause a #VMEXIT, which + * needs to emulated. + * AVIC hardware also cannot handle IPIs to cpus that are + * not running, emulate the IPI for that case as well */ kvm_lapic_reg_write(apic, APIC_ICR2, icrh); kvm_lapic_reg_write(apic, APIC_ICR, icrl);