From patchwork Mon Mar 18 00:56:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 10856721 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 4DF0917E6 for ; Mon, 18 Mar 2019 00:57:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A8A328FF3 for ; Mon, 18 Mar 2019 00:57:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18B4C290BE; Mon, 18 Mar 2019 00:57:11 +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 B2B0428FF3 for ; Mon, 18 Mar 2019 00:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbfCRA5F (ORCPT ); Sun, 17 Mar 2019 20:57:05 -0400 Received: from mx56.baidu.com ([61.135.168.56]:30900 "EHLO tc-sys-mailedm04.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726122AbfCRA5F (ORCPT ); Sun, 17 Mar 2019 20:57:05 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm04.tc.baidu.com (Postfix) with ESMTP id 143A5236C00A; Mon, 18 Mar 2019 08:56:53 +0800 (CST) From: Li RongQing To: x86@kernel.org, kvm@vger.kernel.org, vkuznets@redhat.com, sean.j.christopherson@intel.com Subject: [PATCH][V2] KVM: svm: merge incomplete IPI emulation handling Date: Mon, 18 Mar 2019 08:56:53 +0800 Message-Id: <1552870613-9866-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 Signed-off-by: Li RongQing Signed-off-by: Zhang Yu Signed-off-by: Sean Christopherson --- 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);